Skip to content

Instantly share code, notes, and snippets.

View liluo's full-sized avatar
:octocat:
Hey, there ~

liluo liluo

:octocat:
Hey, there ~
View GitHub Profile
Thread-9jnxc
looping.rb:17:in `block (2 levels) in <main>'
\_ looping.rb:15:in `each'
\_ looping.rb:15:in `block in <main>'
\_ looping.rb:22:in `call'
\_ looping.rb:22:in `condition'
\_ looping.rb:26:in `looping'
\_ looping.rb:31:in `<main>'
@liluo
liluo / redis_key_sizes.sh
Created August 29, 2016 12:25 — forked from epicserve/redis_key_sizes.sh
A simple script to print the size of all your Redis keys.
#!/usr/bin/env bash
# This script prints out all of your Redis keys and their size in a human readable format
# Copyright 2013 Brent O'Connor
# License: http://www.apache.org/licenses/LICENSE-2.0
human_size() {
awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print "1kb"; } '
}
@liluo
liluo / intercept-https-with-python-mitmproxy.md
Created April 14, 2016 05:38 — forked from dannvix/intercept-https-with-python-mitmproxy.md
Intercept and manipulate HTTPs traffic with Python and mitmproxy

Intercepts HTTPs Traffic with Python & mitmproxy

Introduction

Modern applications usually make use of back-end API servers to provide their services. With a non-transparent HTTPs proxy, which intercepts the communication between clients and servers (aka the man-in-the-middle scheme), you can easily manipulate both API requests and responses.

This manual helps you create your own proxy with Python and mitmproxy/libmproxy. Mitmproxy ships with both a standalone command-line tool (mitmproxy) and a Python library (libmproxy).

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@liluo
liluo / singleapp.py
Last active August 29, 2015 14:21 — forked from jinuljt/singleapp.py
import fcntl
import time
import sys
lock = file('singleapp.lock', "w+")
try:
fcntl.lockf(lock, fcntl.LOCK_EX|fcntl.LOCK_NB)
except Exception, e:
print "kill me before start again"
@liluo
liluo / pp.py
Created November 20, 2014 03:45
import sys
def pp(msg):
sys.stdout.write("\r")
sys.stdout.write(msg)
sys.stdout.flush()
@liluo
liluo / json2object.py
Last active August 29, 2015 14:06
Utils
from collections import namedtuple
def json2object(data):
"""
>>> json2object("a")
'a'
>>> data = {"a": 100, "b": 200}
>>> obj = json2object(data)
>>> obj.a
@liluo
liluo / python.sh
Last active December 25, 2015 19:19
基本定制型
C.__init__(self[, arg1, ...]) 构造器(带一些可选的参数)
C.__new__(self[, arg1, ...]) 构造器(带一些可选的参数);通常用在设置不变数据类型的子类。
C.__del__(self) 解构器
C.__str__(self) 可打印的字符输出;内建str()及print 语句
C.__repr__(self) 运行时的字符串输出;内建repr() 和‘‘ 操作符
C.__unicode__(self)b Unicode 字符串输出;内建unicode()
C.__call__(self, *args) 表示可调用的实例
C.__nonzero__(self) 为object 定义False 值;内建bool() (从2.2 版开始)
@liluo
liluo / bash.sh
Created July 31, 2013 16:58
在已有 Apache2 的服务器上配置 passenger
passenger-install-apache2-module --auto --apxs2-path=/usr/local/apache2/bin/apxs --apr-config-path=/usr/local/apache2/bin/apr-1-config
@liluo
liluo / graph.rb
Last active December 17, 2015 12:29 — forked from SaitoWu/graph.rb
require 'date'
author = "fenbi"
email = "[email protected]"
date = Date.new(2012, 7, 30)
l = %w{
. . . . . . .
. . o . . . .
. . o . . . .