Skip to content

Instantly share code, notes, and snippets.

Avatar

Amit Bakshi ambakshi

View GitHub Profile
@ambakshi
ambakshi / asgard-bootstrap.sh
Last active Aug 29, 2015
Download and run Asgard locally
View asgard-bootstrap.sh
#!/bin/bash
#
# curl -fsSL http://bit.ly/YXV7L3 | bash -e
#
#
set -e
DIR=$HOME/bin
[ -d "$DIR" ] || mkdir -p "$DIR"
View screenrc
# screenrc
encoding UTF-8
# Behaviour
termcapinfo xterm ti@:te@
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm' # Tell screen how to set colors. AB = background, AF=foreground
#attrcolor b ".I" # Allow bold colors - NB: This fucks up dircolors in iTerm2
defbce "on" # Erase background with current bg color
altscreen on
#term xterm-256color
@ambakshi
ambakshi / ssh-agent.sh
Created Jun 19, 2014
set up ssh agent
View ssh-agent.sh
#!/bin/bash
SSH_ENV="$HOME/.ssh/environment.$HOSTNAME"
start () {
if [ -f "$SSH_ENV" ]; then
source "$SSH_ENV"
if kill -0 "$SSH_AGENT_PID" 2>/dev/null; then
echo "Run 'source $SSH_ENV'" >&2
return
@ambakshi
ambakshi / puppet-node-extract.awk
Last active Aug 29, 2015
Awk script to extract class decls from pp files
View puppet-node-extract.awk
#!/usr/bin/env gawk
#
# Only print stuff inside the puppet class:
#$0 ~ /^[ \t]*$/ {on = 0}
#
BEGIN {
cls_name="";
}
View build_centos.sh
#!/bin/bash
set -e
## requires running as root because filesystem package won't install otherwise,
## giving a cryptic error about /proc, cpio, and utime. As a result, /tmp
## doesn't exist.
[ $( id -u ) -eq 0 ] || { echo "must be root"; exit 1; }
tmpdir=$( mktemp -d )
@ambakshi
ambakshi / go-vs-aws.txt
Last active Aug 29, 2015
Go compiled binary to query an instance for tags vs aws cli.
View go-vs-aws.txt
$ time aws ec2 describe-instances --instance-ids "$(curl -s http://169.254.169.254/latest/meta-data/instance-id)" --query 'Reservations[*].Instances[*].Tags' --output text
Owner amit.bakshi
Billing_Code ops
Name ops-deploy-003
Hostgroup ops-deploy
Megatron_Deployment deploy
real 0m1.016s
user 0m0.321s
sys 0m0.134s
View bad-args
$ ~/parse-with-help-from-git.sh data --game-tag foo
Hi from the data command
INPUT_FILE=
DATASET=
GAME_TAG=foo
[amit.bakshi@gii1302greendog bin (master)]
$ ~/parse-with-help-from-git.sh data --bad-arg foo
error: unknown option `bad-arg'
usage: parse-with-help-from-git subcommand <options>
subcommands:
View parse-with-help-from-git.sh
OPTS_SPEC="\
$(basename $0 .sh) subcommand <options>
subcommands:
data - download a dataset
--
h,help show help
d,debug debug output
v,verbose verbose output
@ambakshi
ambakshi / jenkins-master.conf
Last active Aug 29, 2015
Jenkins upstart script
View jenkins-master.conf
#upstart script for a jenkins swarm agent
description "upstart script for jenkins-master"
start on started networking
stop on runlevel [016]
# respawn the job up to 10 times within a 10 second period.
# If the job exceeds these values, it will be stopped and
# marked as failed.
@ambakshi
ambakshi / jdk8-update-alternatives.sh
Last active Aug 29, 2015
Update system java to jdk8
View jdk8-update-alternatives.sh
#!/bin/bash
## JDK=$(cd /usr/java/jdk1.8* && pwd)
JDK=/usr/java/latest
update-alternatives \
--install /usr/bin/java java $JDK/jre/bin/java 18000 \
--slave /usr/lib/jvm/jre jre $JDK/jre \
--slave /usr/bin/javac javac $JDK/bin/javac \
--slave /usr/bin/javah javah $JDK/bin/javah \
--slave /usr/bin/javap javap $JDK/bin/javap \
--slave /usr/bin/jar jar $JDK/bin/jar \