Skip to content

Instantly share code, notes, and snippets.

require 'mechanize'
require 'yaml'
$results = []
def find(a, link)
puts "find started on #{link}"
a.get link do |page|, ".blog-post").each do |post|
h2 =, "h2").first
class JobSchedule
# External interface for calling the service
def, opts={})
if perform_asynchronously?
Delayed::Job.enqueue(, object_id, opts))
perform(object_id, opts)
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)}"
elsif paid > total
Namespace = ( ->
merge = (target, source) ->
for key, val of source
target[key] = val
_assertValidFQN = (fqn) ->
unless ///^[a-z0-9_.]+///.test fqn then throw 'invalid namespace'
class Procedure
defunkt / binary.html
Created October 18, 2012 15:47 — forked from ozmm/binary.html
<!-- -->
<script language="vbscript">
Function BinaryArrayToAscCSV( aBytes )
Dim j, sOutput
sOutput = "BinaryArrayToAscCSV"
For j = 1 to LenB(aBytes)
sOutput= sOutput & AscB( MidB(aBytes,j,1) )
defunkt / gist:877705
Created March 19, 2011 18:52 — forked from aumgn/gist:864853
Mustache Object Implementation
class HighlighterHelper
def respond_to?(language)
def method_missing(language)
lambda { |text|
Highlighter.send(language, text)
defunkt / gist:449668
Created June 23, 2010 08:55 — forked from dustin/gist:397971
Emacs Lisp to automatically add, commit, and push when files change
;; 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))
defunkt / mustache_test.rb
Created May 24, 2010 18:06 — forked from rafaelss/mustache_test.rb
Ruby 1.9 Failing Mustache case
# Fails on 1.9.1p376
require 'test/unit'
require 'mustache'
class MTest < Test::Unit::TestCase
def test_array_of_arrays
template = <<template
defunkt / memrate.rb
Created April 8, 2010 08:09 — forked from rtomayko/memrate.rb
Awesome option parsing.
#!/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>