Skip to content

Instantly share code, notes, and snippets.

@spyderman4g63
spyderman4g63 / gist:4164616
Created November 28, 2012 21:19
Get array differences
require 'set'
#create array
a = [1,2,3,4]
b = [2,3,5,6]
#convert to set
a.to_set
b.to_set
@spyderman4g63
spyderman4g63 / gist:4164550
Created November 28, 2012 21:13
ruby csv parse
require 'csv'
csv_text = File.read('test.csv')
csv = CSV.parse(csv_text, :headers => true)
csv.each do |row|
puts "Name: #{row['name']} - Age: #{row['age']} -  Sex: #{row['sex']}"
end