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
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:
//
// Promise.swift
// Promise
//
// Created by Benjamin Gruenbaum on 8/12/14.
// Copyright (c) 2014 Tipranks. All rights reserved.
//
import Foundation
@benjamingr
benjamingr / Promise.swift
Created August 13, 2014 08:32
promise library in swift
//
// Promise.swift
// Promise
//
// Created by Benjamin Gruenbaum on 8/12/14.
// Copyright (c) 2014 Tipranks. All rights reserved.
//
import Foundation
@benjamingr
benjamingr / promise.js
Created January 19, 2015 21:10
Got bored without internet
let once = (fns, called) => // fns is an array of functions, called is undefined if first call
fns.map(orig => function OnceBinded(){
if(called) return; else called = true;
return orig(...arguments);
});
export class Promise {
constructor(resolver){
Object.assign(this, {_handlers: [] , _state : State.Pending, _value: null});
resolver(value => {
if(this._state !== State.Pending) return;

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.

$("button").click(function(){
$.get("demo_testA.html").then(function(res){
$("#div1").load("demo_testB.html", special_value);
});
});
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'); });
}

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"; }); 
/*
*
* What Im trying to get to work
*
*/
function playersGameName(options){
// stuff in here to init whatevs.
}
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.