๐ค
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "os" | |
| _ "github.com/lib/pq" | |
| "database/sql" | |
| ) | |
| var selectStatement = ` |
Based on the main README and the docs, i wrote what i thought should have been a fairly simple peer that i can test on a single machine using multiple ports.
The first peer is started with just a single port, that being the "cluster-port", that is, it's used to identify the cluster subsequent nodes will Join.
Subsequent peers start by specifying two ports, the first being the new node's port, the second being the "cluster-port".
Messages are created from the intial node every second and the message-id is simply a cycle of (currently 10) static values.
This example will launch five processes and watch the output of each node for 120 seconds (it seems at times it takes a long time for nodes to join.)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .PHONY: test | |
| test: | |
| go test -v |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ -d /Volumes/shm ]; then | |
| hdiutil detach /Volumes/shm | |
| else | |
| diskutil erasevolume HFS+ shm $(hdiutil attach -nomount ram://204800) | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // flatMap is basically just building a List by appending Lists: | |
| // List(1) ++ List(2) ++ List(3) ++ Nil = List(1, 2, 3) | |
| def flatMap[A, B](list: List[A])(f: A => List[B]): List[B] = list match { | |
| // ++ appends two Lists, so the reason flatMap flattens is that the List returned by f | |
| // is appended onto the front of the List returned by flatMap. So append is the flattener. | |
| case (x::xs) => f(x) ++ flatMap(xs)(f) | |
| case _ => Nil | |
| } |