Skip to content

Instantly share code, notes, and snippets.

View urjitbhatia's full-sized avatar

Urjit Singh Bhatia urjitbhatia

View GitHub Profile
@urjitbhatia
urjitbhatia / beanstalkd
Last active October 9, 2015 20:04
Beanstalkd upstart config with binary log file for Ubuntu. Place in /etc/init.d/
#!/bin/sh
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.
#
# This is distributed in the hope that it will be useful, but
@urjitbhatia
urjitbhatia / gist:0b3e64c0b7a886c23b3d1890f9cf612b
Created July 21, 2016 22:35
Terraform_Debug_output_enabledMetrics
2016/07/21 15:30:18 [DEBUG] terraform-provider-aws: Action=DescribeAutoScalingGroups&AutoScalingGroupNames.member.1=<redacted>&Version=2011-01-01
2016/07/21 15:30:18 [DEBUG] terraform-provider-aws: -----------------------------------------------------
2016/07/21 15:30:19 [DEBUG] terraform-provider-aws: 2016/07/21 15:30:19 [DEBUG] [aws-sdk-go] DEBUG: Response autoscaling/DescribeAutoScalingGroups Details:
2016/07/21 15:30:19 [DEBUG] terraform-provider-aws: ---[ RESPONSE ]--------------------------------------
2016/07/21 15:30:19 [DEBUG] terraform-provider-aws: HTTP/1.1 200 OK
2016/07/21 15:30:19 [DEBUG] terraform-provider-aws: Connection: close
2016/07/21 15:30:19 [DEBUG] terraform-provider-aws: Transfer-Encoding: chunked
2016/07/21 15:30:19 [DEBUG] terraform-provider-aws: Content-Type: text/xml
2016/07/21 15:30:19 [DEBUG] terraform-provider-aws: Date: Thu, 21 Jul 2016 22:30:19 GMT
2016/07/21 15:30:19 [DEBUG] terraform-provider-aws: Vary: Accept-Encoding
@urjitbhatia
urjitbhatia / darn.sh
Created January 10, 2017 19:21
Running multiple instances of yarnpkg jobs on CI servers
#!/bin/bash
# Place this file in your /usr/local/bin and then use darn instead of calling yarn
# This will wrap all your yarn calls to go through the same network mutex
# Calling yarn as before still works too if needed.
# --- Motivation ---
# Running multiple build jobs on CI servers like Jenkins will cause contention of
# shared yarnpkg resources (cache). This is going to end up badly for builds going
# out for deployment. This problem is usually not seen locally because devs rarely build
@urjitbhatia
urjitbhatia / docker_killer.py
Last active May 13, 2019 21:16
Python script to force kill docker containers older than a certain number of minutes
#!/usr/bin/python
# Quick and dirty script to kill containers older than some number of minutes
# Kills all containers older than 60 minutes by default!
import sys
import subprocess
from sets import Set
CMD_DOCKER_CONTAINERS_WITH_AGE = 'docker ps -a --format "{{.ID}} {{.Status}}"'
@urjitbhatia
urjitbhatia / dockerce_dockercompose_install_ubuntu14.sh
Last active August 9, 2017 01:34
one script to install docker-ce and docker-compose on ubuntu 14
#/bin/bash
sudo apt-get update
sudo apt-get install -y \
linux-image-extra-$(uname -r) \
linux-image-extra-virtual
sudo apt-get install -y \
apt-transport-https \
@urjitbhatia
urjitbhatia / ramdisk.sh
Created June 10, 2017 06:57 — forked from rxin/ramdisk.sh
ramdisk create/delete on Mac OS X.
#!/bin/bash
# From http://tech.serbinn.net/2010/shell-script-to-create-ramdisk-on-mac-os-x/
#
ARGS=2
E_BADARGS=99
if [ $# -ne $ARGS ] # correct number of arguments to the script;
then
@urjitbhatia
urjitbhatia / haproxy_cfg.conf
Created March 29, 2018 21:52
haproxy send a percentage of traffic
# send 10% traffic
http-request set-header Host foo.bar.com if { rand(10) eq 0 }
@urjitbhatia
urjitbhatia / nomadTerminator.sh
Last active December 23, 2021 18:38
Drain a nomad EC2 spot instance node on termination
#!/bin/bash
CMD="curl --write-out %{http_code} --silent --output /dev/null http://169.254.169.254/latest/meta-data/spot/termination-time"
while true
do
if [ "$(${CMD})" != "404" ]; then
# 2 minute warning received. Do all your cleanup work.
echo "2 minute termination warning. Draining nomad node..."
nomad node-drain -yes -self -enable
echo "Hasta la vista baby, I will be back"
break
@urjitbhatia
urjitbhatia / Send docker image over ssh
Created April 2, 2018 00:40
One liner to send docker image to a remote host over ssh
docker save <image> | bzip2 | pv | ssh user@host 'bunzip2 | docker load'
## Credits: https://stackoverflow.com/questions/23935141/how-to-copy-docker-images-from-one-host-to-another-without-via-repository
@urjitbhatia
urjitbhatia / getIfaceIP.sh
Created May 4, 2018 22:33
Get the current external facing interface ip
ip route get 8.8.8.8 | awk '{print $NF; exit}'