This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example of a basic async-callback based pattern | |
function asyncProcess (value, callback) { | |
setTimeout(() => { | |
console.log(value); | |
callback && callback(value ? null : new Error('Something is broken')) | |
}, 1000 * Math.random()) | |
} | |
// use a function generator to map an iterator over the array items |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
usrn=`git config --global user.github-username` | |
yesterday=`date -v-1d +%F` | |
if [ "$1" == "--today" ]; then | |
yesterday=`date +%F` | |
elif [ "$1" != "" ]; then | |
yesterday="$1" | |
fi | |
if [ "$usrn" == "" ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// Add this to your app.js | |
// Listen for console.x events on the front end, and print them in our logging | |
app.get('/console/:type', (req, res) => { | |
console[req.params.type](`[REMOTE: console.${req.params.type}]`, req.query) | |
res.end() | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make sure our master branch is up to date | |
git checkout master | |
git pull | |
# Remove our former release branch | |
git branch -D lastest-release 2>/dev/null | |
git push origin --delete lastest-release 2>/dev/null | |
# Create a new branch to run the build under | |
git checkout -b lastest-release |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
branches="" | |
for branch in $@; do | |
branches="$branches $(git branch | grep -v "master" | grep -v '*' | grep "$branch")"; | |
done; | |
echo "Prune would permenantly remove the following branches from your machine:"; | |
paste -s -d" " <(echo "$branches"); | |
printf 'Are all these ok to remove? [y/N] : ' | |
read -r yN |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @method containsUnicode | |
* @extends {String} | |
* | |
* @returns {Boolean} - True iff <String> contains one or more Unicode Characters | |
*/ | |
String.prototype.containsUnicode = function () { | |
return this.split('').reduce((a,x)=> a || x.charCodeAt(0) > 255, false) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
########################################################################### | |
# USAGE Example: | |
# lang-mv from_files to_files key1 key2 key3@KEY_3_NEW_NAME key4 | |
########################################################################### | |
from_list=$(find . | grep "$1_...json") | |
echo "Moving ${@:3}..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# bashful import json | |
target_repo=$1 | |
target_version=$2 | |
echo "Please consider running 'bower install' before running 'migrate-to'" | |
sleep 3s; | |
echo; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Singleton = (function () { | |
let instance = null; | |
class Singleton { | |
constructor () { | |
if (instance) return instance; | |
instance = this; | |
return this; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################## | |
# @class UncertainValue | |
# (c) 2018 Kyle West - [email protected] | |
# MIT License. See: [Licensing Info](https://opensource.org/licenses/MIT) | |
# | |
# Create a value from a random +/- uncertainty which can be treated like a | |
# float or integer. | |
# | |
# x = UncertainValue(50, 5) # <--- random sample from 45 to 55. | |
# |