Skip to content

Instantly share code, notes, and snippets.

View marcusdb's full-sized avatar

Marcus David Bronstein marcusdb

  • porto, Portugal
View GitHub Profile
@mdwhatcott
mdwhatcott / custom_json.go
Created July 29, 2015 17:15
Example of implementing MarshalJSON and UnmarshalJSON to serialize and deserialize custom types to JSON in Go. Playground: http://play.golang.org/p/7nk5ZEbVLw
package main
import (
"bytes"
"encoding/json"
"fmt"
"strconv"
)
func main() {
function isPromise(thing) {
return (
typeof thing === "object" && thing !== null
&& thing.then instanceof Function
&& thing.catch instanceof Function
);
}
function whileGenerates(gen, prevGenResult) {
@Stuff90
Stuff90 / observable-recursive.js
Last active May 7, 2022 02:53
Example of a recursive call to an API using Observables
// Example for article : https://medium.com/@simonb90/appels-api-itératifs-avec-rxjs-a1c2593c558b
/*
* Definition of API method:
* getEntitiesByPage(page: number): Observable<Entity[]>
*/
let iterator = new BehaviorSubject<number>(1);
iterator.mergeMap((i) => {