Skip to content

Instantly share code, notes, and snippets.

View pjmagee's full-sized avatar
🏠
Working from home

Patrick Magee pjmagee

🏠
Working from home
View GitHub Profile
@pjmagee
pjmagee / extract.go
Last active September 2, 2024 17:05
package main
import (
"context"
"dagger/dsg-icis-openapi-kiota/internal/dagger"
"fmt"
"slices"
)
type Language string
type Fakedeploy struct {
Approved bool
}
func (m *Fakedeploy) WithApproval() (*Fakedeploy, error) {
response, _ := dag.Container().
From("alpine").
WithMountedCache("/tmp/replies", dag.CacheVolume(fmt.Sprintf("reply-%d", time.Now()))).
Terminal(dagger.ContainerTerminalOpts{
2024-07-27 22:07:52,209 - INFO - Making request to https://starwars.fandom.com/api.php?action=parse&page=Aaricetri&format=json&prop=sections%7Cproperties
2024-07-27 22:07:52,427 - INFO - Making request to https://starwars.fandom.com/api.php?action=parse&page=Aaricetri&format=json&prop=categories
2024-07-27 22:07:52,641 - INFO - {
"title": "Aaricetri",
"sections": [
"Overview [ ] Two types of planets existed in the galaxy : gas giants and terrestrial rocky worlds. Moons orbiting gas giants and other rocky worlds were usually not considered planets, even though they could be larger or more populated than other planets. However, Zonama Sekot was considered to be both at different time periods due to its unique mobile nature. Some planets, like Balnab , were still going through stages of organic development Depending on the tilt of its axis, a planet might have had varied seasons with changing temperatures and weather, affecting its habitability. Planets were extremely varied in terms of environmental con
@pjmagee
pjmagee / grid-squares-pages.cs
Created July 22, 2024 18:33
Get all Pages with Galactic Coordinates
class Program
{
private static readonly HttpClient client = new HttpClient();
static async Task Main(string[] args)
{
string category = "Category:Locations_by_grid_square";
List<string> allPages = await GetAllPagesInCategoryAndSubcategories(category);
foreach (string page in allPages)
#Requires -Version 7.0
Param (
[Parameter(Mandatory = $false)][System.Management.Automation.SemanticVersion]$DaggerVersion,
[Parameter(Mandatory = $false)][string][ValidatePattern("^[0-9a-fA-F]{40}$")]$DaggerCommit,
[Parameter(Mandatory = $false)][string]$DownloadPath = [System.IO.Path]::GetTempFileName(),
[Parameter(Mandatory = $false)][string]$InstallPath = "$env:USERPROFILE\dagger",
[Parameter(Mandatory = $false)][System.Boolean]$AddToPath = $false,
[Parameter(Mandatory = $false)][switch]$Interactive = $false
)
@pjmagee
pjmagee / install.ps1
Last active June 9, 2024 12:19
Dagger install with PowerShell
#Requires -Version 7.0
Param (
[Parameter(Mandatory = $false)][System.Management.Automation.SemanticVersion]$DaggerVersion,
[Parameter(Mandatory = $false)][string]$MainGitCommit,
[Parameter(Mandatory = $false)][string]$DownloadPath = [System.IO.Path]::GetTempFileName(),
[Parameter(Mandatory = $false)][string]$InstallPath = "$env:HOMEPATH\dagger",
[Parameter(Mandatory = $false)][System.Boolean]$AddToPath = $false,
[Parameter(Mandatory = $false)][switch]$Interactive = $false
)
@pjmagee
pjmagee / main.go
Last active July 13, 2024 21:51
Example Dagger CICD
package main
import (
"context"
)
type DaggerTerraformAwsLocalstack struct{}
func (m *DaggerTerraformAwsLocalstack) localStackService() *Service {
<#
.SYNOPSIS
Generates code using the Kiota generator in the specified languages for defined OpenAPI specs.
.DESCRIPTION
This script generates code using the Kiota generator in the specified languages for defined OpenAPI specs.
Each subfolder in the examples folder is named after the language and the output is placed in a subfolder named after the namespace.
The generated code is then expanded to include additional functionality.
The additional functionality includes:
type DsgIcisOpenapiKiota struct{}
type Language string
const (
CSharp Language = "CSharp"
Go Language = "Go"
Java Language = "Java"
Python Language = "Python"