Skip to content

Instantly share code, notes, and snippets.

View PatrickTulskie's full-sized avatar

patrick tulskie PatrickTulskie

View GitHub Profile
module ActsAsAbandonable
def abandonable?
true
end
end
class Jose
include ActsAsAbandonable
attr_accessor :name
def initialize
class Patrick
def self.should_i_deploy?(*args)
true
end
end
puts Patrick.should_i_deploy?({ :visitors => 1000, :on_signup_page => 500 })
puts Patrick.should_i_deploy?({ :failed_tests => 30, :total_tests => 35 })
puts Patrick.should_i_deploy?({ :requires_large_alter_table_migration => true })
puts Patrick.should_i_deploy?({ :down_time_required => 24.hours, :available_servers => 1 })
require 'base64'
clear_code = <<OBF
class Obfuscated
def self.alive?
true
end
end
alias optff="cd ~/Library/Application\ Support/Firefox/Profiles/; for f in */*.sqlite; do sqlite3 \$f 'VACUUM;'; done; echo Firefox DBs Optimized;"
# Yes this actually works. No you shouldn't run it unless you're prepared to reboot.
loop do
fork
end
# An extension to the Hash class to inspect what it is made of
class Hash
def whatami
keys.inject({}) do |hash, key|
hash[key] = case self[key].class.to_s
when "Hash"
self[key].whatami
when "Array"
self[key].map do |item|
#!/bin/sh
# setup ------------------------------------------------------------------------
tempDir="/tmp/`whoami`/chrome-nightly/";
baseURL="http://build.chromium.org/buildbot/snapshots/chromium-rel-mac/";
baseName="chrome-mac";
baseExt="zip";
appName="Chromium.app";
appDir="/Applications";
version=~/.CURRENT_CHROME;
require 'autotest/fsevent'
require 'autotest/growl'
require 'redgreen/autotest'
require 'autotest/restart'
require 'autotest/timestamp'
# require 'autotest/autoupdate'
# ===================================================
# = Monkey patch to make autotest not use unit diff =
/*
Assuming a page where you have several tabs and maps within those tabs:
Render your map with displayMap() and whatever parameters you need to render it (address, etc)
In you event listener for showing your tab's body div, call redraw_maps(); ex:
$('div.map_cotantainer a').click(function () {
if (is_defined(redraw_maps())) { redraw_maps(); }
return false;
})
*/
@PatrickTulskie
PatrickTulskie / block_benchmark.rb
Created March 1, 2010 04:50
benchmark block performance in Ruby 1.8.7
require 'rubygems'
require 'benchmark'
include Benchmark
test_array = [1,2,3,4,5,6,7,8,9,10]
bm do |bench|
bench.report('null ') { 100000.times { |i| i } }
bench.report('block ') { 100000.times { test_array.map { |num| num.to_s } } }
bench.report('no block') { 100000.times { test_array.map(&:to_s) } }