Skip to content

Instantly share code, notes, and snippets.

View benjamingr's full-sized avatar
🖊️
Limited availability.

Benjamin Gruenbaum benjamingr

🖊️
Limited availability.
View GitHub Profile
/*
* 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 = {};
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;
}
}
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();
});
});

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

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

RoomMeeting

Please suggest topics below in the comments.

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

You mean something like:

process.on("unhandledRejection", function(p, reason){
  console.log('Uncaught error: ', reason); // this will get called
});

Promise.resolve().then(x => { throw "Hah"; }); 
function createUser(username, callback) {
var connection = DatabaseClient.connect();
var users = connection.call('collection', 'users');
var query = users.call('query', {username: username});
return query.then(function(existing){
if(existing) throw new Error("User already exists: " + username);
else return users.call('create', {username: username});
}).fin(function(connection){ return connection.call('close'); });
}
$("button").click(function(){
$.get("demo_testA.html").then(function(res){
$("#div1").load("demo_testB.html", special_value);
});
});

You walk to your home and you want to share a TipRanks stock page with a friend on your phone, however you forgot your friend's email. You do remember it starts with "Gilad" followed by 4 positive integers whose squares are summed to 101 and are in descending order (what an odd way to remember someone's email) following @tipranks.com. Can you figure out Gilad's email?

Once you figure Gilad's email, send him an email saying you solved the challenge (add your CV for extra credit)!


We're looking for awesome full-stack developers to join our team!

TipRanks is a fintech startup in the Rotcheild area in Tel-Aviv. We're developing a cloud-based service that helps individual investors make better decisions. Our services are embedded in Bank Hapoalim, Bank Leumi, Excellence and several brokers abroad.