Skip to content

Instantly share code, notes, and snippets.

View trevrosen's full-sized avatar
🦆
herding bits

Trevor Rosen trevrosen

🦆
herding bits
View GitHub Profile
# Automatically insert closing parens, braces, etc
vim_plugin_task "autoclose", "git://github.com/Townk/vim-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__)
@trevrosen
trevrosen / .zshrc.sh
Last active October 20, 2015 02:06
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. "github.com/spf13/hugo"
# $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"
╭─trevorrosen@Saramago ~
╰─$ cat argv-test.py
#!/usr/bin/env python
from sys import argv
print argv
╭─trevorrosen@Saramago ~
╰─$ ./argv-test.py
['./argv-test.py']
@trevrosen
trevrosen / gist:653282fc5717c2ab5bdd
Last active November 18, 2015 15:58
How MRI Ruby's ARGV really works
# The docs say that ARGV[0] should be the name of the Ruby executable.
# http://ruby-doc.org/core-2.2.3/Object.html#ARGV
#
# This is **NOT** how Ruby actually behaves:
─trevorrosen@Saramago ~
╰─$ cat argv-test.rb
#!/usr/bin/env ruby
@trevrosen
trevrosen / gist:4708561
Created February 4, 2013 18:31
My terminal prompt, adapted from another oh my zsh theme
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 "
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[magenta]%}‹"
@trevrosen
trevrosen / gist:6694449
Created September 25, 2013 02:29
Hash#fetch -- a good approach for required arguments in argument hashes
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
end
@trevrosen
trevrosen / gist:049a6880c3f53b71b8cd
Created April 15, 2015 16:29
Example of using goroutines and channels to cleanly handle SIGINT
package main
import (
"fmt"
"log"
"os"
"os/signal"
"time"
)