Skip to content

Instantly share code, notes, and snippets.

$ mvn compile -e -rf :org.lamport.tlatools
...
[INFO] ------------------------------------------------------------------------
[INFO] Building org.lamport.tla.toolbox.uitest 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] org.lamport.tlatools ............................... SUCCESS [ 8.409 s]
[INFO] org.lamport.tlatools.api ........................... SUCCESS [ 0.004 s]
(On Ubuntu 16.04)
# Clone repo
$ git clone https://github.com/tlaplus/tlaplus.git
# Install Java 8
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt update
$ sudo apt install oracle-java8-installer
$ javac -version
$ mvn compile -rf :org.lamport.tlatools
...
[INFO] ------------------------------------------------------------------------
[INFO] Building org.lamport.tla.toolbox.uitest 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] org.lamport.tlatools ............................... SUCCESS [ 8.395 s]
[INFO] org.lamport.tlatools.api ........................... SUCCESS [ 0.004 s]
@edahlgren
edahlgren / RingBalance.hs
Created July 6, 2013 02:34
Empirically test the non-uniformness of a hash ring for different server, replication, and bit-space values. Uses Jenkin's hash.
import Data.Bits
import System.IO
import qualified Data.List as L
import qualified Data.Vector as V
import qualified Data.HashMap.Strict as HM
import Statistics.Test.ChiSquared
import Data.BloomFilter.Hash
best :: Int -> Int -> Int
best servers bits = 2^bits `div` servers
trace :: ((input, feedback) -> (output, feedback)) -> input -> output
trace f input = output
where (output, feedback) = f (input, feedback)
sequenceA = 'actgatcgattgatcgatcgatcg'
sequenceB = 'tttagatcgatcttgatc'
"""
Task: Uppercase (highlight) the most similar subsequence in sequenceA and sequenceB. In other words, align sequenceA and sequenceB so they best match.
Why is this useful? If the sequences are big, or you have a lot of sequence pairs, this is tiresome and error prone.
"""
import time
"""
Here's your function/task you want to make parallel
In your case the time.sleep would be replaced with lots
of computation
"""
def computation(threadid):
print "starting thread ", threadid
time.sleep(2)
import time
from multiprocessing import Process
"""
Here's your function/task you want to make parallel
In your case the time.sleep would be replaced with lots
of computation
"""
def computation(threadid):
print "starting thread ", threadid