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 os,sys | |
f = open(sys.argv[1], "w") | |
for i in xrange(100000): | |
key = "a%s"%(str(i)) | |
data = "\"local ts = redis.call('lindex', KEYS[1], 1) or -1\\r\\nif tonumber(ARGV[2]) > tonumber(ts) then\\r\\nredis.call('del', KEYS[1])\\r\\nredis.call('rpush', KEYS[1], ARGV[1], ARGV[2])\\r\\nreturn ARGV[1]\\r\\nelse\\r\\nreturn {err='Stale'}\\r\\nend\"" | |
cmd = "EVAL %s %s %s %s %s\n"%(data, 1, key, i, i); | |
f.write(cmd) | |
cmd = "EVAL %s %s %s %s %s\n"%(data, 1, key, i, i+100); | |
f.write(cmd) |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <ctype.h> | |
#include <string.h> | |
#define CR '\r' | |
#define LF '\n' | |
class message { |
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
public class MyList<Element> { | |
public class ElementNode<Element> { | |
Element node; | |
ElementNode<Element> prev,next; | |
public ElementNode() { | |
clear(); | |
} | |
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
-module(list_max). | |
-export([list_max/1]). | |
list_max([Head|Rest]) -> | |
list_max(Head, Rest). | |
list_max(Res, []) -> | |
Res; | |
list_max(Result_so_far, [Head|Rest]) when Head > Result_so_far -> |
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
-module(mylist). | |
-export([append/2, sum/1]). | |
append([H|T], Tail) -> | |
[H] ++ append(T, Tail); | |
append([], Tail) -> | |
[Tail]. | |
sum([H|T]) -> H + sum(T); |
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
package main | |
import ( | |
"fmt" | |
"./tree" | |
) | |
func main() { | |
tree := tree.New() | |
tree.Add(4) |
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
public class MarketUnknownSourceInformation { | |
public static boolean getMarketUnknownSourceInformation() { | |
boolean unknownSource = false; | |
if (Build.VERSION.SDK_INT < 3) { | |
unknownSource = Settings.System.getInt(getContentResolver(), | |
Settings.System.INSTALL_NON_MARKET_APPS, 0) == 1; | |
} else if (Build.VERSION.SDK_INT < 17) { | |
unknownSource = Settings.Secure.getInt(getContentResolver(), | |
Settings.Secure.INSTALL_NON_MARKET_APPS, 0) == 1; | |
} else { |
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 redis | |
import time | |
r = redis.StrictRedis('127.0.0.1', 6379) | |
last_total = 0 | |
while(True): | |
ret = r.info() | |
if (last_total > 0): | |
print "command: ", int(ret["total_commands_processed"]) - last_total | |
print "clients: ", ret["connected_clients"] |
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
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
type SkipListNode struct { | |
level int |
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
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
type UniversalHash struct { | |
table [] byte |
OlderNewer