Skip to content

Instantly share code, notes, and snippets.

$ bash -x powerline.sh left
++ dirname powerline.sh
+ export TMUX_POWERLINE_DIR_HOME=.
+ TMUX_POWERLINE_DIR_HOME=.
+ source ./config/helpers.sh
+ source ./config/paths.sh
++ export TMUX_POWERLINE_DIR_LIB=./lib
++ TMUX_POWERLINE_DIR_LIB=./lib
++ export TMUX_POWERLINE_DIR_SEGMENTS=./segments
++ TMUX_POWERLINE_DIR_SEGMENTS=./segments
@urbanautomaton
urbanautomaton / enumerator.rb
Last active December 14, 2015 15:19
jruby destructuring oddity
pairs = [[1,1],[2,2],[3,3]]
enumerator = Enumerator.new do |y|
pairs.each { |x| y.yield(x) }
end
puts "Array:"
puts pairs.find {|a,b| a > 2}.inspect
puts pairs.find {|a,b| b > 2}.inspect
@urbanautomaton
urbanautomaton / git_ps1_fast.sh
Last active December 15, 2015 05:09
Faster version of __git_ps1 if you only want current branch
#!/bin/bash
function git_ps1_fast() {
local dir="$PWD"
local git_dir
until [[ -z "$dir" ]]; do
git_dir="$dir/.git"
if [[ -d "$git_dir" ]]; then
echo " (`git rev-parse --abbrev-ref HEAD`)"
@urbanautomaton
urbanautomaton / wtf.rb
Last active December 19, 2015 22:58
Fuck Rails const autoloading
# lib/a.rb
module A
end
# lib/b.rb
class B
end
# $ rails console
# > A.const_missing("B")
@urbanautomaton
urbanautomaton / doc.markdown
Last active December 21, 2015 07:29
Git: interactive rebase autosquash helpers

Update: as I suspected, this is a stupid exercise in wheel-reinventing, and I could've done git commit --fixup=<commitish> all along. Thanks, Mudge.

For interactive rebase and autosquash background, see here.

All this helper does is construct commit messages that will be picked up by autosquash, using a commitish reference so you don't have to do the message yourself. If we know we have some changes that should've gone in the commit before last, and we don't want to add to its commit message, our workflow is now:

  1. make changes
  2. stage changes
  3. $ fixup HEAD^
  4. $ git rebase -i --autosquash when ready
method=POST path=/training_sessions format=api_v1 controller=training_sessions action=create status=201 duration=738.18 view=303.25 db=0.00 params={"workout_duration"=>nil, "workout_name"=>nil, "training_session"=>{"workout_id"=>nil, "post_to_twitter"=>1, "started_at"=>"12 Sep 2013", "content"=>"Cycle to work", "map_visibility"=>"public", "photos_attributes"=>{}, "training_logs_attributes"=>[{"distance"=>1.526738, "time_minutes"=>5, "time_hours"=>0, "time_seconds"=>33, "raw_data"=>"[FILTERED]", "amount"=>nil, "exercise_id"=>nil, "route_name"=>nil, "distance_unit"=>"km", "weight"=>nil, "weight_unit"=>"kg"}], "visibility"=>"public", "post_to_facebook"=>1}, "workout_difficulty"=>nil}
method=POST path=/training_sessions format=api_v1 controller=training_sessions action=create status=201 duration=322.64 view=53.30 db=0.00 params={"workout_duration"=>nil, "workout_name"=>nil, "training_session"=>{"workout_id"=>nil, "post_to_twitter"=>1, "started_at"=>"12 Sep 2013", "content"=>nil, "map_visibility"=>"public", "photo
@urbanautomaton
urbanautomaton / disable_autospell.md
Last active April 12, 2018 08:46
disable autospell completely
sudo mv /System/Library/Services/AppleSpell.service/Contents/Resources{,.disabled}

Then in Activity Monitor, find and kill the AppleSpell.service process, and restart any apps that are using it.

Worked On My Machine(tm).

@urbanautomaton
urbanautomaton / core.clj
Last active August 29, 2015 14:02
Overtone code to play the amen break
(ns amen.core
(:require [overtone.live :refer :all]))
(def snare (freesound 26903))
(def crash (freesound 26884))
(def ride (freesound 26889))
(def kick (freesound 26888))
(def amen-tabs
[{:sound crash, :tab "----------------|----------------|----------------|----------x-----"}
@urbanautomaton
urbanautomaton / example
Last active August 29, 2015 14:19
Set GOPATH and PATH if .goworkspace present
$ echo $GOPATH
$ echo $PATH
/bin:/usr/bin:/usr/local/bin
$ mkdir -p /tmp/some_project
$ touch /tmp/some_project/.goworkspace
$ cd /tmp/some_project
$ echo $GOPATH
/tmp/some_project
$ echo $PATH
302 Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
72 Extra empty line detected at block body end.
71 Extra empty line detected at block body beginning.
52 Extra empty line detected at class body beginning.
47 Final newline missing.
45 Extra empty line detected at class body end.
40 Align the operands of an expression in an assignment spanning multiple lines.
35 Extra blank line detected.
22 Trailing whitespace detected.
22 Tab detected.