Skip to content

Instantly share code, notes, and snippets.

1.upto 12 do |mon|
1.upto 31 do |mday|
firsthalf="#{mday.to_s.rjust(2,'0')}#{mon.to_s.rjust(2,'0')}"
puts "#{firsthalf}#{firsthalf.reverse}" if firsthalf.reverse.to_i >=2010 && firsthalf.reverse.to_i <= 2099
end
end
Array.class_eval <<-END
def batch_process(batch_size = 20)
((self.size/batch_size)+1).times do |iter|
yield self[batch_size*iter..(batch_size*(iter+1)-1)]
end
end
END
This is another file for demo purposes
Host heroku.com
HostName heroku.com
User git
IdentityFile ~/.ssh/heroku.identity
IdentitiesOnly yes
Feature: Parsing a stock file
In order to perform analysis of stock pricing data
As the importer
I want to parse a data file
Scenario: Parsing an AMEX data file
Given a data file containing:
"""
exchange,stock_symbol,date,stock_price_open,stock_price_high,stock_price_low,stock_price_close,stock_volume,stock_price_adj_close
AMEX,KBE,2010-02-08,22.26,22.45,21.90,21.91,5147800,21.91
require 'fastercsv'
class StockParser::Parser
attr_reader :rows
def initialize
@rows=[]
end
def import(data)
@rows = FasterCSV.parse(data, :headers => true)
unless defined? PhusionPassenger
module PhusionPassenger
def self.on_event(event_name, &block)
#the only event I use this with is :starting_worker_process,
#which takes a `forked` parameter, which we want to be false
yield false
end
end
end
@karmajunkie
karmajunkie / gist:3230290
Created August 1, 2012 20:11
Recruiters, FYI
When you say things like "I'm not like other recruiters because I used to be a techie" we all pretty much know that's what they tell you to say in Recruiter school. Because if you really were formerly an engineer, you wouldn't use words like "techie", and you'd know we don't believe you anyway.

One of the few problems I have with Janus, the vim settings bundle/plugin/whatever you want to call it, is that whenever I change to the vim window it refreshes the NERDTree. My project has a ton of files in it (like really, a ridiculous amount) so that refresh takes tens of seconds sometimes. Thanks to Tim Tyrrell's (@timtyrrell) tip on twitter after I bitched about it, I found the offending lines in Janus's NERDTree plugin:

#~/.vim/janus/vim/tools/janus/after/plugin/nerdtree.vim
augroup AuNERDTreeCmd
autocmd AuNERDTreeCmd VimEnter * call s:CdIfDirectory(expand("<amatch>"))
autocmd AuNERDTreeCmd FocusGained * call s:UpdateNERDTree()

By adding the following line to your ~/.vimrc.after or ~/.gvimrc.after you can punt on the autocommands from Janus (I don't care about either of them)

:autocmd! AuNERDTreeCmd

@karmajunkie
karmajunkie / gist:3801509
Created September 28, 2012 18:51
In which I make a crude analogy

Watching Jack Danger's GoGaRuCo presentation the following analogy came to mind.

/lib is the asshole of your Rails application. Its fine (and desirable) for stuff to pass through there. But if you don't poop it out into nicely formed little turds we call gems eventually, your application is going to become constipated. Then you get stomachaches.

Don't constipate your app. Eat lots of roughage.