Skip to content

Instantly share code, notes, and snippets.

View jdalton's full-sized avatar

John-David Dalton jdalton

View GitHub Profile
@junosuarez
junosuarez / top 1000
Created November 17, 2012 11:27
common english words which aren't npm modules yet
in
was
the
of
her
and
his
he
you
for
@dherman
dherman / nans.js
Last active December 15, 2015 11:19
a NaN isn't a NaN isn't a NaN
function bufferBytes(buffer) {
return [].map.call(new Uint8Array(buffer), function(x) {return x})
}
function nanBytes(nan) {
var a = new Float64Array(1);
a[0] = nan;
return bufferBytes(a.buffer);
}
@henrahmagix
henrahmagix / map-with-filter-differences.js
Last active December 20, 2015 06:49
Difference in map between underscore/lodash and jQuery/Zepto.
// Difference in map between underscore/lodash and jQuery/Zepto.
//
// $ allows filtering at the same time; _ does not.
//
// In your client-side JavaScript apps that use _ and $, this can come as a
// surprise since the assumption is that all your map, each, filter, etc. needs
// are fulfilled by _, and you'd be right to use them for speed since they
// alias native methods where available. However, sometimes $ can be useful,
// and this is one such case where that's true.
//
> eshost host --list
┌──────────────┬─────────┬────────────────────────────────────────────────────┬─────────┐
│ name │ type │ path │ args │
├──────────────┼─────────┼────────────────────────────────────────────────────┼─────────┤
│ chakra │ ch │ C:\Users\brterlso\projects\runify\hosts\ch.exe │ │
├──────────────┼─────────┼────────────────────────────────────────────────────┼─────────┤
│ node │ node │ c:\Program Files\nodejs\node.exe │ │
├──────────────┼─────────┼────────────────────────────────────────────────────┼─────────┤
│ spidermonkey │ jsshell │ C:\Users\brterlso\projects\runify\hosts\js.exe │ │
├──────────────┼─────────┼────────────────────────────────────────────────────┼─────────┤
@paulirish
paulirish / gist:43b68a2b6a38ceaaf345
Last active August 4, 2016 11:29
jQuery 3.0 Ideas

Just some early draft thoughts

Increased modularity is a long-standing request of jQuery. 3.0 should deliver on that. Many authors will use jQuery 3.0 in ES6 codebases, and often alongside frameworks that have overlap in functionality.

That said, a majority of developers will use a monolithic build. jQuery 3.0 must aggressively remove API surface area and functionality from this core build to protect developers from performance footguns. The jQuery team has reasonably voiced concern that removing modules means it's less likely for people to upgrade. While some users do attempt jQuery version upgrades, many freeze their version and never revisit it. I'd like to get more data on this phenomenon as I think we're optimizing API deprecation policy for a small audience.

Lastly, it's 2015 and the gap between JavaScript developers and jQuery developers has never been bigger. Let's bridge that gap. We should encourage the developer to use modern DOM APIs (that don't suck) and polyfill as neccessary.

Rem

var browserslist = require('browserslist');
var request = require('sync-request');
var res = request('GET', 'https://saucelabs.com/rest/v1/info/browsers/webdriver');
function lookup(requestedBrowsers, cb) {
var result = {};
var sauce = JSON.parse(res.getBody().toString())
//console.log(sauce);
@malte-wessel
malte-wessel / browserify-replace-underscore-with-lodash-globally.md
Last active December 29, 2016 17:22
Replace underscore with lodash globally

If you are using backbone (and backbone.marionette) in a browserify managed project, you will likely run into issues with underscore (at least if you manage your dependencies with npm). Each package, that has underscore as a dependency, will require its own version of underscore (making your bundle file contain multiple versions of underscore). Back in the days, you could shim backbone and underscore like:

browserify({
	shim: {
		'underscore': {
			path: './node_modules/underscore/underscore.js',
			exports: '_'
 },
@RReverser
RReverser / acorn-top-level.js
Created March 14, 2017 10:00
Acorn: top-level parsing experiment
// See https://jsperf.com/acorn-top-level-parsing-experiment/1 for example
acorn.plugins.top_level = function (instance) {
// Could skip other things as well, but this
// is where the most time can be saved
instance.parseBlock = function () {
var node = this.startNode();
var length = this.context.length;
do {
this.next();
@deathbearbrown
deathbearbrown / accessibility.md
Last active April 27, 2017 20:33
Please be accessible, my dudes.

If you have images and you are showing them on the web using an <img> tag, you must ALWAYS include alt text.

If you are writing markdown, you have no excuse not to add alt text.

![Alt text right here buddy](src)

Doing this is lazy. You're better than that.

![](src)
@WebReflection
WebReflection / inherit.js
Last active October 16, 2018 16:26
a meaningful shim limited to the first argument only of `Object.create()`, able to create empty dictionaries too such `inherit(null)` even in older browsers, down to IE5, without `__proto__` and/or without ES5 `Object.create()` support.
/*!(C) WebReflection *//** @license Mit Style */
// inspired by https://gist.github.com/4395291
this.inherit || (this.inherit = function(create){
if (!create) {
if ({__proto__:null} instanceof Object) {
for (var
Null = function Null() {},
doc = document,
html = doc.documentElement,
iframe = html.insertBefore(