Skip to content

Instantly share code, notes, and snippets.

View hoffrocket's full-sized avatar
👋

Jon Hoffman hoffrocket

👋
  • Anomaly
  • New York, NY
View GitHub Profile
#!python
import requests
import csv
if __name__ == '__main__':
"""
FDIC dividends api returns a json list of objects like this:
{
"inst_drr_web_id": 2148,
@hoffrocket
hoffrocket / liccheck.py
Created August 23, 2021 14:15
Get licenses for all python packages in environment
import pkg_resources
import sys
def get_pkg_license(pkg):
try:
lines = pkg.get_metadata_lines('METADATA')
except Exception:
lines = pkg.get_metadata_lines('PKG-INFO')
@hoffrocket
hoffrocket / election_predictions.py
Last active November 3, 2020 22:00
538 Election predictions to TSV
from urllib import request
import json
all_votes = json.load(request.urlopen("https://projects.fivethirtyeight.com/2020-election-forecast/states_electoral_votes.json"))
predictions = json.load(request.urlopen("https://projects.fivethirtyeight.com/2020-election-forecast/state_summary.json"))[0]["states"]
predictions.sort(key=lambda p: p["state"])
for prediction in predictions:
state = prediction["state"]
vote_count = next(v["votes"] for v in all_votes if v["state"] == state)
# not an endorsement!
import requests
from zipfile import ZipFile
import gzip
from io import BytesIO
import io
import struct
zip_req = requests.get("http://download.geonames.org/export/zip/US.zip")
zip_bytes = BytesIO(zip_req.content)
@hoffrocket
hoffrocket / body_replace.py
Created March 22, 2016 12:53
mitm moat body replacement
# mitmproxy -s this_script.py
def response(context, flow):
if flow.request.host == "z.moatads.com" and flow.request.path.startswith("/FRSQ/ios/status.json"):
flow.response.status_code = 200
flow.response.reason = "OK"
flow.response.content = "98e3f87ddccbbc4e7bfe70ad4679308073ad7169"
package j.nettytest;
/*
** JkKdTree.java by Julian Kent
**
** Licenced under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
**
** Licence summary:
** Under this licence you are free to:
** Share — copy and redistribute the material in any medium or format
Linux - create "Default (Linux).sublime-mousemap" in ~/.config/sublime-text-3/Packages/User
Mac - create "Default (OSX).sublime-mousemap" in ~/Library/Application Support/Sublime Text 3/Packages/User
Win - create "Default (Windows).sublime-mousemap" in %appdata%\Sublime Text 3\Packages\User
[
{
"button": "button1",
"count": 1,
"modifiers": ["super"],
"press_command": "drag_select",

Keybase proof

I hereby claim:

  • I am hoffrocket on github.
  • I am hoff (https://keybase.io/hoff) on keybase.
  • I have a public key whose fingerprint is A4AB A02A 4F21 DA7D B7EC E7BC 8BFD 1D7C 2B6E E597

To claim this, I am signing this object:

@hoffrocket
hoffrocket / server.py
Last active August 6, 2020 03:56
Tornado + multiprocessing
#!/usr/bin/env python
from multiprocessing import Process, Queue
import os
import sys
import time
import tornado.ioloop
import tornado.web
JonAir:~ jon$ curl -v --socks5-hostname localhost:9150 -i ef13c001238735351bfaf0f8832bfbac
* Adding handle: conn: 0x7f8911003a00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f8911003a00) send_pipe: 1, recv_pipe: 0
* About to connect() to proxy localhost port 9150 (#0)
* Trying ::1...
* Trying 127.0.0.1...
* Can't complete SOCKS5 connection to 0.0.0.0:0. (4)