Skip to content

Instantly share code, notes, and snippets.

/(<a[^>]*?>.*?)?(?!<[^>]*?)([a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-])+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(?![^<]*?>)/gi
@adam-lynch
adam-lynch / Viewport and scale meta tag.html
Created January 27, 2014 11:01
Viewport and scale meta tag
<meta name="viewport" content="width=device-width, initial-scale=1.0">
# thing - {mixed}. Anything you want to get the type of.
getType: do =>
unless @classToType?
@classToType = {}
for type in ['Boolean', 'Number', 'String', 'Function', 'Array', 'Date', 'RegExp', 'Undefined', 'Null']
@classToType["[object #{type}]"] = type
return (thing) =>
className = Object::toString.call thing
return if @classToType[className]? then @classToType[className].toLowerCase() else 'object'
@adam-lynch
adam-lynch / existsInAny.js
Last active August 29, 2015 13:57
A (probably inefficient) functional approach to determine if any object contains a specific value for a property in an array of objects. Very Haskelly.
var existsInAny = function(needle, propertyName, haystack){
return haystack.map(function(el){return el[propertyName] === needle;}).reduce(function(a,b){return a||b;});
}
/*
# CoffeeScript version
existsInAny = (needle, propertyName, haystack) ->
haystack.map((el)-> el[propertyName] is needle).reduce((a,b)-> a||b)
*/
find . -name \* -print0 | perl -MFile::Basename -0nle 'rename $_, dirname($_)."/prefix_".basename($_)'
@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');
@adam-lynch
adam-lynch / requireNoCache.js
Last active April 12, 2025 08:46
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 / clearExplorerIconCache
Created October 5, 2014 20:11
How to clear Windows Explorer icon cache
ie4uinit.exe -ClearIconCache
.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 / 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);