Skip to content

Instantly share code, notes, and snippets.

View arriqaaq's full-sized avatar
🎯
Focusing

Farhan arriqaaq

🎯
Focusing
View GitHub Profile
@arriqaaq
arriqaaq / guardian_gaza.ipynb
Last active August 29, 2015 14:25 — forked from darribas/guardian_gaza.ipynb
A IPython Notebook to analyze the Gaza-Israel 2012 crisis
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
package main
import (
"fmt"
zerolog "github.com/rs/zerolog/log"
"github.com/sirupsen/logrus"
"go.uber.org/zap"
"log"
"net/http"
)
package main
import "github.com/tidwall/gjson"
const json = `{"name":{"first":"Janet","last":"Prichard"},"age":47}`
type User struct{
FirstName string `gjson:"name.first"`
LastName string `gjson:"name.last"`
Age string `gjson:"age"`
package main
import (
"log"
"net/http"
)
func main() {
// Simple static webserver:
log.Fatal(http.ListenAndServe(":8080", http.FileServer(http.Dir("/usr/share/doc"))))
errs := make(chan error, 2)
server := &http.Server{Addr: ":8080", Handler: handler}
go func() {
errs <- server.ListenAndServe()
}
go func() {
// Setting up signal capturing
c := make(chan os.Signal)
package main
import (
"fmt"
lucio "github.com/arriqaaq/server"
"log"
"net/http"
"os"
)
func main() {
client := boomerang.NewHttpClient(clientCnf)
mux := http.NewServeMux()
mux.HandleFunc("/ping", func(w http.ResponseWriter, req *http.Request) {
request, _ := http.NewRequest("GET", URL_SERVICE_B, strings.NewReader("gopher"))
resp, httpErr := client.Do(request)
if httpErr != nil {
fmt.Println("ping failed ", httpErr)
w.Write([]byte("fail"))
return
func main() {
client := redis.NewClient(&redis.Options{Addr:"localhost:6379",Password: "", DB:0, // use default DB})
pong, err := client.Ping().Result()
if err == nil {
log.Fatalln(pong, err)
}
client.Set("isco", "alarcon", 0).Err()
promCtx := boomerang.NewPrometheusMetrics("service_b", "info")
mux := http.NewServeMux()
mux.HandleFunc("/pong", func(w http.ResponseWriter, req *http.Request) {
// fingerEntry represents a single finger table entry
type fingerEntry struct {
Id []byte // ID hash of (n + 2^i) mod (2^m)
Node *internal.Node
}
func newFingerTable(node *internal.Node, m int) fingerTable {
ft := make([]*fingerEntry, m)
for i := range ft {
ft[i] = newFingerEntry(fingerID(node.Id, i, m), node)
type Node struct {
*internal.Node
predecessor *internal.Node
successor *internal.Node
fingerTable fingerTable
storage Storage
transport Transport
}