Skip to content

Instantly share code, notes, and snippets.

Avatar

Johan Harjono jharjono

View GitHub Profile
@jharjono
jharjono / array.c
Created Mar 22, 2013
simple illustration of why C is awesome once you understand it
View array.c
#include <stdio.h>
int main() {
int a[10];
int i;
for (i=0; i < 10; i++) {
a[i] = i;
}
@jharjono
jharjono / tserializer.java
Created Nov 6, 2012
Snippet from Thrift's TSerializer.java
View tserializer.java
/**
* Serialize the Thrift object into a byte array. The process is simple,
* just clear the byte array output, write the object into it, and grab the
* raw bytes.
*
* @param base The object to serialize
* @return Serialized object in byte[] format
*/
public byte[] serialize(TBase base) throws TException {
baos_.reset();
@jharjono
jharjono / cdf_screen_distribute.sh
Created Apr 5, 2012
Script to distribute training jobs to multiple nodes in a system and create a screen for each job
View cdf_screen_distribute.sh
#!/bin/bash
# Script to distribute MATLAB training jobs to multiple nodes in a system and create a screen for each job
# some helpers, stolen shamelessly from internet forums
rand() {
printf $(( $1 * RANDOM / 32767 ))
}
rand_element () {
local -a th=("$@")
View Ruby script to scrape off images from Tumblr
# Quick hack - really hacky, untested, and probably breaks a lot
require 'rubygems'
require 'mechanize'
module TumblrScraper
class TumblrPost
attr_accessor :url, :post_id, :tumblr_id
@jharjono
jharjono / eol-bootstrap.sh
Created Oct 15, 2011
EOL Fresh install script for a fresh Ubuntu machine
View eol-bootstrap.sh
# 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
@jharjono
jharjono / git-cdf.sh
Created Sep 27, 2011
Create git servers on CDF
View git-cdf.sh
#!/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 / watched-repos.py
Created Aug 20, 2011
Python script to clone all watched repos that a user is watching on Github
View watched-repos.py
#!/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 / constant_viewer.rb
Created Jul 12, 2011
Show all constants, classes, modules, etc that are recognized in this namespace
View constant_viewer.rb
puts self.class.constants.inspect
@jharjono
jharjono / resume_structure.tex
Created Mar 27, 2011
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
View resume_structure.tex
\documentclass{article}
% Custom Macros and Packages---------------------------
\input{macros}
% Header and Footer------------------------------------
\input{header_footer}
\begin{document}
@jharjono
jharjono / pycon2011_talks.py
Created Mar 14, 2011
Python script to help grab all PyCon 2011 Videos
View pycon2011_talks.py
#!/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)
You can’t perform that action at this time.