Skip to content

Instantly share code, notes, and snippets.

@chmullig
chmullig / Makefile
Last active December 14, 2015 02:38
A little pointer program to help show exactly how pointer functions work.
CC = gcc
CFLAGS = -Wall -g
LDFAGS = -g
pointerfun:
pointerfun_clang: pointerfun.c
clang $(CFLAGS) $(LDFLAGS) -o pointerfun_clang pointerfun.c
pointerfun.o:
@chmullig
chmullig / lakeMerritt.R
Last active December 14, 2015 16:58
Lake Merritt trash removal graph cleanup
#inspired by: http://www.reddit.com/r/dataisbeautiful/comments/19tgz2/one_of_the_worst_graphs_ive_ever_seen_courtesy_of/
#data from: http://www.lakemerrittinstitute.org/abt_lake_watershed_trash.htm
library(plyr)
library(reshape2)
library(zoo)
library(ggplot2)
library(scales)
df <- read.csv(textConnection("Month,2012,2011,2010,2009,2008,2007,2006,2005,2004,2003,2002,2001,2000,1999,1998,1997
@chmullig
chmullig / main.c
Last active December 15, 2015 08:49
fork demo
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char **argv) {
fprintf(stderr, "Program starting with pid %d\n", getpid());
pid_t forkvalue = fork();
@chmullig
chmullig / gist:5537762
Last active December 17, 2015 02:39
gem issue
chmullig@minsk:~/tmp$ gem install --user-install mbox
Successfully installed mbox-0.0.4.6
1 gem installed
Installing ri documentation for mbox-0.0.4.6...
Installing RDoc documentation for mbox-0.0.4.6...
chmullig@minsk:~/tmp$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
@chmullig
chmullig / README.md
Last active December 17, 2015 02:39
Summarize coms3157 commits

CS3157 Stats

This is a simple project to create summary statistics about Jae Woo Lee's COMSW3157 Advanced Programming class at Columbia: http://www.cs.columbia.edu/~jae/

This started as a way to familiarize myself with ruby before an internship this summer requires me to use it. This turned into a script that parses the submitted git patches to look at who commited which lab when, and what they changed.

The result is entirely anonymous in terms of both name and content. Each time

@chmullig
chmullig / StringLiteralsTest.cpp
Last active December 30, 2015 05:19
Testing String Literal comparisons
#include <iostream>
#include <cstdio>
int main() {
std::cout << "\"hello\" == \"world\" = " << ("hello" == "world") << std::endl;
std::cout << "\"hello\" == \"hello\" = " << ("hello" == "hello") << std::endl;
std::cout << "\"hello\" < \"world\" = " << ("hello" < "world") << std::endl;
std::cout << "\"hello\" < \"abc\" = " << ("hello" < "abc") << std::endl;
printf("hello is @ %p\n", "hello");
@chmullig
chmullig / 0_point.java
Last active August 29, 2015 14:06
point-distance
public class Point {
private double x;
private double y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public double distance(Point that) {
@chmullig
chmullig / Makefile
Last active August 29, 2015 14:08
simple python script to recode gcc mips assembly output to use nice register names
CC=mipsel-unknown-linux-gnu-gcc
CFLAGS=-Wall -static -fno-inline-small-functions -S
default: palindrome_nice.s palindrome_O1_nice.s palindrome_O2_nice.s palindrome_O3_nice.s palindrome_32r2_nice.s countzeroes_nice.s countzeroes_O1_nice.s countzeroes_O2_nice.s countzeroes_O3_nice.s countzeroes_32r2_nice.s
%_nice.s: %.s recode_gcc.py
python recode_gcc.py < $< > $@
%.s: %.c
require(dplyr)
require(reshape2)
require(ggplot2)
mturk <- read.csv("What-If-Games-Were-Shorter-Data-MTurk.csv")
head(mturk)
tallturk <- melt(mturk, id.vars=c("ID"), variable.name="quarter", value.name="fav_win_prob")
tallturk <- tallturk[tallturk$quarter %in% c("FavWinProbQ1", "FavWinProbQ2", "FavWinProbQ3", "FavWinProbQ4"),]