Skip to content

Instantly share code, notes, and snippets.

View liuyix's full-sized avatar

Yi Liu liuyix

View GitHub Profile
@liuyix
liuyix / douban-api-demo.py
Created September 28, 2013 05:59
Simple douban api python demo
# -*- coding=utf-8 -*-
'''
Created on 2011-12-4
@author: liuyix
'''
'''
输入文件格式定义:每行一个isbn,可能有重复,错误的
输出格式:
书名--评分--评分人数--作者--出版社等信息--豆瓣链接--书简介--rawxml
@liuyix
liuyix / addr_filter.py
Last active December 23, 2015 17:18
读取trace,制作访存时序图
#!/usr/bin/env python
#-*- encoding:utf-8 -*-
def addr_filter(pc, addr, collect_stack=False):
if pc is not None and pc <= 0x4fffff:
if (addr > 0x7fff00000000 and collect_stack) \
or (addr <= 0x7fff00000000 and not collect_stack):
return True
return False

设置ssh访问VirtualBox虚拟机

  1. 设置(Host + S) --> 网络 --> 端口转发
  2. 设置内容
Host Port: 5678
Client Port: 22
#去优酷广告
0.0.0.0 stat.youku.com
0.0.0.0 static.lstat.youku.com
0.0.0.0 valb.atm.youku.com
0.0.0.0 valc.atm.youku.com
0.0.0.0 valf.atm.youku.com
0.0.0.0 valo.atm.youku.com
0.0.0.0 valp.atm.youku.com
0.0.0.0 vid.atm.youku.com
0.0.0.0 walp.atm.youku.com
@liuyix
liuyix / shell-script-dir.sh
Last active December 22, 2015 06:39
shell script: 返回当前script所在路径,即使是symlink也可以。
#!/bin/bash
# http://stackoverflow.com/a/422123
# http://stackoverflow.com/questions/242538/unix-shell-script-find-out-which-directory-the-script-file-resides
dir=$(dirname $(readlink -f "$BASH_SOURCE"))
#!/usr/bin/python
#-*- encoding:utf-8 -*-
class ClassTest:
FOO = 'foo'
__bar = 'secret!'
def __init__(self, **args):
self.__dict = {}
self.__dict[ClassTest.FOO] = args[ClassTest.FOO]
self.fill_dict(ClassTest.FOO, **args)
@liuyix
liuyix / file-exists.sh
Last active December 22, 2015 03:18
shell snippet detect file exists by regexp
function exist() {
if [ ! -z $1 ];then
if ls $1 &>/dev/null;then
echo 0
return 0
fi
fi
echo 1
return 1
}
@liuyix
liuyix / make_ext4fs-parameters.md
Created September 2, 2013 03:16
android make_ext4fs parameters

make_ext4fs -l 512M -s -a system system.img ./system

  • -l partition size
  • -s sparse mode 压缩模式,将image文件压缩
  • -a system mount point make_ext4fs会根据private/android_filesystem_config.h里定义好的权限来给文件夹里的所有文件重新设置权限
  • ./system file directory
@liuyix
liuyix / show-filesize.sh
Created September 2, 2013 02:27
shell script print file size
#credit:http://www.cyberciti.biz/faq/bash-csh-sh-check-and-file-file-size/
stat -c %s $file