Skip to content

Instantly share code, notes, and snippets.

View pirate's full-sized avatar
🗃️
Archiving all the things!

Nick Sweeting pirate

🗃️
Archiving all the things!
View GitHub Profile
@OrionReed
OrionReed / dom3d.js
Last active May 4, 2024 19:48
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@pirate
pirate / docker_netcat_tunnel.sh
Last active January 29, 2024 08:07
Remote control a Docker container from another container in the same network using netcat, ssh, or pure python
# Three ways to control a docker container remotely from another docker container or host: Python, SSH, or ncat/nc/socat.
#
# Useful if you have two containers in a Docker Compose project and you want
# container1 to be able to run commands in container2 without having to share /var/run/docker.sock
#
# Further Reading: https://www.revshells.com/#bind
### 1. Using pure Python, the cleanest option
# supports dbus/x11/etc as it doesnt spawn a new login shell, correctly handles exiting after finished commands without hacky workarounds
@pirate
pirate / music_in_screenshots.py
Created January 12, 2024 14:43
Automatically detect song/video title/artist/album/metadata captured in screenshots using GPT-4-vision via the OpenAI API.
#!/usr/bin/env python3
# Script to extract song/video title, artist, album, etc. metadata from screenshots w/ GPT-4.
### Example Usage: ###############################################################################
#
# ➜ ~/Desktop # python3 music_in_screnshots.py --prompt=prompt.txt --attach=spotify_screenshot.PNG
# {
# "found_prominent_media": true,
# "all_strings": [
@pirate
pirate / imgur_backup.sh
Created May 4, 2023 05:26
Backup all Imgur URLs found in a given set of files using ripgrep + wget. Searches all text and binary files for any imgur URLs and downloads them locally.
#!/usr/bin/env bash
# imgur_backup.sh
# Backup all Imgur URLs found in a given directory using ripgrep + wget. Searches all text files, binary files, PDFs, database dumps, etc. for any imgur URLs and downloads them into a local directory.
#
# Note: make sure you apt/brew install ripgrep first, and replace grep with ggrep (brew install grep) on macOS
# Usage:
#
# $ mkdir db_dumps
# $ docker-compose exec postgres env PGPASSWORD=somepassword pg_dump -U someuser somedb > ./db_dumps/db_dump.sql
# $ bash imgur_backup.sh db_dumps
@BlackPropaganda
BlackPropaganda / U2F_ssh_ecdsa.txt
Created September 22, 2022 21:58
U2F ECDSA SSH Key Generation using Flipper Zero
#
# U2F SSH key generation and installation guide
#
# install U2F libraries on client machine
sudo apt-get install pamu2fcfg libpam-u2f
#
# Currently, there are only two ciphers that support
# 'special keys' or (sk) this is the notation in the
@wlib
wlib / LICENSE
Last active April 30, 2024 17:07
Run a shell script with bash, line-by-line, prompted on each command. Useful for running unknown scripts or debugging. Not a secure substitute for understanding a script beforehand.
MIT License
Copyright (c) 2021 Daniel Ethridge
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@pirate
pirate / asymptotic_progress_bar.py
Last active May 31, 2023 08:43
Animated CLI progress bar that fills up over N seconds, gracefully handling delays by filling slower and slower if the task exceeds the expected time. Good for when you don't know how long a task is going to take, but you still need it to A. feel fast in the avg case, and B. not freeze in the worst case (unknown total time).
#!/usr/bin/env python3
# asymptotic_progress_bar.py
# MIT License © 2021
#
# A pretty non-blocking python progress bar timer that fills up asymptotically until you stop it.
# Good for when you don't know how long a task is going to take (up to some max timeout),
# but you want it to feel fast and accurate / not stuck the whole time.
# ████████████████████ 0.9% (1/60sec)
# useful for animating e.g. file copy progress, download progress, package install progress, etc.
#
@pirate
pirate / auto_timezone_from_browser.html
Last active April 11, 2021 07:13
Automatically get the user's timezone from their browser time (for Django but works elsewhere).
{% load tz %}
<html>
<head>
<script>
{% get_current_timezone as TIME_ZONE %}
window.TIME_ZONE = '{{TIME_ZONE}}' // timezone server thinks we're in
function setCookie(name, value, days) {
let expires = ""
if (days) {
@pirate
pirate / django_auto_tz.py
Created March 23, 2021 15:52
Automatic timezone detection based on the user's browser for Django
# Inspiration from here: https://tutti.me/post/5453/
# Or you can use a library like:
# - https://github.com/adamcharnock/django-tz-detect (last updated 2019)
# - https://github.com/Miserlou/django-easy-timezones (last updated 2016)
# - https://github.com/jamesmfriedman/django-easytz (last updated 2015)
# Or guess TZ using visitors IP GEOIP: https://codereview.stackexchange.com/questions/161261/set-time-zone-from-cookie
# settings.py
TEMPLATES = [{