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
http://www.10gen.com/video/mongosv2010/intro | |
mongo - shell | |
mongod, mongos - db w/ sharding | |
db has collection of documents | |
bson for fast scanability - think 2mb json string | |
bson can store binary data (no need to do base64) |
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 node | |
var Underscore = require('./underscore') | |
function randomizedArray(size, limit) { | |
var result = [] | |
for (var i=0; i < size; i++) { | |
var rnd = Math.floor(Math.random() * limit) | |
result.push(rnd + '') | |
} |
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
<!-- Simple Paint in plain HTML --> | |
<html> | |
<style> | |
html, body { margin:0; padding:0; } | |
#undo { | |
background: #666; | |
color: #fff; | |
cursor: pointer; | |
padding: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
#! /usr/bin/env python3 | |
# USAGE: | |
# h -- prints out the http server headers for a given URL | |
# Command-Line: h [agent] URL | |
# Agent can be any of: ff, chrome, ie, googlebot, safari | |
# If nothing is given on the command line, clipboard data | |
# is tried (under OS X and Windows). If it contains a valid | |
# URL, then that is used. |
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
# daemoinze the current process | |
# Copied from the Python Cookbook | |
import sys, os | |
LOG = "path where you want the program output to go" | |
def daemonize(): | |
try: | |
pid = os.fork() | |
if pid > 0: | |
# exit parent | |
sys.exit(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
# Arbitrary precision Multiplication & Addition -- the slow, slow way | |
def mul(x, y): | |
if len(x) < len(y): | |
x, y = y, x | |
results = [] | |
x = list(x) | |
y = list(y) | |
x.reverse() | |
y.reverse() |
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
// node.js example | |
// usage: http://localhost:8080/?path=. will list | |
// all files under '.' | |
var Sys = require('sys'), | |
Http = require('http'), | |
Fs = require('fs'), | |
Url = require('url') | |
function stat(f, if_file, if_dir, if_other) { | |
Fs.stat(f, function(err, stat) { |
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
# Download all dependencies and parse a bunch of Outlook MSG files. | |
# See http://defcraft.blogspot.com/2010/03/extracting-phone-numbers-from-outlook.html | |
# Released under the GNU GPL. | |
# http://www.gnu.org/copyleft/gpl.html | |
require 'fileutils' | |
DOWNLOADS = %w{ |
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 python3 | |
# Released under MIT License. | |
# Linked list implementation after reading this | |
# http://www.rethinkdb.com/blog/2010/06/will-the-real-programmers-please-stand-up/ | |
import sys | |
class Node: | |
def __init__(self, value): | |
self.next = None |
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 | |
# usd2rs AMOUNT - convert from US dollars to Indian Rupees | |
# Prints out Rupees in Lakhs & Crores as necessary | |
require 'open-uri' | |
LAKH, CRORE = 100_000, 10_000_000 | |
dollars = (ARGV[0] || begin; printf "Dollars? "; gets.chomp; end). | |
gsub(/,/, ''). | |
to_i |