Keeping it Simple
- http://flickr.com
- http://cnn.com
- http://letsfreckle.com # You need to log in
class JobSchedule | |
# External interface for calling the service | |
def self.call(object_id, opts={}) | |
if perform_asynchronously? | |
Delayed::Job.enqueue(EnqueuedJob.new(name, object_id, opts)) | |
else | |
perform(object_id, opts) | |
end | |
end |
puts "What is the amount due?" | |
total = gets.chomp.to_f | |
puts "What is the amount tendered?" | |
paid = gets.chomp.to_f | |
if paid < total | |
puts "WARNING: Customer still owes $#{format("%.2f", total-paid)}" | |
puts Time.now | |
elsif paid > total |
Namespace = ( -> | |
merge = (target, source) -> | |
for key, val of source | |
target[key] = val | |
target | |
_assertValidFQN = (fqn) -> | |
unless ///^[a-z0-9_.]+///.test fqn then throw 'invalid namespace' | |
class Procedure |
<!-- http://emilsblog.lerch.org/2009/07/javascript-hacks-using-xhr-to-load.html --> | |
<html5> | |
<head> | |
<script language="vbscript"> | |
Function BinaryArrayToAscCSV( aBytes ) | |
Dim j, sOutput | |
sOutput = "BinaryArrayToAscCSV" | |
For j = 1 to LenB(aBytes) | |
sOutput= sOutput & AscB( MidB(aBytes,j,1) ) |
class HighlighterHelper | |
def respond_to?(language) | |
Highlighter.highlight?(language) | |
end | |
def method_missing(language) | |
lambda { |text| | |
Highlighter.send(language, text) | |
} | |
end |
;; Automatically add, commit, and push when files change. | |
(defvar autocommit-dir-set '() | |
"Set of directories for which there is a pending timer job") | |
(defun autocommit-schedule-commit (dn) | |
"Schedule an autocommit (and push) if one is not already scheduled for the given dir." | |
(if (null (member dn autocommit-dir-set)) | |
(progn | |
(run-with-idle-timer |
# Fails on 1.9.1p376 | |
require 'test/unit' | |
require 'mustache' | |
class MTest < Test::Unit::TestCase | |
def test_array_of_arrays | |
template = <<template | |
{{#items}} | |
start |
#!/usr/bin/env ruby | |
## Usage: memrate.rb [-l <lib>] [-i <num>] [-t <threshold>] [-k <size>] [<host>] | |
## Measure memcached server read time. | |
## | |
## Options | |
## -l, --library=<lib> Memcached client library to use. memcache-client by | |
## default. memcached also supported. | |
## -i, --iterations=<num> Number of times to read the value. If not set, read | |
## until interrupted. | |
## -t, --threshold=<time> Report iterations that take longer than <time> |
require 'rubygems' | |
require 'mustache' | |
class HandleBar < Mustache | |
def respond_to?(methodname) | |
methodname = methodname.to_s.split(/\s+/).first | |
super methodname | |
end | |
def method_missing(methodname, *args) |