Skip to content

Instantly share code, notes, and snippets.

Avatar

Zhou Hao upbit

View GitHub Profile
@upbit
upbit / key_binding.json
Created Jan 7, 2017
Sublime Text 2/3 Home/End binding for MacOS
View key_binding.json
[
{
"keys": [ "home" ],
"command": "move_to",
"args": { "to": "bol" }
},
{
"keys": [ "end" ],
"command": "move_to",
"args": { "to": "eol" }
@upbit
upbit / JumpConsistentHash.cpp
Last active Aug 5, 2016
Google Jump Consistent Hash
View JumpConsistentHash.cpp
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
#include <string>
using namespace std;
/****************************************************************
*
View nginx_go_imaou.conf
# /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 / gitlab_install.md
Last active Feb 12, 2016
Install GitLab CE
View gitlab_install.md

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
@upbit
upbit / qzone_feeds_dump.py
Created Dec 10, 2015
QZone 说说抓取脚本
View qzone_feeds_dump.py
# -*- coding: utf-8 -*-
import os
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
sys.dont_write_bytecode = True
import time
import requests
@upbit
upbit / baidu.py
Created Nov 27, 2015
百度geo反查例子
View baidu.py
#!/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 / api_bridge.ex
Created Oct 21, 2015
Module for rpc call remote api@node functions
View api_bridge.ex
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 / process_info.erl
Last active Oct 10, 2015
Erlang shell scripts for process
View process_info.erl
%% 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 / tiny_json_decoder.py
Last active Aug 29, 2015
使用raw_unicode_escape解析转义过的unicode字符串
View tiny_json_decoder.py
# -*- coding:utf-8 -*- #
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import operator
import urllib
import json
@upbit
upbit / interval_test.py
Created Jul 21, 2015
merge/sub intervals list
View interval_test.py
# -*- 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: