Skip to content

Instantly share code, notes, and snippets.

View derekchiang's full-sized avatar

Derek Chiang derekchiang

View GitHub Profile
@derekchiang
derekchiang / Quotes.md
Last active September 4, 2017 15:41
A collection of interesting and/or inspiring quotes.

"I would have written a shorter letter, but I did not have the time." -- Blaise Pascal


"Logging into Google+ feels like logging into a seminar, or stumbling into the wrong conference room at an airport Marriott. It looks like a cubicle farm and smells like a hospital. Posting anything on Google+ is like talking into a pillow." -- BuzzFeed


How Our CS Curriculum Is Becoming Easier, and Why This Probably Isn't a Good Idea

Let me start off by saying that I have the uttermost respect for all the faculty members of the fantastic Cornell Computer Science Department. I have been enjoying the education ever since I came here and I've become a much better budding software engineer / computer scientist than I was only half a year ago, thanks to all the amazing professors, TAs, and classmates from and with whom I have been learning.

However, I've noticed a trend that is making me quite uneasy. The CS curriculum, for some reason, is becoming easier. The hard courses are still pretty hard, but the easier courses, in particular CS1110 and CS2110, which traditionally together make up an introductory sequel which a student has to complete before he can affiliate with the computer science major, have been made easier.

As most CS majors probably know, CS1110 has undergone a major redesign over the last summer. Before the 2012-13 academic year, CS1110 w

@derekchiang
derekchiang / extend.coffee
Created May 24, 2013 07:43
A standalone copy of jQuery's extend(), in CoffeeScript
# Adopted from: https://github.com/dansdom/extend
# Translated using js2coffee
extend = ->
options = undefined
name = undefined
src = undefined
copy = undefined
copyIsArray = undefined
clone = undefined
@derekchiang
derekchiang / getExtension.coffee
Last active December 17, 2015 16:49
A simple function for getting the extension of a filename.
getExtension = (filename) ->
i = filename.lastIndexOf '.'
return if i < 0 then '' else filename.substr (i+1)
@derekchiang
derekchiang / basename.coffee
Created May 25, 2013 09:23
A little function that returns the basename of a filename.
baseName = (str) ->
base = new String(str).substring(str.lastIndexOf("/") + 1)
base = base.substring(0, base.lastIndexOf(".")) unless base.lastIndexOf(".") is -1
return base
@derekchiang
derekchiang / get-erlang-deps.sh
Created June 5, 2013 06:34
Install all dependencies needed for compiling Erlang R16B from source.
# for erlang
apt-get install fop
apt-get install libncurses5-dev
apt-get install openjdk-7-jdk
apt-get install unixodbc-dev
apt-get install g++
apt-get install make
apt-get install libssl-dev
@derekchiang
derekchiang / simple-server.py
Created August 22, 2013 04:27
A script for serving static files from the current directory. Very handy.
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
from argparse import ArgumentParser
import socket
parser = ArgumentParser(
description='Serve static files in the current directory.')
@derekchiang
derekchiang / json_example.rs
Created November 22, 2013 09:24
It's amazing how hard it is to get code to compile in Rust. This is the result of an hour-long struggle. It demonstrates one usage of `extra::json`. Hope it helps someone.
// Compile with rustc 0.9-pre (727b70d 2013-11-17 21:11:24 -0800)
#[feature(managed_boxes)];
extern mod extra;
use extra::json;
use std::io::stdio;
use extra::serialize::Encodable;
@derekchiang
derekchiang / split_owned_vec.rs
Created January 5, 2014 14:23
A Rust function for splitting an owned vector into two owned vectors.
fn split_owned_vec<T>(mut v: ~[T], index: uint) -> (~[T], ~[T]) {
assert!(index <= v.len());
let new_len = v.len() - index;
let mut new_v = vec::with_capacity(v.len() - index);
unsafe {
ptr::copy_nonoverlapping_memory(new_v.as_mut_ptr(), v.as_ptr().offset(index as int), new_len);
v.set_len(index);
new_v.set_len(new_len);
}
@derekchiang
derekchiang / green_bench.rs
Created February 14, 2014 02:20
A benchmark of Rust libgreen.
extern mod extra;
extern mod sync;
use sync::mutex::{StaticMutex, MUTEX_INIT};
use std::os;
static mut LOCK: StaticMutex = MUTEX_INIT;
fn work() {
for _ in range(0, 10000000) {
unsafe {