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
<script type="text/javascript"> | |
document.observe('dom:loaded', function() { | |
var li = new Element('li').update('li'); | |
$('a').update(li); | |
var killIE = true; | |
if (killIE) { | |
li.update('new name'); | |
} else { | |
$('a').update(); |
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
--- a/public/javascripts/application.js | |
+++ b/public/javascripts/application.js | |
@@ -70,9 +70,15 @@ | |
if (this.input && $F(this.input)) | |
this.positionThumb(parseFloat($F(this.input)) * this.width / 100); | |
- this.div.observe('mousedown', this.onMouseDown.bindAsEventListener(this)); | |
- this.div.observe('mouseup', this.onMouseUp.bindAsEventListener(this)); | |
- this.div.observe('mousemove', this.onMouseMove.bindAsEventListener(this)); | |
+ if (Prototype.Browser.MobileSafari) { |
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
# login to jabber/gtalk and have your computer say whatever people are saying to you | |
require 'rubygems' | |
require 'xmpp4r/client' | |
include Jabber | |
# settings | |
if ARGV.length != 2 | |
puts "Run with ./echo_thread.rb user@server/resource password" | |
exit 1 |
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 'rubygems' | |
require 'scrubyt' | |
google_data = Scrubyt::Extractor.define do | |
fetch 'http://www.google.com/search?hl=en&q="guarded by a dragon"' | |
excerpt "//div[@class=s]" | |
next_page '//td/a', :limit => ARGV.shift.to_i || 3 | |
end |
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 'rubygems' | |
require 'open-uri' | |
require 'json' | |
url = 'http://twitter.com/statuses/user_timeline.json?id=visnup&count=3200' | |
dates = open(url) { |f| JSON.parse f.read }.map { |e| Date.parse e['created_at'] } | |
sum = dates.inject(Hash.new(0)) { |s, t| s[t] += 1; s } | |
sum.keys.sort.each { |k| puts "#{k} (#{sum[k]}) #{'=' * sum[k]}" } |
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
# Detect rss feed, parse it, and report number of posts per date. | |
require 'rubygems' | |
require 'hpricot' | |
require 'open-uri' | |
# First find the rss | |
url = ARGV[0] || "http://twitter.com/burnto" | |
doc = Hpricot(open(url)) |
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 'rubygems' | |
require 'activesupport' | |
class String | |
def emphasize substrings | |
highlight self, substrings | |
end | |
end |
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 | |
# calculate average uptime of my machine | |
require 'rubygems' | |
require 'activesupport' | |
times = `last | grep ^shutdown` | |
times = times.map { |l| Time.parse l[/shutdown\s+~\s+(.*)/, 1] } | |
times = times.map { |t| t > Time.now ? t - 1.year : t } | |
diffs = times.zip(times[1 .. -1]).map { |(a, b)| a - b if b }.compact |
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
#!/bin/sh | |
# Configure your desired options here | |
DESIRED_HOSTNAME="lazeroids.com" | |
# Ensure hostname is configured | |
if [ -z "$DESIRED_HOSTNAME" ]; then | |
echo DESIRED_HOSTNAME must be set. | |
exit 1 | |
fi |