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 / 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
@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 / 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 / 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 / pycon2011_talks.py
Created March 14, 2011 06:38
Python script to help grab all PyCon 2011 Videos
#!/usr/bin/env python
# List all source video URLs for Pycon 2011 Videos
# easy_install bliptv.reader
from bliptv.reader import Show
def list_episodes_url(page):
urls = []
for episode in page.episodes:
enclosure = episode.enclosures.get('video/mp4', None)
@jharjono
jharjono / resume_structure.tex
Created March 27, 2011 03:15
Sample main file for a LaTeX resume; being able to structure resumes like this is one of the reasons why I like LaTeX for resumes
\documentclass{article}
% Custom Macros and Packages---------------------------
\input{macros}
% Header and Footer------------------------------------
\input{header_footer}
\begin{document}
@jharjono
jharjono / constant_viewer.rb
Created July 12, 2011 14:52
Show all constants, classes, modules, etc that are recognized in this namespace
puts self.class.constants.inspect
@jharjono
jharjono / watched-repos.py
Created August 20, 2011 15:31
Python script to clone all watched repos that a user is watching on Github
#!/usr/bin/env python
# Script to clone all the github repos that a user is watching
import requests
import json
import subprocess
# Grab all the URLs of the watched repo
user = 'jharjono'
r = requests.get("http://github.com/api/v2/json/repos/watched/%s" % (user))
repos = json.loads(r.content)
@jharjono
jharjono / git-cdf.sh
Created September 27, 2011 01:52
Create git servers on CDF
#!/bin/bash
# This script creates a git repository on your local machine and your CDF account and links them together
# Set up env
REPO_NAME=myproj # or $1 if you want to run this script often
CDF_NAME=g1someone
SERVER=redwolf.cdf.toronto.edu
# Creating the project
mkdir $REPO_NAME
@jharjono
jharjono / eol-bootstrap.sh
Created October 15, 2011 14:43
EOL Fresh install script for a fresh Ubuntu machine
# make sure all packages and sources are up-to-date
sudo apt-get update
# update system and kernel files as well
sudo apt-get dist-upgrade
# install compiler packages
sudo apt-get install build-essential
# Git