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
@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
@gangefors
gangefors / Install FreeNAS SCALE on a partition and create a mirror.md
Last active May 11, 2025 13:07
How to install TrueNAS SCALE on a partition instead of the full disk

Install TrueNAS SCALE on a partition instead of the full disk

The TrueNAS installer doesn't have a way to use anything less than the full device. This is usually a waste of resources when installing to a modern NVMe which is usually several hundred of GB. TrueNAS SCALE will use only a few GB for its system files so installing to a 16GB partition would be helpful.

The easiest way to solve this is to modify the installer script before starting the installation process.

@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 August 29, 2024 00:37
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 = [{
@WesleyAC
WesleyAC / build.sh
Last active May 14, 2025 13:43
Simple rust build and deploy script β€” https://blog.wesleyac.com/posts/simple-deploy-script
#!/usr/bin/env bash
cd $(dirname $0)
docker run --rm -it -v "$(pwd)":/home/rust/src -v cargo-git:/home/rust/.cargo/git -v cargo-registry:/home/rust/.cargo/registry -v "$(pwd)/target/":/home/rust/src/target ekidd/rust-musl-builder:nightly-2021-01-01 sudo chown -R rust:rust /home/rust/.cargo/git /home/rust/.cargo/registry /home/rust/src/target
docker run --rm -it -v "$(pwd)":/home/rust/src -v cargo-git:/home/rust/.cargo/git -v cargo-registry:/home/rust/.cargo/registry -v "$(pwd)/target/":/home/rust/src/target ekidd/rust-musl-builder:nightly-2021-01-01 cargo build --release
@pirate
pirate / test_stdin_stdout_stderr.py
Last active February 19, 2021 00:10
Get all the information you could ever want about stdin, stdout, and stderr file descriptors in Python (e.g. is it a TTY, terminal, pipe, redirection, etc.)
#!/usr/bin/env python3
# Get all the information you could ever want about the STDIN, STDOUT, STDERR file descriptors (e.g. is it a TTY, terminal, pipe, redirection, etc.)
# Works cross-platform on Windows, macOS, Linux, in Docker, and in Docker-Compose by using stat library
#
# Useful for detecting and handling different stdin/stdout redirect scenarios in CLI scripts,
# e.g. is the user piping a file in or are they interactively typing things in?
# is the process output being saved to a file or being printed to a terminal?
# can we ask the user for input or is it a non-interactive masquerading as a TTY?
#
# Further reading:
@mysteriouss
mysteriouss / key-remap.md
Last active November 22, 2024 13:44
M1 MacBook Air F5 & F6 KeyRemap
#!/bin/sh

## xref: https://www.reddit.com/r/MacOS/comments/jy5ry8/m1_macbook_air_keysshortcut_for_keyboard/ghryk3j/?utm_source=reddit&utm_medium=web2x&context=3

cat > ~/Library/LaunchAgents/com.local.KeyRemapping.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>