Skip to content

Instantly share code, notes, and snippets.

View upbit's full-sized avatar

Zhou Hao upbit

  • China
View GitHub Profile
@upbit
upbit / SLNovel2Txt.md
Created March 30, 2015 15:56
转换空之文库(轻国阅读Android)sln文档格式为txt

SLNovel2Txt

转换空之文库(轻国阅读Android)sln文档格式为txt Script to convert Sora.SLNovel to txt

  • 使用方法
  1. 安装Python并下载 slnovel_to_txt.py 到任意文件夹中
@upbit
upbit / cmd.erl
Created June 18, 2015 10:59
erlang cmd.erl
-module(cmd).
%% https://kisao.wordpress.com/2013/12/16/how-to-run-a-system-command-in-erlang/
-export([run/1, run/2, test/0]).
run(Cmd) ->
run(Cmd, 5000).
run(Cmd, Timeout) ->
Port = erlang:open_port({spawn, Cmd},[exit_status]),
@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