Skip to content

Instantly share code, notes, and snippets.

@truncs
truncs / regress_with_uniform.R
Created April 6, 2012 06:24
Uniform sampling
# Get a subset of values from the training set where days spent is zero
temp <- subset(train, DaysInHospital_Y2 == log1p(0))
# Get 100 samples from it with replacement and add it to a new dataframe
uniform_set <- temp[sample(nrow(temp), 100, replace=TRUE),]
# Keep on doing this for other values as well
uniform_set <- merge(uniform_set, temp[sample(nrow(temp), 100, replace=TRUE),], all=T)
# Train a tree on it
#! /usr/bin/python
import argparse
import os
import pwd
import subprocess
import string
import random
import signal
import sys
@truncs
truncs / gist:2650766
Created May 10, 2012 03:05
python-ptrace traceexit example
#! /usr/bin/python
import argparse
import os
import pwd
import subprocess
import string
import random
import signal
import sys
@truncs
truncs / pcm.py
Created May 10, 2012 19:16
Final PCM
#! /usr/bin/python
import argparse
import os
import pwd
import subprocess
import string
import random
import signal
import sys
@truncs
truncs / ex1.py
Created July 17, 2012 07:40
Project Euler
f = lambda x : x * (x + 1) / 2
f(999/3)*3 + f(999/5)*5 - f(999/15)*15
@truncs
truncs / multiplot.R
Created July 25, 2012 21:15
R multiplot
multiplot <- function(..., plotlist=NULL, cols) {
require(grid)
# Make a list from the ... arguments and plotlist
plots <- c(list(...), plotlist)
numPlots = length(plots)
# Make the panel
plotCols = cols # Number of columns of plots
@truncs
truncs / gist:3777093
Created September 24, 2012 17:15
coin change
#! /usr/bin/python
import sys
denominations = [1, 2,3]
def find_all_denom(value, denom, current_denom):
if value < 0:
return
@truncs
truncs / gist:4065285
Created November 13, 2012 11:18
try 2
<!DOCTYPE html>
<html>
<head>
<title>I have a back bone</title>
</head>
<body>
<div id="contact-app">
<div class="title">
<h1>Contacts App</h1>
@truncs
truncs / gist:4070555
Created November 14, 2012 05:55
backup 3
<!DOCTYPE html>
<html>
<head>
<title>I have a back bone</title>
</head>
<body>
<form>
Name: <input type="text" name="name" id="name"/>
Age: <input type="text" name="address" id="address"/>
<input type="submit" value="Submit"></input>
@truncs
truncs / gist:4071195
Created November 14, 2012 09:30
backup 5
<!DOCTYPE html>
<html>
<head>
<title>I have a back bone</title>
</head>
<body>
Name: <input type="text" name="name" id="name"/>
Age: <input type="text" name="address" id="address"/>
<button class="post">Create</button>