Skip to content

Instantly share code, notes, and snippets.

John-David Dalton jdalton

View GitHub Profile
ralphholzmann / _with.js
Created Apr 25, 2012
JavaScript with-like function
View _with.js
var obj = {
"ralph" : 1,
"jon" : 2,
"alex" : 3
function _with( fn, data ) {
var keys = Object.keys( data ),
values = key ) {
paulmillr /
Last active Jul 3, 2020
Most active GitHub users (by contributions).

Most active GitHub users (

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at from Tue, 06 Dec 2016 17:06:46 GMT till Wed, 06 Dec 2017 17:06:46 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

  .filter(user => user.followers > 1000)
bobrik / benchmark.js
Created Jul 11, 2012
lodash objectDifference implementation and benchmark code
View benchmark.js
(function(module) {
var Benchmark = require('../vendor/benchmark.js/benchmark.js'),
_ = require('../vendor/underscore/underscore.js'),
lodash = require('../lodash.js');
var numbers = [],
fourNumbers = [5, 25, 10, 30],
twoNumbers = [12, 21],
jameswomack / javascript_background_thread.js
Created Sep 11, 2012
Extend function prototype to run a function as a WebWorker
View javascript_background_thread.js
Function.prototype.runOnBackgroundThread = function (aCallback) {
var _blob = new Blob(['onmessage = '+this.toString()],{"type":"text/javascript"});
var _worker = new Worker((webkitURL.createObjectURL || URL.createObjectURL)(_blob));
_worker.onmessage = aCallback;
var _test = function () {
junosuarez / top 1000
Created Nov 17, 2012
common english words which aren't npm modules yet
View top 1000
WebReflection / inherit.js
Last active Oct 16, 2018
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.
View inherit.js
/*!(C) WebReflection *//** @license Mit Style */
// inspired by
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(
dherman / nans.js
Last active Dec 15, 2015
a NaN isn't a NaN isn't a NaN
View nans.js
function bufferBytes(buffer) {
return [] Uint8Array(buffer), function(x) {return x})
function nanBytes(nan) {
var a = new Float64Array(1);
a[0] = nan;
return bufferBytes(a.buffer);
henrahmagix / map-with-filter-differences.js
Last active Dec 20, 2015
Difference in map between underscore/lodash and jQuery/Zepto.
View map-with-filter-differences.js
// 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.
View gist:9698100


Computes a new version of a String value in which certain characters have been escaped, so that the regular expression engine will interpret any metacharacters that it may contain as character literals.

When the escape function is called with one argument string, the following steps are taken:

  1. Let string be ToString(string).
  2. ReturnIfAbrupt(string).
  3. Let length be the number of characters in string.
  4. Let R be the empty string.
View nosy_facetype_demo.html
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Live demo of Nosy Facetype by Rory Harnden</title>
<link href=',400italic' rel='stylesheet' type='text/css'>
<style type="text/css">
@font-face {
font-family: "Nosy";
src: url(NOSY_Facetype_by_Rory_Harnden.otf) format("opentype");
You can’t perform that action at this time.