Skip to content

Instantly share code, notes, and snippets.

@aogilvie
aogilvie / trap.md
Last active November 2, 2021 04:53
JavaScript Code Trap Example #1
/**
 * Fetch users by projectId
 *
 * @param {String} projectId (required)
 * @param {Object} options (to further narrow query) e.g. [postcode, disabled]
 */
api.prototype.getUsers = function(projectId, options, cb) {
    let query = {
        projectId,
@aogilvie
aogilvie / keyboard_driver_hack.md
Created December 14, 2017 03:12
Japanese Apple Extended Keyboard Layout for Windows Hack
  • plug in your USB keyboard (if not using a laptop).
  • in Windows click start and type "keyboard" this should match the Keyboard window in the Control Panel.

screenshot1

  • Update the driver to Fujitsu 109 Japaese Keyboard.

screenshot2

@aogilvie
aogilvie / convert.md
Created August 31, 2017 04:08
Nix (CentOS) .md to .pdf with pandoc

Install pandoc

yum install -y texlive-latex texlive-latex-bin texlive
yum install -y pandoc

Given a file sample.md make sample.pdf

pandoc -o sample.pdf sample.md

@aogilvie
aogilvie / ProxyThingsForDocker.md
Last active November 14, 2016 05:13
Proxy Things For Docker

Notes on using proxy env vars with Docker or Dockerfile

Running the daemon behind a proxy:

sudo env https_proxy=http://proxy:8080 docker daemon

Building

sudo docker build --build-arg HTTP_PROXY=$http_proxy -t some/imagename .

@aogilvie
aogilvie / prettyInfoScope.js
Last active December 7, 2015 03:01
Pretty console the scope of your console.info
(function() {
// Usage - attach scope to last argument for printing scope:
// console.info('whatever', this);
// console.info('whatever', { a: 'abc'}, ..., this);
if (window.console && console.info){
var old = console.info;
console.info = function() {
var len = arguments.length;
if (len -1 > 0 &&
Object.prototype.toString.call(arguments[len - 1]) === '[object Object]' &&
@aogilvie
aogilvie / monit_install_setup.md
Created August 27, 2015 05:48
Setup and Install Monit (Yum)

Install

  • Download monit-5.5-1.el6.rf.x86_64.rpm
  • $ sudo yum install monit-5.5-1.el6.rf.x86_64.rpm
  • Installs to /usr/bin/monit
  • Start deamon $ monit
  • Start services $ monit start all (all is monitor all)

Setup

@aogilvie
aogilvie / gist:94eb38759624b3866bf3
Last active August 29, 2015 14:23
Linux: Cordova add android platform: TypeError: Request path contains unescaped char

Cordova: 5.1.1

Node.js: v0.12.0

Replace ~/Documents/node_modules/cordova/node_modules/cordova-lib/node_modules/npm/node_modules/request/index.js (or whatever the error output says)

with https://github.com/mikeal/tunnel-agent

@aogilvie
aogilvie / gist:102e6687780dd81c63d6
Created June 24, 2015 01:44
Atom IDE Proxy workaround

For 0.211.0 when behind a proxy.

# Windows temporary:
set ATOM_NODE_URL=http://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist

# Windows permanently:
setx ATOM_NODE_URL http://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist /M

# Linux
@aogilvie
aogilvie / gist:cddeeb0b415d79a77b27
Last active August 29, 2015 14:07
Splitting a large commit after having created a PR

Scenario

Working on a feature branch, let's say "feature/local-notification". Once finished, one commits all the files and sends the PR to let's say "develop" on a remote repositiory used by your team.

When a reviewer comes to check the PR they announce they are unable to comment on diffs or view all the diffs on Github as Github's diff limit was reached.

You are asked to (kindly) split the commit...

Below I will outline the (what I think is the best and most flexible) method of doing this (there are perhaps other ways depending on your situation).

@aogilvie
aogilvie / gist:1818972c834590c2b53d
Last active August 29, 2015 14:02
OrbitControls modification for Ejecta

To use OrbitControls for Ejecta you will need to modify the OrbitControls.js where touchmove is looking for variable element.clientHeight and element.clientWidth. These are read-only properties of Element which are not available in Ejecta.

If you are passing the default document Element using controls = new THREE.OrbitControls( camera );, then you can replace the following lines with the innerWidth and innerHeight properties of window. (window == document are basically same element in Ejecta).


function touchmove( event ) {

		if ( scope.enabled === false ) { return; }