Skip to content

Instantly share code, notes, and snippets.

💭
Building cool things at @testimio

Benjamin Gruenbaum benjamingr

💭
Building cool things at @testimio
Block or report user

Report or block benjamingr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View q50370916.js
const obj1 = {"1,1" : "hello"},
obj2 = {"1,1" : "hi"},
obj3 = [obj1, obj2].reduce((a, c) => {
return {...a, [k] : (a[k] || []).concat(c[k]);
}, {});
@benjamingr
benjamingr / peer5-load-conditionally.js
Last active Aug 31, 2017
This code snippet lets you load Peer5 without
View peer5-load-conditionally.js
// load Peer5 with a script timeout
var initiated;
function initClappr() {
if (initiated) return;
initiated = true;
// var player = new Clappr.Player();
// rest of clappr initialization
}
View eggs.js
Eggs.Map = function() {}
,
Eggs.Map.init = function() {
function t() {
var t = ($(window).scrollTop() + $(window).height()) / $(document).height() * .6;
s.css("background-size", t * a + "px auto"),
s.css("background-position", 800 - o.x * t + "px " + (40 - o.y * t) + "px")
}
function e() {
var t = i()
View 1.diff
diff --git a/benchmark/doxbee-sequential/callbacks-caolan-async-waterfall.js b/benchmark/doxbee-sequential/callbacks-caolan-async-waterfall.js
deleted file mode 100644
index 439f9bba..00000000
--- a/benchmark/doxbee-sequential/callbacks-caolan-async-waterfall.js
+++ /dev/null
@@ -1,71 +0,0 @@
-require('../lib/fakes');
-var async = require('async');
-
-module.exports = function upload(stream, idOrPath, tag, done) {
View gem-from-2013.js
/*
* Mustache like logic less templating with reverse data binding
*/
//HACK, do not use, EVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVER
//EVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVER
//EVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVEREVER
// in production code
//templates a given view based on the given viewmodel, for more detail on how this works please check the unit tests
window.Mustache = {};
View liquidate.bluebird.js
function liquidate(obj, F = Promise.getNewLibraryCopy()) {
const promised = F.promisifyAll({__proto__: Object.create(obj)});
Object.assign(F.prototype, whenReadyAll.call(obj, promised)); // add the API
return promised;
function whenReadyAll(obj, target = {}) {
for(const prop in obj) target[prop] = (...args) => this.then(() => obj[prop](...args));
return target;
}
}
View code.js
return Promise.resolve().then(function rest() {
return Rest.webService({apiUrl: "/v4_6_release/apis/3.0/system/members", method: "GET" }).then(result =>
(Array.isArray(result) && result.length === 0) ? "Done" : rest();
});
});
View Post Mortem.md

Post Mortem Debugging in NodeJS in the Light of Promises

Context:

we're discussing how we can safely abort on unhandled rejections and obtain meaningful debugging information. Related reading: https://gist.github.com/misterdjules/2969aa1b5e6440a7e401#file-post-mortem-debugging-with-promises-md.

In particular, we're discussing https://gist.github.com/misterdjules/2969aa1b5e6440a7e401#removing-implicit-trycatch-blocks-from-v8s-promises-implementation

Othe recommended reading: On unhandledRejection https://gist.github.com/benjamingr/0237932cee84712951a2

View file.cs
public class EmailAddress
{
[Match("^")] public string _;
[Match(@"\w+")] public string User;
[Match("@")] public string _1;
[Match("[^@]+")] public string Host;
[Match("$")] public string _2;
}
public static class Matcher
View RoomMeeting.md

RoomMeeting

Please suggest topics below in the comments.

Meeting will be held this Saturday in 19:00 GMT.

You can’t perform that action at this time.