Skip to content

Instantly share code, notes, and snippets.

View nealfennimore's full-sized avatar
:shipit:
RGlkIHlvdSBhbHNvIGRlY29kZSB0aGlzPw==

Neal Fennimore nealfennimore

:shipit:
RGlkIHlvdSBhbHNvIGRlY29kZSB0aGlzPw==
View GitHub Profile
@nealfennimore
nealfennimore / wireguard.conf
Last active April 3, 2024 09:49
Wireguard VPN - Forward all traffic to server
# ------------------------------------------------
# Config files are located in /etc/wireguard/wg0
# ------------------------------------------------
# ---------- Server Config ----------
[Interface]
Address = 10.10.0.1/24 # IPV4 CIDR
Address = fd86:ea04:1111::1/64 # IPV6 CIDR
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # Add forwarding when VPN is started
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE # Remove forwarding when VPN is shutdown
@nealfennimore
nealfennimore / key.sh
Created October 28, 2019 14:14
Updating PGP key expiration
gpg -k # List keys
gpg --edit-key hi@neal.codes # Or key ID
key 1 # Select expired key
expire # Set new expiration
save
gpg --send-keys # Update keys on server
gpg --armor --output /tmp/key.gpg --export hi@neal.codes # ASCII safe key for Github or another service
@nealfennimore
nealfennimore / toggle_vpn
Created October 6, 2019 04:13
Toggle VPNs
#!/usr/bin/env bash
IFS=$'\n'
VPNS=($(nmcli con | grep vpn))
UUID_REGEX="^.*\(\w\{8\}.*\w\{12\}\).*$"
is_active_vpn() {
row=$(nmcli con | grep $1 | sed 's/\s*$//g' ) # Trim whitespace so we can test ending column
if [[ $row =~ ^.*--$ ]]; then
echo -n 0
@nealfennimore
nealfennimore / unmount-busy-drive
Last active October 6, 2019 04:15
Unmounting busy drive
# Check to see what processes are using drive
fuser -vm /dropbox
sudo umount /dropbox
// https://stackoverflow.com/questions/6672374/convert-rgb-to-rgba-over-white
function RGBtoRGBA(r, g, b){
if((g == null) && (typeof r === 'string')){
var hex = r.replace(/^\s*#|\s*$/g, '');
if(hex.length === 3){
hex = hex.replace(/(.)/g, '$1$1');
}
r = parseInt(hex.substr(0, 2), 16);
g = parseInt(hex.substr(2, 2), 16);
b = parseInt(hex.substr(4, 2), 16);
@nealfennimore
nealfennimore / iota-full-node.sh
Created December 10, 2017 22:07
IOTA Full Node scripts
function addNeighbor() {
payload=$(jq -n --arg uris "$1" '{"command":"addNeighbors", "uris":[ $uris ]}')
curl http://localhost:14265 -H "X-IOTA-API-VERSION: 1.4" -d "$payload" | jq
}
function removeNeighbor() {
payload=$(jq -n --arg uris "$1" '{"command":"removeNeighbors", "uris":[ $uris ]}')
curl http://localhost:14265 -H "X-IOTA-API-VERSION: 1.4" -d "$payload" | jq
}
@nealfennimore
nealfennimore / moment.js
Created September 27, 2017 00:14
Mock Moment with Jest so it's always utc for tests
import moment from 'moment';
const _constructor = ( ...args ) => moment.utc( ...args );
const clone = Object.assign( _constructor, moment );
export default clone;
@nealfennimore
nealfennimore / git-branch.sh
Created May 6, 2017 22:33
Terminal git branch state
# https://gist.github.com/chrisnolet/d07a55580337cfe7d5388b1d3c4960cc
function git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (*\([^)]*\))*/\1/'
}
function markup_git_branch {
if [[ -n $@ ]]; then
if [[ -z $(git status --porcelain 2> /dev/null | tail -n1) ]]; then
echo -e " \001\033[32m\002($@)\001\033[0m\002"
@nealfennimore
nealfennimore / visually-hidden.css
Last active April 21, 2017 17:53
Accessible Hiding of DOM Elements
/* http://a11yproject.com/posts/how-to-hide-content/ */
.visually-hidden {
position: absolute !important;
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
padding:0 !important;
border:0 !important;
height: 1px !important;
width: 1px !important;
@nealfennimore
nealfennimore / smb.conf
Last active March 28, 2017 03:47
Working SAMBA config for Ubuntu (Server)
[global]
workgroup = WORKGROUP
netbios name = FROOBUN
security = user
encrypt passwords = yes
interfaces = lo wlp5s0 #Uses loopback and wireless interface names
[froobun]
comment = Home
path = /home/neal
valid users = neal