Skip to content

Instantly share code, notes, and snippets.

@righthandabacus
righthandabacus / dedup.py
Last active February 3, 2018 21:23
Remove duplicate files in a directory
#!/usr/bin/env python
from __future__ import print_function
import argparse
import hashlib
import itertools
import os
import multiprocessing as mp
import sys
@righthandabacus
righthandabacus / kalman.py
Created February 3, 2018 05:45
Smoothing data using Kalman filter
# Kalman filtering
# Prediction:
# x_pre[k] = A*x[k-1] + B*u[k]
# P_pre[k] = A*P[k-1]*A' + Q
# Measurement update:
# K[k] = P_pre[k]*H'*(H*P_pre[k]*H'+R)**(-1)
# x[k] = x_pre[k] + K[k]*(z[k]-H*x_pre[k])
# P[k] = (I-K[k]*H)*P_pre[k]
#
# Simplified with A=H=1, B=0, Q=0:
@righthandabacus
righthandabacus / unzip.rb
Created February 2, 2018 19:21
Extract zip file with filename encoding conversion
#!/usr/bin/env ruby
require 'optparse'
require 'zip'
require 'fileutils'
# parse command line arguments
options = {}
OptionParser.new do |opt|
opt.on('-f FROM_ENC') {|o| options[:from_enc] = o}