Skip to content

Instantly share code, notes, and snippets.

var fs = require('fs'),
sys = require('sys'),
http = require('http');
http.createServer(function (req, res) {
checkBalanceFile(req, res);
}).listen(8000);
function checkBalanceFile(req, res) {
fs.stat("balance", function(err) {
@sandywu
sandywu / gist:1983976
Created March 6, 2012 06:03 — forked from cmoore4/gist:998126
Node.io Scraper
// This is the library that'll handle all of our input tracking and job dispatching
var nodeio = require('node.io');
// The base_url is the site you want to crawl.
// Links is an array of all the links seen as <a> tags, but not yet scraped.
// crawled_links is the array of all the pages already scraped.
var base_url = 'http://reddit.com',
links = [base_url],
crawled_links = [];
@sandywu
sandywu / README
Created June 30, 2012 10:31 — forked from vangberg/README
Deploying a Sinatra app to Heroku
# Deploying a Sinatra app to Heroku
## Database
The location of the database Heroku provides can be found in the environment
variable DATABASE_URL. Check the configure-block of toodeloo.rb for an example
on how to use this.
## Server
Heroku is serving your apps with thin, with means you have all your thin goodness available,
such as EventMachine.
@sandywu
sandywu / gist:3071570
Created July 8, 2012 16:14
TextMate 2 .tm_properties

This is all based on the [alpha release][1].

Properties

From the built-in help system:

For many settings TextMate will look for a .tm_properties file in the current folder and in any parent folders (up to the user’s home folder).

These are simple setting = value listings where the value is a format string in which other variables can be referenced.

@sandywu
sandywu / gist:3207479
Created July 30, 2012 14:45 — forked from madrobby/gist:3201472
Check if the browsers supports SVG
// comments welcome, there may be better ways to do this!
function supportsSVG(){
return !!('createElementNS' in document &&
document.createElementNS('http://www.w3.org/2000/svg','svg').createSVGRect)
}
echo "Hi, I'm Douglas Crockford. What do you want?";
while read question
do
what="$question"
if [ -z "${what}" ]; then
echo "Stop waisting my time."
exit
else
@sandywu
sandywu / index.js
Created August 20, 2012 06:31 — forked from max-mapper/index.js
official semicolon style of @maxogden
Mdb.prototype.toCSV = function(table, cb) {
;;;;var cmd = spawn('mdb-export', [this.file, table])
;;;;cmd.stdout.pipe(
;;;;;;;;concat(function(err, out) {
;;;;;;;;;;;;if (err) return cb(err)
;;;;;;;;;;;;if (!out) return cb('no output')
;;;;;;;;;;;;cb(false, out.toString())
;;;;;;;;})
;;;;)
}
@sandywu
sandywu / gist:3414874
Created August 21, 2012 11:53 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@sandywu
sandywu / perferences.json
Created August 23, 2012 02:27 — forked from soffes/perferences.json
My Sublime Text 2 config
{
"bold_folder_labels": true,
"color_scheme": "Packages/User/Espresso Soda.tmTheme",
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns": [
".DS_Store",
".gitkeep",
"dump.rdb"
],
"folder_exclude_patterns": [
@sandywu
sandywu / .tm_properties
Created August 29, 2012 15:39
My textmate properties file
TMGIT = "/usr/local/bin/git"
PATH = "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:$PATH"
NODEPATH = "/usr/local/lib/node_modules"
fontName = "Monaco"
fontSize = 14
tabSize = 2
softTabs = Spaces
exclude = "{.{o,pyc},Icon\r,CVS,darcs,MTN,{arch},blib,~.nib}"