Skip to content

Instantly share code, notes, and snippets.

View cbednarski's full-sized avatar

Chris Bednarski cbednarski

View GitHub Profile
@cbednarski
cbednarski / gist:4138965
Last active October 13, 2015 04:27
javascript code to convert AWS hour rates to monthly rates (put it in a bookmarklet)
rates = jQuery(".rate");
for(i in rates) {
rate = rates[i].innerHTML;
if(rate){
matches = rate.match(/\$([\d.]+) per hour/i);
if(matches instanceof Array) {
rates[i].innerHTML = "$"+ Math.ceil(parseFloat(matches[1])*100*(365/12)*24)/100 + " per month";
}
}
}
@cbednarski
cbednarski / gist:4449892
Last active December 10, 2015 14:48
Sublime text build system for phpunit -- runs on the current file
// Mac Lion using homebrew
{
"cmd": ["/usr/local/opt/php54/bin/php", "/usr/local/bin/phpunit", "$file"]
}
// Ubuntu 12.04 with pear-installed PHPUnit
// Ctrl + B to run phpunit
// Ctrl + Shift + B to run the script
@cbednarski
cbednarski / gist:4507950
Created January 11, 2013 04:27
Syntax-specific settings for Sublime Text 2
{
"tab_size": 4,
"translate_tabs_to_spaces": true
}
@cbednarski
cbednarski / gist:4983212
Created February 19, 2013 04:51
Read from standard input using php
<?php
$f = fopen('php://stdin', 'r');
while ($line = fgets($f)) {
// do stuff
}
fclose($f);
@cbednarski
cbednarski / 404.html
Last active December 14, 2015 20:59
Slick 404 page
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
background-color: #333;
font: 60px 'Helvetica, Arial, Ubuntu, sans-serif';
color: #111;
}
h1 {
@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`