Skip to content

Instantly share code, notes, and snippets.

@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 / axml.py
Created October 21, 2014 16:51
quick & dirty Android manifest bulk extractor
#!/usr/bin/env python
#
# quick and dirty Android manifest extractor
# ripped from androguard to be standalone
#
import os
import sys
from struct import unpack, pack
from xml.dom import minidom
@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 / re_gex_solver.py
Last active August 17, 2016 20:00
PlaidCTF 2015 "RE GEX" solver
#!/usr/bin/env python
#
# PlaidCTF 2015 "RE GEX" solver
# @zxcvgm
#
from z3 import *
validchars = 'plaidctf'
flaglen = 171
@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