Skip to content

Instantly share code, notes, and snippets.

View miketahani's full-sized avatar

Mike Tahani miketahani

View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# scrape complex systems article pdfs
# requires bs4: `pip install beautifulsoup4`
import os
import re
import json
from urllib import urlopen as get, urlretrieve as save
from bs4 import BeautifulSoup as bs
/* post-fx pass by blending a solid white fullscreen quad, no texture required */
/*uniform*/ float fmin = 0.7;
void main(void)
{
float fmod = mod(gl_FragCoord.y, 2.0);
float fstep = fmin + (1.0 - fmin) * fmod;
gl_FragColor = vec4(1.0, 1.0, 1.0, fstep);
}
@miketahani
miketahani / grabber.py
Created January 24, 2018 20:16
egghead.io series scraper
#!/usr/local/bin/python3
# one-off scraper for egghead.io videos in a series
# usage: chmod +x grabber.py && ./grabber.py <series stub>
# requires youtube-dl (`brew install youtube-dl`)
import os
import subprocess
import json
import argparse
from urllib.request import urlretrieve
@miketahani
miketahani / tree.md
Created April 9, 2020 03:42 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@miketahani
miketahani / mac-setup.md
Last active January 16, 2023 16:22
Mac setup
  • XCode CLI
  • iTerm2
  • Python
  • Node/nvm
  • PostGIS
  • GDAL
  • TileMill
  • QGIS + OpenLayers, mmqgis
  • Sublime Text 3
  • Firefox + LastPass, Disconnect, uBlock Origin, HTTPS Everywhere, Privacy Badger, Auto Tab Discard, React Devtools, Decentraleyes, Neat URL, Weasel WebSocket Client, Multi-Account Containers, Cookie AutoDelete
@miketahani
miketahani / date_finding.py
Last active January 16, 2023 16:22
answer to a NICAR-L question
import re
from datetime import datetime as dt
fake_dates = '10-Jan-2011, 01-Feb-02, ##-Bla-##, 01-Bla-2014'
# you can probably do some lookahead assertion at the end of the regex to only capture 2 digits or the last 2 digits
# instead of the mess below [1]
date_finder = re.compile('(\d{2}-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2,4})')
dates = re.findall(date_finder, fake_dates)
@miketahani
miketahani / web-servers.md
Created May 26, 2020 03:31 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@miketahani
miketahani / Blink.jsx
Created January 24, 2018 17:18
React <blink>
@miketahani
miketahani / wtf.py
Created November 5, 2015 22:38
python html parsing inconsistencies
import re
from sys import argv
from bs4 import BeautifulSoup as bs
from pyquery import PyQuery as pq
from lxml import etree
filename = argv[-1]
anchors = re.compile('<a.+?>.+?<\/a>', re.DOTALL|re.I)
with open(filename, 'r') as infile:
const radians = deg => deg * Math.PI / 180
// @param {Number} z Offset from radius
export default function convertLatLngToSphere (lat, lng, baseRadius, z) {
// radians
const phi = radians(lat)
const theta = radians(lng - 180)
const radius = baseRadius + z