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
"This actually did happen to a real person, and the real person is me. I had gone to catch a train, This was April 1976, in Cambridge, U.K. | |
I was about twenty minutes early. | |
I'd got the time of the train wrong. I suppose it is at least equally possible," | |
he added after a moment's reflection, | |
"that British Rail had got the time of the train wrong. Hadn't occurred to me before." | |
"Get on with it." Fenchurch laughed. | |
"So I bought a newspaper, to do the crossword, and went to the buffet to get a cup of coffee." | |
"You do the crossword?" | |
"Yes." | |
"Which one?" |
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
# Currently in Rails 2 and 3... | |
# https://github.com/rails/rails/blob/3-2-stable/actionpack/lib/action_dispatch/http/headers.rb | |
# | |
# headers = ActionDispatch::Http::Headers.new | |
# headers['HTTP_FOO_BAR'] = 'a1b2c3' | |
# puts headers['foo-bar'] #=> 'a1b2c3' | |
# puts headers.has_key? 'foo-bar' #=> false | |
# puts headers.has_key? 'HTTP_FOO_BAR' #=> true | |
# | |
# I found this pseudo hash syntax, where the array [] lookup returned a 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
require 'irb/completion' | |
ARGV.concat [ "--readline", | |
"--prompt-mode", | |
"simple" ] | |
require 'irb/ext/save-history' | |
IRB.conf[:SAVE_HISTORY] = 100 | |
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history" | |
# load wirble |
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
# Format large numbers nicely for Millions, Billions and Trillions | |
# Example: | |
# humanize_large_number(123456789) => 123.46M | |
# humanize_large_number(123) => 123 | |
def humanize_large_number(i) | |
i = Integer(i) | |
case i | |
when 1000000..999999999 | |
"%.2fM" % (i/1000000.0) |
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
DELIMITER $$ | |
DROP FUNCTION IF EXISTS `test`.`distance` $$ | |
CREATE FUNCTION `distance`(a POINT, b POINT) RETURNS double | |
DETERMINISTIC | |
COMMENT 'distance function' | |
BEGIN | |
RETURN round(glength(linestringfromwkb(linestring(asbinary(a), asbinary(b))))); | |
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
# Monkey patch/hack for adding in a to_json for Sequel datasets | |
# See http://sequel.rubyforge.org | |
class Sequel::Dataset | |
def to_json | |
naked.all.to_json #Note: 'naked' converts dataset to plain hash... | |
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
// From: http://matt.might.net/articles/implementation-of-recursive-fixed-point-y-combinator-in-javascript-for-memoization/ | |
// | |
// A "functional" is just a function that takes | |
// another function as input. | |
// The Y combinator finds the fixed point | |
// of the "functional" passed in as an argument. | |
// Thus, the Y combinator satisfies the property: |
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
<script src="prototype.js"></script> | |
<script language="javascript" type="text/javascript" src="jsonp.js"></script> | |
<title>JSONP test page</title> | |
</head> |
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 'pp' | |
class KDTree | |
attr_reader :root | |
attr_reader :points | |
def initialize(points, dim) | |
@dim = dim | |
@root = KDNode.new(dim).parse(points) | |
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
<!-- include the data file. This dumps everything into a JS variable called 'data' --> | |
<script src="/data/genres.js" type="text/javascript"></script> | |
<!-- print out some trivial data to show that it's loaded --> | |
<script> | |
$('container').update("Total count from trackdata is: " + | |
data.trackdata.total + | |
" <br />and total count from listendata is: " + | |
data.listendata.total); | |
</script> |
NewerOlder