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 | |
### BEGIN INIT INFO | |
# Provides: mongodb | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Mongodb startup script | |
# Description: Mongodb start stop daemon sends SIGINT to terminate | |
# say man signal to see details | |
# Please check the startup params and replication options |
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($) { | |
$.fn.tweet = function(o){ | |
var s = { | |
username: ["your-twitter-username"], | |
count: 3, | |
loading_text: null | |
}; | |
$.fn.extend({ |
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
var data = {"listendata" : { | |
"genre_id":0, | |
"genre_name":"all", | |
"counts":[112,32,12,312,43,1], | |
"total":30303030, | |
"children": { | |
"genre_id":12, | |
"genre_name":"rock", | |
"counts":[112,32,12,312,43,1], | |
"total":434, |
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> |
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
<!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
// 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
# 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
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
# 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) |
OlderNewer