Skip to content

Instantly share code, notes, and snippets.

View xjdrew's full-sized avatar
:octocat:

xjdrew xjdrew

:octocat:
View GitHub Profile
@xjdrew
xjdrew / jump_consistent_hash.lua
Created April 21, 2020 03:48
lua version: A Fast, Minimal Memory, Consistent Hash Algorithm
local function jump_consistent_hash(key, num_buckets)
local b = -1
local j = 0
while j < num_buckets do
b = j
key = key * 2862933555777941757 + 1
j = math.floor((b+1) * (1<<31) / ((key>>33) + 1))
end
return b
end
@xjdrew
xjdrew / cloudSettings
Last active November 29, 2021 08:49
vscode settings sync
{"lastUpload":"2021-11-29T08:49:08.133Z","extensionVersion":"v3.4.3"}

build

go build tcpinfo.go

run

./tcpinfo -h
./tcpinfo
@xjdrew
xjdrew / map.cpp
Created August 14, 2020 03:15
hash_map vs lua table
extern "C" {
#include "lua.h"
#include "lauxlib.h"
}
#include <string>
#include <ext/hash_map>
using namespace std;
using namespace __gnu_cxx;