Skip to content

Instantly share code, notes, and snippets.

View andfaulkner's full-sized avatar
🐻
Working from home

Andrew Faulkner andfaulkner

🐻
Working from home
  • Ottawa Health Research Institute: mHealth lab (@Ottawa-mHealth)
  • Ottawa, Ontario
View GitHub Profile
@andfaulkner
andfaulkner / hasContent.js
Created February 3, 2015 20:51
Comprehensive Javascript detector of whether a variable contains actual content
//Comprehensive check for whether or not a Javascript variable has actual content
var hasContent = function(input) {
if (typeof input === 'number') {
if (isNaN(input)) {
return false;
};
} else {
if (input === 0) {
return false;
}
/**
* Custom Lodash functions for transforming http GET requests
*/
_.mixin({
//Shifts an item in an array from one location in an array to another
move: function (array, fromIndex, toIndex) {
array.splice(toIndex, 0, array.splice(fromIndex, 1)[0] );
return array;
},
@andfaulkner
andfaulkner / bash-utils.sh
Created July 30, 2015 06:15
Bash npm utils
#find version of globally installed package
alias npmpv="npm list -g | grep"
#add new alias to bashrc, also make immediately available
function newalias {
echo "" >> ~/.bashrc
echo "" >> ~/.bashrc
echo 'alias' ${1}='"'${2}'"' >> ~/.bashrc
$(echo 'alias' ${1}'='${2})
}
@andfaulkner
andfaulkner / GULP-list-all-tasks-registered.js
Created August 28, 2015 09:34
Gulp task that lists all gulp tasks registered (excluding built-ins 'install' and 'uninstall')
require('colors');
gulp.task('get-tasks', () =>
(process.nextTick(() => {
console.log('\n_________ALL REGISTERED GULP TASKS_________');
Object.keys(gulp.tasks).forEach((t) =>
((t === 'install' || t === 'uninstall') ? null :
console.log('-- ' + t.bgBlack.green)))
console.log('___________________________________________\n');
})));
@andfaulkner
andfaulkner / cut_command_examples.sh
Last active August 3, 2022 13:58
Unix "cut" examples
which node
#-->node: /usr/bin/node /usr/bin/X11/node /usr/local/bin/node /usr/share/man/man1/node.1.gz
which node | cut -d':' -f1
#-->node
which node | cut -d':' -f2
#--> /usr/bin/node /usr/bin/X11/node /usr/local/bin/node /usr/share/man/man1/node.1.gz
which node | cut -d':' -f3
@andfaulkner
andfaulkner / useful_Unix_cmds.sh
Last active November 29, 2017 14:12
Useful Unix commands (including postgres & redis related)
################################################################################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROJECT INFO ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
################################################################################
#display name of current git branch [TOADD]
alias curbranch="git branch | grep '\*'"
#output a divider to the cli [TOADD]
alias clidivider="echo '======================================'"
#provides the current directory name - without the full path [TOADD]
@andfaulkner
andfaulkner / SenecaErrorOutputCleaner.sh
Last active October 7, 2015 14:29
Seneca error output cleaner - bash (for Seneca microservices framework for NodeJS)
# Private action used by function slicesenerr below - do not use
alias __slicesenerr_slicer="sed 's/ at/\n at/g' | \
sed 's/trace=/\n\ntrace=/g'| \
sed 's/\/home\/andfaulkner\/Projects\/testbed\/testbed-seneca--4//g' | \
sed 's/, argv=/,\n argv=/g' | \
sed 's/, rss=/,\n rss=/g' | \
sed 's/, heapTotal=/,\n heapTotal=/g' | \
sed 's/, loadavg=/,\n loadargv=/g' | \
sed 's/ date=/\n date=/g' | \
sed 's/ native=\(true\|false\), / /g' | \
alert('HIJACKED!');
@andfaulkner
andfaulkner / batsignal_templates.md
Last active May 16, 2016 08:51
Batsignal templates: a simple microtemplate intended for temporary injection of code for debugging: highly obtrusive tag, easy to match, no accidental captures, super-simple.

BATSIGNAL MICROTEMPLATES

  • let your code swoop in and swoop out like a bat. Like a Batman.
  • concept: template markers so absurdly safe they can be injected & extracted without tokenization
    • use: temporary injections of code for debugging purposes
  • only a single template operator / matching tag-set provided.
    • One operator is all you need, when your operator is the batsignal.

Tags - aka the batsignal

@andfaulkner
andfaulkner / goto-sublime
Created June 24, 2016 17:13 — forked from kendellfab/goto-sublime
Add mouse click `goto definition` in sublime text 3.
Linux - create "Default (Linux).sublime-mousemap" in ~/.config/sublime-text-3/Packages/User
Mac - create "Default (OSX).sublime-mousemap" in ~/Library/Application Support/Sublime Text 3/Packages/User
Win - create "Default (Windows).sublime-mousemap" in %appdata%\Sublime Text 3\Packages\User
[
{
"button": "button1",
"count": 1,
"modifiers": ["ctrl"],
"press_command": "drag_select",