Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
RGlkIHlvdSBhbHNvIGRlY29kZSB0aGlzPw==

Neal Fennimore nealfennimore

:shipit:
RGlkIHlvdSBhbHNvIGRlY29kZSB0aGlzPw==
View GitHub Profile
View btree-depth.js
const getBTreeDepth = (tree) => {
const isEmpty = arr => arr.every(item => item === -1)
let nodes = 1;
let depth = 0;
let start = 0;
let end = 1;
while (nodes <= tree.length) {
@nealfennimore
nealfennimore / xor-encryption-decryption.js
Last active Dec 28, 2019
XOR encryption and decryption
View xor-encryption-decryption.js
/**
* Convert character string to binary
*
* @param {String} str Character string
* @returns Binary String
*/
function toBinary(str) {
let binary = '';
for (let i = 0, l = str.length; i < l; i++) {
binary += str.codePointAt(i).toString(2).padStart(8, '0');
@nealfennimore
nealfennimore / diffie-hellman.txt
Created Dec 26, 2019
Diffie-Hellman Key Exchange
View diffie-hellman.txt
--- Step 1 - exchanged common values
Initial common values:
p = 13 (prime number)
g = 7
--- Step 2 - Each user creates own secret number
Alice secret number:
a = 5
@nealfennimore
nealfennimore / binary-addition.js
Last active Jul 6, 2020
Binary addition in javascript
View binary-addition.js
/**
* Add two bits together and get resulting bits
*
* @param {Number} a bit a
* @param {Number} b bit b
* @returns {Array<Number, Number>} Carry and sum as a result of addition
*/
function addBits(a, b){
return [ +( a && b ), +( a !== b ) ];
View resume.json
{
"basics": {
"name": "Neal Fennimore",
"label": "Front-End Engineering Professional",
"picture": "https://s.gravatar.com/avatar/fc8bb1dfce8f9841f9d153637fd16b38?s=200",
"email": "hi@neal.codes",
"phone": "6093578917",
"website": "https://neal.codes",
"summary": "Highly-analytical, innovative, and performance-driven, Front-End Engineering Professional with 8+ years of transferable experience and exposure in web development, programming languages, front-end development, JavaScript, ReactJS, strategic planning, data analysis, and cross-functional team collaboration. Possess a track record of accomplishment in managing multiple technical projects & initiatives, identifying discrepancies to create innovative solutions, facilitating continuous process improvements, and completing multiple technical projects in alignment with requirements.",
"location": {
@nealfennimore
nealfennimore / nextcloud.sh
Last active Feb 19, 2020
Nextcloud Snap Setup
View nextcloud.sh
# Setup firewall
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
# Install nextcloud
sudo snap install nextcloud
# Update memory limit
sudo snap set nextcloud php.memory-limit=1024M
@nealfennimore
nealfennimore / checkit.sh
Created Nov 14, 2019
Git checkout to previous working commit
View checkit.sh
# We're currently on `non-working` branch, and we've identified a previous working commit of `abcdef123456`.
# We want to go back to commit `abcdef123456`, and then start work anew from there
# First checkout to the working commit `abcdef123456`
git checkout abcdef123456
# You'll be in a temporary staging area now. If we want to make changes now, we'll need to copy the current commit
# into a new branch.
git checkout -b previous-working-branch
@nealfennimore
nealfennimore / wireguard.conf
Last active Oct 26, 2020
Wireguard VPN - Forward all traffic to server
View wireguard.conf
# ------------------------------------------------
# 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 Oct 28, 2019
Updating PGP key expiration
View key.sh
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
View toggle_vpn
#!/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
You can’t perform that action at this time.