Skip to content

Instantly share code, notes, and snippets.

View upbit's full-sized avatar

Zhou Hao upbit

  • China
View GitHub Profile
@upbit
upbit / cassandra_dump.py
Created July 15, 2015 09:07
dump big cassandra table
# -*- coding:utf-8 -*- #
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import codecs
try:
import cassandra
@upbit
upbit / interval_test.py
Created July 21, 2015 14:23
merge/sub intervals list
# -*- coding:utf-8 -*- #
def merge(lists):
sorted_list = sorted(lists)
result = []
(tmp_start, tmp_end) = sorted_list[0]
for (start, end) in sorted_list:
if tmp_end >= start:
tmp_end = max(tmp_end, end)
else:
@upbit
upbit / tiny_json_decoder.py
Last active August 29, 2015 14:28
使用raw_unicode_escape解析转义过的unicode字符串
# -*- coding:utf-8 -*- #
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import operator
import urllib
import json
@upbit
upbit / process_info.erl
Last active October 10, 2015 12:05
Erlang shell scripts for process
%% message_queue_len
lists:sublist(lists:sort(fun(R1,R2) -> proplists:get_value(message_queue_len,R1,0) > proplists:get_value(message_queue_len,R2,0) end,
lists:filtermap(fun(Pid) -> case erlang:process_info(Pid) of undefined -> false; R -> {true, R} end end,
erlang:processes())), 10).
%% reductions
lists:sublist(lists:sort(fun(R1,R2) -> proplists:get_value(reductions,R1,0) > proplists:get_value(reductions,R2,0) end,
lists:filtermap(fun(Pid) -> case erlang:process_info(Pid) of undefined -> false; R -> {true, R} end end,
erlang:processes())), 10).
@upbit
upbit / api_bridge.ex
Created October 21, 2015 09:39
Module for rpc call remote api@node functions
defmodule ApiBridge do
@moduledoc """
Module for rpc call remote api@node functions.
"""
@defualt_rpc_timeout 3000
@doc """
rpc macro for api call
"""
defmacro rpc(exp, timeout \\ @defualt_rpc_timeout) do
@upbit
upbit / baidu.py
Created November 27, 2015 10:25
百度geo反查例子
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
sys.dont_write_bytecode = True
import urllib
import hashlib
@upbit
upbit / qzone_feeds_dump.py
Created December 10, 2015 12:26
QZone 说说抓取脚本
# -*- coding: utf-8 -*-
import os
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
sys.dont_write_bytecode = True
import time
import requests
@upbit
upbit / gitlab_install.md
Last active February 12, 2016 09:35
Install GitLab CE

https://about.gitlab.com/downloads/#ubuntu1404

* apt-get install curl openssh-server ca-certificates postfix

* curl -LJO https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/trusty/gitlab-ce_8.4.4-ce.0_amd64.deb/download
* dpkg -i gitlab-ce_8.4.4-ce.0_amd64.deb

* gitlab-ctl reconfigure
# /etc/nginx/sites-enabled/go_imaou.conf
server {
listen 80;
server_name go.imaou.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:32181;
}
}
@upbit
upbit / JumpConsistentHash.cpp
Last active August 5, 2016 08:22
Google Jump Consistent Hash
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
#include <string>
using namespace std;
/****************************************************************
*