Skip to content

Instantly share code, notes, and snippets.

View jonluca's full-sized avatar

JonLuca De Caro jonluca

View GitHub Profile
@jonluca
jonluca / script.mjs
Created October 8, 2023 00:59
Copy Files Examples - Bun/Node
import fs from 'fs/promises';
import path from 'path';
const source = '/Volumes/Untitled/DCIM/101MSDCF'
const dest = '/Volumes/JonLuca\'s\ Pics/Pics/San\ Francisco,\ CA\ \(Fleetweek\)/'
const sourceFiles = await fs.readdir(source)
const destFiles = await fs.readdir(dest)
const filesToCopy = sourceFiles.filter(f => !destFiles.includes(f))
console.log(`Copying ${filesToCopy.length} files`)
let done = 0;
@jonluca
jonluca / requests.py
Created June 15, 2021 04:06
Fast AsyncIO HTTP requests
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 June 13, 2023 09:22
Fast asyncio HTTP requests
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 February 23, 2019 04:04
Watch all of your own repositories
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 December 30, 2018 18:34
Bandersnatch options
{
"videos": {
"80988062": {
"interactiveVideoMoments": {
"$type": "atom",
"$size": 273075,
"value": {
"type": "bandersnatch",
"choicePointNavigatorMetadata": {
"config": {
@jonluca
jonluca / system report
Created December 22, 2018 13:55
System report 2018mbp
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:
@jonluca
jonluca / ioreg -r -n ARPT > ioreg.txt
Created December 22, 2018 13:53
ioreg outpt for ARPT
+-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 December 22, 2018 13:51
sudo dtruss -afs -W ifconfig > ifconfig.out 2>&1 - all syscalls made when changing mac addresses
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 December 22, 2018 13:49
sudo dapptrace -ac ifconfig en0 ether ce:a1:fc:be:ac:a1 > functrace.txt 2>&1
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)
40994/0x24b5f4: 1131 . . -> libsystem_pthread.dylib:pthread_key_create(0x7FFF9DF13FF0, 0x7FFF6B138BA2, 0x0)
@jonluca
jonluca / functions.zsh
Last active September 11, 2018 17:13
Bash/Zsh Kill Port
kill_by_port(){
lsof -i ":${1}" | awk 'NR > 1 {print $2}' | xargs kill -9
}