Skip to content

Instantly share code, notes, and snippets.

Patrick Moody patmood

View GitHub Profile
@patmood
patmood / mailchimp-firebase.js
Created Oct 1, 2017 — forked from eibrahim/mailchimp-firebase.js
A node worker for firebase to add a user to mailchimp
View mailchimp-firebase.js
var mcapi = require('./node_modules/mailchimp-api/mailchimp');
var usersRef = db.ref('users');
var mc = new mcapi.Mailchimp('xxxxxxxxxx-api-key-us4');
usersRef.orderByChild('added_to_mailchimp').equalTo(null).on('child_added',function(snapshot){
var user = snapshot.val();
var key = snapshot.key;
if(user && user.email){
var listId = 'xxxx-list-id-xxxx';
var name = user.displayName || '';
@patmood
patmood / basscss.css
Created Jul 14, 2017
Basscss in a single file
View basscss.css
/* Basscss Type Scale */
.h1 { font-size: var(--h1) }
.h2 { font-size: var(--h2) }
.h3 { font-size: var(--h3) }
.h4 { font-size: var(--h4) }
.h5 { font-size: var(--h5) }
.h6 { font-size: var(--h6) }
:root {
@patmood
patmood / bubbleSort.js
Last active Nov 6, 2016
Javascript Bubble Sort
View bubbleSort.js
// Bubble sort
// Time: O(n^2)
// Space: O(1)
const test = require('assert').deepEqual
const bubbleSort = (arr) => {
// Create a variable to store values temporarily - Only needs to be created once for O(1) space complexity
let temp = null
@patmood
patmood / quicksort.js
Last active Feb 27, 2019
Javascript Quicksort
View quicksort.js
// Quicksort
// Time: O(n log(n))
// Space: O(log(n))
const test = require('assert').deepEqual
const quickSort = (arr) => {
if (arr.length <= 1) return arr
const pivotIndex = arr.length - 1
View ANSI-color-codes.txt
TP_ANSI_RESET "\x1b[0m"
TP_ANSI_BOLD_ON "\x1b[1m"
TP_ANSI_INVERSE_ON "\x1b[7m"
TP_ANSI_BOLD_OFF "\x1b[22m"
TP_ANSI_FG_BLACK "\x1b[30m"
TP_ANSI_FG_RED "\x1b[31m"
TP_ANSI_FG_GREEN "\x1b[32m"
TP_ANSI_FG_YELLOW "\x1b[33m"
TP_ANSI_FG_BLUE "\x1b[34m"
TP_ANSI_FG_MAGENTA "\x1b[35m"
@patmood
patmood / regex.js
Last active Aug 29, 2015
Javascript Email validation regex
View regex.js
var string = si_eg-h+esg34576457s@slei.ghsegse.lsi.ehg.com
string.match(/^(\w|\+|\d|\-|\.)+\@(\w|\d|\-)+\.(\w|\.)+$/i)
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@patmood
patmood / tmux_reference
Last active Aug 29, 2015
tmux cheat sheet
View tmux_reference
Split vertically: <Ctrl-b>%
Split horizontally: <Ctrl-b>"
Move around panes: <Ctrl-b>[Up, Down, Right, Left]
Previous pane: <Ctrl-b>;
Rotate panes: <Ctrl-b><Ctrl-o>
Resize: <Ctrl-b>:resize-pane -U[D,L,R] 10
Close pane: <Ctrl-b>x
@patmood
patmood / README.md
Last active Feb 22, 2017
Git pre-commit to prevent bad commits (forbidden branches and code)
View README.md

What it does

If you try to commit directly to a "forbidden" branch like master or staging, you'll get a warning like this:

 HOLD UP!
 You are trying to commit directly to *master* branch.
 (>_<)

 You can force the commit by adding --no-verify to the command.
@patmood
patmood / clean_branches.md
Last active Aug 29, 2015
Delete all merged branches from a repo
View clean_branches.md

Clean up old git branches

This will delete branches that have already been merged. Good for cleaning up local repos. Wont delete your current branch.

git branch --merged | grep -v "\*" | xargs -n 1 git branch -d

Saved here for my own reference but all credit to this guy: http://stevenharman.net/git-clean-delete-already-merged-branches

WARNING: This will only spare your current branch. Remember that you might lose master/staging/etc if you're not currently on that branch.

You can’t perform that action at this time.