Skip to content

Instantly share code, notes, and snippets.

View finesse-fingers's full-sized avatar

Bobby Koteski finesse-fingers

  • Amplify Health
  • Singapore
View GitHub Profile
@finesse-fingers
finesse-fingers / clone-github-org.sh
Created February 3, 2021 02:45
A script to clone all repos in a github organisation
#!/bin/bash
# Substitute variables here
ORG_NAME="<ORG_NAME>"
GITHUB_INSTANCE="<GITHUB_INSTANCE>"
URL="https://${GITHUB_INSTANCE}/api/v3/orgs/${ORG_NAME}/repos"
curl ${URL} | ruby -rjson -e 'JSON.load(STDIN.read).each {|repo| %x[git clone #{repo["clone_url"]} ]}'
docker run -d \
-e POSTGRES_PASSWORD=SuperSecret \
-v ~/postgresql/13/data:/var/lib/postgresql/data \ # windows: -v d:/postgresql/13/data:/var/lib/postgresql/data
-p 5432:5432 \
--name postgres \
postgres:13
docker run -p 5050:80 -d \
-e '[email protected]' \
-e 'PGADMIN_DEFAULT_PASSWORD=SuperSecret' \
@finesse-fingers
finesse-fingers / run-couchdb-docker.sh
Last active April 3, 2021 08:29
Start a CouchDB container with mount
mkdir -p /home/ubuntu/couchdb/data
docker run -d \
--restart unless-stopped \
-v /home/ubuntu/couchdb/data:/opt/couchdb/data \
-e COUCHDB_USER=admin \
-e COUCHDB_PASSWORD=strongPassword \
-p 5984:5984 \
--name couchdb \
couchdb:latest
@finesse-fingers
finesse-fingers / ProtoLink.csproj
Created June 13, 2020 05:16
Link a proto from a shared location in a csproj
@finesse-fingers
finesse-fingers / FunctionsStartup.cs
Created May 12, 2020 11:30
Using ConfigurationBuilder to add KeyVault as a provider
public static class ServiceExtensions
{
/// <summary>
/// Creates a custom configuration for easier development of Azure Functions.
/// When environment is not Development, it adds support for keyvault
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static IConfiguration GetCustomConfiguration(this IFunctionsHostBuilder builder)
{
@finesse-fingers
finesse-fingers / CheckIfSecretExists.ps1
Created May 12, 2020 11:27
Pscore snippet checking to see if a secret exists in azure keyvault
# check to see if secret exists in keyvault, otherwise throw error
$SecretName = "HttpClientConfiguration--ApiKey"
$doesExist=$(az keyvault secret show `
--vault-name $KeyVaultName `
--name $SecretName `
--query id -o tsv)
if ($doesExist) {
echo "Secret '$SecretName' found in vault '$KeyVaultName' OK"
} else {
echo "Expecting secret '$SecretName' to be in vault '$KeyVaultName'"
@finesse-fingers
finesse-fingers / ServiceBusOptions.cs
Created May 12, 2020 10:16
Example showing how to configure azure function service bus in Startup
builder.Services.Configure(delegate(ServiceBusOptions options)
{
options.MessageHandlerOptions.AutoComplete = false;
});
# Set other app settings
$values = [System.IO.File]::ReadAllText($appSettings)
$appSettingsList = $values.Split([System.Environment]::NewLine)
echo "setting app settings: $appSettingsList"
az functionapp config appsettings set `
--name $functionAppName `
--resource-group $resourceGroup `
--settings $appSettingsList
@finesse-fingers
finesse-fingers / bash-argument-parsing.sh
Created May 4, 2020 09:10
Demonstrates how to parse arguments in bash
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# -e: immediately exit if any command has a non-zero exit status
# -o: prevents errors in a pipeline from being masked
# IFS new value is less likely to cause confusing bugs when looping arrays or arguments (e.g. $@)
function usage()
{