Skip to content

Instantly share code, notes, and snippets.

View cmmartin's full-sized avatar

Charlie Martin cmmartin

  • Founderpath
  • Brooklyn, NY
View GitHub Profile
@cmmartin
cmmartin / upgrade-node.sh
Created April 7, 2015 19:50
Upgrade node.js using n
#!/bin/bash
# Updates your version of node.js using the version control system "n"
# @param a version (default is latest stable)
# https://github.com/tj/n
sudo npm cache clean -f
sudo npm install -g n
version=`node -v`
@cmmartin
cmmartin / cm-mixins.js
Last active August 29, 2015 14:13
My collection of Underscore.js mixins
_.mixin({
// _.contains for strings with optional case sensitivity
hasSubstring: function (stringA, stringB, caseSensitive) {
if (caseSensitive) return stringA.indexOf(stringB) >= 0;
return stringA.toLowerCase().indexOf(stringB.toLowerCase()) >= 0;
},
// Get the difference between two arrays - shallow only
diffArrays: function (a, b) {
@cmmartin
cmmartin / moment-filter.js
Last active July 31, 2019 09:01
A generic Moment.js date filter for Angular.js
// REQUIRES:
// moment.js - http://momentjs.com/
// USAGE:
// {{ someDate | moment: [any moment function] : [param1] : [param2] : [param n]
// EXAMPLES:
// {{ someDate | moment: 'format': 'MMM DD, YYYY' }}
// {{ someDate | moment: 'fromNow' }}
@cmmartin
cmmartin / pullall
Created March 13, 2014 21:41 — forked from oztune/pullall
#!/bin/bash
for file in *
do
if [ -d $file ]
then
cd $file
echo Pulling `pwd` `git branch 2>/dev/null | grep -e '^*' | sed -E 's/^\* (.+)$/(\1) /'`
git pull
cd ../