Skip to content

Instantly share code, notes, and snippets.

View mallond's full-sized avatar
:electron:
-.- .--- --... -.- --. ---

David Mallon ⚙ mallond

:electron:
-.- .--- --... -.- --. ---
View GitHub Profile
@mallond
mallond / Simple Node Promise Example with Chaining
Last active January 29, 2016 01:30
Simple Node Promise Example with Chaining
/** Copy All and run in Chrome inspect
* Simple Node Promise Example with Chaining
* @param input
* @returns {Promise}
*/
function calculate(input) {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (input.value===input.numberToReject) {
console.log('reject');
@mallond
mallond / Load Underscore into Chrome Console
Created January 29, 2016 01:32
Javascript Cool Tricks
var script = document.createElement("script");
script.src = "https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js";
document.body.appendChild(script);
/**
* Created by dm on 2/19/16.
*/
'use strict';
const _ = require('underscore');
const tableMemo = _.memoize(loadTable, function(input) {
return input.name;
});
@mallond
mallond / Git Backup
Last active February 24, 2017 22:54
GIT Download All
#!/bin/bash
#
# Crude script to backup an organisations repositories and its members forks.
#
# Name of organisation
ORG="change"
# Needed to talk to API
@mallond
mallond / gist:ec9c41a3fb206a29ae0cd4a7a4083e14
Last active November 1, 2016 20:02
Mac osx X11 Docker Example
#firefox example
- Install XQuartz
open -a XQuartz
ip=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
xhost + $ip
# Merge a branch B1 in N1 with rebase
git checkout N1
git pull
git checkout B1
git rebase N1
git checkout N1
git rebase B1
# Yet another approach
https://medium.com/@sda/git-rebase-based-workflow-cheat-sheet-3e37ad39da66#.lovwmnkbo
Run MongoDB and the Mongo Client from Docker
Step 1: Start the mongodb service via docker
$ docker run --name localmongo -p 27017:27017 -d mongo
Step 2: exec into the machine
$ docker exec -it localmongo mongo mongodb://localhost:27017
Other:
Substitute the localhost:27017 string for remote access
@mallond
mallond / gist:78986f7db045fa10fac2412e7a75a8e5
Last active February 22, 2017 21:20
Node Emitter Example
/**
* Created by dm on 2/22/17.
*/
'use strict';
// Set Up a Node Global OnOff Emitter
const events = require('events');
if (!global.OnOffEmitter) {
global.OnOffEmitter = new events.EventEmitter();
}
Verifying that "malloda.id" is my Blockstack ID. https://onename.com/malloda
Verifying that "davidmallon.id" is my Blockstack ID. https://onename.com/davidmallon