Skip to content

Instantly share code, notes, and snippets.

View cbednarski's full-sized avatar

Chris Bednarski cbednarski

View GitHub Profile
@cbednarski
cbednarski / nginx-error.conf
Created March 13, 2013 04:52
Example nginx.conf for custom error pages
server {
listen 80;
server_name HOSTNAME;
root /opt/PATH/;
index index.html;
rewrite ^/$ /en/PATH/ redirect;
@cbednarski
cbednarski / balsamiq-installer.sh
Last active December 16, 2015 04:49
Install script for Balsamiq Mockups on Ubuntu 12.04.2
#!/usr/bin/env bash
if [ $EUID != 0 ]; then
"This script must be run with sudo"
exit $?
fi
echo " Installing dependencies"
apt-get install ia32-libs -y # Note: This dep is a bit overkill but it's useful anyway
ln -s /usr/lib/i386-linux-gnu/libgnome-keyring.so.0 /usr/lib/libgnome-keyring.so.0
@cbednarski
cbednarski / gist:5712796
Created June 5, 2013 09:42
Run `jslint` on all of your json files.
jslint `find . | grep "\.json$"`
@cbednarski
cbednarski / bootstrap.sh
Last active December 18, 2015 09:19
Knife bootstrap shell wrapper
#!/bin/bash
set -x
if [ $# == 2 ]; then
echo ">>> Cleaning up existing chef environment"
knife node delete -y $2
knife client delete -y $2
ssh -l root $2 'yum remove -y chef'
ssh -l root $2 'rm -rf /etc/chef'
ssh -l root $2 'rm -rf /opt/chef'
echo ">>> Bootstrapping $1 $2"
@cbednarski
cbednarski / doorme.sh
Created June 12, 2013 02:08
If you already have sudo, add yourself to root
#!/bin/bash
if [ $# == 1 ]; then
echo "adding ssh key to root on $1"
ssh $1 'sudo mkdir /root/.ssh/ || sudo chmod 700 /root/.ssh/'
cat ~/.ssh/id_rsa.pub | ssh $1 'sudo tee -a /root/.ssh/authorized_keys'
exit 0
else
echo "wrong number of parameters"
exit 1
fi
@cbednarski
cbednarski / .zshrc
Last active December 18, 2015 16:28
ZSH=$HOME/.oh-my-zsh
ZSH_THEME="robbyrussell"
plugins=(git)
source $ZSH/oh-my-zsh.sh
export EDITOR=vim
# Java
export JAVA_HOME=`/usr/libexec/java_home -v 1.6`
@cbednarski
cbednarski / gist:6180620
Created August 8, 2013 01:22
Simple wrapper for system calls in python
def call(command):
return subprocess.check_output(command.split(' '))
@cbednarski
cbednarski / gist:6181146
Created August 8, 2013 03:15
When untarring a ton of files at once and you want to see when they finish
watch -d "find /opt/artifacts -mindepth 1 -maxdepth 1 -type d | wc -l | tr -d '\n' ; echo -n ' / ' ; find /opt/artifacts -mindepth 1 -maxdepth 1 -type f | wc -l"
@cbednarski
cbednarski / gist:6198582
Last active December 20, 2015 21:38
pymongo collections and data binding
class MongoModel(object):
def __init__(**kwargs):
for key, value in kwargs.iteritems():
# self.__dict__[key] = value
setattr(self, key, value)
class MongoList(object):
def __init__():
if not self._type:
self._type = self.__name__[:-1]
@cbednarski
cbednarski / go-build.sublime-build
Last active December 22, 2015 01:59
Go build systems for Sublime Text 3
{
"env": {"GOPATH":"$HOME/go"},
"cmd": ["go", "build", "$file"]
}