Skip to content

Instantly share code, notes, and snippets.

View landovsky's full-sized avatar

landovsky

  • Applifting
  • Prague
View GitHub Profile
@signaes
signaes / Rails Console time travel
Created February 18, 2020 22:29
Using active support time helpers to change the current date in the rails console
require 'active_support/testing/time_helpers'
# the class below could have any name
class Tempo
include ActiveSupport::Testing::TimeHelpers
end
# any desidered date
desired_date = Date.today - 2.days
@synth
synth / add_signature_fields_to_delayed_jobs.rb
Last active November 21, 2023 10:03
Prevent Duplicates with Delayed Jobs
class AddFieldsToDelayedJobs < ActiveRecord::Migration
def change
add_column :delayed_jobs, :signature, :string
add_column :delayed_jobs, :args, :text
end
end
@easierbycode
easierbycode / monkey_patching.rb
Created February 29, 2012 04:25 — forked from bagwanpankaj/monkey_patching.rb
Monkey Patching done right
#first we create a subclass of class string
class MyString < String
end
MyString.new
# => ""
#now we are going to override this method by some Ruby magic
MyString.class_eval do
def empty?