Skip to content

Instantly share code, notes, and snippets.

@omigo
omigo / inthash.c
Created January 5, 2018 02:26 — forked from lh3/inthash.c
Invertible integer hash functions
/*
For any 1<k<=64, let mask=(1<<k)-1. hash_64() is a bijection on [0,1<<k), which means
hash_64(x, mask)==hash_64(y, mask) if and only if x==y. hash_64i() is the inversion of
hash_64(): hash_64i(hash_64(x, mask), mask) == hash_64(hash_64i(x, mask), mask) == x.
*/
// Thomas Wang's integer hash functions. See <https://gist.github.com/lh3/59882d6b96166dfc3d8d> for a snapshot.
uint64_t hash_64(uint64_t key, uint64_t mask)
{
key = (~key + (key << 21)) & mask; // key = (key << 21) - key - 1;
@omigo
omigo / consumer.sh
Created July 21, 2017 08:29 — forked from dongjinleekr/consumer.sh
Kafka benchmark commands
## Consumer Throughput: Single consumer thread, no compression
## Consumer Throughput: 3 consumer thread, no compression
bin/kafka-consumer-perf-test.sh --topic benchmark-3-3-none \
--zookeeper kafka-zk-1:2181,kafka-zk-2:2181,kafka-zk-3:2181 \
--messages 15000000 \
--threads 1
@omigo
omigo / 在线预览本地图片.html
Created July 29, 2016 03:55 — forked from yangsaipp/在线预览本地图片.html
在线预览本地图片,html5
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>本地图片在线预览</title>
</head>
<body>
<script type="text/javascript">
var result=document.getElementById("result");
var file=document.getElementById("file");
@omigo
omigo / inthash.md
Last active August 29, 2015 14:24 — forked from badboy/inthash.md