Skip to content

Instantly share code, notes, and snippets.

# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="agnoster"
# Example aliases

grep -rn notify_friend_timeline* action.log.* | grep -C 2 2014-06-11 | grep -C 2 790894974407517218

Each of our IDs consists of:

41 bits for time in milliseconds (gives us 41 years of IDs with a custom epoch) 13 bits that represent the logical shard ID 10 bits that represent an auto-incrementing sequence, modulus 1024. This means we can generate 1024 IDs, per shard, per millisecond Let’s walk through an example: let’s say it’s September 9th, 2011, at 5:00pm and our ‘epoch’ begins on January 1st, 2011. There have been 1387263000 milliseconds since the beginning of our epoch, so to start our ID, we fill the left-most 41 bits with this value with a left-shift:

id = 1387263000 << (64-41)

Next, we take the shard ID for this particular piece of data we’re trying to insert. Let’s say we’re sharding by user ID, and there are 2000 logical shards; if our user ID is 31341, then the shard ID is 31341 % 2000 -> 1341. We fill the next 13 bits with this value:

curl -O -L 'http://us2.dl.carbon-rom.com/files/hammerhead/nightly/CARBON-KK-NIGHTLY-20140220-0349-hammerhead.zip' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Connection: keep-alive' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Referer: http://carbon-rom.com/downloads/?device=hammerhead&type=nightly&country=CN' -H 'Accept-Language: en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,zh-TW;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1838.2 Safari/537.36' --compressed
@xiocode
xiocode / gist:9088935
Last active August 29, 2015 13:56
Hadoop安装
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
export CLASSPATH=.:$JAVA_HOME/lib
export HADOOP_HOME=/home/docker/hadoop
export HIVE_HOME=/home/docker/hive
export PATH=$JAVA_HOME/bin:$HADOOP_HOME/bin:$HIVE_HOME/bin:$PATH

Hadoop配置文件 https://github.com/xiocode/playground

@xiocode
xiocode / gist:8997143
Last active August 29, 2015 13:56
docker note
先删除运行的image
sudo docker ps -a | grep Exit | awk '{print $1}' | sudo xargs docker rm
然后删除docker images下不用的
var Pages = mongoose.model('pages', pagesChema)
var contents = new Array()
Pages.find(function (err, pages) {
for (var i = 0; i < pages.length; i++) {
contents[i] = new Array()
var page = pages[i]
console.log(page)
contents[i][0] = {"value": "", "formatCode": "General"}
contents[i][1] = {"value": "vipabc", "formatCode": "General"}
contents[i][2] = {"value": page.createdat, "formatCode": "General"}
{
"autocomplete_closures": true,
"autocomplete_builtins": true,
"autocomplete_suggest_imports": true,
"use_named_imports": true,
"fmt_cmd": ["goimports"],
"env":{
"GOROOT": "/Users/shao/Developer/go",
"GOPATH": "/Users/shao/Developer/workspace"
}
@xiocode
xiocode / gist:8267527
Created January 5, 2014 12:13
.zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="agnoster"
# Example aliases