Skip to content

Instantly share code, notes, and snippets.

Avatar
🗃️
Archiving all the things!

Nick Sweeting pirate

🗃️
Archiving all the things!
View GitHub Profile
@BlackPropaganda
BlackPropaganda / U2F_ssh_ecdsa.txt
Created Sep 22, 2022
U2F ECDSA SSH Key Generation using Flipper Zero
View U2F_ssh_ecdsa.txt
#
# 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 Jun 10, 2022
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.
View LICENSE
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 Jul 18, 2021
A nice python progress bar timer that fills logarithmically. Good for when you don't know how long a task is going to take but you want it to feel fast.
View asymptotic_progress_bar.py
#!/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)
#
# Usage:
@pirate
pirate / auto_timezone_from_browser.html
Last active Apr 11, 2021
Automatically get the user's timezone from their browser time (for Django but works elsewhere).
View auto_timezone_from_browser.html
{% 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 / test_stdin_stdout_stderr.py
Last active Feb 19, 2021
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.)
View test_stdin_stdout_stderr.py
#!/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 Aug 2, 2022
M1 MacBook Air F5 & F6 KeyRemap
View key-remap.md
#!/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>
@pirate
pirate / compress_videos.sh
Created Jan 30, 2021
Re-encode a bunch of video files into x265 MP4 without losing EXIF metadata
View compress_videos.sh
#!/usr/bin/env bash
# Requires: ffmpeg, exiftool (install via apt/brew first)
# Usage:
# $ cd ~/Videos
# $ ./compress_videos.sh
# [+] Converting all .mp4 files in ~/Videos to .x265.mp4 files...
# - √ GP013838.mp4 (2.5GB) -> GP013838.x265.mp4 (142MB)
# - √ ...
# [√] Done converting all .mp4 files in $PWD.
@pirate
pirate / cloudflare_dns_secrets.fish
Last active Jan 30, 2021
Get and set config & secret values in DNS TXT records (via CloudFlare API)
View cloudflare_dns_secrets.fish
#!/usr/bin/env fish
# Script to store and retrieve config/secret key=value pairs in Cloudflare DNS records
# Encrypts secrets with a specified passphrase + salt using AES-256-CBC
#
# Usage:
#
# $ set_config some_config_key "example config value abc"
# $ get_config some_config_key
# example config value abc
#
@pirate
pirate / docker-compose.yml
Last active Jan 24, 2023
Example database container setups for PostgreSQL, MariaDB, Redis, Memcached, MongoDB, Neo4j, Hasura GraphQL, CockroachDB, and TiDB in Docker Compose
View docker-compose.yml
# Example database container setups for PostgreSQL, MariaDB, Redis, Memcached, MongoDB, Neo4j, Hasura GraphQL, CockroachDB, and TiDB in Docker Compose
# https://gist.github.com/pirate/1fafaa18a47254f388aa5c0f79f7d263
# Goes well with these docker-compose networking/ingress container examples:
# https://gist.github.com/pirate/1996d3ed6c5872b1b7afded250772f7c
version: '2.4'
services:
postgres: