Skip to content

Instantly share code, notes, and snippets.

@adam-lynch
adam-lynch / gist:c09a66551c4cdc713fdacfee40bdb9d1
Last active September 19, 2017 11:11
deals/1?include=events&page[events][size]=10&sort[events]=-createdAt&filter[events][type]=notes,files
{
id: 1,
type: deals,
attributes: {
...
},
relationships: {
events: {
data: [{
type: notes
@adam-lynch
adam-lynch / convertBooleanToStringNumber.coffee
Created March 11, 2016 19:36
How to convert a Boolean to a string number in ES5, ES6, and CoffeeScript
convertBooleanToStringNumber = (boolean) -> +boolean + ''
@adam-lynch
adam-lynch / windowsKillAllExeByName
Created October 16, 2015 10:15
Windows: Kill all .exe by name
taskkill /F /IM <processname.exe> /T
browserSync = require 'browsersync'
# if you're using gulp, replace this with `require('gulp-util').colors`
chalk = require 'chalk'
# method - {String} (uppercase)
colourMethod = (method) ->
map =
'GET': 'green'
'POST': 'yellow'
'PUT': 'blue'
@adam-lynch
adam-lynch / index.js
Created June 11, 2015 21:59
Testing restarting NW.js app
var gui = require("nw.gui"),
child_process = require("child_process"),
win = gui.Window.get(),
child;
if (process.platform == "darwin") {
child = child_process.spawn("open", ["-n", "-a", process.execPath.match(/^([^\0]+?\.app)\//)[1]], {detached:true});
} else {
child = child_process.spawn(process.execPath, [], {detached: true});
}
@adam-lynch
adam-lynch / preventScrollOnFocus.js
Created January 10, 2015 15:06
Preventing the document from scrolling when you trigger focus on something
document.getElementById('field').focus(); window.scrollTo(0,0);
.classNameOfADiv
span This is a span
| &nbsp;inline text next to the span which as far as I remember needs to be prepended with &nbsp; or be wrapped in a span
@adam-lynch
adam-lynch / clearExplorerIconCache
Created October 5, 2014 20:11
How to clear Windows Explorer icon cache
ie4uinit.exe -ClearIconCache
@adam-lynch
adam-lynch / requireNoCache.js
Last active January 4, 2022 01:47
Require a module, without going to Node.js's require cache
var path = require('path');
var _invalidateRequireCacheForFile = function(filePath){
delete require.cache[path.resolve(filePath)];
};
var requireNoCache = function(filePath){
_invalidateRequireCacheForFile(filePath);
return require(filePath);
};
@adam-lynch
adam-lynch / duckPunchingGulpStart.js
Last active August 29, 2015 13:59
Duck punching Gulp into waiting for something asynchronous. Example: Varying pipelines / tasks based on the contents of an external file.
/*
* Example: productionMode.txt contains either 0 or 1
*/
var productionMode = true; //defaults to production, don't change this
var gulp = require('gulp');
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');