This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function remove_a(title) { | |
var all = document.getElementsByTagName('a'); | |
for (i = 0; i < all.length; i++) { | |
element = all[i]; | |
if (element.title.match(title)) { | |
element.parentNode.removeChild(element); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# This stupid Braid game completely locks up OSX when the | |
# campaign file gets corrupted. Rather than restarting over | |
# and over again while I try to restore from a previous save | |
# point, I decided to whip up this kill script. | |
while true do | |
braid_id = %x[ps auxx | grep "Braid.app" | grep -v auxx | grep -v grep | awk '{print $2}'] | |
if braid_id.empty? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/env ruby | |
# | |
# Watch a set of files and open them in Safari and/or Firefox if they change. | |
# The files should probably be plain HTML files, but I'm not the boss of you. | |
# Refreshes index.htm or index.html by default (if they exist) | |
require 'optparse' | |
require 'ostruct' | |
options = OpenStruct.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formInputs() { | |
return document.getElementById('loginform').getElementsByTagName('input'); | |
} | |
function formClear() { | |
var inputs = formInputs(); | |
for (i = 0; i<inputs.length; i++) { | |
if (inputs[i].type != 'submit' && inputs[i].value == inputs[i].defaultValue) { | |
inputs[i].value = ''; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
184c184 | |
< String addr = request.getRemoteAddr(); | |
--- | |
> String addr = request.getHeader("x-real-ip"); | |
> if (addr == null) { | |
> addr = request.getRemoteAddr(); | |
> } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
n = 100000 | |
Benchmark.bm do |x| | |
x.report('copy') { n.times do ; h = {}; h = h.merge({1 => 2}); end } | |
x.report('no copy') { n.times do ; h = {}; h.merge!({1 => 2}); end } | |
end | |
# user system total real | |
# copy 0.460000 0.180000 0.640000 ( 0.640692) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT size_bytes | |
FROM bitstream , item2bundle, bundle2bitstream | |
WHERE item2bundle.bundle_id = bundle2bitstream.bundle_id | |
AND bundle2bitstream.bitstream_id = bitstream.bitstream_id | |
AND item2bundle.item_id = ANY( | |
SELECT item_id | |
FROM item | |
WHERE owning_collection = ANY( | |
SELECT collection_id | |
FROM community2collection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prettier test declarations via: | |
# test "something being tested" do | |
# test code goes here... | |
# end | |
class Test::Unit::TestCase | |
def self.test(name, &block) | |
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym | |
defined = instance_method(test_name) rescue false | |
raise "#{test_name} is already defined in #{self}" if defined | |
if block_given? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of using Gchart (gchart.rubyforge.org) to graph | |
# some basic carpooling data (www.petrock.org/carpool) | |
Gchart.line(:size => "800x300", :title => "Carpool Data", | |
:legend => @participants.collect {|person| person.name}, | |
:line_colors => @participants.collect {|person| person.color}.join(','), | |
:format => 'image_tag', | |
:data => @participants.collect {|person| @history[person.name] }) |
NewerOlder