Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
RGlkIHlvdSBhbHNvIGRlY29kZSB0aGlzPw==

Neal Fennimore nealfennimore

:shipit:
RGlkIHlvdSBhbHNvIGRlY29kZSB0aGlzPw==
View GitHub Profile
View nyu_vpn_openconnect.sh
#! /usr/bin/env bash
if [[ -z $NYU_AUTHGROUP || -z $NYU_NETID || -z $NYU_PASSWORD || -z $NYU_2FA ]]; then
cat << EOF
One or more env varibles missing
\$NYU_AUTHGROUP
- "NYU VPN: NYU-NET Traffic Only"
- "NYU VPN: All Traffic"
@nealfennimore
nealfennimore / script-template.sh
Created Dec 22, 2020 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
View script-template.sh
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
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 Apr 11, 2021
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