Skip to content

Instantly share code, notes, and snippets.

@patmood
patmood / mailchimp-firebase.js
Created October 1, 2017 21:34 — forked from eibrahim/mailchimp-firebase.js
A node worker for firebase to add a user to mailchimp
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 July 14, 2017 04:40
Basscss in a single file
/* 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 November 6, 2016 22:33
Javascript Bubble Sort
// 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 February 27, 2019 16:41
Javascript Quicksort
// 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
@patmood
patmood / ANSI-color-codes.txt
Created November 11, 2015 05:51
Atom Snippets
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 August 29, 2015 14:03
Javascript Email validation regex
var string = si_eg-h+esg34576457s@slei.ghsegse.lsi.ehg.com
string.match(/^(\w|\+|\d|\-|\.)+\@(\w|\d|\-)+\.(\w|\.)+$/i)

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@patmood
patmood / tmux_reference
Last active August 29, 2015 14:00
tmux cheat sheet
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 February 22, 2017 18:28
Git pre-commit to prevent bad commits (forbidden branches and code)

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 August 29, 2015 13:57
Delete all merged branches from a repo

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.