We have changed our check_url implementation from curl to wget for three reasons
- It gives us the ability to retry on connection refused. Compare the command we used previously with curl:
curl -sSfL --retry 3 URL
to the current one:
me@redacted:~$ python | |
Python 2.7.3 (default, Mar 14 2014, 11:57:14) | |
[GCC 4.7.2] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import ssl | |
>>> | |
[1]+ Stopped python | |
me@redacted:~$ ps | |
PID TTY TIME CMD | |
24815 pts/1 00:00:00 bash |
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 |
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 |
#!/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 |
We have changed our check_url implementation from curl to wget for three reasons
curl -sSfL --retry 3 URL
to the current one:
# 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) |
#!/usr/bin/env ruby | |
pid = Kernel.fork do | |
`#{ARGV.join(" ")}` | |
exit | |
end | |
trap(:CHLD) do | |
print "\n" | |
exit |
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 |
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: |