This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# mark dir | |
# add this line to ~/.bashrc: | |
# if [ -f cd_mark ]; then ./cd_mark; fi | |
# usage: func $mark | |
# mls: list all the mark |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'rubygems' | |
require 'json' | |
require 'uri' | |
topicId='DOubanTA' | |
maxCount = 50 | |
# get topic count | |
#response = Net::HTTP.get_response('www.baidu.com', "/index.html"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'win32api' | |
class KeyBoardHelper | |
attr_reader :ctrl, :shift, :alt, :win | |
def initialize | |
@ctrl, @shift, @alt, @win = 0x11, 0x10, 0x12, 0x5b | |
@bScan, @downFlag, @upFlag, @extraInfo = 0x45, 1, 3, 0 | |
@ke = Win32API.new('User32.dll', 'keybd_event', 'IIII') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
""" | |
as bash command: du -sb dir | |
+4906: add 4096bytes for the top dir | |
""" | |
def du_sb(dir): | |
return sum(os.path.getsize(f) for f in reduce(lambda x,y:x+y, [[os.path.join(w[0], fe) for fe in w[1] + w[2]] for w in os.walk(dir)])) + 4096; | |
def get_total_file_size(dir): | |
return sum(os.path.getsize(f) for f in reduce(lambda x,y:x+y, [[os.path.join(w[0], fe) for fe in w[1] + w[2]] for w in os.walk(dir)]) if os.path.isfile(f)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -e $(dirname "$0")/nsenter ]; then | |
# with boot2docker, nsenter is not in the PATH but it is in the same folder | |
NSENTER=$(dirname "$0")/nsenter | |
else | |
NSENTER=nsenter | |
fi | |
if [ -z "$1" ]; then | |
echo "Usage: `basename "$0"` CONTAINER [COMMAND [ARG]...]" | |
echo "" |