Skip to content

Instantly share code, notes, and snippets.

diff --git a/lib/middleware/visitor.rb b/lib/middleware/visitor.rb
new file mode 100644
index 0000000..fdfb96d
--- /dev/null
+++ b/lib/middleware/visitor.rb
@@ -0,0 +1,100 @@
+module Middleware
+ class Visitor
+ class Node < Struct.new(:id, :name)
+ end
class Dot
class Node
attr_reader :children, :name, :started
attr_accessor :finished
def initialize name, fields = [], started = Time.now
@name = name
@fields = fields
@children = []
@started = started
*.c
*.rl
@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
# 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)

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

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
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
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