Skip to content

Instantly share code, notes, and snippets.

# Serializing of Ruby objects compatible with PHP’s unserialize() function
# Ciarán Walsh
require 'enumerator'
class Float
def serialize
['d', self].join(':') + ';'
end
end
class Integer
plugin do
def tinysong(title, artist)
response = Net::HTTP.new("tinysong.com").start do |h|
req = Net::HTTP::Get.new("?s=#{URI.escape "#{t.name} by #{t.artist}"}")
r.add_field("X-Requested-With", "XMLHttpRequest")
h.request(req)
end
response.body =~ %r{"(http:\\/\\/tinysong.com.+?)"} ? $1.gsub("\\", "") : nil
end
#!/bin/sh
SUBDIRECTORY_OK=Yes
. git-sh-setup
require_work_tree
ref_stash=refs/stash
COLOR_RED="\e[0;31m"
COLOR_GREEN="\e[32;40m"
raise "bad email" unless "[email protected]" =~ /@(.*)/
return $1