Skip to content

Instantly share code, notes, and snippets.

@tekton
tekton / gist:6133900
Created August 1, 2013 18:27
Primitive switch in Python
import random
def functionToCall(x="..."):
print "I got called with " + x + "!"
class SwitchTest:
state = {}
state_dict = {0: {"stat": "one", "function": functionToCall},
@tekton
tekton / gist:9943256
Last active August 29, 2015 13:58
get pylibmc working on mavericks
#!/bin/bash
brew install libmemcached
easy_install pip
pip install virtualenv
virtualenv VENV
source VENV/bin/activate
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
pip install pylibmc
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain
@tekton
tekton / p3.sh
Created June 18, 2014 20:17
Ubuntu 14.04 Python 3.4 Virtual Environment
#!/bin/bash
V_PATH=.
VENV=VENV
# check for folder path and name...
if [ $1 ]; then
V_PATH=$1
fi
if [ $2 ]; then
VENV=$2
@tekton
tekton / sshfix.sh
Created June 26, 2014 18:37
ubuntu 14.04 SSH Server Fix
#!/bin/bash
sudo ssh-keygen -b 1024 -t rsa -f /etc/ssh/ssh_host_key
sudo ssh-keygen -b 1024 -t rsa -f /etc/ssh/ssh_host_rsa_key
sudo ssh-keygen -b 1024 -t dsa -f /etc/ssh/ssh_host_dsa_key
@tekton
tekton / gist:c93d50f7de4b5099c93d
Last active August 29, 2015 14:07
newrelic_server.bash
#!/bin/bash
echo "deb http://apt.newrelic.com/debian/ newrelic non-free" > newrelic.list
sudo cp newrelic.list /etc/apt/sources.list.d/newrelic.list
rm newrelic.list
#
wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install newrelic-sysmond
#
sudo nrsysmond-config --set license_key=$1
@tekton
tekton / cdh5.bash
Created November 2, 2014 21:01
cloudera 5 manager install
#!/bin/bash
wget http://archive.cloudera.com/cm5/installer/latest/cloudera-manager-installer.bin
chmod u+x cloudera-manager-installer.bin
sudo ./cloudera-manager-installer.bin
@tekton
tekton / gist:caec3623e3a8f60e4b0c
Last active August 29, 2015 14:19
centos-prep-vbox
#!/bin/bash
yum --enablerepo rpmforge install dkms
yum groupinstall -y "Development Tools"
yum install -y kernel-devel
@tekton
tekton / gist:736ba476aa416e413d2d
Created May 22, 2015 02:44
operator_string_switch
"""
The goal here is to create a "switch" like environment to allow for using
strings and other representations for dynamic comparison of two values.
Uses the operator library: https://docs.python.org/2/library/operator.html
"""
import operator
OPS = {
'=': operator.eq,
@tekton
tekton / iptables_update.bash
Last active September 23, 2015 16:30
Using the "standard" locations for openvpn settings this will create a self contained file for connecting
#!/bin/bash
sudo iptables -A INPUT -i tun+ -j ACCEPT
sudo iptables -A FORWARD -i tun+ -j ACCEPT
sudo iptables -A FORWARD -i tun+ -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o tun+ -m state --state RELATED,ESTABLISHED -j ACCEPT
# be sure to replace 10.8.0.0/24 with whatever is in your settings, this example for default install
sudo iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
sudo iptables -A OUTPUT -o tun+ -j ACCEPT