Skip to content

Instantly share code, notes, and snippets.

View tom-lord's full-sized avatar
🔥
🚒

Tom Lord tom-lord

🔥
🚒
View GitHub Profile
@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(){
eyJ2ZXJzaW9uIjoxLjMsImZlYXR1cmVzIjp7ImxvY2F0aW9uIjp7InJvb20iOnRydWUsIm91dHNpZGUiOnRydWUsIndvcmxkIjp0cnVlLCJzcGFjZVNoaXAiOnRydWV9fSwic3RvcmVzIjp7Indvb2QiOjY1MjUsIm1lYXQiOjU2MzAsImJhaXQiOjczOSwic2NhbGVzIjo2NywidGVldGgiOjUwNCwiZnVyIjoyMzAwNCwiY2xvdGgiOjIzNywiY2hhcm0iOjYsImN1cmVkIG1lYXQiOjQzMCwiY29tcGFzcyI6MSwibGVhdGhlciI6MTAxOCwibWVkaWNpbmUiOjUsImJvbmUgc3BlYXIiOjEsInRvcmNoIjo5NSwibCBhcm1vdXIiOjEsIndhdGVyc2tpbiI6MSwicnVja3NhY2siOjEsImlyb24iOjU4MiwiaXJvbiBzd29yZCI6MCwiY2FzayI6MSwid2Fnb24iOjEsInN0ZWVsIHN3b3JkIjoyLCJzdGVlbCI6NDU4LCJpIGFybW91ciI6MSwiY29hbCI6MjgzLCJidWxsZXRzIjo0NjcsImJvbGFzIjoyLCJzIGFybW91ciI6MSwiY29udm95IjoxLCJ3YXRlciB0YW5rIjoxLCJyaWZsZSI6NSwiYmF5b25ldCI6MCwic3VscGh1ciI6NDE0LCJhbGllbiBhbGxveSI6MCwiZW5lcmd5IGNlbGwiOjEyLCJsYXNlciByaWZsZSI6MX0sImNoYXJhY3RlciI6eyJwdW5jaGVzIjo0MCwic3RhcnZlZCI6MSwicGVya3MiOnsic3RlYWx0aHkiOnRydWUsInNjb3V0Ijp0cnVlfX0sImluY29tZSI6eyJnYXRoZXJlciI6eyJkZWxheSI6MTAsInN0b3JlcyI6eyJ3b29kIjoyNX0sInRpbWVMZWZ0Ijo4fSwiYnVpbGRlciI6eyJkZWxheSI6MTAsInN0b3JlcyI6eyJ3b29kIjoyfSwidGltZUxlZnQi
@tom-lord
tom-lord / edd_cow.rb
Created June 22, 2018 16:03
EDD - Cow
class Cow
def 🔪
"🥩 "
end
end
🐄 = Cow.new
puts 🐄.🔪 # => 🥩
@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 / 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
class LeaseDeal < ApplicationRecord
def self.expire_all(time: Time.current)
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, batch_size: 1000)
in_batches(of: batch_size).update_all(expired_at: time)
end
end
SELECT "lease_deals"."id"
FROM "lease_deals"
WHERE "lease_deals"."expired_at" IS NULL
AND "lease_deals"."dealership_id" = 1234
AND ( updated_at < '2018-10-09 09:34:11.818701' )
ORDER BY "lease_deals"."id" ASC
LIMIT 1000
Bitmap Heap Scan on lease_deals (cost=172.99..18520.04 rows=5903 width=205)
Recheck Cond: (dealership_id = 1234)
Filter: ((expired_at IS NULL) AND (updated_at < '2018-10-09 09:34:11.818701'::timestamp without time zone))
-> Bitmap Index Scan on index_lease_deals_on_dealership_id (cost=0.00..172.70 rows=9724 width=0)
Index Cond: (dealership_id = 1234)