Skip to content

Instantly share code, notes, and snippets.

View jharjono's full-sized avatar

Johan Harjono jharjono

  • San Francisco
View GitHub Profile
# 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 / cdf_screen_distribute.sh
Created April 5, 2012 01:09
Script to distribute training jobs to multiple nodes in a system and create a screen for each job
#!/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=("$@")
@jharjono
jharjono / tserializer.java
Created November 6, 2012 07:30
Snippet from Thrift's 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 / array.c
Created March 22, 2013 03:47
simple illustration of why C is awesome once you understand it
#include <stdio.h>
int main() {
int a[10];
int i;
for (i=0; i < 10; i++) {
a[i] = i;
}