sent hil sent-hil

View ey.rb
1 2 3 4 5 6 7 8 9 10
[33] pry(main)> api = "token_goes_here")
=> #<EY::CloudClient:0x007f8d378e29b8
@endpoint=#<URI::HTTPS:0x007f8d378e2698 URL:>,
[34] pry(main)> account =, {:id => 4212, :name => 'drnic'})
=> #<struct EY::CloudClient::Account
View go_vroom
1 2 3 4 5 6 7 8 9
if exists("g:loaded_go_vroom")
if &compatible
echohl ErrorMsg
echohl none
View gist:6259773
1 2 3 4 5 6 7 8 9
function RunGoTestUnderLine()
let line_text = getline(".")
let raw_test_name = matchstr(getline("."), "Test.*\(")
if raw_test_name != -1
let test_name = substitute(raw_test_name, "\(", "", "")
exec '!go test -run ' . test_name
autocmd FileType go nnoremap <leader>s :call RunGoTestUnderLine()<cr>
View gist:5601204
1 2 3 4 5 6
start kod=node:koding('id:*') match kod-[r]-() delete kod, r;
//start kod=relationship(*) delete kod;
//start kod=node(*) delete kod;
//start n=node(*) return count(*);
//start r=rel(*) return count(*);
View rvm
1 2 3 4 5 6 7 8 9
function fish_prompt --description 'Write out the prompt'
# Just calculate these once, to save a few cycles when displaying the prompt
if not set -q __fish_prompt_hostname
# set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)

Activity feeds are ubiquitous on the Internet.

Nearly every site I use daily has an activity feed or something that represents a constantly changing group of infomation presented in a list like format. I first had the idea for River when I realized every activity on the web has four common properties: actor, verb, object & context. "Susie posted a commented on your photo" Here 'Susie' is the actor, 'posted' is the verb, 'photo' is the object and 'your photo' is the context. Turns out there's even a spec for it.

River brings it all together.

The golden rule is any group of related activities can be a River: your Github feed, blog's rss, HackerNews entries about Ruby. A user can then subscribe to it and receive updates on that particular River's activities only. Or they don't have to be connected at all, such as a random River. Just like Pandora allowed users to create their own ratio statios, River allows users to create their own activity streams.


  • Ma
View gist:4641437
1 2 3 4 5 6 7 8 9 10
prompt_rspec_stats() {
if [[ ((-d app || -d lib) && -d spec) ]]; then
if [[ (-d app) ]]; then
local app=`wc -l app/**/*.rb | grep -oE "[0-9]+" | tail -n 1`
local app=`wc -l lib/**/*.rb | grep -oE "[0-9]+" | tail -n 1`
local spec=$((`wc -l spec/**/*.rb | grep -oE "[0-9]+" | tail -n 1`))+0.01
local ratio=`printf "%.2f\n" $((spec/app))`

Recently I've been learning a lot about OOP, especially how to structure code to make it easier to change in the future. The following are some of the ways I refactored my open_auth2 library.

Don't optimize prematurely

I did the mistake of assuming what sugars were required, only to realize I never used them. Source.

Inject dependencies

The Token object accesses Config object for information. Before it was hard coded into Token, so they're highly coupled, so now I pass it as an argument to #initialize. Better yet it defaults to so it's only optional. Source.


When working through unknown code method, ask:

What does a given method do?
What is the current object context that I am in?
What other methods can I call here?
module Purchasable
  def purchase
    result = total, credit_card: card)
View endpoint.rb
1 2 3 4 5 6 7 8 9 10
module Saran
# Makes http requests.
class Endpoint
attr_reader :verb, :path, :provider, :endpoint, :access_token
# TODO: remove config dependency,
# can combine path, endpoint, access_token
# depends on if OpenAuth can deal with full_url
# how to deal with provider?
Something went wrong with that request. Please try again.