Skip to content

Instantly share code, notes, and snippets.

@tmarthal
tmarthal / brush.js
Created September 27, 2013 00:30 — forked from enjalot/brush.js
if(!d3.chart) d3.chart = {};
d3.chart.brush = function() {
var g;
var data;
var width = 600;
var height = 30;
var dispatch = d3.dispatch(chart, "filter");
function chart(container) {
@tmarthal
tmarthal / Linear Dependent VAR
Last active December 21, 2015 09:49
Auto-Correlation of statsmodels VAR process with linear dependent timeseries.
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@tmarthal
tmarthal / gist:5286991
Last active December 15, 2015 16:09
Python time list filtering
import datetime
base = datetime.datetime.today()
dateList = [ base - datetime.timedelta(minutes=2*x) for x in range(0,48) ]
hour_ago = base - datetime.timedelta(hours=1)
# get the number of dates from less than an hour ago
len(filter(lambda x: x > hour_ago, dateList))
@tmarthal
tmarthal / gist:5248035
Created March 26, 2013 18:48
PowerSet Calculation in java
import java.util.HashSet;
import java.util.Set;
public class PowerSet {
private Set<Set<Object>> powerSet;
private void setCombinations(Set<Object> set) {
digits2alpha = {'1':('1'),
'2':('a','b','c'),
'3':('d','e','f'),
'4':('g','h','i'),
'5':('j','k','l'),
'6':('m','n','o'),
'7':('p','q','r','s'),
'8':('t','u','v'),
'9':('w','x','y','z'),
'0':('0')}
@tmarthal
tmarthal / csvprocessor.py
Last active August 26, 2015 16:18 — forked from miku/csvprocessor.py
CSV processor examples for luigi. Can serialize *args to CSV. Can deserialize CSV rows into namedtuples if requested. -- "works on my machine".
from luigi.format import Format
import csvkit
class CSVOutputProcessor(object):
"""
A simple CSV output processor to be hooked into Format's
`pipe_writer`.
If `cols` are given, the names are used as CSV header, otherwise no
explicit header is written.