This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class YrModel < ActiveRecord::Base | |
has_many :derps | |
def self.find_with_cursor(query, &blk) | |
cursor_name = "cursor_#{(rand * 1000000).ceil}" | |
self.transaction do | |
self.connection.execute("DECLARE #{cursor_name} CURSOR FOR #{query.to_sql}") | |
while !(records = self.find_by_sql("FETCH FORWARD 1000 FROM #{cursor_name}")).empty? | |
#FIXME I think this method is deprecated in 3.1 in favor of #preload | |
preload_associations(records, [:derps]) | |
blk.call(records) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
opts = {'meep' => 'feep', :derp => 'herp'} | |
opts.default_proc = ->(h,k) { h.fetch(k.to_s) { nil } } | |
opts[:meep] | |
=> 'feep' | |
opts['derp'] | |
=> 'herp' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RSpec::Example::DelegatesMatcher | |
def it_delegates(*args) | |
options = args.pop | |
if options.is_a?(Hash) | |
options.symbolize_keys! | |
delegated_instance = options.fetch(:to) { raise 'You must provide a :to option to it_delegates' } | |
else | |
raise 'You must provide an options hash to it_delegates' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def do_stuff(stuff) | |
{}.tap do |thing| | |
thing['guys'] = stuff | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select date_trunc('day', created_at), sum(value) from channel_stats group by date_trunc('day', created_at); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
def hi | |
'hi' | |
end | |
end | |
module B | |
def hi | |
super + 'hi' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add "add bitty account" link in networks index page | |
problem with twitter lists on twitter account (won't load) | |
followers button on twitter account (won't load?) | |
remove quick reply actions (pictures, link) until we have them working | |
loader on timeline network nav change (wtf does this mean?) | |
performance on loading a single twitter account (can't really be helped, api request bound..) | |
add ok/apply button on report date select | |
padding on left of users index | |
show on report clicks (load info in bottom) (wtf does this mean?) | |
all external links in system should load to new page using target="_blank" (fb post links don't do this atm) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
p = Net::HTTP.get(URI.parse('http://bukk.it')) | |
regexp = /href=\"(.*?\..*?)\"/ | |
images = p.scan(regexp).flatten | |
image = images[rand(images.length)] | |
puts "http://bukk.it/" + image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'net/http' | |
require 'uri' | |
thrs = [] | |
url = URI.parse('http://yahoo.com') | |
class Parayield | |
attr_accessor :threads |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function percentChanged(newVal, oldVal) { | |
if(oldVal == 0) { | |
return (newVal * 100); | |
} else { | |
return parseInt((((newVal - oldVal) / oldVal) * 100).toFixed()); | |
} | |
} |
NewerOlder