Skip to content

Instantly share code, notes, and snippets.

View liuyix's full-sized avatar

Yi Liu liuyix

View GitHub Profile
@liuyix
liuyix / learning_argparse.md
Last active December 18, 2015 22:39
Python Tips

Python 命令行参数

Documentation: http://docs.python.org/2.7/library/argparse.html

  • 指定--foo 时内部提供数值或者其他参数: store_const
    • 特殊情况 store_true/store_falsefoo 赋予True/False布尔值
  • 可以参数可以出现多次时:append,类似的还有append_const

Example

@liuyix
liuyix / gist:6019070
Created July 17, 2013 09:20
python sqlite3
We couldn’t find that file to show.
@liuyix
liuyix / select.py
Last active October 21, 2019 06:33
python sqlite3 insert demo
def get_firmware_urls(self):
conn = self.get_connection()
result_cur = conn.execute(Downloader_SQLite.SELECT_CHINA_COMMAND)
print type(result_cur)
#print result_cur.fetchone()
result_list = result_cur.fetchall()
print type(result_list)
# for row in result_cur.fetchall():
# print type(row)
# print row
@liuyix
liuyix / generate_random_by_epoch.py
Created July 18, 2013 08:24
Python 根据时间生成随机数
import time
rand = int(time.mktime(time.gmtime()))
@liuyix
liuyix / seandroid.md
Last active December 20, 2015 04:09
SE for Android
@liuyix
liuyix / octopress-clone-guide.md
Last active December 20, 2015 06:58
octopress different places

Credit: Clone Your Octopress to Blog From Two Places

原理

每个octopress建立的静态站点的结构是(假定octopress目录为 $octopress):

  • $octopress 是 username.github.com的source分支
  • $octopress/_deploy 是 username.github.com的master分支

部署步骤

@liuyix
liuyix / python-distribution.md
Created August 5, 2013 05:41
Python program distribution
#define LOGE(fmt,args...) fprintf(stderr, fmt, ##args)
#define LOGD(fmt,args...) fprintf(stderr, fmt, ##args)
#define LOGW(fmt,args...) fprintf(stderr, fmt, ##args)
#include <errno.h>
#include <string.h>
#define PLOGE(fmt,args...) LOGE(fmt " failed with %d: %s", ##args, errno, strerror(errno))
#define PLOGEV(fmt,err,args...) LOGE(fmt " failed with %d: %s", ##args, err, strerror(err))
@liuyix
liuyix / yank_select.md
Created August 13, 2013 03:21
emacs Cut, Copy, and Paste

copy/cut多个文本,可以通过 C-y 粘贴,之后通过多次 M-y 逐个选择

@liuyix
liuyix / gist:6217694
Created August 13, 2013 03:37
PF_UNIX, AF_UNIX, PF_LOCAL, AF_LOCAL
http://blog.csdn.net/qiaoliang328/article/details/4722377
http://alas.matf.bg.ac.rs/manuals/lspe/snode=38.html