Skip to content

Instantly share code, notes, and snippets.

@gilesbowkett
gilesbowkett / clean-branches.bash
Created April 16, 2019 20:14
easily clean git branches
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
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"
}
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
function unicode_nonsense {
if [ $? -eq 0 ]
then echo "\[\033[0;32m\]ᕕ(ᐛ)ᕗ"
else echo "\[\033[0;31m\]¯\_(ツ)_/¯"
fi
}
@gilesbowkett
gilesbowkett / にほんご.rb
Last active October 14, 2016 22:16
flash cards vocabulary
# 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
gilesbowkett / d-gen.clj
Created September 22, 2016 17:15 — forked from mattly/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 September 8, 2016 00:20
remove the duplication
¯\_(ツ)_/¯ 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 March 11, 2016 02:03
GitHub and "canonical" vs "original"
@gilesbowkett
gilesbowkett / table.md
Last active December 1, 2015 19:00
table test
Topic Remark
Potatoes Hot
Butter Inedible
Chile Green
class PeopleController < ActionController::Base
# This will raise an ActiveModel::ForbiddenAttributes exception because it's using mass assignment
# without an explicit permit step.
def create
Person.create(params[:person])
end
# This will pass with flying colors as long as there's a person key in the parameters, otherwise
# it'll raise a ActionController::MissingParameter exception, which will get caught by
# ActionController::Base and turned into that 400 Bad Request reply.