Skip to content

Instantly share code, notes, and snippets.

@domharrington
domharrington / gist:2182666
Created March 24, 2012 13:14
OS X Clean Install

Chrome

Spotify

Homebrew

Git (brew install git)

Iterm 2

@domharrington
domharrington / gist:2948559
Created June 18, 2012 14:09 — forked from bengourley/gist:2948429
Fileupload API
var fileUpload = require('file-upload')
, gridfsAdapter = require('fileupload-gridfs')
var middleware = fileUpload.createFileUpload({
adapter: gridfsAdapter({ dbName: 'mydb' })
}).middleware
Exactly the same as this, just a bit nicer for the examples:
var middleware = fileUpload.createFileUpload({
@domharrington
domharrington / .slate
Created October 27, 2012 17:12
Slate config file
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
# Push Bindings
bind right:ctrl;cmd;alt push right bar-resize:screenSizeX/2
bind left:ctrl;cmd;alt push left bar-resize:screenSizeX/2
bind m:ctrl;cmd;alt move screenOriginX-0;screenOriginY-0 screenSizeX;screenSizeY
# Throw Bindings
@domharrington
domharrington / gist:5040710
Created February 26, 2013 18:14
Usage of model-not-found delegate in Catfish
var modelNotFoundDelegate = require('../lib/model-not-found-delegate')
, modelNotFound = modelNotFoundDelegate(router, collection, debug)
router.route('sections/:id/layout(/)', 'editLayout', function (id) {
collection.fetch(
{ update: true
, success: function () {
if (modelNotFound(id)) return false
var view = new LayoutView({ model: collection.get(id) })
router.render(view, 'Section Layout')

Clock Committing Style Guide

To allow us to automatically create a good quality changelog from our git history we recommend the following formats for commit messages.

The aim is to capture a reference to any ticket, card, or story that this commit contributes towards.

The most important part is to capture the platform and reference number:

{Platform} #{Reference ID} {Commit Message}
@domharrington
domharrington / gist:884346cc04c30eeb1237
Created November 28, 2014 14:55
Download file via ajax. Copied from here http://stackoverflow.com/a/23797348
module.exports = downloadAjaxFile
function downloadAjaxFile (xhr) {
/* jshint maxcomplexity: 7 */
var filename = ''
, disposition = xhr.getResponseHeader('Content-Disposition')
if (disposition && disposition.indexOf('attachment') !== -1) {
var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/
, matches = filenameRegex.exec(disposition)
@domharrington
domharrington / .mongorc.js
Created December 5, 2014 11:38
.mongorc.js file
DBCollection.prototype.read = function (id) {
return this.findOne({ _id: ObjectId(id) })
}
DBCollection.prototype.delete = function (id) {
return this.remove({ _id: ObjectId(id) })
}
function notablescan() {
var currentValue = db.getSiblingDB('admin').runCommand({ getParameter: 1, notablescan: 1 }).notablescan
@domharrington
domharrington / iojs-1.2.0.js
Created February 17, 2015 09:51
Node v0.10.36 and io.js v1.2.0 js error message differences
var assert = require('assert')
assert.throws(function () {
var a = {}
a.b()
}, /undefined is not a function/)
const request = require('request-promise')
const cheerio = require('cheerio')
request('http://www.bbcgoodfood.com/recipes').then(html => {
const $ = cheerio.load(html)
var categories = $('a[href^="/recipes/category"]').map(function (i, category) {
return { href: $(this).attr('href'), label: $(this).text() }
}).filter((i, category) => {
return category.label !== 'see more ...'
}).toArray()
@domharrington
domharrington / Adds a delete button to ionic app user device tokens.user.js
Created June 6, 2016 14:50
Adds a delete button to ionic app user device tokens
// ==UserScript==
// @name Adds a delete button to ionic app user device tokens
// @namespace http://tampermonkey.net/
// @version 0.1
// @author Dom Harrington (https://github.com/domharrington)
// @match https://apps.ionic.io/app/*/users/list
// @grant none
// ==/UserScript==
(function() {