Skip to content

Instantly share code, notes, and snippets.

View computerphysicslab's full-sized avatar

Juan Ignacio Pérez Sacristán computerphysicslab

View GitHub Profile
Published on March 26, 2020
https://www.linkedin.com/pulse/covid-19-pron%C3%B3stico-de-la-curva-para-abril-2020-p%C3%A9rez-sacrist%C3%A1n/
2.- Contagio masivo en Mayo al levantar el confinamiento, con la esperanza de que el calor del verano reduzca la epidemia (pero los datos de Malasia y Brasil nos indican que no será así).
3.- Entrar en bucle de confinamiento y fase R0 cada 3 meses.
--
/*
When debugging your code in goLang you may need a pretty print function not just for int or strings,
but capable to render any kind of data structure. Here it is, simple and useful. Enjoy it!
*/
package main
import (
"encoding/json"
"fmt"
package main
import (
"fmt"
"math/rand"
"sync"
"time"
)
var wg sync.WaitGroup
// https://jdanger.com/build-a-web-crawler-in-go.html
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
// https://play.golang.org/p/XnuBNaigHcF
/*
Loop through an interface array to find the item matching by any of its keys/values or struct fields
In this example:
[0]:
"Fruta": "manzana",
"Verdura": "coliflor"
[1]:
"Fruta": "pera",
"Verdura": "guisante"

Message brokers vs. APIs

REST APIs must be designed to expect an immediate response. If the client receiving the response is down, the sending service will be blocked while it awaits the reply. Failover and error handling logic should be built into both services.

Message brokers enable asynchronous communications between services so that the sending service need not wait for the receiving service’s reply. This improves fault tolerance and resiliency in the systems in which they’re employed. In addition, the use of message brokers makes it easier to scale systems since a pub/sub messaging pattern can readily support changing numbers of services. Message brokers also keep track of consumers’ states.

https://www.ibm.com/cloud/learn/message-brokers

https://kafka.apache.org/uses

What can I compare 2^256 with?

2^256 = 1.158 x 10^77

There is an estimated 7.5 x 10^18 grains of sand on Earth There are estimations of anywhere from 30 x 10^21 to 70 x 10^21 and even 10 x 10^23 stars in the “observable” universe. There is an estimation of anywhere from 1 x 10^78 to 1 x 10^83 atoms in the known, observable universe.

How do you pronounce 2^256?

// Loop through a map array to find the item matching by any of its keys/values
// In this example:
// [0]:
// "fruta": "manzana",
// "verdura": "coliflor"
// [1]:
// "planas": "lentejas",
// "redondas": "garbanzos"
// searching for "planas": "lentejas" yields array item [1]
//
@computerphysicslab
computerphysicslab / gist:dc120f13c11f418bedfec64a0f3b4a2b
Last active July 7, 2020 07:00
goLang debugging through JSON MarshalIndent
// IMPORTANT!!! You need to export the T1.id field so that the json package can see it. Rename the name field to Id.
package main
import (
"encoding/json"
"fmt"
"reflect"
)