Skip to content

Instantly share code, notes, and snippets.

@spilliton
spilliton / gist:a502e87a13067a9163545ab8025ae3c9
Created April 8, 2016 23:29
Mp3 Tag Json Export Configuration
$filename(json,utf-8)'['
$loop(%_filename_ext%)
{"composer": "%composer%", "artist": "%artist%", "trackname": "%title%"},
$loopend()
']'
@spilliton
spilliton / delayed_job_monkey_patch
Created January 18, 2014 19:06
Monkey patch for delayed_job to to ignore Delayed::DeserializationError when a job is run against a deleted active record model.
# config/initializers/delayed_job_config.rb
module Delayed
module Backend
module Base
def invoke_job_with_deserialize_catch
begin
invoke_job_without_deserialize_catch
rescue Delayed::DeserializationError
Rails.logger.error "Record was deleted when job ran!"
@spilliton
spilliton / random vs. random_by_id_shuffle
Last active December 18, 2015 07:08
Comparing random() and random_by_id_shuffle() on sqlite3 and postgres
DB=sqlite3 ruby test/benchmark_test.rb
DB driver: sqlite3
Using 1.9.2 AR 3.2.13 with sqlite3
Loaded suite test/benchmark_test
Started
-------------------------------------
Time to populate 10,000,000 rows: 1102.7106530666351s
random(1), avg: 18.829100692272185s (55.41% faster)
random_by_id_shuffle(1), avg: 42.231236004829405s