Skip to content

Instantly share code, notes, and snippets.

View upbit's full-sized avatar

Zhou Hao upbit

  • China
View GitHub Profile
@upbit
upbit / deprecated_func.py
Created March 10, 2017 02:32
@deprecated define for Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import warnings
import functools
# http://stackoverflow.com/questions/2536307/decorators-in-the-python-standard-lib-deprecated-specifically
def deprecated(func):
"""This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emmitted
@upbit
upbit / key_binding.json
Created January 7, 2017 02:32
Sublime Text 2/3 Home/End binding for MacOS
[
{
"keys": [ "home" ],
"command": "move_to",
"args": { "to": "bol" }
},
{
"keys": [ "end" ],
"command": "move_to",
"args": { "to": "eol" }
@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;
/****************************************************************
*
# /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 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
@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 / 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 / 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 / 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 / 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