Skip to content

Instantly share code, notes, and snippets.

View mariojunior's full-sized avatar

Mario de Souza Junior mariojunior

View GitHub Profile
@nhagen
nhagen / PromisAllWithFails.js
Last active November 15, 2022 18:11
Wait until all promises have completed even when some reject, with Promise.all
var a = ["sdfdf", "http://oooooolol"],
handleNetErr = function(e) { return e };
Promise.all(fetch('sdfdsf').catch(handleNetErr), fetch('http://invalidurl').catch(handleNetErr))
.then(function(sdf, invalid) {
console.log(sdf, invalid) // [Response, TypeError]
})
.catch(function(err) {
console.log(err);
})
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@mariojunior
mariojunior / gist:2003261
Created March 8, 2012 20:32
Magic line for BlazeDS null/NaN Number (Java/AS3) serialization
//On input class....
...
} else if ((value instanceOf Double) && (null == value)) {
return Double.NaN;
} else ...
//on output class...
...
} else if ((o instanceOf Double) && (null == o)) {