Skip to content

Instantly share code, notes, and snippets.

STEP 1
-------
cache hotplays.json (user centeric) in redis or as a static file
When hotplays.json is hit:
serve cached copy
fire off a worker to re-cache it
@dreamr
dreamr / gist:6415655
Last active December 22, 2015 04:18
cl-digger searches
laying hens
hand tools
drill press
wood lathe
...
def feeds_counts
@result = []
current_user.feeds.each do |feed|
@result << {
id: feed.id,
title: feed.title,
count: feed.post_count_since_last_read
}
end
def feeds_counts
@result = []
current_user.feeds.each do |feed|
@result << {
id: feed.id,
title: feed.title,
count: feed.post_count_since_last_read
}
end
[[{"trdprc_1"=>"470.09", "open_prc"=>"467.0101", "mnemonic"=>"AAPL", "cf_close"=>"494.64", "cf_date"=>"11 SEP 2013", "cf_exchng"=>"NSQ", "cf_high"=>"473.69", "cf_low"=>"464.81", "cf_volume"=>"24862036", "cf_name"=>"APPLE INC"}, {"trdprc_1"=>"470.09", "open_prc"=>"467.0101", "mnemonic"=>"AAPL", "cf_close"=>"494.64", "cf_date"=>"11 SEP 2013", "cf_exchng"=>"NSQ", "cf_high"=>"473.69", "cf_low"=>"464.81", "cf_volume"=>"24862036", "cf_name"=>"APPLE INC"}, {"trdprc_1"=>"470.09", "open_prc"=>"467.0101", "mnemonic"=>"AAPL", "cf_close"=>"494.64", "cf_date"=>"11 SEP 2013", "cf_exchng"=>"NSQ", "cf_high"=>"473.69", "cf_low"=>"464.81", "cf_volume"=>"24862036", "cf_name"=>"APPLE INC"}, {"trdprc_1"=>"470.09", "open_prc"=>"467.0101", "mnemonic"=>"AAPL", "cf_close"=>"494.64", "cf_date"=>"11 SEP 2013", "cf_exchng"=>"NSQ", "cf_high"=>"473.69", "cf_low"=>"464.81", "cf_volume"=>"24862036", "cf_name"=>"APPLE INC"}, {"trdprc_1"=>"470.09", "open_prc"=>"467.0101", "mnemonic"=>"AAPL", "cf_close"=>"494.64", "cf_date"=>"11 SEP 2013", "cf
module PersonName
attr_reader :first_name, :middle_initial, :last_name
def full_name(*options)
return send(:full_name_first_name_first) if options.nil? || options.empty?
options.map {|option| raise OptionError.new unless options_whitelist.include?(option) }
method = "full_name_OPT"
send(:"#{method.gsub("OPT", options[0].to_s)}")
end
create_table "bonds", :force => true do |t|
t.string "currency"
t.string "display_name"
t.decimal "current_yield", :precision => 19, :scale => 4
t.decimal "previous_yield", :precision => 19, :scale => 4
t.datetime "close_date"
t.string "ric"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
alias rtest='ruby -Ilib -Itest '
alias gs="git status"
alias gcb="git checkout -b "
alias gch="git checkout "
alias gca="git commit -a"
alias gpo="git push origin "
alias gri="git rebase -i "
alias gfo="git fetch origin"
alias gl='git log --pretty='\''format:%Cblue%h%d%Creset %ar %Cgreen%an%Creset %s'\'' --graph'
@dreamr
dreamr / gist:6672090
Last active December 23, 2015 17:59
ruby self trick - learning aid for the jr devs
require "forwardable"
class Items
include Enumerable
extend Forwardable
def_delegators :@all, :each, :map, :inject,
:reduce, :select, :reject
attr_reader :all, :filtered
@dreamr
dreamr / gist:6672685
Last active December 23, 2015 17:59
learning aid for the jr devs, passing ruby lambdas as first class args
printer = ->(msg) { puts "#{msg}" }
logger = ->(msg) { File.open("test.txt", "a") {|f| f.write(msg) } }
class Person
def initialize(first_name, last_name)
@first_name, @last_name = first_name,
last_name
end