Skip to content

Instantly share code, notes, and snippets.

@jonluca
jonluca / requests.py
Created Jun 15, 2021
Fast AsyncIO HTTP requests
View requests.py
import http.cookies
http.cookies._is_legal_key = lambda _: True
import asyncio
import aiohttp
import nest_asyncio
import time
nest_asyncio.apply()
async def gather_with_concurrency(n, *tasks):
semaphore = asyncio.Semaphore(n)
@jonluca
jonluca / file.py
Last active May 18, 2022
Fast asyncio HTTP requests
View file.py
import sys
import os
import json
import asyncio
import aiohttp
# Initialize connection pool
conn = aiohttp.TCPConnector(limit_per_host=100, limit=0, ttl_dns_cache=300)
PARALLEL_REQUESTS = 100
@jonluca
jonluca / github_watcher.py
Created Feb 23, 2019
Watch all of your own repositories
View github_watcher.py
import os
from github import Github
# set an environment variable named GITHUB_KEy to the access token from here https://github.com/settings/tokens
# this script watches all repositories that are under your username
# if you'd like to watch all the repos you've contributed to or that are in your orgs, remove the if check on line 12
g = Github(os.environ['GITHUB_KEY'])
user = g.get_user()
@jonluca
jonluca / Bandersnatch
Created Dec 30, 2018
Bandersnatch options
View Bandersnatch
{
"videos": {
"80988062": {
"interactiveVideoMoments": {
"$type": "atom",
"$size": 273075,
"value": {
"type": "bandersnatch",
"choicePointNavigatorMetadata": {
"config": {
@jonluca
jonluca / system report
Created Dec 22, 2018
System report 2018mbp
View system report
Software Versions:
CoreWLAN: 13.0 (1370.8)
CoreWLANKit: 13.0 (1370.8)
Menu Extra: 13.0 (1376.2)
System Information: 12.0 (1300.2)
IO80211 Family: 12.0 (1200.12.2)
Diagnostics: 1.0 (805)
AirPort Utility: 6.3.9 (639.7)
Interfaces:
en0:
View ioreg -r -n ARPT > ioreg.txt
+-o ARPT@0 <class IOPCIDevice, id 0x10000037e, registered, matched, active, busy 0 (18308 ms), retain 17>
| {
| "IOInterruptControllers" = ("io-apic-0","IOPCIMessagedInterruptController")
| "built-in" = <00>
| "wlan.tx.ring.size" = 512
| "bcom.oscar.profilestates" = <0000000200200022090d0000>
| "bcom.roam.profiles" = <0c00f6ffb5ff0200b80bb4000200b0041400bfff32001000b5ff80ff02005a001e0001001e000c00bfff3200000000000000000000000000000000000000000000001000b5ff80ff02005a001e0001001e000c0080ff0a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400b5ff80ff02005a001e000200b4000c00bfff320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400b5ff80ff02005a001e000200b4000c0080ff0a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00f6ffb5ff0200b80bb4000200b0041400bfff32001000b5ff80ff02005a001e000200b4000c00bfff3200000000000000000000000000000000000000000000001000b5ff80ff02005a001
@jonluca
jonluca / sudo dtruss -afs -W ifconfig > ifconfig.out 2>&1
Created Dec 22, 2018
sudo dtruss -afs -W ifconfig > ifconfig.out 2>&1 - all syscalls made when changing mac addresses
View sudo dtruss -afs -W ifconfig > ifconfig.out 2>&1
Waiting for ifconfig, hit Ctrl-C to stop waiting...
PID/THRD RELATIVE ELAPSD CPU SYSCALL(args) = return
38782/0x244665: 701 54 0 thread_selfid(0x0, 0x0, 0x0) = 2377317 0
dyld`__thread_selfid+0xa
dyld`mach_init+0x13
dyld`dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*)+0x432
dyld`_dyld_start+0x36
ifconfig`0x4
@jonluca
jonluca / gist:0c8477e2a6194b5adb23fc45e71b8c1a
Created Dec 22, 2018
sudo dapptrace -ac ifconfig en0 ether ce:a1:fc:be:ac:a1 > functrace.txt 2>&1
View gist:0c8477e2a6194b5adb23fc45e71b8c1a
This file has been truncated, but you can view the full file.
PID/THRD RELATIVE ELAPSD CPU CALL(args) = return
40994/0x24b5f4: 1093 . . -> dyld:mach_msg_destroy(0x7FFEE2BE0970, 0x3, 0xA80)
40994/0x24b5f4: 1095 . . -> dyld:mach_msg_destroy_port(0x0, 0x0, 0xA80)
40994/0x24b5f4: 1096 . . -> dyld:mach_msg_destroy_port(0x0, 0x0, 0xA80)
40994/0x24b5f4: 1099 . . -> dyld:mach_port_destruct(0x203, 0x807, 0x0)
40994/0x24b5f4: 1100 . . -> dyld:_kernelrpc_mach_port_destruct_trap(0x203, 0x807, 0x0)
40994/0x24b5f4: 1108 19 7 <- dyld:_kernelrpc_mach_port_destruct_trap = 10
40994/0x24b5f4: 1110 54 10 <- dyld:mach_port_destruct = 66
40994/0x24b5f4: 1124 . . -> libdyld.dylib:tlv_initializer(0x203, 0x807, 0x0)
@jonluca
jonluca / functions.zsh
Last active Sep 11, 2018
Bash/Zsh Kill Port
View functions.zsh
kill_by_port(){
lsof -i ":${1}" | awk 'NR > 1 {print $2}' | xargs kill -9
}
@jonluca
jonluca / functions.zsh
Created Sep 11, 2018
Bash/Zsh Kill Port
View functions.zsh
kill_by_port{
lsof -i ":${1}" | awk 'NR > 1 {print $2}' | xargs kill -9
}