Skip to content

Instantly share code, notes, and snippets.

I = -> x { x }
C = -> x { -> y { -> z { x[z][y] } } }
T = -> C[I]
K = -> x { -> y { x } }
U = -> f { f[f] }
# I know, this technically isn't the Y combinator,
# and it isn't exactly the Z combinator either (like Y, but for applicative order languages).
Y = -> g { U[-> f { -> x { g[U[f]][x] } } ] }
@benolee
benolee / a.rb
Last active August 29, 2015 14:01 — forked from ahoward/a.rb
# make this script run, update your gist with the running script, and it's
# output in a separate gist. the entire quzi should take 1-3 minutes, but you
# get 5.
#
# the meat - take < 5 minutes to do this
#
assert :hash do
x = x.to_h
def get_rstring(addr):
s = addr.cast(string_t.pointer())
if s['basic']['flags'] & (1 << 13):
return s['as']['heap']['ptr'].string()
else:
return s['as']['ary'].string()
def get_lineno(iseq, pos):
if pos != 0:
pos -= 1
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
class AssignCaseCommand < Command
attribute :case, Case
attribute :owner, User
attribute :created_by, User
attribute :comments, String
attribute :distribute_at, DateTime
attribute :distribute_rule_name, String
attribute :require_initial, Boolean

Convert MOV to GIF using FFmpeg and ImageMagick

I tried a few different techniques to make a GIF via command-line and the following gives me the best control of quality and size. Once you're all setup, you'll be pumping out GIFs in no time!

Preparation

Install FFmpeg

  • $ brew install ffmpeg [all your options]
    • Example: $ brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools

Install ImageMagick

# Convenient way to fetch URLs. It follows redirections and handles SSL. Usage:
# Net::HTTP.fetch_url('http://google.com')
# Net::HTTP.fetch_url('https://www.google.fr/?q=ruby')
module Net
class HTTP
def self.fetch_url(url, limit = 10)
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
url = URI.parse(url)
options = {use_ssl: url.scheme.downcase == 'https'}
request = Net::HTTP::Get.new(url.path.to_s + '?' + url.query.to_s)
@benolee
benolee / 0. double dispatch.txt
Created December 12, 2013 21:23 — forked from tenderlove/as_array.rb
double dispatch
Link: [1]RSS (alternate)
NOTE:This blog had a good run, but is now in retirement.
If you enjoy the content here, please support Gregory's ongoing work on
the [2]Practicing Ruby journal.
[3]Gregory Brown [4]James Britt [5]Robert Klemme [6]Magnus Holm
[7]Ruby Best Practices
*.c
*.rl