Skip to content

Instantly share code, notes, and snippets.

View jdunphy's full-sized avatar

Jacob Dunphy jdunphy

  • Google
  • Madison, WI
View GitHub Profile
(require 'url-util)
(defun url-encode-region ()
"Replace the current region text with a url-encoded version of
the same data."
(interactive)
(let ((beg (region-beginning))
(end (region-end))
)
(save-excursion
module Kernel
def omg_mem!
puts "From #{caller[0]}"
puts `ps vx | grep mongrel`.split(' ')[7]
end
end
require 'rubygems'
require 'test/unit'
require 'mocha'
class Foo
def self.foo(a_param)
a_param.upcase
end
end
-# the require for fastthread is run together on one line to avoid unimportant coverage analysis skip
-#
-begin; require 'fastthread'; rescue LoadError; puts "FastThread not installed - using default thread/mutex ha
+
+begin
+ require 'fastthread'
+rescue LoadError
+ puts "FastThread not installed - using default thread/mutex hanlding"
+end
class MemoryProfiler
# profile is a CLEAN, totally minimal memory profiler:
#
# * 1 thread
# * 2 hashes (curr, prev)
# * classes as keys
# * fixnums as values.
#
# No extra memory required if I can help it. Keep it as simple as
def add_rpc_method_with_soapaction_as(name, name_as, soapaction, *params)
param_def = SOAPMethod.create_rpc_param_def(params)
qname = XSD::QName.new(@namespace, name_as)
@proxy.add_rpc_method(qname, soapaction, name, param_def)
add_rpc_method_interface(name, param_def)
end
if ENV['DATABASE_URL']
::DB = Sequel.sqlite(ENV['DATABASE_URL'])
else
dbfile = File.dirname(__FILE__) + "/db/#{env}.sqlite3"
FileUtils.touch(dbfile)
::DB = Sequel.sqlite(dbfile)
end
def merge_ad_data!
return unless adv_fields = @values.delete('AdvFields')
adv_fields = Zlib::GzipReader.new(
StringIO.new(Base64.decode64( adv_fields))).read
adv_fields = JSON.parse(adv_fields).map { |af| JSON.parse(af) }
module TheExtended
def using_the_thing
"I use #{a_thing}!"
end
def a_thing
raise "O NOSE!"
end
end
# bloopsaphone won my heart
require '../bloopsaphone/ext/ruby/bloops'
# the song object
b = Bloops.new
b.tempo = 320
saw = b.sound Bloops::SAWTOOTH