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
class Foo<A,B>{
var bar:[(A,B)] = [(A,B)]() // why is this invalid?
}
//
// Promise.swift
// Promise
//
// Created by Benjamin Gruenbaum on 8/12/14.
// Copyright (c) 2014 Tipranks. All rights reserved.
//
import Foundation
@benjamingr
benjamingr / gist:5b42be523b7f313a79b7
Created August 12, 2014 09:10
lol, promise constructor
//
// Promise.swift
// Promise
//
// Created by Benjamin Gruenbaum on 8/12/14.
// Copyright (c) 2014 Tipranks. All rights reserved.
//
import Foundation
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 / gist:0237932cee84712951a2
Last active October 6, 2023 08:31
Promise unhandled rejection tracking global handler hook

Possibly Unhandled Rejection NodeJS Promise Hook

###Unhandled Rejection Tracking

Several promise libraries such as bluebird and when as well as some native promise implementations offer potentially unhandled rejection tracking. This means that the following:

Promise.reject(new Error("err")); // never attach a `catch`
@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);
});
});