Skip to content

Instantly share code, notes, and snippets.

View JohnB's full-sized avatar

John Baylor JohnB

View GitHub Profile
=begin
Read the db/schema.rb file and churn out a .DOT file containing
tables and linkages for *all* tables, not just the ones that
have ActiveRecord models. Guess that columns ending in _id are
links to other tables; assume all relations are one-to-many.
BACKGROUND
I'm working with a schema that is shared by a Rails app and a C++ app.
Some tables are only accessed by the C++ code and have no need to be
represented in the Rails models. A side-effect of this is that a tool
=begin
My brother created a C++ app for parsing cal files (not calendars)
and outputting the final matching data as a CSV. This is my attempt
in Ruby.
Expected incoming format: some text files that match the regexp's in
the list (e.g. "value=123")
Expected output: CSV format, ordered according to the columns array.
=end
# I just realized how easy it is to create a
# shuffled deck of cards.
# (and to create a gist - thanks github!)
def shuffled_deck
suits = %w[Hearts Clubs Diamonds Spades]
pips = %w[2 3 4 5 6 7 8 9 10
Jack Queen King Ace]
deck = suits.collect do |s|
pips.collect {|p| "#{p} of #{s}" }