Skip to content

Instantly share code, notes, and snippets.

gilesbowkett / clean-branches.bash
Created April 16, 2019 20:14
easily clean git branches
View clean-branches.bash
ruby bin/clean-branches.rb $* >/dev/null 2>/dev/null && git for-each-ref --sort='-authordate:iso8601' --format=' %(authordate:relative)%09%(refname:short)' refs/heads
gilesbowkett / default.js
Created June 30, 2011 16:43
posterous, come on, fuck off already, take the hint
View default.js
// since they do it on non-posterous domains, I put this in ~/.js/default.js
// (using, of course,
$().ready(function() {
if ($('meta[content="Posterous"]')) {
$("<style type='text/css'>a#posterous_footerbar{ display: none }</style>").appendTo("head");
// thnx to @voodootikigod for the meta check - skips unnecessary DOM manipulation delays
View personal git punch card grapher
# usage: ruby timecard.rb path branch name-of-graph-file-not-including-extension
# e.g.: ruby timecard.rb . master timecard #=> produces timecard.png
require 'rubygems'
# This requires the 'cyberfox-gchart' gem (0.5.4), as the standard
# gchart gem is woefully broken for this kind of graph. Broken to the
# point that it's an inherent design choice that doesn't work well for
# this kind of chart. I'm sure that the cyberfox-gchart gem won't
gilesbowkett / migration.rb
Created June 13, 2011 05:38
Rails migrations which automatically put the new filename in your paste buffer
View migration.rb
# this monkey-patches code defined in railties-3.1.0.rc1/lib/rails/generators/migration.rb
# (obviously, this might differ very slightly in the latest release candidate)
module Rails
module Generators
module Migration
module ClassMethods
# differs from the "real" version by only one line
def migration_template(source, destination=nil, config={})
destination = File.expand_path(destination || source, self.destination_root)
View tab-title.bash
function this() { # obtain git branch
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
function tab-title {
echo -ne "\033]0;"$*"\007"
View giles_prompt.bash
function giles_prompt {
tab-title $(this)
# display git user name for pairing via git pair
# "this" function returns git branch name
export PS1="\[\033[0;95m\]<\u (\$(git config> \[\033[0;96m\]\w\[\033[0m\]\[\033[0;32m\] \$(this)\[\033[0m\]\n\[\033[0;34m\] $(unicode_nonsense)\[\033[0m\] "
export PROMPT_COMMAND=giles_prompt
View unicode_nonsense.bash
function unicode_nonsense {
if [ $? -eq 0 ]
then echo "\[\033[0;32m\]ᕕ(ᐛ)ᕗ"
else echo "\[\033[0;31m\]¯\_(ツ)_/¯"
gilesbowkett / heroku_style_baby.rb
Created June 17, 2012 22:37
Heroku-style dev on EC2 || Slicehost || whatev
View heroku_style_baby.rb
require 'rubygems'
require 'sinatra'
require 'json'
class GitHubUpdater
def self.update?(json)
(JSON.parse(json)["ref"] == "refs/heads/master")
gilesbowkett / にほんご.rb
Last active October 14, 2016 22:16
flash cards vocabulary
View にほんご.rb
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
# Examples:
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
# FIXME: only a few flash cards have forms or parts of speech, enough to get the idea going.
gilesbowkett / d-gen.clj
Created September 22, 2016 17:15 — forked from mattly/d-gen.clj
View d-gen.clj
(defn- state-line [[state results]]
(let [d (->> results
(sort-by :year)
(reduce (fn [line {:keys [year from-center]}]
(conj line (str (x-for-margin from-center)
(+ 10 (year-base year)))))