Skip to content

Instantly share code, notes, and snippets.

@x684867
x684867 / key_distribution
Created December 31, 2014 20:32
Key distribution
#!/usr/bin/env python
#
import hashlib
def hasher(s):
m=hashlib.sha1()
m.update(s)
return m.hexdigest()
def stringify_keyspace(a):
@x684867
x684867 / centralizedSyslog
Created November 20, 2014 23:37
Syslog centralization script
#centralizedSyslog
#
SET -e
apt-get update --fix-missing -y
apt-get install rsyslog-gnutls -y
echo '# /etc/rsyslog.conf
\$ModLoad imuxsock # provides support for local system logging
\$ModLoad imklog # provides kernel logging support
@x684867
x684867 / NGINX Config
Created November 7, 2014 05:02
Demonstrates proxy pass load balancing to alternative localhost ports.
#See documentation at http://nginx.com/resources/admin-guide/load-balancer/
upstream loadbalancer {
#LHS:80 load balancer end point
server 127.0.0.1 max_fails=1 fail_timeout=5s;
#RHS:80 load balancer end point
server 127.0.0.2 max_fails=1 fail_timeout=5s;
}
server {
#
@x684867
x684867 / monalisa DockerFile
Created November 4, 2014 23:59
DockerFile and plan for munna
# Git project structure
#/--
# DockerFile
# /src/monalisa.tar.gz
# <git source tarball from wercker for monalisa>
# /bin
#Install the Java Runtime
# ./installJre
#Install Maven
@x684867
x684867 / init pattern
Created November 4, 2014 23:14
A simple pattern for init scripts...just for munna.
#!/bin/sh
### BEGIN INIT INFO
# Provides: SERVICE_NAME
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 4 5
# Default-Stop: 0 1 6
# Short-Description: SERVICE_DESCRIPTION
# Description: starts named service using start-stop-daemon
@x684867
x684867 / swap.sh
Created October 26, 2014 20:35
This gist will create swap on an Amazon or GCE cloud server...useful for avoiding crashes.
sudo dd if=/dev/zero of=/swap count=1048576 bs=2048
sudo mkswap /swap
sudo swapon /swap
@x684867
x684867 / install-aws-cli-linux
Created October 15, 2014 20:35
Installs AWS-CLI
#!/bin/bash
sudo apt-get update --fix-missing -y
sudo apt-get install unzip -y
wget https://s3.amazonaws.com/aws-cli/awscli-bundle.zip
unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
rm -rf awscli-bundle*
#!/bin/bash
[ ! -f ./stackdriver.conf ] && {
$(cat ./stackdriver.conf)
export DEBIAN_FRONTEND=noninteractive;
export APTOPT='-y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold --force-yes --yes --fix-missing -qq';
curl -s -o /etc/apt/sources.list.d/stackdriver.list https://repo.stackdriver.com/wheezy.list
curl -s --silent https://app.stackdriver.com/RPM-GPG-KEY-stackdriver |apt-key add -
apt-get update -y
apt-get install stackdriver-agent
sudo sed -i -e "s/STACKDRIVER_API_KEY=\"\"/STACKDRIVER_API_KEY=\"\"/' /etc/default/stackdriver-agent
cat > /etc/sudoer << EOF
Enter your file contents here.
EOF
@x684867
x684867 / prune_large_file.sh
Created September 17, 2014 12:39
This gist covers how to prune large files from a git repo when moving from gitlab to github. It's also helpful for times when someone commits a large .war .iso or other file to the repo.
# Example specifies *.war.
#
# It would work for *.log for developers who git -A . when they shouldn't and upload the contents of /var/log/*
# Just change the --ignore-unmatch parameter.
#
git filter-branch \
--prune-empty \
-d ../scratch \
--index-filter "git rm --cached -f --ignore-unmatch *.war" \
--tag-name-filter cat -- --all