Skip to content

Instantly share code, notes, and snippets.

View malclocke's full-sized avatar

Malcolm Locke malclocke

  • Christchurch, New Zealand
View GitHub Profile
# Example integration spec for a Rake task in Rails
#
# cat <<EOT > lib/tasks/myapp.rake
# namespace :myapp do
# task :mytask => :environment do
# puts "Hello"
# end
# end
# EOT
echo -n "3pm Christmas Day in LA in local timezone: "
date --date 'TZ="America/Los_Angeles" 2016-12-25T15:00'
echo -n "3pm Christmas Day in LA in London: "
TZ="Europe/London" date --date 'TZ="America/Los_Angeles" 2016-12-25T15:00'
#
# Example of how to convert CSV data on read, in this case parsing
# some JSON in a CSV.
#
require 'csv'
require 'json'
csv = <<EOT
id,json_stuff
1,"{""foo"":""bar""}"
require 'sequel'
require 'logger'
DB = Sequel.sqlite(loggers: [Logger.new(STDOUT)])
DB.create_table :authors do
primary_key :id
String :name
end