Skip to content

Instantly share code, notes, and snippets.

View joshgav's full-sized avatar

Josh Gavant joshgav

View GitHub Profile
@joshgav
joshgav / node_env_mgr.md
Last active November 3, 2016 21:23
Justification for managing Node environment managers in the Node Foundation.

Environment managers like Python's venv/virtualenv, Ruby's rvm, and Node's nvm make it easy for users to install and configure a runtime's versions and constituent components. Each virtual environment can support a specific runtime version and configuration and an independent set of global modules. In fact, some runtimes, such as .NET Core, can bundle and refer to a specific runtime configuration for each app. To summarize, environment managers enable developers to:

  • install the runtime with a specific configuration.
  • change runtime configurations for test and other needs.
  • manage runtime and component updates.
@joshgav
joshgav / weather_api.js
Created June 8, 2017 18:00
Simple Weather API (sample)
const http = require('http');
const url = require('url');
// assumes a sibling .env file with
// OPENWEATHER_APIKEY=your_key
const dotenv = require('dotenv').config();
const appid = process.env.OPENWEATHER_APIKEY;
function httpHandler (request, response) {
let parsed_url = url.parse(request.url, true);
@joshgav
joshgav / gist:0a9b1e3f184a93f545ab6400b85e54de
Created July 7, 2017 18:49 — forked from smoser/gist:4756561
boot a cloud image in kvm
## Install a necessary packages
$ sudo apt-get install kvm cloud-utils genisoimage
## URL to most recent cloud image of 12.04
$ img_url="http://cloud-images.ubuntu.com/server/releases/12.04/release"
$ img_url="${img_url}/ubuntu-12.04-server-cloudimg-amd64-disk1.img"
## download the image
$ wget $img_url -O disk.img.dist
## Create a file with some user-data in it
@joshgav
joshgav / gist:8a87200f1c333280cab66aab0be9dcea
Last active December 6, 2017 01:02
keyvault data plane methods in Go SDK
## data plane
func New() ManagementClient
func NewWithoutDefaults() ManagementClient
func (client ManagementClient) BackupKey(vaultBaseURL string, keyName string) (result BackupKeyResult, err error)
func (client ManagementClient) BackupSecret(vaultBaseURL string, secretName string) (result BackupSecretResult, err error)
func (client ManagementClient) CreateCertificate(vaultBaseURL string, certificateName string, parameters CertificateCreateParameters) (result CertificateOperation, err error)
func (client ManagementClient) CreateKey(vaultBaseURL string, keyName string, parameters KeyCreateParameters) (result KeyBundle, err error)
func (client ManagementClient) Decrypt(vaultBaseURL string, keyName string, keyVersion string, parameters KeyOperationsParameters) (result KeyOperationResult, err error)
func (client ManagementClient) DeleteCertificate(vaultBaseURL string, certificateName string) (result DeletedCertificateBundle, err error)
@joshgav
joshgav / azurerm.sh
Last active September 27, 2018 19:06
Azure resource management helper shell scripts
declare prefix="azuregosdkjuglaptop"
# cleanup_groups requests deletion of groups with names starting with `prefix`
# it returns after request acceptance, i.e. it does not wait for deletion to actually finish
# `prefix` string "___": first letters of names of groups to delete
function cleanup_groups () {
declare prefix=${1:-"___"} # default to unlikely value for safety
# set up jmespath query
jmespath_query="[? starts_with(name, \`${prefix}\`)].name"
@joshgav
joshgav / create_azure_web.sh
Last active February 1, 2019 23:48
Create an Azure Web App
app_name=your-unique-name
app_repo_url=https://github.com/your-name-here/your-repo-here
location=westus
# choose from: `az webapp list-runtimes --linux`
runtime='NODE|10.10'
env_vars=(
APPINSIGHTS_INSTRUMENTATIONKEY=af4b1113-bc85-41d0-be2b-343c3f178b7b
YOUR_ENV_VAR=test
)
@joshgav
joshgav / create_file_share.sh
Created February 13, 2019 23:34
Create an SMB file share in Azure Storage and mount in a Linux system.
#! /usr/bin/env bash
# requires cifs-utils - `apt install cifs-utils`
group_name=joshgav-oryx-test-group
group_location=westus2
storage_account_name=joshgavoryxsharetest
storage_account_group_name=${group_name}
storage_account_location=${group_location}
share_name=intermediate
@joshgav
joshgav / github_practices.md
Created March 8, 2019 21:49
GitHub open project best practices

Open source on GitHub: what and why

  • Participants: users, contributors and maintainers.
    • We're looking for users.
    • README.md and CONTRIBUTING.md
  • Why open source?
    • Collect better feedback on our software from users.
    • Gather direct insights into how users use our software.
    • Developers are empowered to:
      1. fix problems and answer questions themselves and maybe even blog about it
  1. open detailed and actionable issues for us
@joshgav
joshgav / install.sh
Created May 28, 2019 16:14
mac app installers
# install tmux
TMUX_VER=2.9a
LIBEVENT_VER=2.1.10
PREFIX=${HOME}/.local
# get tmux and libevent
curl -LO https://github.com/tmux/tmux/releases/download/${TMUX_VER}/${TMUX_VER}.tar.gz
curl -LO https://github.com/libevent/libevent/releases/download/release-${LIBEVENT_VER}-stable/libevent-${LIBEVENT_VER}-stable.tar.gz
tar -xzf "./tmux-${TMUX_VER}.tar.gz"