Skip to content

Instantly share code, notes, and snippets.

View ultrafunkamsterdam's full-sized avatar

Leon ultrafunkamsterdam

View GitHub Profile
@ultrafunkamsterdam
ultrafunkamsterdam / breakpoint.py
Created August 27, 2024 09:47
Python breakpoint using Ipython debugger
# this makes debugging such a breeze with autocomplete available and such.
# requires ipython to be installed of course : pip install IPython
def breakpoint():
"""breakpoint() replacement, which uses IPython instead of plain pdb"""
import sys
from IPython.terminal.debugger import set_trace
set_trace(sys._getframe(1))
@ultrafunkamsterdam
ultrafunkamsterdam / file_streaming.py
Created August 25, 2024 20:46
Fastapi File Streaming Response (HTML Video etc.)
import mimetypes
from pathlib import Path
import fastapi
import aiofiles
router = fastapi.APIRouter()
@router.get('{path:path}')
@ultrafunkamsterdam
ultrafunkamsterdam / notes
Last active February 26, 2024 16:29
NODRIVER - Notes to self - needs implementation asap
// add option to retrieve
// the browser devtools page for a headless tab of nodriver
def get_inspector_page(tab: uc.Tab):
s = 'http://{config.host}:{config.port}/devtools/inspector.html?ws={wsurl}'
return s.format(config=tab.browser.config, wsurl=tab.websocket_url[5:])
// proxy the following information, which is nulled whenever you override the user agent
@ultrafunkamsterdam
ultrafunkamsterdam / differentProps
Created February 23, 2024 13:09
hmmmmm interesting
headless:
vendorSub, productSub, vendor, maxTouchPoints, scheduling, userActivation, doNotTrack, geolocation, connection, plugins, mimeTypes, pdfViewerEnabled, webkitTemporaryStorage, webkitPersistentStorage, hardwareConcurrency, cookieEnabled, appCodeName, appName, appVersion, platform, product, userAgent, language, languages, onLine, webdriver, getGamepads, javaEnabled, sendBeacon, vibrate, bluetooth, clipboard, credentials, keyboard, managed, mediaDevices, storage, serviceWorker, virtualKeyboard, wakeLock, deviceMemory, login, ink, mediaCapabilities, hid, locks, gpu, mediaSession, permissions, presentation, usb, xr, serial, windowControlsOverlay, userAgentData, canShare, share, clearAppBadge, getBattery, getUserMedia, requestMIDIAccess, requestMediaKeySystemAccess, setAppBadge, webkitGetUserMedia, getInstalledRelatedApps, registerProtocolHandler, unregisterProtocolHandler
headfull:
vendorSub, productSub, vendor, maxTouchPoints, scheduling, userActivation, doNotTrack, geolocation, connection, plugins, mime
@ultrafunkamsterdam
ultrafunkamsterdam / custom-prefix-color.scss
Last active May 2, 2023 14:20
Bootstrap 5.3 scss/css to create custom color class prefixes and custom scrollbar gradient shade
@import '../node_modules/bootstrap/scss/functions';
@import '../node_modules/bootstrap/scss/mixins';
@import '../node_modules/bootstrap/scss/variables';
@import '../node_modules/bootstrap/scss/variables-dark';
@import '../node_modules/bootstrap/scss/maps';
/* make sure you have installed bootstrap 5.3 or later!
in earlier versions this won't work
---
at the time of writing:
@ultrafunkamsterdam
ultrafunkamsterdam / fastapi_react.py
Last active June 20, 2024 18:35
FastAPI support for React ( with working react-router )
"""
███████╗ █████╗ ███████╗████████╗ █████╗ ██████╗ ██╗
██╔════╝██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔══██╗██║
█████╗ ███████║███████╗ ██║ ███████║██████╔╝██║
██╔══╝ ██╔══██║╚════██║ ██║ ██╔══██║██╔═══╝ ██║
██║ ██║ ██║███████║ ██║ ██║ ██║██║ ██║
╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝
██████╗ ███████╗ █████╗ ██████╗████████╗
██╔══██╗ ██╔════╝ ██╔══██╗ ██╔════╝╚══██╔══╝
██████╔╝ █████╗ ███████║ ██║ ██║
@ultrafunkamsterdam
ultrafunkamsterdam / fingerprint.botd.source.js
Created February 5, 2023 14:06
fingerprint.com bot detection source
function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
_construct = Reflect.construct.bind();
} else {
_construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) setPrototypeOf(instance, Class.prototype);
@ultrafunkamsterdam
ultrafunkamsterdam / bit_replace.py
Last active November 28, 2022 13:19
bit replace
def bit_replace(byte:int, pos:int, new_val:int):
"""
Takes a integer <byte> and changes the bit on <pos> with <new_val> (0 or 1).
pos is counted from right to left, so pos 0 = LSB
:param byte (int): unsigned int
:param pos (int) the binary position to replace. pos is counted from "right" to "left", so pos 0 is LSB
:param new_val (int): the new value. either 0 (off) or 1 (on)
@ultrafunkamsterdam
ultrafunkamsterdam / bind.c
Created October 26, 2022 13:34
Bind process to specific network interface/ip
/*
LD_PRELOAD library to make bind and connect to use a virtual
IP address as localaddress. Specified via the enviroment
variable BIND_ADDR.
Compile on Linux with:
gcc -nostartfiles -fpic -shared bind.c -o bind.so -ldl -D_GNU_SOURCE
Example in bash to make inetd only listen to the localhost
@ultrafunkamsterdam
ultrafunkamsterdam / ctrlc.py
Created September 26, 2022 10:56
Python windows native console ctrl+c callback
from ctypes import wintypes as w
import ctypes as c
def handler( *args ):
print( 'Native console ctrl handler call:' , args )
return 0