Skip to content

Instantly share code, notes, and snippets.

View jharjono's full-sized avatar

Johan Harjono jharjono

  • San Francisco
View GitHub Profile
@jharjono
jharjono / mongo_dumper.rb
Created March 9, 2011 05:22
Dump JSON documents into MongoDB
#!/usr/bin/env ruby
# Dump JSON documents into MongoDB
require 'rubygems'
require 'mongo'
require 'json'
# Grab the dataset from a dump
filename = ARGV.first
docs = JSON.parse(File.open(filename).read)
@jharjono
jharjono / sinatra_sass_coffee.rb
Created March 7, 2011 19:12
a setup of Sinatra using Slim for HTML, Sass for CSS, and CoffeeScript for JavaScript
#!/usr/bin/env ruby
# Libraries:::::::::::::::::::::::::::::::::::::::::::::::::::::::
require 'rubygems'
require 'sinatra/base'
require 'slim'
require 'sass'
require 'coffee-script'
# Application:::::::::::::::::::::::::::::::::::::::::::::::::::
@jharjono
jharjono / hello.js
Created March 4, 2011 20:40
Quick Hello World using node.js and Express, shows all the config options for using Jade templating lang
var express = require('express');
var app = express.createServer();
// Configure static files directory
app.configure('development', function(){
app.use(express.staticProvider(__dirname + '/public'));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
// configure views directory
@jharjono
jharjono / doc_downloader.py
Created February 26, 2011 21:09
Downloads all files of a certain file format on a web page to local filesystem
#!/usr/bin/env python
# Downloads all files of a certain file format on a web page to local filesystem
import urllib2
import lxml
import os
from lxml.html import fromstring
from urlparse import urljoin
from urllib import urlretrieve