Skip to content

Instantly share code, notes, and snippets.

Adrian Price aprice

Block or report user

Report or block aprice

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@aprice
aprice / RemoveWin10Garbage.ps1
Created Sep 5, 2019
PowerShell script to remove Windows 10 bloatware crap
View RemoveWin10Garbage.ps1
Import-Module AppX
Import-Module Dism
$AppsList = "Microsoft.Bing" , "Microsoft.BingFinance" , "Microsoft.BingMaps" , "Microsoft.BingNews"`
, "Microsoft.BingSports" , "Microsoft.BingTravel" , "Microsoft.BingWeather" , "Microsoft.Camera"`
, "microsoft.microsoftskydrive" , "Microsoft.Reader" , "microsoft.windowscommunicationsapps"`
, "microsoft.windowsphotos" , "Microsoft.XboxLIVEGames" , "Microsoft.ZuneMusic"`
, "Microsoft.ZuneVideo" , "Microsoft.Media.PlayReadyClient", "Microsoft.WindowsMaps"`
, "Microsoft.XboxApp", "SpotifyAB.SpotifyMusic", "king.com.CandyCrushFriends"`
, "king.com.CandyCrushSaga"
@aprice
aprice / every.go
Created Jun 5, 2018
Execute a function on a ticker.
View every.go
package every
import (
"context"
"time"
)
// Every executes fn every d until ctx is canceled. Note that the first execution will not be until time.After(d).
func Every(ctx context.Context, d time.Duration, fn func()) {
t := time.NewTicker(d)
@aprice
aprice / mrclean.sh
Created Nov 30, 2017
Simple utility for showing/cleaning up kitchen test instances that may have been forgotten.
View mrclean.sh
#!/bin/bash
# Usage:
# mrclean - list kitchen instances in all cookbooks
# mrclean destroy - destroy kitchen instances in all cookbooks
# Update to your cookbook path
CBDIR=$HOME/chef-repo/cookbooks
for c in $CBDIR/*; do
echo $(basename $c)
@aprice
aprice / tf.sh
Created Nov 28, 2017
Terraform helper script for workspace-per-environment model
View tf.sh
#!/bin/bash
cmd=$1
shift
env=$1
shift
terraform workspace select $env || exit_error "failed to select workspace $env"
case $cmd in
# Custom command: plan -> outfile, confirm, apply outfile
planapply)
@aprice
aprice / busboy.go
Created Aug 11, 2017
busboy cleans up after Chef nodes terminated in EC2 by listening for CloudWatch termination events on an SQS queue.
View busboy.go
package main
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"time"
@aprice
aprice / password.go
Last active May 10, 2017
Simple, secure, best-practices password storage in Go.
View password.go
package password
import (
"bytes"
"crypto/rand"
"crypto/sha256"
"fmt"
"bufio"
"errors"
"io"
@aprice
aprice / collator.go
Last active Apr 26, 2017
Simple, un-typed fan-in/fan-out result collator. Easy to customize for type safety.
View collator.go
type Collator struct {
results chan interface{}
errors chan error
wg *sync.WaitGroup
}
func NewCollator() *Collator {
return &Collator{
results: make(chan interface{}),
errors: make(chan error),
@aprice
aprice / aws_peers.go
Last active Apr 7, 2017
Get the list of IP addresses of instances in the same ASG, excluding this instance
View aws_peers.go
package config
import (
"errors"
"io/ioutil"
"net/http"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/autoscaling"
@aprice
aprice / makefile
Last active Jul 21, 2019
Full base Golang makefile for developers and Jenkins. Handles installing tools, formatting, linting, cross-compilation, installation, and packaging for distribution.
View makefile
# This file is intended as a starting point for a customized makefile for a Go project.
#
# Targets:
# all: Format, check, build, and test the code
# setup: Install build/test toolchain dependencies (e.g. gox)
# lint: Run linters against source code
# format: Format the source files
# build: Build the command(s) for target OS/arch combinations
# install: Install the command(s)
# clean: Clean the build/test artifacts
@aprice
aprice / benchwc.sh
Created Sep 16, 2016
Compare golang benchmarks between working copy and pristine
View benchwc.sh
#!/bin/bash
# Usage: benchwc.sh "path/to/package" "-build flags"
# e.g. benchwc.sh ./mypkg "-cpu=1,2,4 -tags=debug -benchtime=2s"
DIR=${1:-.}
BFLAGS=$2
git stash save || exit 1
cd $DIR && go test -run=^$ -bench=. -benchmem $BFLAGS | tee old.out
git stash pop || exit 1
cd $DIR && go test -run=^$ -bench=. -benchmem $BFLAGS | tee new.out
benchcmp old.out new.out | tee comparison.out
You can’t perform that action at this time.