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 gist:98cb672cb289cb53bab6
func then<NT,NE>(onFulfilled:(T) -> Promise<NT,NE>) -> Promise<NT,NE> {
var p = Promise<NT,NE>()
switch self.state.state {
case .Rejected:
p.reject(self.state.error) // this is a type error
case .Fulfilled:
let result = onFulfilled(self.state.value!)
result.then( { p.fulfill($0) })
result.catch( {p.reject($0) })
case .Pending:
View Promise
// Promise.swift
// Promise
// Created by Benjamin Gruenbaum on 8/12/14.
// Copyright (c) 2014 Tipranks. All rights reserved.
import Foundation
benjamingr / Promise.swift
Created Aug 13, 2014
promise library in swift
View Promise.swift
// Promise.swift
// Promise
// Created by Benjamin Gruenbaum on 8/12/14.
// Copyright (c) 2014 Tipranks. All rights reserved.
import Foundation
benjamingr / promise.js
Created Jan 19, 2015
Got bored without internet
View promise.js
let once = (fns, called) => // fns is an array of functions, called is undefined if first call => function OnceBinded(){
if(called) return; else called = true;
return orig(...arguments);
export class Promise {
Object.assign(this, {_handlers: [] , _state : State.Pending, _value: null});
resolver(value => {
if(this._state !== State.Pending) return;
View gist:9172c4f2ddbce3e91ba3

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 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.

View gist:bf199d640053ea497fde
$("#div1").load("demo_testB.html", special_value);
View correct.js
function createUser(username, callback) {
var connection = DatabaseClient.connect();
var users ='collection', 'users');
var query ='query', {username: username});
return query.then(function(existing){
if(existing) throw new Error("User already exists: " + username);
else return'create', {username: username});
}).fin(function(connection){ return'close'); });

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"; }); 
View gist:5427228
* What Im trying to get to work
function playersGameName(options){
// stuff in here to init whatevs.
View gist:5612583
Here is some `Code` and words. This is more random wody stuff, `some code` suddenly a widd more some more `Other Code` which makes the above code seems `Related` although it is not.
You can’t perform that action at this time.