Skip to content

Instantly share code, notes, and snippets.

View neonexus's full-sized avatar

NeoNexus DeMortis neonexus

  • USA
  • 14:37 (UTC -06:00)
View GitHub Profile
@neonexus
neonexus / PwnedPasswordsAPI.md
Last active December 21, 2023 03:56
Check with PwnedPasswords.com API

Check with PwnedPasswords.com API

This little script will take in a raw password string, hash it, then search PwnedPasswords.com API using only the first 5 characters of the password hash.

See: https://haveibeenpwned.com/API/v2#PwnedPasswords

@neonexus
neonexus / General Programming Rules.md
Last active November 18, 2023 05:26
General rules to live by, that generally apply to most things programming, broadly speaking... generally.
  • Master branch (master) is treated as the best, current WIP, destined to be a PRODUCTION release.

    • Used as the basis for all remote DEVELOPMENT servers.
    • Force pushes are allowed.
  • Release branch (release) is treated as a final source of truth for remote PRODUCTION servers.

    • The current version of release should reflect what all PRODUCTION servers should be running (or updating to).
    • This is the branch from which all version tags are created.
    • Force pushes are NEVER ALLOWED. The history is immutable. If something must change, it must be reflected in its history, and not overwritten.
  • Version tags are immutable.

@neonexus
neonexus / mysql_docker.md
Created August 8, 2020 05:02
Commands to spin up a MySQL instance in Docker.
docker run --name=name_of_container -d -it -p 3306:3306 -e "MYSQL_ROOT_PASSWORD=mypass" -e "MYSQL_ROOT_HOST=%" mysql/mysql-server:latest
docker exec -it name_of_container bash
mysql --host=localhost --user=root --password=mypass myappdb
@neonexus
neonexus / Mac OSX Dock Spacer.sh
Last active July 20, 2020 03:20
Add spacer to Mac OSX Dock
# /bin/bash
alias add_spacer="defaults write com.apple.dock persistent-apps -array-add '{\"tile-type\"=\"spacer-tile\";}'; killall Dock"
@neonexus
neonexus / Update Lambda@Edge Function.md
Last active January 28, 2022 13:39
Update Lambda@Edge Function

First, zip up your function:

rm lambda.zip; zip -r lambda.zip lambda-function/*

Then, update the current working function:

aws lambda update-function-code --zip-file fileb://lambda.zip --function-name LambdaFunctionName
@neonexus
neonexus / Sails Schema Validation.md
Last active December 23, 2022 03:07
Sails Schema Validation

Sails Schema Validation

A bootstrap.js script designed to prevent Sails.js from lifting, in the event the database schema does not match the model definitions.

Perfect for preventing AWS ELB from deploying an incompatible version to production (requires using immutable deployments).

This is designed using native queries (MySQL), but likely can be easily adapted for most any adapter.

See https://github.com/neonexus/sails-react-bootstrap-webpack for an example.

@neonexus
neonexus / Count lines in git repo.md
Last active May 24, 2020 01:27
Count lines in git repo, minus common files / folders you didn't actually write.
git ls-files --exclude-standard -- ':!:**/*.[pjs][npv]g' ':!:**/*.ai' ':!:.idea' ':!:**/*.eslintrc' ':!:package-lock.json' | xargs wc -l

':!:**/*.[pjs][npv]g' excludes all png, jpg and svg files.

':!:**/*.ai' excludes .ai files.

':!:.idea' excludes the .idea (WebStorm anyone?) folder.

@neonexus
neonexus / Sails Request Logging.md
Last active December 23, 2022 03:05
Sails config files to capture request logs. Replace "_" in filenames with "/". See https://github.com/neonexus/sails-react-bootstrap-webpack for a working example.

Sails Request Logging

This is a set of files to configure Sails.js v1, to log all requests / responses in the database.

Replace underscores "_" in filenames with forward slashses "/".

@neonexus
neonexus / fromUTF8Array.js
Last active September 25, 2019 20:06
Encode / decode UTF8 array in JavaScript (original: https://gist.github.com/joni/3760795)
function fromUTF8Array(data) { // array of bytes
let str = '',
i;
for (i = 0; i < data.length; i++) {
let value = data[i];
if (value < 0x80) {
str += String.fromCharCode(value);
} else if (value > 0xBF && value < 0xE0) {
@neonexus
neonexus / .bash_profile
Last active July 20, 2020 03:12
Git tools for the command line
source ~/.git-completion.sh
source ~/.git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
export PS1='\[\033[00;00m\] \w\[\033[00;32m\]$(__git_ps1)\[\033[00m\] ⚡ '
# A quick way to find the answer: `google "cat videos"` (Mac OSX / macOS)
function google() { open /Applications/Google\ Chrome.app/ "http://www.google.com/search?q=$1"; }