Skip to content

Instantly share code, notes, and snippets.

Giles gilesbowkett

Block or report user

Report or block gilesbowkett

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gilesbowkett
gilesbowkett / clean-branches.bash
Created Apr 16, 2019
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
gilesbowkett / migration.rb
Created Jun 13, 2011
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/'
}
# https://superuser.com/a/599156
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 user.name))> \[\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\]¯\_(ツ)_/¯"
fi
}
@gilesbowkett
gilesbowkett / heroku_style_baby.rb
Created Jun 17, 2012
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")
end
@gilesbowkett
gilesbowkett / にほんご.rb
Last active Oct 14, 2016
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.
View d-gen.clj
(asdf)
(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)))))
@gilesbowkett
gilesbowkett / wat.txt
Created Sep 8, 2016
remove the duplication
View wat.txt
¯\_(ツ)_/¯ ag "remove the duplication"
node_modules/angular2/bundles/angular2-all.umd.js
160: // TODO(alexeagle): remove the duplication of this doc. It is copied from ComponentMetadata.
185: // TODO(alexeagle): remove the duplication of this doc. It is copied from DirectiveMetadata.
565: // TODO(alexeagle): remove the duplication of this doc. It is copied from ViewMetadata.
614: // TODO(alexeagle): remove the duplication of this doc. It is copied from QueryMetadata.
723: // TODO(alexeagle): remove the duplication of this doc. It is copied from ContentChildrenMetadata.
745: // TODO(alexeagle): remove the duplication of this doc. It is copied from ContentChildMetadata.
767: // TODO(alexeagle): remove the duplication of this doc. It is copied from ViewChildrenMetadata.
848: // TODO(alexeagle): remove the duplication of this doc. It is copied from ViewChildMetadata.
@gilesbowkett
gilesbowkett / governance.md
Last active Mar 11, 2016
GitHub and "canonical" vs "original"
View governance.md
You can’t perform that action at this time.