Skip to content

Instantly share code, notes, and snippets.

View ambakshi's full-sized avatar

Amit Bakshi ambakshi

View GitHub Profile
@ambakshi
ambakshi / asgard-bootstrap.sh
Last active August 29, 2015 13:58
Download and run Asgard locally
#!/bin/bash
#
# curl -fsSL http://bit.ly/YXV7L3 | bash -e
#
#
set -e
DIR=$HOME/bin
[ -d "$DIR" ] || mkdir -p "$DIR"
@ambakshi
ambakshi / screenrc
Created April 30, 2014 21:24
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 June 19, 2014 21:37
set up ssh agent
#!/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 August 29, 2015 14:04
Awk script to extract class decls from pp files
#!/usr/bin/env gawk
#
# Only print stuff inside the puppet class:
#$0 ~ /^[ \t]*$/ {on = 0}
#
BEGIN {
cls_name="";
}
#!/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 August 29, 2015 14:04
Go compiled binary to query an instance for tags vs aws cli.
$ 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
OPTS_SPEC="\
$(basename $0 .sh) subcommand <options>
subcommands:
data - download a dataset
--
h,help show help
d,debug debug output
v,verbose verbose output
$ ~/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:
@ambakshi
ambakshi / jenkins-master.conf
Last active August 29, 2015 14:06
Jenkins upstart script
#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 / block-device-map.json
Last active August 29, 2015 14:06
Using jq to modify a Json object
// Modify the following JSON object such that the SnapshotId of device /dev/sda1 is 'snap-12345678' and size is 4,
// while maintaining the structure of the of the object.
// You can't make assumptions about how it is formatted, except to say it's legal json.
[
{
"Ebs": {
"VolumeSize": 32,
"SnapshotId": "snap-ee16314e",
"DeleteOnTermination": true