Skip to content

Instantly share code, notes, and snippets.

require 'fastercsv'
class StockParser::Parser
attr_reader :rows
def initialize
@rows=[]
end
def import(data)
@rows = FasterCSV.parse(data, :headers => true)
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
Host heroku.com
HostName heroku.com
User git
IdentityFile ~/.ssh/heroku.identity
IdentitiesOnly yes
This is another file for demo purposes
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
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
@karmajunkie
karmajunkie / schedule_store.js.jsx
Created June 21, 2015 01:33
Doing React all wrong...
var ScheduleStore = Reflux.createStore({
init(){
this.listenToMany(ScheduleActions);
},
schedule(){
return this._schedule;
},
setSchedule(schedule){
this._schedule = schedule;

Keybase proof

I hereby claim:

  • I am karmajunkie on github.
  • I am karmajunkie (https://keybase.io/karmajunkie) on keybase.
  • I have a public key whose fingerprint is EC67 CF80 F69A A0F6 4495 ABF5 AD08 F721 9592 3238

To claim this, I am signing this object:

require_relative "../proofs_init.rb"
class ReplayTest
include Replay::EventSource
end
class ReplayTest
include Replay::EventSource
events do
SomeEvent(pid: Integer)
@karmajunkie
karmajunkie / replay_test.rb
Last active August 29, 2015 13:57
Replay events
class ReplayTest
include Replay::EventSource
#define an event inline to the class
event SomethingHappened(name: String, pid: Integer)
apply SomethingHappened do |event|
@name = event.name
@pid = event.pid
end