Skip to content

Instantly share code, notes, and snippets.

View pfctgeorge's full-sized avatar

Jianjin Fan pfctgeorge

  • Amazon
  • Toronto, Canada
  • 23:28 (UTC -04:00)
View GitHub Profile
@pfctgeorge
pfctgeorge / add_and_commit
Created March 29, 2014 17:23
add and commit every file in a directory separately
import os
from subprocess import check_call
filenames = list(os.walk("."))[0][2]
for filename in filenames:
if filename.endswith(".java"):
classname = filename.partition(".java")[0]
check_call(["git", "add", filename])
diff --git a/Gemfile b/Gemfile
index 195de7b..84bb745 100644
--- a/Gemfile
+++ b/Gemfile
@@ -164,7 +164,7 @@ gem "jquery-ui-rails", "2.0.2"
gem "raphael-rails", "~> 2.1.2"
gem 'bootstrap-sass', '~> 3.0'
gem "font-awesome-rails", '~> 3.2'
-gem "gitlab_emoji", "~> 0.0.1.1"
+gem "gemoji", "~> 1.3.0"
@pfctgeorge
pfctgeorge / pre-receive
Last active November 23, 2015 12:21
Git hooks
#!/env/python
# coding: utf-8
from subprocess import check_output, PIPE, Popen
import sys
import re
BADREV = "0000000000000000000000000000000000000000"
@pfctgeorge
pfctgeorge / flume.md
Last active August 29, 2015 14:04
Flume operation
  1. 明确哪个agent出现了问题。
  2. 查看这个agent的哪个channel发生了问题。
  3. ps aux | grep <这个agent的名字>kill -15 <pid> 停掉这个agent。
  4. 确认agent停掉后(ps aux | grep不到),调大对应agent中对应channel的sink.batchSize,但不能>=2000。配置文件位置:~/local/flume/flume-ng/conf/<agent>/<pkg_name>.properties
  5. cat ~/local/flume/flume-ng/start.sh后,找到对应agent的启动命令。比如Main的agent:nohup bin/flume-ng agent --conf conf/main --conf-file conf/main/Main.properties --name Main -Dflume.monitoring.type=http -Dflume.monitoring.port=30005 > /dev/null 2>&1 </dev/null &
  6. 用这个命令启动这个agent。
@pfctgeorge
pfctgeorge / Problem 2.md
Last active August 29, 2015 14:06
Algorithms

(a)

  • ExtractMin: 堆顶元素依然是最小值,取出后Heapify一次。时间复杂度:O(logdn*d(注意logdn中d是底数)
  • DecreaseKey:减少一个节点的值可能使这个值比它的父亲更小,需要递归的与它当前的父亲比较和交换,直到当前父亲的值更小。时间复杂度O(logdn)
  • Heapify:比较当前子堆的堆顶是否比它的儿子小,若不是就将它最小的儿子交换,递归下去。时间复杂度:O(logdn*d)
@pfctgeorge
pfctgeorge / main.py
Last active August 29, 2015 14:10
intensity
import csv
import os
class M15(object):
'''Every 15mins data'''
def __init__(self):
self.size = 0