This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.
To capture the video (filesize: 19MB), using the free "QuickTime Player" application:
| #! /bin/bash | |
| array=( $@ ) | |
| len=${#array[@]} | |
| app=${array[$len-1]} | |
| args=${array[@]:0:$len-1} | |
| buffer_file=/tmp/last_heroku_run_`date +%N` | |
| /usr/bin/heroku run "$args; echo \$?" --app $app 2>&1 | tee $buffer_file |
| class Module | |
| # We often find ourselves with a medium-sized chunk of behavior that we'd | |
| # like to extract, but only mix in to a single class. | |
| # | |
| # We typically choose to leave the implementation directly in the class, | |
| # perhaps with a comment, because the mental and visual overhead of defining | |
| # a module, making it a Concern, and including it is just too great. | |
| # | |
| # | |
| # Using comments as lightweight modularity: |
| require 'connection_pool' | |
| require 'redis' | |
| require 'metriks' | |
| class RedisClientWrapper | |
| def initialize(options) | |
| @options = options.delete(:pool) | |
| @pool = ConnectionPool.new(@options) do | |
| ::Redis.new(options) | |
| end |
| #!/usr/bin/env ruby | |
| pid = Kernel.fork do | |
| `#{ARGV.join(" ")}` | |
| exit | |
| end | |
| trap(:CHLD) do | |
| print "\n" | |
| exit |
| # A program that works jobs in newly created UNIX | |
| # process by calling fork. The number of processes | |
| # running at any given time is bounded by our use | |
| # of a sized queue. | |
| require 'thread' | |
| # Run at most 4 UNIX processes for any given time. | |
| @limiter = SizedQueue.new(4) |
We have changed our check_url implementation from curl to wget for three reasons
curl -sSfL --retry 3 URL
to the current one:
| #!/usr/bin/env ruby | |
| # Bonus: place in PATH and use from the command line. | |
| # Usage: | |
| # find path -type f | xargs ruby highlight.rb | |
| # gem contents metric_fu | grep lib | xargs ruby highlight.rb | |
| # The highlighted code will be output to 'output.html' in the working directory | |
| require 'coderay' | |
| class Highlighter | |
| def initialize |
| task :outdated => :environment do | |
| include ActionView::Helpers::DateHelper | |
| regexp = /\* ([^ ]+) \((\S+) > ([^)]+)\)/ | |
| outdated = `bundle outdated`.scan(regexp) | |
| outdated.each do |gem_name, available, current| | |
| data = JSON.parse(`curl --silent https://rubygems.org/api/v1/versions/#{gem_name}.json`) | |
| version = data.find { |e| e['number'] == current } | |
| age = distance_of_time_in_words_to_now(Time.parse(version['built_at'])) | |
| puts " * #{gem_name}: (#{available} > #{current}, built #{age} ago)" | |
| end |
| class Ticket < ActiveRecord::Base | |
| belongs_to :grouper | |
| belongs_to :user | |
| validate :user_cant_be_blacklisted, on: :confirmation | |
| validate :user_cant_double_book, on: :confirmation | |
| validate :grouper_cant_be_full, on: :confirmation | |
| validate :grouper_cant_have_occurred, on: :confirmation |