Skip to content

Instantly share code, notes, and snippets.

class CoolingOffManager < Disposable::Twin
property :cooled_off_at
def skip
set_timestamp(Time.at 0)
end
def finish
set_timestamp(Time.current)
end
@smathy
smathy / bash
Created September 29, 2015 17:18
~/work/peerstreet $ ll app/
total 4.0K
drwxr-xr-x+ 6 jk admin 204 Apr 18 10:11 assets/
drwxr-xr-x+ 5 jk admin 170 Aug 13 16:43 attributes/
drwxr-xr-x+ 3 jk admin 102 Jul 9 16:50 caches/
drwxr-xr-x+ 11 jk admin 374 Sep 23 16:38 cells/
drwxr-xr-x+ 7 jk admin 238 Sep 14 16:41 clients/
drwxr-xr-x+ 27 jk admin 918 Sep 29 10:55 controllers/
drwxr-xr-x+ 3 jk admin 102 Feb 16 2015 datatables/
drwxr-xr-x+ 4 jk admin 136 Sep 23 16:38 decorators/
function RM() {
killall -m "spring .* \| $(basename $1) \|";
rm -rf $1;
}
@smathy
smathy / pry.rb
Created September 22, 2015 15:30
09:30:19 ~/work/r30 $ rails c
Loading development environment (Rails 3.0.20)
irb(main):001:0> nil.try :foo
=> nil
@smathy
smathy / car.rb
Created September 21, 2015 21:26
class Car
has_many :cross_sections, as: :collectible
end
@smathy
smathy / foo.rb
Last active September 15, 2015 16:53
# in seeds/foo.rb
class Seeds
class Foo
def self.call
::Foo.create! NAMES.map{|n| { name: n } }
end
end
end
class HandshakeOrderItem < ActiveRecord::Base
establish_connection 'production_hs'
require 'open-uri'
def self.parameter_for_query_string
today_start_of_day = DateTime.now.in_time_zone("Eastern Time (US & Canada)").beginning_of_day# - 86400
parameter = today_start_of_day.strftime("%Y%m%dT%H:%M:%S")
puts "started for #{today_start_of_day}"
puts "parameter prepared for query string - #{parameter}"
parameter
@smathy
smathy / pry.rb
Created September 10, 2015 19:53
[14] pry(main)> def foo; "ACK!"; end
=> :foo
[15] pry(main)> "".foo
=> "ACK!"
[16] pry(main)> nil.foo
=> "ACK!"
[17] pry(main)>
@smathy
smathy / form.haml
Last active September 3, 2015 18:45
= simple_form_for model do |f|
= f.error_notification
.form-inputs
= f.input :name
.form-actions
= f.button :submit
class MyThing < ActiveRecord::Migration
def create_table table_name, options={}
super table_name, options.merge(primary_key: :not_id)
end
end