Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Farrell farrellit

View GitHub Profile
View t.c
#include <stdio.h>
void f() {
printf("Hello, world") ;
}
int main() {
f();
}
@farrellit
farrellit / stdin_yaml_to_json.sh
Last active Sep 19, 2019
shell inline python invocation to transform yaml to json
View stdin_yaml_to_json.sh
python -c "import yaml, sys, json; print(json.dumps(yaml.safe_load(sys.stdin.read())))"
@farrellit
farrellit / README.md
Last active Oct 25, 2018
thoughts on git commands for automatic k8s branch deployments
View README.md

Git commands for a slim deployment pipeline for github branches

get current branch

TODO: what happens if you're not on a branch?

git rev-parse --abbrev-ref HEAD

Get upstram of current branch

View overwrite-ssh-pubkey
ip=...
#pubkey=... # default should suffice if you have the default key location
ssh $ip "bash -c 'mkdir -p ~/.ssh; chmod 0700 ~/.ssh; cat > ~/.ssh/authorized_keys'" < ${pubkey:-~/.ssh/id_rsa.pub
View docker-cleanup.sh
# remove containers which have exited
docker ps -a | awk '/Exited[ ]\(/ {print $1}' | xargs docker rm
# remove images without tag nor repo
docker images | awk '/^<none>[[:space:]]*<none>/ {print $3}' | xargs docker rmi
View gist:8cc1c16449ee04170103a73bec1c85d1
# find directories containing .git subdirs
find ~/ -type d -name '.git' -print0 | xargs -n 1 -0 dirname \
| xargs -I % -n 1 bash -c 'cd "%" && pwd 1>&2; (git status --porcelain| grep -q . && [[ ! -n "`git diff`" ]] ) || echo %'\
| xargs -I % bash -c '[[ -n "`cd %; git status --porcelain; git diff;`" ]] && echo %' \
| tee /dev/stderr | sort > purportedly-empty-repos.txt
#That makes sure you don't have any uncommitted changes. But it still doesn't check to make sure you don't have unpushed commits.
@farrellit
farrellit / ec2-describe-instances.go
Last active Dec 13, 2019
golang awssdk ec2 describe-instances
View ec2-describe-instances.go
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
)
func main() {
View rerun-on-change.sh
olddate=''
cmd='make r53'
while true; do newdate=`stat -f %m rotate-by-r53.py `; [[ "$olddate" == "$newdate" ]] || { olddate="$newdate"; $cmd; }; sleep 0.25; done
View discover-r53-elbs.sh
aws route53 list-hosted-zones --query HostedZones[?Id!=null].Id --output text \
| grep -v None \
| xargs -n 1 -P 10 \
aws route53 list-resource-record-sets \
--query 'ResourceRecordSets[?AliasTarget!=null][AliasTarget.DNSName]' \
--output text --hosted-zone-id | grep -F elb.amazonaws.com
View gist:4e526552f1b322706d8d0003d607edfe
aws route53 list-hosted-zones --query HostedZones[?Id!=null].Id --output text | grep -v None | xargs -n 1 aws route53 list-resource-record-sets --query 'ResourceRecordSets[?AliasTarget!=null][AliasTarget.DNSName]' --hosted-zone-id --output text | grep -F elb.amazonaws.com