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 / AngleBetween3PointsIn3DSpace.js
Last active November 3, 2023 15:26
Get the angle between 3 coordinates (x, y, z) in 3D space
/**
* Calculate angle between 3 points in 3D space.
* Note: assumes we want 1 vector to run from coord1 -> coord2, and the other
* from coord3 -> coord2.
*
* @param {x: number; y: number; z: number} coord1 1st (3D) coordinate
* @param {x: number; y: number; z: number} coord2 2nd (3D) coordinate
* @param {x: number; y: number; z: number} coord3 3rd (3D) coordinate
*
* @return {number} Angle between the 3 points
@andfaulkner
andfaulkner / sublime-text-3-snippet-scopes.md
Last active April 25, 2018 10:25
Sublime Text 2/3 snippet scopes - i.e. each file type's top-level scope (for use in snippets, syntaxes, plugins, etc)

List of top-level scopes for use in Sublime Text 2/3 snippets, syntaxes, and plugins:

ActionScript:                source.actionscript.2
AppleScript:                 source.applescript
ASP:                         source.asp
Assembly (x86/NASM):         source.assembly
Bash:                        source.shell
Batch (Windows):             source.dosbatch
BibTex:                      source.bibtex
C:                           source.c
@andfaulkner
andfaulkner / externals-webpack.config.js
Last active April 4, 2024 12:43
Split Webpack configuration into modules by functionality (rather than environment)
const prodExternals = {
'react': 'React',
'react-dom': 'ReactDOM',
'lodash': '_',
'redux': 'Redux',
'react-redux': 'ReactRedux',
'react-bootstrap': 'ReactBootstrap'
};
const testExternals = {
@andfaulkner
andfaulkner / irjs.js
Last active June 28, 2020 03:45 — forked from coolaj86/injs.js
REPL tools for NodeJS
#!/usr/bin/env node
// boot node repl with a few libraries auto-loaded and some top-level convenience functions
(function () {
"use strict";
var repl = require("repl");
var context = repl.start("irjs> ").context;
var path = require('path');
var fs = require('fs');
@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",
@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

alert('HIJACKED!');
@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' | \
@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 / 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