Skip to content

Instantly share code, notes, and snippets.

View chreke's full-sized avatar
💭
Just catching up on some reading

Christoffer Ekeroth chreke

💭
Just catching up on some reading
View GitHub Profile
@chreke
chreke / .gitconfig
Created October 4, 2016 07:26
Example Git configuration
; Aliases lets you define shortcuts for common git commands,
; so you can type "git st" instead of "git status", for example.
[alias]
st = status
ci = commit --verbose
br = branch
co = checkout
; IMPORTANT! Please specify the same email address here as the one
; you use on GitHub!
[user]
[{
username: 'chreke',
url: 'http://allihoopa.com/chreke'
}, {
username: 'mhallin',
url: 'http://allihoopa.com/mhallin'
}]
It is amazing what you can accomplish if you do not care who gets the credit. ~ Harry S. Truman
If we knew what we were doing, it wouldn't be called research, would it? ~ Albert Einstein
Most people would rather die than think; in fact, they do so. ~ Bertrand Russell
Experience is the name everyone gives to their mistakes. ~ Oscar Wilde
All animals are equal — but some animals are more equal than others. ~ Animal Farm by George Orwell
This country has come to feel the same when Congress is in session as when the baby gets hold of a hammer. ~ Will Rogers
I think all foreigners should stop interfering in the internal affairs of Iraq. ~ Paul Wolfowitz
The law will never make men free; it is men who have got to make the law free. ~ Henry David Thoreau
History would be an excellent thing if only it were true. ~ Leo Tolstoy
Without friends no one would choose to live, though he had all other goods. ~ Aristotle
@chreke
chreke / remotes.sh
Created May 27, 2015 07:02
Show remotes sorted by date
for branch in `git branch -r | grep -v HEAD`
do
echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch
done | sort -r
@chreke
chreke / prune.sh
Last active August 29, 2015 14:07
Prune merged branches from your repository
git fetch --prune && git branch --merged master | grep -v 'master$' | xargs -n 1 git branch -d
@chreke
chreke / cleaner.rb
Last active August 29, 2015 14:07
Ruby script to clean up dead git branches
#!/usr/bin/ruby
# Interactively remove branches not in remote, *by name*. This is
# useful for pruning branches that were rebased prior to merging,
# since those branches will not show up in `git branch --merged`.
# List local branches which may have been merged
remotes = `git branch -r`.split.map {|x| x.sub('origin/', '') }
locals = `git branch`.split.select {|x| x != '*' }
complement = locals.select {|x| not (remotes.include? x) }
@chreke
chreke / mdpreview.sh
Last active August 29, 2015 14:07
Render Markdown and open in browser
#!/usr/bin/env bash
OUTPUT=/tmp/$(basename $1).html
markdown $1 > $OUTPUT
open $OUTPUT
# FIXME: This is a hack to prevent deleting the file before it's opened.
# Is it possible to use `wait` instead?
sleep 1
rm $OUTPUT
@chreke
chreke / json-to-csv.py
Last active August 29, 2015 14:07
JSON to CSV
#!/usr/bin/env python
# Reads JSON from a file or STDIN and outputs CSV to STDOUT.
import fileinput
import json
import sys
import csv
jsonstr = ''
@chreke
chreke / gist:7740342
Last active December 29, 2015 22:59
JSQL Sketch
// Quick sketch / spec for how a JSQL module might work
var people = [{
'name': 'Mary Jane Watson',
'job': 'Actress',
'alignment': 'Good',
'age': 23
}, {
'name': 'Peter Parker',
'job': 'Photographer',
@chreke
chreke / json-to-csv
Last active December 26, 2015 04:49
Convert JSON to CSV using Ruby
#!/usr/bin/env ruby
# USAGE:
#
# json-to-csv [filename]
#
# This script takes a JSON array of objects as its input and outputs
# the data as CSV to STDOUT. The JSON array can be fed to the
# script either via STDIN or by supplying a filename as an argument.