Skip to content

Instantly share code, notes, and snippets.

@geekman
geekman / image_renamer.py
Created February 25, 2014 15:48
image files renamer
#!/usr/bin/python
#
# renames a directory of files with their image extension
# currently works with only JPEG and PNG files
#
# 2014.02.25 darell tan
#
import os
import sys
@geekman
geekman / flatten_objs.js
Created June 19, 2014 15:09
flattens JS object hierarchies (used for shaping data for D3.js)
//
// flattens object hierarchies like {'US': {'AZ': {size: 999, ...} } }
// into array of "rows" like {country: 'US', state: 'AZ': size: 999, ...}
// e.g. flatten(data, 2, ['country', 'state'])
//
// values can also form another level like so:
// e.g. flatten(data, 3, ['country', 'state', 'stat'])
// which produces: {country: 'US', state: 'AZ', stat: 'size', value: 999}
//
// NOTE: modifies objects directly, so don't run multiple times with diff levels
@geekman
geekman / zip-itead.cmd
Created July 9, 2014 10:46
zips up generated Gerber files in a directory
cd %1
zip itead-gerbers.zip *.GTL *.GBL *.GTS *.GBS *.GTO *.GBO *.TXT *.GKO *.GMO
pause
@geekman
geekman / extract.py
Created December 24, 2014 13:34
mass-extract permissions & features from Android manifest
#!/usr/bin/env python
#
# extract permissions and features from Android manifest
# put this script into the androguard directory
#
import os
import sys
import csv
import traceback
@geekman
geekman / ipynb_renum.py
Created December 25, 2014 17:30
sequentially re-numbers cells in an IPython Notebook file
#!/usr/bin/python
#
# sequentially re-numbers cells in an IPython notebook
# 2014.12.26 darell tan
#
import json
import sys
def main():
@geekman
geekman / yahoo_pf_export.user.js
Last active August 29, 2015 14:14
user script to export Yahoo finance portfolio
// ==UserScript==
// @name Yahoo! Finance Portfolio Export
// @description Adds a button that lets you export your portfolio
// @author Darell Tan
// @version 1.2
// @namespace https://gist.github.com/geekman
// @match https://finance.yahoo.com/portfolio/pf_*/holdings/edit*
// @match https://*.finance.yahoo.com/portfolio/pf_*/holdings/edit*
// ==/UserScript==
@geekman
geekman / merge_srt.py
Created February 1, 2015 16:59
merge OCR fuck-ups in SRT file
#!/usr/bin/env python
#
# merges screwed up OCR'ed subs, which generated 2 separate items for the same
# text, maybe sometimes with italics or not, or different upper/lower case
#
import sys
from pysrt import SubRipFile
@geekman
geekman / circles.ipynb
Created May 12, 2015 10:46
D3.js sunburst concentric rings visualization
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@geekman
geekman / modzip.py
Created July 1, 2015 16:36
Patches file attributes in ZIP files
#!/usr/bin/python
#
# modifies zip file attributes
# 2015.07.01 darell tan
#
from zipfile import *
import struct
import sys
@geekman
geekman / foxit_hist.py
Created August 31, 2015 10:25
dumps Foxit Reader history from registry
#
# lists Foxit Reader last opened files from registry
# 2015.08.31 darell tan
#
from _winreg import *
from ctypes import windll, create_unicode_buffer
def GetLongPathName(path):