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
| Jedis j = new Jedis(HOSTNAME, PORT); | |
| j.set("foo", "314"); | |
| Pipeline p = j.pipelined(); | |
| p.multi(); | |
| Response<String> r = p.get("foo"); | |
| Response<String> multiResp = p.exec(); | |
| p.sync(); | |
| multiResp.get(); // to achieve r.get() | |
| System.out.println(r.get()); |
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 net.heartsavior.dev; | |
| import java.util.ArrayList; | |
| import java.util.Collections; | |
| import java.util.HashSet; | |
| import java.util.List; | |
| import java.util.Map; | |
| import java.util.Random; | |
| import java.util.Set; |
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 net.heartsavior.dev; | |
| import redis.clients.jedis.Jedis; | |
| import redis.clients.jedis.exceptions.JedisConnectionException; | |
| public class JedisConnectionSuddenlyBrokenTest { | |
| public static void main(String[] args) throws InterruptedException { | |
| Jedis jedis = new Jedis("127.0.0.1", 6379); | |
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
| public class ListCommandsTest extends JedisCommandTestBase { | |
| public void blpopWithForceKill() throws InterruptedException { | |
| Thread th = new Thread(new Runnable() { | |
| @Override | |
| public void run() { | |
| jedis.blpop(100, "foo"); | |
| } | |
| }); | |
| th.start(); |
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
| // not a good solution, loop relies on n, outer variable. | |
| // I can include it to loop but then loop needs 4 parameters. | |
| def fib(n: Int): Int = { | |
| @annotation.tailrec | |
| def loop(pp: Int, p: Int, idx: Int): Int = { | |
| if (idx == n) | |
| pp + p | |
| else | |
| loop(p, pp + p, idx + 1) | |
| } |
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
| def tail[A](lst: List[A]): List[A] = lst match { | |
| case Nil => Nil | |
| case x :: xs => xs | |
| } | |
| // solution in a book | |
| // https://github.com/fpinscala/fpinscala/blob/master/answerkey/datastructures/02.answer.scala | |
| /* | |
| // Although we could return `Nil` when the input list is empty, we choose to throw an exception instead. This is a somewhat subjective choice. In our experience, taking the tail of an empty list is often a bug, and silently returning a value just means this bug will be discovered later, further from the place where it was introduced. | |
| // It's generally good practice when pattern matching to use `_` for any variables you don't intend to use on the right hand side of a pattern. This makes it clear the value isn't relevant. |
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
| def gen_redis_proto(*cmd) | |
| proto = "" | |
| proto << "*"+cmd.length.to_s+"\r\n" | |
| cmd.each{|arg| | |
| proto << "$"+arg.to_s.bytesize.to_s+"\r\n" | |
| proto << arg.to_s+"\r\n" | |
| } | |
| proto | |
| end |
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
| import threading | |
| def repeatEvery(n, func, *args, **kwargs): | |
| def and_again(): | |
| func(*args, **kwargs) | |
| t = threading.Timer(n, and_again) | |
| t.daemon = True | |
| t.start() | |
| t = threading.Timer(n, and_again) | |
| t.daemon = True |
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
| 015-07-14 17:56:14 TRACE CommonsHttpTransport:186 - Opening HTTP transport to <ip>:9200 | |
| 2015-07-14 17:56:14 ERROR NetworkClient:130 - Node [Invalid target URI HEAD@null/bfdc.error-2015.07.03/fluentd}] failed (<ip>:9200); selected next node [<ip>:9200] | |
| 2015-07-14 17:56:14 TRACE NetworkClient:118 - Caught exception while performing request [<ip>:9200][bfdc.error-2015.07.03/fluentd}] - falling back to the next node in line... | |
| org.elasticsearch.hadoop.rest.EsHadoopTransportException: Invalid target URI HEAD@null/bfdc.error-2015.07.03/fluentd} | |
| at org.elasticsearch.hadoop.rest.commonshttp.CommonsHttpTransport.execute(CommonsHttpTransport.java:393) | |
| at org.elasticsearch.hadoop.rest.NetworkClient.execute(NetworkClient.java:101) | |
| at org.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:317) | |
| at org.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:309) | |
| at org.elasticsearch.hadoop.rest.RestClient.exists(RestClient.java:366) | |
| at org.elasticsearch.hadoop.rest.RestRepository.indexExists(RestReposit |
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
| # -*- encoding: utf-8 -*- | |
| import sys | |
| if len(sys.argv) < 3: | |
| print "usage: %s [start] [end]" % sys.argv[0] | |
| sys.exit(1) | |
| start = int(sys.argv[1]) | |
| end = int(sys.argv[2]) |
OlderNewer