Skip to content

Instantly share code, notes, and snippets.

@qtfkwk
qtfkwk / up.bat
Created December 5, 2023 15:13
Update script for Windows
winget upgrade -h --all
rustup self update
rustup update
cargo list --outdated --update
@qtfkwk
qtfkwk / .gitconfig
Last active November 7, 2023 15:02
Git configuration file
[alias]
d = diff --color=always
dc = d --cached
dcw = d --cached --word-diff=color
dw = d --word-diff=color
dwc = d --word-diff=color --cached
s = status
l = log --show-signature --stat --numstat
ln = log --show-signature --name-status --stat --numstat
lp = log --show-signature -p --stat --numstat
@qtfkwk
qtfkwk / swap-ctrl-caps.reg
Created August 1, 2023 20:44
System-wide Swap Left Control and Caps Lock in Windows 10
Windows Registry Editor Version 5.00
; https://superuser.com/a/1264295
;
; The hex data is in five groups of four bytes:
; 00,00,00,00,\ header version (always 00000000)
; 00,00,00,00,\ header flags (always 00000000)
; 03,00,00,00,\ # of entries (3 in this case) plus a NULL terminator line.
; Entries are in 2-byte pairs: Key code to send & keyboard key to send it.
; Each entry is in LSB, MSB order.
@qtfkwk
qtfkwk / zig-up.bash
Last active July 5, 2023 09:42
Install or update Zig on Debian
#!/usr/bin/env bash
# Install or update Zig on Debian
set -xeo pipefail
dst="$HOME/zig"
minisign_pub="RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U"
json_url="https://ziglang.org/download/index.json"
version="master"
arch="x86_64"
os="linux"
json_file="$(basename "$json_url")"
@qtfkwk
qtfkwk / cargo-check-vulns.sh
Created June 8, 2023 18:26
Updating Rust projects
#!/bin/sh
cargo outdated --exit-code 1 && cargo audit
@qtfkwk
qtfkwk / Makefile.toml
Last active December 11, 2022 22:39
Rust cargo-make Makefile.toml
[tasks.default]
alias = "fast"
[tasks.fast]
dependencies = ["build", "test", "clippy", "doc"]
[tasks.all]
dependencies = ["check", "fast"]
[tasks.full]
@qtfkwk
qtfkwk / fix_console.rs
Created March 27, 2022 12:33
Fix seed-rs' weird debug, log, warn, error macros...
// 1. Add the following to your seed-rs project's src/lib.rs:
use web_sys::console;
const ENABLE_CONSOLE_DEBUG: bool = true;
const ENABLE_CONSOLE_LOG: bool = true;
const ENABLE_CONSOLE_WARN: bool = true;
const ENABLE_CONSOLE_ERROR: bool = true;
macro_rules! debug {
@qtfkwk
qtfkwk / run.py
Last active August 31, 2021 18:48
ez command runner
from subprocessing import Popen, PIPE
class run:
def __init__(self, cmd, stdin=None, ttl=None):
self.cmd, self.stdin, self.ttl = cmd, stdin, ttl
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
self.stdout, self.stderr = p.communicate(stdin, ttl)
self.code = p.wait()
@qtfkwk
qtfkwk / ssh-init.sh
Created August 27, 2021 12:43
Start SSH agent and/or add keys (add to your .bashrc or .zshrc)
# Start the SSH agent (not needed if desktop environment starts it)
SSH_ENV="$HOME/.ssh/agent"
function start_agent {
MASK=$(umask)
umask 0077
/usr/bin/ssh-agent |sed 's/^echo/#echo/' >"${SSH_ENV}"
umask $MASK
. "${SSH_ENV}" >/dev/null
}
@qtfkwk
qtfkwk / wsl-ssh.ps1
Created January 20, 2021 14:44
WSL SSH
# Usage
#
# 1. Install WSL https://aka.ms/wsl
# 2. Install distribution (Microsoft Store > Debian) https://www.microsoft.com/en-us/p/debian/9msvkqc78pk6
# 3. Initialize WSL (start it, set username, etc)
# 4. Install SSH server
#
# ```bash
# sudo apt update && sudo apt install openssh-server -y
# ```