Skip to content

Instantly share code, notes, and snippets.

require 'singleton'
class AtMost
include Singleton
def initialize
@table = { |h, k| h[k] = -1 }
def call(n)
class Container {
constructor() {
this.defResolvers = {};
this.defPromises = {};
require(depList, body) {
let depPromises = => this.defPromise(d));
return Promise.all(depPromises)
.then((deps) => body(...deps))
[17] pry(main)> puts
SELECT 1 FROM "posts"
=> nil
[18] pry(main)> puts
SELECT  1 FROM "posts" LIMIT 1

Why put two space after SELECT?

def build(str)
str = str.dup
str.prepend '\A'
str.gsub! %r{/:([a-z]+)}, '/(?<\1>[^\/]+)'
str << '(?<format>\.[a-z]\w*)?'
str << '\z'
rx = build('/posts/:id/comments')
module ToBoolean
def self.cast(value)
@type ||=
!! @type.type_cast_from_user(value)
class Yo < ActiveRecord::Base
def self.ordered_find(ids)
where(id: ids).to_a.index_by(&:id).values_at(*ids)

Keybase proof

I hereby claim:

  • I am marshall-lee on github.
  • I am async_prince ( on keybase.
  • I have a public key ASDBDye6iuyGh7j0xupyz5-4kpssL5tbVWR0aeyyl4k7bQo

To claim this, I am signing this object:

# app/models/document.rb
class Person < ActiveRecord::Base
validate &PassportValidator
# lib/yoba_validator.rb
class YobaValidator < SimpleDelegator
include ActiveModel::Validations
# Prevent HTTP requests to be made into private network (in Ruby!)
# Just an example, don't use it in production!
require 'http'
require 'resolv'
class StaticResolveTCPSocket
def initialize(lookup)
@lookup = lookup.dup
@lookup.default_proc = proc do |_h, host|
# decompress gzip-ed VCR fixtures
require 'zlib'
require 'psych'
Dir.glob('spec/fixtures/vcr_cassettes/**/*.yml').each do |filename|
data = Psych.load_file(filename)
changed = false
data['http_interactions'].each do |interaction|