This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
import requests | |
import csv | |
if __name__ == '__main__': | |
""" | |
FDIC dividends api returns a json list of objects like this: | |
{ | |
"inst_drr_web_id": 2148, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from multiprocessing import Process, Pool | |
import time | |
import urllib2 | |
def millis(): | |
return int(round(time.time() * 1000)) | |
def http_get(url): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from multiprocessing import Process, Queue | |
import os | |
import sys | |
import time | |
import tornado.ioloop | |
import tornado.web | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jon; | |
import java.util.concurrent.Callable; | |
import java.util.concurrent.ExecutionException; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.ForkJoinPool; | |
import java.util.concurrent.Future; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.TimeoutException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Map; | |
import java.util.Random; | |
import java.util.function.Function; | |
import java.util.stream.Collectors; | |
import java.util.stream.Stream; | |
public class Histogram { | |
public static <T> Map<T, Integer> histogram(Stream<T> stream) { | |
return stream.collect( | |
Collectors.groupingBy(Function.<T>identity(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
NewerOlder