Skip to content

Instantly share code, notes, and snippets.

module ActivityLogger
include ActiveSupport
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def log_with(model_name, options = {})
class Foo
include DataMapper::Resource
include ActivityLogger
log_with :foo_activity_log
# ...snip ...
end
class ActivityLog
include DataMapper::Resource
property :id, Serial
property :type, Discriminator
property :model_id, Integer
property :event, String
@svs
svs / trip_booker.rb
Last active December 11, 2015 02:39
class TripBooker
# Given a trip and a list of vendors, this class makes bookings for all the vendors
def initialize(trip, vendors = :all)
@trip = trip
@vendors = VendorSelector.new(vendors).all
@credentials = CredentialSelector.get_available_credentials
end
class VendorBooker
# This class is responsible for calling the appropriate translation mechanism to convert a CRM Trip
# into the appropriate format to book
#
# It also translates the response into a CRM Booking object to persist to the database
def initialize(trip, vendor, credentials)
@trip = trip
@vendor = vendor
@svs
svs / gist:5508369
Last active December 16, 2015 22:39
EuRuKo Leaderboard
Grzegorz Witek = 104
Dirkjan Bussink = 84
Konstantin Tennhard = 74
Pat Shaughnessy = 74
Benjamin Smith = 72
Daniel Lobato García = 59
Josep M. Bach = 56
Javier Ramírez = 56
Alexandre de Oliveira = 52
Alexey Vasiliev = 49
require 'mechanize'
a = Mechanize.new
results = {}
last_id = 647
(1..last_id).map do |id|
begin
page = a.get("http://cfp.euruko2013.org/users/#{id}/selections")
d = page.
@svs
svs / wc
Last active December 19, 2015 11:18
$ wc -l **/*.rb | sort -r | head -10
7104 total
720 models/question.rb
468 controllers/god_controller.rb
407 controllers/analytics_controller.rb
382 controllers/admin/god_controller.rb
258 models/user.rb
252 controllers/mobile/api_controller.rb
167 controllers/admin/foo_controller.rb
140 models/quux.rb
$ wc -l spec/**/*.rb | sort -r | head -10
zsh: no matches found: spec/**/*.rb
flog app/controllers | head -10 rvm:ruby-2.0.0-p195
6097.5: flog total
23.8: flog/method average
438.8: AController#overall
311.8: Ad::IQController#create
226.7: AController#level_meter
204.9: QController#topic_level_selector
168.2: M::ApiController#flip
140.2: TController#index