Skip to content

Instantly share code, notes, and snippets.

View whiteley's full-sized avatar

Matt Whiteley whiteley

View GitHub Profile
@timcharper
timcharper / gist:198039
Created September 30, 2009 11:44
how to create an empty commit under an existing initial commit
$ rm -rf .git
$ git init
Initialized empty Git repository in /Users/timcharper/project/.git/
$ date > file.txt
$ git add file.txt
$ git commit -m "initial commit"
[master (root-commit) 399a71c] initial commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 file.txt
master$
@dysinger
dysinger / *scratch*
Created April 14, 2010 05:16
Chef-repo & Opsode Cookbooks in the same git repo
#!/bin/sh
# Demo how your can merge opscode chef-repo & cookbooks
# and perm. keep up to date with opscode cookbooks (the last "git" cmd)
% git clone git://github.com/opscode/chef-repo.git
Initialized empty Git repository in /home/tim/src/chef-repo/.git/
remote: Counting objects: 107, done.
remote: Compressing objects: 100% (99/99), done.
remote: Total 107 (delta 45), reused 0 (delta 0)
Receiving objects: 100% (107/107), 16.14 KiB, done.
Resolving deltas: 100% (45/45), done.
@bakins
bakins / gist:804922
Created January 31, 2011 22:02
brain dead data bags in chef solo
if Chef::Config[:solo]
class Chef
module Mixin
module Language
def data_bag(bag)
@solo_data_bags = {} if @solo_data_bags.nil?
unless @solo_data_bags[bag]
@solo_data_bags[bag] = {}
Dir.glob(File.join(Chef::Config[:data_bag_path], bag,
@potatosalad
potatosalad / project-web-reload.conf
Created February 11, 2012 03:32
Upstart + Bluepill + Unicorn with hot restart
# /etc/init/project-web-reload.conf
pre-start script
initctl restart project-web
sleep 15
end script
exec /usr/local/rvm/bin/default_bluepill restart
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@juanje
juanje / gist:3797297
Created September 28, 2012 00:38
Mount apt cache of a Vagrant box in the host to spin up the packages installation

This is a little trick I use to spin up the packages instalation on Debian/Ubuntu boxes in Vagrant.

I add a simple function that checks if a directory named something similar to ~/.vagrant.d/cache/apt/opscode-ubuntu-12.04/partial (it may have another path in Windows or MacOS) and create the directory if it doesn't already exist.

def local_cache(basebox_name)
  cache_dir = Vagrant::Environment.new.home_path.join('cache', 'apt', basebox_name)
  partial_dir = cache_dir.join('partial')
  partial_dir.mkdir unless partial_dir.exist?
 cache_dir
@dariusk
dariusk / amazonlogin.js
Created November 14, 2012 14:39
Logging in to Amazon using PhantomJS
// phantomjs code to log in to Amazon
// based on the code from this Stackoverflow answer: http://stackoverflow.com/questions/9246438/how-to-submit-a-form-using-phantomjs
// I'm injecting jQuery so this assumes you have jquery in your project directory
var page = new WebPage(), testindex = 0, loadInProgress = false;
page.onConsoleMessage = function(msg) {
console.log(msg);
};
@chrisberkhout
chrisberkhout / mirror-apt-opengeo-org.sh
Last active November 21, 2016 17:49
A script to mirror the OpenGeo APT repository on S3 (so you still have packages for your version of the suite when OpenGeo releases a new version). Depends on `wget` and `s3cmd`.
#!/bin/bash
repo_host="apt.opengeo.org"
repo_dir="suite/v3/ubuntu"
repo_release="lucid"
echo -n "===> Please enter a bucket name: "
read -e bucket
echo "===> Confirming you have s3cmd configured..."
@savethefails
savethefails / RubyScope.rb
Last active December 12, 2019 21:18
I found keeping track of 'self' in Ruby Classes to be exhausting, so I created this handy example illustrating when self changes, where instance variables are stored, and against which self methods are executed.
class RubyScope
# `self` is the RubyScope Class
# (i.e. an Instance of RubyScope MetaClass)
@variable_type = 'class instance variable'
# Methods are defined in a class, but executd on an instance
# Created on self: "RubyScope", Executed on self: "any instance of RubyScope"
def initialize
# `self` is an Instance of RubyScope Class
@variable_type = 'instance variable'