This file contains 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
COUNTER_URL=http://172.17.6.114:8888/count | |
# get uniq increment val by key | |
curl ${COUNTER_URL}/my_key | |
# reset counter by key | |
curl -X DELETE ${COUNTER_URL}/my_key | |
# post key value | |
curl -X POST -d '{"key": "my_key", "val": "some_value"}' ${COUNTER_URL}/count |
This file contains 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
set -g prefix ` | |
bind ` send-keys ` | |
unbind % | |
bind \ split-window -h | |
bind - split-window -v |
This file contains 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
# install dependencies | |
sudo apt-get install python-pip python-dev | |
pip install --upgrade pip | |
sudo apt-get install openjdk-8-jdk git python-dev python3-dev python-numpy python3-numpy build-essential python-pip python3-pip python-virtualenv swig python-wheel libcurl3-dev | |
# install bazel | |
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list | |
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add - | |
sudo apt-get update |
This file contains 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
### Pattern matching | |
1. CTRL-G displays your location in the file and the file status. | |
G moves to the end of the file. | |
number G moves to that line number. | |
gg moves to the first line. | |
2. Typing / followed by a phrase searches FORWARD for the phrase. | |
Typing ? followed by a phrase searches BACKWARD for the phrase. |
This file contains 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
// using math.pow | |
public static double round(double value, int places) { | |
if (places < 0) throw new IllegalArgumentException(); | |
long factor = (long) Math.pow(10, places); | |
value = value * factor; | |
long tmp = Math.round(value); | |
return (double) tmp / factor; | |
} |
This file contains 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
# docker image: https://hub.docker.com/_/redis/ | |
# start redis server with append | |
docker run -itd --name redis --net=host -v /docker/redis/data:/data redis redis-server --appendonly yes | |
# start redis cli (localhost) | |
docker run -it --net=host --rm redis redis-cli -h localhost -p 6379 | |
# get multiple values | |
MGET key1, keyN |
This file contains 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
val a: PartialFunction[String, Int] = { case "a" => 1 } | |
val b: PartialFunction[String, Int] = { case "b" => 2 } | |
val c: PartialFunction[String, Int] = { case "c" => 3 } | |
val ab = a orElse b // combine functions a and b | |
ab("a") // 1 | |
ab("b") // 2 | |
ab("c") // MatchError |
This file contains 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
import akka.actor.Status.Failure | |
import akka.actor.{Actor, ActorLogging, ActorRef, ActorRefFactory, ActorSystem, PoisonPill, Props} | |
import akka.dispatch.ExecutionContexts | |
import akka.testkit.{ImplicitSender, TestKit} | |
import org.scalatest._ | |
import scala.concurrent.duration._ | |
import akka.pattern.{ask, pipe} | |
import akka.util.Timeout | |
/* |
This file contains 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
import com.twitter.algebird.HyperLogLogMonoid | |
//define test data | |
val data = Seq("aaa", "bbb", "ccc") | |
//create algebird HLL | |
val hll = new HyperLogLogMonoid(bits = 10) | |
//convert data elements to a seq of hlls | |
val hlls = data.map { str => | |
val bytes = str.getBytes("utf-8") | |
hll.create(bytes) |
This file contains 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
import scala.concurrent.Await | |
import scala.concurrent.ExecutionContext | |
import scala.concurrent.Future | |
import scala.concurrent.blocking | |
import scala.concurrent.duration.Deadline | |
import scala.concurrent.duration.Duration | |
import scala.concurrent.duration.DurationInt | |
import scala.concurrent.duration.DurationLong | |
import scala.concurrent.future | |
import scala.concurrent.promise |
NewerOlder