Skip to content

Instantly share code, notes, and snippets.

Avatar

James Pansarasa mill5james

View GitHub Profile
@mill5james
mill5james / main.tf
Created Apr 14, 2021
Docker for Windows Airflow Development Env
View main.tf
##############################################################################
# State Storage
##############################################################################
terraform {
backend "kubernetes" {
secret_suffix = "airflow"
load_config_file = true
}
}
View _helpers.tpl
{{/*
Convert YAML to envirment variables for .NET Core hosting environment naming
*/}}
{{- define "translateEnv" -}}
{{- range $key, $value := . }}
{{- if or (kindIs "map" $value) (kindIs "slice" $value) }}
{{- include "prefixItem" (dict $key $value) }}
{{- else }}
- name: {{ $key }}
value: {{ $value | squote }}
View Repeat-Command.ps1
function Repeat-Command
{
param (
[Parameter(Mandatory=$true)][scriptblock]$Command,
[Parameter(Mandatory=$false)][int]$Delay = 1
)
$Title = $host.ui.RawUI.WindowTitle;
try {
$host.ui.RawUI.WindowTitle = $Command
View Configure-RemoteDebug.ps1
<#
.SYNOPSIS
Configures remote machine debugging for Visual Studio Code and Visual Studio 2017+.
.DESCRIPTION
Will ensure that all the required software is available or it will install the prerequisites, creates any necessary SSH keys and files on the local and remote machine, validates the connection to the remote host, and finally configures remote debugging for IoT Edge modules.
.PARAMETER RemoteHost
The DNS name or IP address of the remote host. If not suppllied, the script will prompt the user.
View Init-AzSphere.ps1
function Init-AzSphere {
pushd "C:\Program Files (x86)\Microsoft Azure Sphere SDK"
cmd /c "InitializeCommandPrompt.cmd&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
}
popd
Write-Host "`nDeveloper Command Prompt for Azure Sphere tools set." -ForegroundColor Yellow
View tfs.ps1
function Tfs-GetAll { tf vc get /force /noprompt /recursive }
function Tfs-CleanAll {
param (
[switch]$NoPrompt = $false
)
$optional = ''
if ($NoPrompt) { $optional += '/noprompt '}
Move-Item -Path ./.vscode ./.vscode-hold
tf vc reconcile /clean /recursive /exclude:.store,.vs,.vscode-hold,*.vspscc $optional
View docker.ps1
function Clean-DockerImages {
docker images -q | % { docker rmi -f $_ }
}
function Stop-DockerContainers {
docker ps -a -q | % { docker rm -f $_ }
}
View Retry-Command.ps1
function Retry-Command
{
param (
[Parameter(Mandatory=$true)][string]$command,
[Parameter(Mandatory=$true)][hashtable]$args,
[Parameter(Mandatory=$false)][int]$retries = 5,
[Parameter(Mandatory=$false)][int]$secondsDelay = 2
)
# Setting ErrorAction to Stop is important. This ensures any errors that occur in the command are
@mill5james
mill5james / VsDev.ps1
Created Nov 5, 2018
Visual Studio Vars in PowerShell
View VsDev.ps1
function VsDev {
pushd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools"
cmd /c "VsDevCmd.bat&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
}
popd
Write-Host "`nVisual Studio 2017 Command Prompt variables set." -ForegroundColor Yellow
@mill5james
mill5james / App.java
Last active Apr 20, 2018
Rulebook problem
View App.java
import com.deliveredtechnologies.rulebook.Fact;
import com.deliveredtechnologies.rulebook.FactMap;
import com.deliveredtechnologies.rulebook.NameValueReferableMap;
import com.deliveredtechnologies.rulebook.model.runner.RuleBookRunner;
public class App {
public static void main(String[] args) {
RuleBookRunner rules = new RuleBookRunner("rules");
NameValueReferableMap<String> facts = new FactMap<>();
facts.put("key", new Fact<>("value"));