Skip to content

Instantly share code, notes, and snippets.

herding bits

Trevor Rosen trevrosen

herding bits
View GitHub Profile
View gist:7239fdb11eb826abe616
╭─trevorrosen@Saramago ~
╰─$ cat
#!/usr/bin/env python
from sys import argv
print argv
╭─trevorrosen@Saramago ~
╰─$ ./
trevrosen / gist:653282fc5717c2ab5bdd
Last active Nov 18, 2015
How MRI Ruby's ARGV really works
View gist:653282fc5717c2ab5bdd
# The docs say that ARGV[0] should be the name of the Ruby executable.
# This is **NOT** how Ruby actually behaves:
─trevorrosen@Saramago ~
╰─$ cat argv-test.rb
#!/usr/bin/env ruby
trevrosen /
Last active Oct 20, 2015
A shell function to set up a Go project for contribution
# Set up a Go project for contribution. This setup gets around issues related to intra-package import paths
# $1 - the origin of the package, e.g. ""
# $2 - the name of the package in the fork, e.g. "hugo"
export GITHUB_USERNAME="trevrosen"
gohack (){
echo "[-] Getting package $1"
go get $1
cd $GOPATH/src/$1
echo "[-] Creating fork environment for $2"
View gist:32635216d03ab96e5593
# From Dave Thomas' Elixir book:
fizzbuzz = fn
0,0,_ -> "FizzBuzz"
0,_,_ -> "Fizz"
_,0,_ -> "Buzz"
_,_,n -> n

Keybase proof

I hereby claim:

  • I am trevrosen on github.
  • I am trevrosen ( on keybase.
  • I have a public key whose fingerprint is 17F7 7DE6 AF9C A777 FA53 8281 5605 4B6F F40D E0F9

To claim this, I am signing this object:

trevrosen / gist:049a6880c3f53b71b8cd
Created Apr 15, 2015
Example of using goroutines and channels to cleanly handle SIGINT
View gist:049a6880c3f53b71b8cd
package main
import (
trevrosen / gist:6694449
Created Sep 25, 2013
Hash#fetch -- a good approach for required arguments in argument hashes
View gist:6694449
def foobar(args={})
@required = args.fetch(:required) # .fetch will throw exception if key doesn't exist in Hash
@optional = args[:optional] # simple access returns nil if key isn't set -- no exception raised
trevrosen / gist:4708561
Created Feb 4, 2013
My terminal prompt, adapted from another oh my zsh theme
View gist:4708561
export LSCOLORS="Dxfxcxdxbxegedabagacad"
local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
local git_branch='$(git_prompt_info)%{$reset_color%}'
PROMPT="╭─${user_host}${current_dir} ${git_branch}
╰─%B$%b "
View gist:1424987
# Automatically insert closing parens, braces, etc
vim_plugin_task "autoclose", "git://"
# Bunch of nice snippets for Snipmate
vim_plugin_task "scrooloose-snippets" do
snippet_dirs = %w(ruby-rspec javascript-jquery html haml) # dirs w/ snippets you want
storage_path = File.expand_path("~/.vim/extra_snippets", __FILE__)
snipmate_path = File.expand_path("~/.vim/snippets", __FILE__)
View Blackboard-ish.xccolortheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<string>0.044 0.063 0.129</string>
<string>1.000 1.000 1.000</string>