Skip to content

Instantly share code, notes, and snippets.

View tom-lord's full-sized avatar
πŸ”₯
πŸš’

Tom Lord tom-lord

πŸ”₯
πŸš’
View GitHub Profile
class LeaseDeal < ApplicationRecord
def self.expire_all(time: Time.current, batch_size: 1000)
in_batches(of: batch_size).update_all(expired_at: time)
end
end
UPDATE "lease_deals"
SET "expired_at" = '2018–10–08 23:50:50.138061'
WHERE "lease_deals"."expired_at" IS NULL
AND "lease_deals"."dealership_id" = 1234
AND ( updated_at < '2018–10–08 23:47:32.862470' )
class LeaseDeal < ApplicationRecord
def self.expire_all(time: Time.current)
update_all(expired_at: time)
end
end
@tom-lord
tom-lord / active_emoji.rb
Created June 25, 2018 08:49
Samples from active_emoji.rb
class Array
alias βͺ <<
alias 🈴 concat
alias πŸ’§ drop
alias πŸ” each
alias πŸˆ³β“ empty?
alias πŸ€ sample
alias 🎲 sample
alias ♻️ shuffle
alias πŸ‘ˆ push
@tom-lord
tom-lord / edd_cow_test.rb
Last active June 25, 2018 08:43
Emoji-Driven tests for πŸ„
require 'minitest/autorun'
require 'minitest/emoji'
module MiniTest
class Emoji
add_utf_theme :carwow, 0x1f3ce, 0x1f694, 0x1f690, 0x1f6b6
end
end
describe Cow do
@tom-lord
tom-lord / edd_cow.rb
Created June 22, 2018 16:03
EDD - Cow
class Cow
def πŸ”ͺ
"πŸ₯© "
end
end
πŸ„ = Cow.new
puts πŸ„.πŸ”ͺ # => πŸ₯©
eyJ2ZXJzaW9uIjoxLjMsImZlYXR1cmVzIjp7ImxvY2F0aW9uIjp7InJvb20iOnRydWUsIm91dHNpZGUiOnRydWUsIndvcmxkIjp0cnVlLCJzcGFjZVNoaXAiOnRydWV9fSwic3RvcmVzIjp7Indvb2QiOjY1MjUsIm1lYXQiOjU2MzAsImJhaXQiOjczOSwic2NhbGVzIjo2NywidGVldGgiOjUwNCwiZnVyIjoyMzAwNCwiY2xvdGgiOjIzNywiY2hhcm0iOjYsImN1cmVkIG1lYXQiOjQzMCwiY29tcGFzcyI6MSwibGVhdGhlciI6MTAxOCwibWVkaWNpbmUiOjUsImJvbmUgc3BlYXIiOjEsInRvcmNoIjo5NSwibCBhcm1vdXIiOjEsIndhdGVyc2tpbiI6MSwicnVja3NhY2siOjEsImlyb24iOjU4MiwiaXJvbiBzd29yZCI6MCwiY2FzayI6MSwid2Fnb24iOjEsInN0ZWVsIHN3b3JkIjoyLCJzdGVlbCI6NDU4LCJpIGFybW91ciI6MSwiY29hbCI6MjgzLCJidWxsZXRzIjo0NjcsImJvbGFzIjoyLCJzIGFybW91ciI6MSwiY29udm95IjoxLCJ3YXRlciB0YW5rIjoxLCJyaWZsZSI6NSwiYmF5b25ldCI6MCwic3VscGh1ciI6NDE0LCJhbGllbiBhbGxveSI6MCwiZW5lcmd5IGNlbGwiOjEyLCJsYXNlciByaWZsZSI6MX0sImNoYXJhY3RlciI6eyJwdW5jaGVzIjo0MCwic3RhcnZlZCI6MSwicGVya3MiOnsic3RlYWx0aHkiOnRydWUsInNjb3V0Ijp0cnVlfX0sImluY29tZSI6eyJnYXRoZXJlciI6eyJkZWxheSI6MTAsInN0b3JlcyI6eyJ3b29kIjoyNX0sInRpbWVMZWZ0Ijo4fSwiYnVpbGRlciI6eyJkZWxheSI6MTAsInN0b3JlcyI6eyJ3b29kIjoyfSwidGltZUxlZnQi
@tom-lord
tom-lord / thebutton.js
Last active December 22, 2020 18:12
A "nicely formatted" (readable) version of the javascript sourcecode at www.reddit.com/r/thebutton -- taken from http://www.redditstatic.com/reddit.en-gb.KaNkkPAPGl0.js
r.thebutton = {
_setTimer:function(e){
var t = "00000",
n = (e > 0 ? e : 0).toString(),
i = t.substring(0, t.length - n.length) + n;
for(var s = 0; s < 4; s++)
r.thebutton._timerTextNodes[s].nodeValue = i[s];
e%100 === 0 && r.thebutton._drawPie(e, 6e4)
},
_countdown:function(){
@tom-lord
tom-lord / Missy Elliott's perfect oscillations
Created March 28, 2015 20:58
What's not to love about them?
127, 63, 95, 31, 111, 47, 79, 15, 119, 55, 87, 23, 103, 39, 71, 7, 123, 59, 91, 27, 107, 43, 75, 11, 115, 51, 83, 19, 99, 35, 67, 3, 125, 61, 93, 29, 109, 45, 77, 13, 117, 53, 85, 21, 101, 37, 69, 5, 121, 57, 89, 25, 105, 41, 73, 9, 113, 49, 81, 17, 97, 33, 65, 1, 126, 62, 94, 30, 110, 46, 78, 14, 118, 54, 86, 22, 102, 38, 70, 6, 122, 58, 90, 26, 106, 42, 74, 10, 114, 50, 82, 18, 98, 34, 66, 2, 124, 60, 92, 28, 108, 44, 76, 12, 116, 52, 84, 20, 100, 36, 68, 4, 120, 56, 88, 24, 104, 40, 72, 8, 112, 48, 80, 16, 96, 32, 64, 0
@tom-lord
tom-lord / Missy Elliott is reciprocal!
Created March 28, 2015 15:26
The Missy Elliott encoding algorithm is the inverse of itself!
MissyElliott.encode("How is this even possible?!")
# => "\xF6\x84\x88\xFD\xB4\x98\xFD\xE8\xF4\xB4\x98\xFD\xAC\xC8\xAC\xC4\xFD\xF8\x84\x98\x98\xB4\xDC\xE4\xAC\x81\xBD"
MissyElliott.encode("\xF6\x84\x88\xFD\xB4\x98\xFD\xE8\xF4\xB4\x98\xFD\xAC\xC8\xAC\xC4\xFD\xF8\x84\x98\x98\xB4\xDC\xE4\xAC\x81\xBD")
# => "How is this even possible?!"
MissyElliott.decode("How is this even possible?!")
# => "\xF6\x84\x88\xFD\xB4\x98\xFD\xE8\xF4\xB4\x98\xFD\xAC\xC8\xAC\xC4\xFD\xF8\x84\x98\x98\xB4\xDC\xE4\xAC\x81\xBD"
MissyElliott.decode("\xF6\x84\x88\xFD\xB4\x98\xFD\xE8\xF4\xB4\x98\xFD\xAC\xC8\xAC\xC4\xFD\xF8\x84\x98\x98\xB4\xDC\xE4\xAC\x81\xBD")