Skip to content

Instantly share code, notes, and snippets.

View jamesmcm's full-sized avatar

James McMurray jamesmcm

View GitHub Profile
@jamesmcm
jamesmcm / docker_in_netns.txt
Created June 23, 2025 21:15
Running docker in a network namespace
# After creating the network namespace e.g. vo_none_none
# See https://unix.stackexchange.com/questions/686155/how-can-i-use-a-bind-mount-in-a-network-namespace
# The trick is to bind mount sys, as otherwise ip netns exec will create a mount namespace without it
# Note that each invocation of ip netns exec has its own mount namespace!
$ (on host) sudo -E unshare -m sh -c 'mount --bind /sys /sys; exec ip netns exec vo_none_none sudo --user archie --preserve-env bash'
$ (in netns) sudo umount /sys
$ (in netns) sudo dockerd --host=unix:///var/run/docker-netns.sock --data-root=/var/lib/docker-netns --default-runtime=runc
$ (in netns) DOCKER_OPTS="--dns=YOURDNSHERE" DOCKER_HOST=unix:///var/run/docker-netns.sock sudo --user archie --preserve-env docker ... # your docker command here
@jamesmcm
jamesmcm / foo.conf
Created June 22, 2025 18:20
Wireguard self-hosted VPN config for both IPv4 and IPv6
# This is the client config, run on the client machine with:
# sudo wg-quick up ./foo.conf
# from wireguard-tools
[Interface]
Address = 10.200.200.2/32, fd42:42:42::2/128
PrivateKey = clientprivatekey # CHANGEME: Set client private key here
# Google DNS
DNS = 8.8.8.8
DNS = 2001:4860:4860::8888
@dantonnoriega
dantonnoriega / est-tax-etrade-GL-collapsed.md
Last active June 7, 2025 17:17
instructions on how to download gains and losses sheet from etrade and then estimate capital gains tax

Quick Way to Estimate Taxes Owed on Capital Gains (E*Trade)

This short explainer goes through

  1. where to download your Gains and Losses sheet on one E*Trade account.
  2. how to quickly estimate taxes owned.

(1) Downloading Gains & Losses Sheet (G&L_collapsed.xlsx) from E*Trade

@1player
1player / bazarr.docker-compose.yml
Last active January 17, 2025 15:40
Poor man's media centre
# Bazarr downloads subtitles
version: "3.4"
services:
bazarr:
image: linuxserver/bazarr:1.0.5-development
container_name: bazarr
restart: unless-stopped
environment:
- TZ=Europe/London
@reneklacan
reneklacan / aoe4-mp-fix.sh
Last active December 8, 2024 14:48
Script to fix AOE4 desync issues
#!/bin/bash
set -ex
STEAM_DIR=/home/$USER/.steam/steam/steamapps
AOE4_DIR=$STEAM_DIR/compatdata/1466860
AOE4_WIN_DIR=$AOE4_DIR/pfx/drive_c/windows
AOE4_WIN_SYS32_DIR=$AOE4_WIN_DIR/system32
AOE4_WIN_SYS64_DIR=$AOE4_WIN_DIR/syswow64
@bbqtd
bbqtd / macos-tmux-256color.md
Last active June 4, 2025 17:47
Installing tmux-256color for macOS

Installing tmux-256color for macOS

  • macOS 10.15.5
  • tmux 3.1b

macOS has ncurses version 5.7 which does not ship the terminfo description for tmux. There're two ways that can help you to solve this problem.

The Fast Blazing Solution

Instead of tmux-256color, use screen-256color which comes with system. Place this command into ~/.tmux.conf or ~/.config/tmux/tmux.conf(for version 3.1 and later):

@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active June 18, 2025 19:09
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@bgauduch
bgauduch / multiple-repository-and-identities-git-configuration.md
Last active May 2, 2025 13:16
Git config with multiple identities and multiple repositories

Setup multiple git identities & git user informations

/!\ Be very carrefull in your setup : any misconfiguration make all the git config to fail silently ! Go trought this guide step by step and it should be fine 😉

Setup multiple git ssh identities for git

  • Generate your SSH keys as per your git provider documentation.
  • Add each public SSH keys to your git providers acounts.
  • In your ~/.ssh/config, set each ssh key for each repository as in this exemple:
@belst
belst / rocketguide.md
Last active March 29, 2025 20:35
Deploy Rocket in production

Deploy Rocket using Letsencrypt and nginx

Information

This guide uses the domain your-domain.tld and its www. prefixed version. It starts the rocket application on 127.0.0.1:1337 and as the user www-data. The proxy listens on port 80 and 443 though.
If you need other values, update them accordingly in your nginx and systemd configs.

Prerequisites

You need to have nginx, certbot and rust installed.

@AravindaM
AravindaM / SHA256HMAC.scala
Last active March 2, 2022 20:51
Generate HMAC using SHA256 in Scala
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
Object HMACgen {
def generateHMAC(sharedSecret: String, preHashString: String): String = {
val secret = new SecretKeySpec(sharedSecret.getBytes, "SHA256") //Crypto Funs : 'SHA256' , 'HmacSHA1'
val mac = Mac.getInstance("SHA256")
mac.init(secret)
val hashString: Array[Byte] = mac.doFinal(preHashString.getBytes)