Skip to content

Instantly share code, notes, and snippets.

View xirixiz's full-sized avatar

Bram van Dartel xirixiz

View GitHub Profile
@xirixiz
xirixiz / gpg-import-and-export-instructions.md
Created March 30, 2018 23:42 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@xirixiz
xirixiz / Set up GitHub push with SSH keys.md
Last active December 27, 2024 11:51 — forked from developius/README.md
Set up GitHub push with SSH keys

SSH keypair setup for GitHub (or GitHub/GitLab/BitBucket, etc, etc)

Create a repo.

Make sure there is at least one file in it (even just the README.md)

Generate a SSH key pair (private/public):

ssh-keygen -t rsa -C "[email protected]"
@xirixiz
xirixiz / git_clone_all.sh
Last active December 19, 2018 07:03
Clone all projects from a GitLab group, even for +100 pages.
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
#---------------------------------------------------------------------------------------------------------------------------
# INFO
#---------------------------------------------------------------------------------------------------------------------------
# ./git_clone_all.sh <group> <token> <url> <branch>
@xirixiz
xirixiz / pihole-macvlan-synology-docker.txt
Last active December 2, 2024 19:32
Add a PiHole instance on a macvlan enabled Docker network (Synology eth0 example)
#!/bin/bash
# NAS IP: 192.168.1.10 in this example
# DHCP scope reservation for macvlan: 192.168.1.210/28 (Details below)
## Network: 192.168.1.210/28
## HostMin: 192.168.1.211
## HostMax: 192.168.1.224
## Hosts/Net: 14
# Create a Synology macvlan0 bridge network attached to the physical eth0, and add the ip range scope (sudo)
#!/bin/bash
function __set_proxy_envs() {
NO_PROXY_ENV="no_proxy NO_PROXY"
PROXY_ENV="http_proxy https_proxy all_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY"
}
function __unset_proxy_envs() {
unset NO_PROXY_ENV PROXY_ENV
}
@xirixiz
xirixiz / corporate proxy bash without cntlm.md
Last active November 13, 2021 07:28
corporate proxy bash without cntlm

You can also make things static, like PROXY_USER, PROXY_SERVER, PROXY_PORT, but my advice is to never add the password. Ofcourse, when possible, you could also use CNTLM or CNTLM in Docker. However, I experienced that I couldn't use it always with CNTLM, hence this script, which I souce from ~/.bashrc

For the password you could also setup an ENV VAR called DOMAIN_PASSWORD. Long story short, I use it together with encrypted secrets to set this ENV VAR, but I didn't want to add it here :).

Usage: source ~/proxy.sh proxy_enable

#!/bin/python2s
# Symbolic name, meaning all available interfaces
VAR_HOST = ""
# Arbitrary non-privileged port
VAR_PORT = 9003
import socket
import sys
@xirixiz
xirixiz / UGW3_Wireguard.md
Last active February 25, 2024 22:12 — forked from pamolloy/README.md
Ubiquiti USG configuration for Wireguard

The purpouse is to have a WireGuard server running with a configuration for 2 clients to connect to the WireGuard server.

Installation - First steps

Follow the instructions for downloading and installing the WireGuard package here: https://github.com/WireGuard/wireguard-vyatta-ubnt

curl -OL https://github.com/WireGuard/wireguard-vyatta-ubnt/releases/download/${RELEASE}/${BOARD}-${RELEASE}.deb
sudo dpkg -i ${BOARD}-${RELEASE}.deb
# Bram van Dartel: Fix WSL2 network connection after setting up a Cisco Anyconnect VPN.
# Boot your laptop, start Docker and WSL2, setup a Cisco Anyconnect VPN connection, run this fix.
function Fix-WSLNet {
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1
Get-NetAdapter | Where-Object { $_.InterfaceDescription -Match "Cisco AnyConnect" } | Set-NetIPInterface -InterfaceMetric 6000
}
Fix-WSLNet
@xirixiz
xirixiz / ventilation.yaml
Created February 21, 2021 15:11 — forked from SqyD/ventilation.yaml
ESPHome PWM fan using a Wemos D1 mini lite
# Controlling my Buva Qstream ventilation system using:
# * A Wemos D1 mini lite (an ESP8266 based board)
# * A Wemos power shield so I can power the Wemos from the ventilation units 12V supply.
# * A simple PWM to 10V convertor like this: https://www.cheaptech.nl/pwm-signaal-te-voltage-converter-1-3-khz-0-10-v-pw.html
# * The amazing ESPHome firmware tool: https://esphome.io
# * Home Assistant to tie it all together: https://www.home-assistant.io
#
# I used to use a Raspberry Pi and some Python code for this. See https://gist.github.com/SqyD/a927ab612df767a0cc892bcde23d025c
# The Wemos approach seems more stable and doesn't require external USB power.