Skip to content

Instantly share code, notes, and snippets.

View kcha's full-sized avatar

Kevin Ha kcha

View GitHub Profile
@kcha
kcha / .Rprofile
Last active August 29, 2015 14:05
# Rprofile.site file
.First <- function() {
#.libPaths(c("~/lib/R/3.0", .libPaths()))
if (Sys.getenv("TERM") == "xterm-256color") {
library("colorout")
}
}
.Last <- function() {
@kcha
kcha / stats.py
Last active August 29, 2015 14:04
Python math and stats functions
# $Date: 2010-10-29 16:09:50 -0400 (Fri, 29 Oct 2010) $
# Filename: stats.py
#
# A bunch of math/stats functions
import math
'''calculate average'''
def calcAvg(ls):
n, mean = len(ls), 0.0
@kcha
kcha / hclust_example.R
Created July 30, 2014 19:53
Hierarchical clustering example
# Sample code for performing hierarchical clustering
# install.packages("gplots")
library(gplots)
library(RColorBrewer)
##### Use iris dataset ####
# See ?iris for more info
data <- as.matrix(iris[,1:4])
@kcha
kcha / multiprocessing_template.py
Last active August 29, 2015 14:02 — forked from ngcrawford/multiprocessing_template.py
Modified with options. Compatible with python 2.6.
#!/usr/bin/env python
# encoding: utf-8
import sys
import fileinput
from optparse import OptionParser, OptionGroup
import multiprocessing
import time
from itertools import izip_longest, izip, repeat
#!/usr/bin/perl
# KH: This is modified from the original lastjoboutput script.
#
# Shows the output of the last N jobs that finished running on the cluster
# with an exit status OTHER THAN ZERO.
# Convenience function to avoid having to find the most recent job output file
use strict;
use warnings;