Skip to content

Instantly share code, notes, and snippets.

@gservat
gservat / display-switcher.sh
Created April 14, 2019 14:37
Display profile switcher using nvidia-settings
#!/bin/bash
exec > >(tee -a "/tmp/display-switcher.log") 2>&1
# NOTE: This requires GNU getopt. On Mac OS X and FreeBSD, you have to install this
# separately; see below.
usage() {
cat << HELP >&2
Usage: $0 [option ...] {profile}
@gservat
gservat / aws-instance-types.sh
Created January 9, 2018 22:31
Create a CSV with the available instance types in each AZ
#!/bin/bash
echo "Getting list of Availability Zones"
all_regions=$(aws ec2 describe-regions --output text --query 'Regions[*].[RegionName]' | sort)
all_az=()
while read -r region; do
az_per_region=$(aws ec2 describe-availability-zones --region $region --query 'AvailabilityZones[*].[ZoneName]' --output text | sort)
while read -r az; do
@gservat
gservat / docker-stackdump.log
Created January 2, 2018 06:38
Docker stacktrace while "docker ps" is hung
=== BEGIN goroutine stack dump ===
goroutine 10 [running]:
github.com/docker/docker/pkg/signal.DumpStacks()
/usr/src/docker/.gopath/src/github.com/docker/docker/pkg/signal/trap.go:67 +0x98
github.com/docker/docker/daemon.setupDumpStackTrap.func1(0xc82001a3c0)
/usr/src/docker/.gopath/src/github.com/docker/docker/daemon/debugtrap_unix.go:18 +0x5e
created by github.com/docker/docker/daemon.setupDumpStackTrap
/usr/src/docker/.gopath/src/github.com/docker/docker/daemon/debugtrap_unix.go:20 +0x12a
goroutine 1 [chan receive, 148194 minutes]:
@gservat
gservat / rancher-update-lb.go
Last active December 18, 2017 03:04
Non-working example to update a load balancer in Go
import (
"fmt"
"os"
"time"
rancher "github.com/rancher/go-rancher/v2"
log "github.com/sirupsen/logrus"
)
func createClient(rancherURL, accessKey, secretKey string) *rancher.RancherClient {

hKRib2R5hqhkZXRhY2hlZMOpaGFzaF90eXBlCqNrZXnEIwEgilz5nTwAInFPJueJuchbYy2tVEQDvBGYXkDCKmVKJioKp3BheWxvYWTFAuh7ImJvZHkiOnsia2V5Ijp7ImVsZGVzdF9raWQiOiIwMTIwOGE1Y2Y5OWQzYzAwMjI3MTRmMjZlNzg5YjljODViNjMyZGFkNTQ0NDAzYmMxMTk4NWU0MGMyMmE2NTRhMjYyYTBhIiwiaG9zdCI6ImtleWJhc2UuaW8iLCJraWQiOiIwMTIwOGE1Y2Y5OWQzYzAwMjI3MTRmMjZlNzg5YjljODViNjMyZGFkNTQ0NDAzYmMxMTk4NWU0MGMyMmE2NTRhMjYyYTBhIiwidWlkIjoiYjZkOGQwZTY0Yjk0YzcwYmU2ZDUxYTc3NTc1NDAzMTkiLCJ1c2VybmFtZSI6ImdvbnoifSwic2VydmljZSI6eyJuYW1lIjoiZ2l0aHViIiwidXNlcm5hbWUiOiJnc2VydmF0In0sInR5cGUiOiJ3ZWJfc2VydmljZV9iaW5kaW5nIiwidmVyc2lvbiI6MX0sImNsaWVudCI6eyJuYW1lIjoia2V5YmFzZS5pbyBnbyBjbGllbnQiLCJ2ZXJzaW9uIjoiMS4wLjIxIn0sImN0aW1lIjoxNDkyNDc1OTMwLCJleHBpcmVfaW4iOjUwNDU3NjAwMCwibWVya2xlX3Jvb3QiOnsiY3RpbWUiOjE0OTI0NzU2MTAsImhhc2giOiJhMWMzMDMyNDk3YjhjYWNlZTYyOWY1ODJkYjI3NGQ0ZDcyMjY2ZGQyZDQzYTU2ZWE3MzA5YzQ2MDQ4ZGQwODQ5ZmEwMmU3ODY2ZWIxZjE3ZDkwNTlhYjg4YTYyZjE1ZTEzNmIwMzZlZTQ2MjkzY2ZkZmU4YmFiNzU2M2VlMzRlNSIsInNlcW5vIjoxMDI1MTY2fSwicHJldiI6ImViOTZjNzcxNzc2N2JjNDJiNDRiMzkyMjg5MzQxYzAzZWU3ZjJh

@gservat
gservat / mov_to_gif.sh
Last active August 16, 2016 13:19 — forked from zmdominguez/mov_to_gif.sh
Converts a .mov to an animated .gif.Requires ffmpeg and gifsicle.
#!/bin/bash
for i in "$@"
do
case $i in
-f=*|--file=*)
FILENAME="${i#*=}"
;;
-o=*|--out=*)
OUTPUT="${i#*=}"