Skip to content

Instantly share code, notes, and snippets.

a simple git branching model

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

The gist

@bmarini
bmarini / stdin.go
Created December 30, 2014 16:57
Read lines from stdin
package main
import (
"bufio"
"fmt"
"io"
"os"
)
func main() {
class Array
# Converts [[k1,v1],[k2,v2]] into {k1 => v1, k2 => v2}
# The opposite of Hash#to_a
# Same as `Hash[ary.flatten]`
def to_h
inject({}) {|h,el| h[el[0]] = el[1]; h }
end
end
@bmarini
bmarini / keybase.md
Created June 30, 2015 18:20
keybase.md

Keybase proof

I hereby claim:

  • I am bmarini on github.
  • I am benmarini (https://keybase.io/benmarini) on keybase.
  • I have a public key whose fingerprint is 071F BE82 8D4C 65BA D311 A8BA FC0E E0BF 8831 987C

To claim this, I am signing this object:

#/bin/bash
# Builds a gc patched ruby according to:
# http://guides.rubyonrails.org/benchmarking_and_profiling.html#_performance_test_cases
mkdir ${HOME}/rubygc
mkdir -p ${HOME}/src
# 1. Compile
echo "-- compiling ruby from source with gc patch --"
cd ${HOME}/src
@bmarini
bmarini / backup-sites
Created January 4, 2009 20:51
A quick and dirty website backup script
#!/bin/bash
# a quick and dirty backup script.
# if you have a websites folder and some databases to backup
# this script might be a good starting point.
# this script assumes you have user named admin.
BASE_DIR='/'
TARGET_DIR='sites'
BACKUP_TIME=`date +%Y%m%d%H%I%S`
BACKUP_FILENAME="${BACKUP_TIME}-${TARGET_DIR}"
=== Epic Snow Leopard Upgrayyyyd Guide ===
More info here: http://www.gregbenedict.com/2009/08/29/fixing-ruby-gems-mysql-and-passenger-phusion-on-snow-leopard-10-6/
Son, you’re now living in the land of 64-bit systems.
That means that some of your 32-bit shit is now broken.
Not all is lost.
Example for .bashrc:
export LSCOLORS="exfxcxdxbxegedabagacad"
a black
b red
c green
d brown
e blue
f magenta
g cyan
sudo atsutil databases -remove
atsutil server -shutdown
atsutil server -ping
@bmarini
bmarini / average_time_of_day.rb
Created October 19, 2009 01:07
Solution to RPCFN #2
module AverageTimeOfDay
require 'date'
# Assumes times_of_day is an array of valid time strings in chronological
# order.
def average_time_of_day(times_of_day)
# Convert times_of_day to an array of Time objects, ensuring that times
# are in chronological order by adding a day if the the time of the
# current iteration is earlier than the last iterated time.
times = times_of_day.inject([]) do |times, time_of_day|
dt = DateTime.strptime(time_of_day, "%I:%M%p")