Intelligence without ambition is a bird without wings.

2014-12-03
python解析x-www-form-urlencoded数据

代码

  • urlencodedstring
1
2
3
query_string = 'access_token=CB4C8F99D9B3E4AD376E7CF179CFA470&expires_in=7776000&refresh_token=4CCB49CAD66A9506F0621CE8E427F492'
data = urlparse.parse_qs(query_string)
access_token = data['access_token'][0]
  • dicturlencoded
1
2
params = {'criterias[]': ['member', 'issue']}
urllib.urlencode(params, True)

参考

  1. https://docs.python.org/2/library/urlparse.html
阅读此文

2014-12-02
yed使用技巧

  • 让【节点】自适应【标签】

    Tool => Fit Node to Label
    
阅读此文

2014-12-01
ssh常见问题

  • Could not open a connection to your authentication agent.

    eval “$(ssh-agent)”

参考

  1. http://unix.stackexchange.com/questions/48863/ssh-add-complains-could-not-open-a-connection-to-your-authentication-agent
阅读此文

2014-12-01
python管理拓展包

pip提供python的包管理操作

安装

  • 下载安装脚本get-pip.py

  • python get-pip.py

  • win下添加C:\Python27-32\ScriptsPATH

使用

  • 安装

    pip install PACKET_NAME
    

参考

  1. https://pip.pypa.io/en/latest/installing.html
阅读此文

2014-12-01
替换clover图标

  • 使用ResHacker打开clover.dll

  • 【操作】=>【替换图标】=> 【选择要替换的图标】=>101

阅读此文

2014-12-01
快速查看python帮助

第一种:命令行使用

python -m pydoc CONTENT

第二种:使用python自包装

作用

可以在任意路径下执行pydoc CONTENT

步骤

  • 建立脚本文件pydoc.py

    #!/usr/bin/env python
    # encoding: utf-8
    
    import os
    import sys
    
    if len(sys.argv) != 2:
        print("usage:pydoc.py OBJECT")
        exit(1)
    
    cmd = 'python -m pydoc ' + sys.argv[1]
    # print(cmd)
    os.system(cmd)
    
  • 复制到PATH目录下

    建议自建目录(Win:X:/XXX/bin,Linux:/XXX/bin),添加该目录到PATH

    优点:

    1. 容易管理
    2. 重装系统或系统损坏,不丢失,下次复用方便
  • 【Windows建议】

修改环境变量PATHEXT追加.py,这样直接使用pydoc CONTENT即可,不用每次都输入’.py’!

阅读此文

2014-12-01
windows下git生成SSH公钥

步骤

  • cd %HOMEPATH%

  • mkdir .ssh

  • ssh-keygen -t rsa -C "qian_cheng_long@163.com"

    • 输入生成文件名(.ssh/rd_rsa)
    • 2次输入密码(空密码可以方便连接)
  • 添加到ssh-agent

    ssh-agent -s
    ssh-add ~/.ssh/id_rsa
    
  • 复制到粘贴板

    clip < ~/.ssh/id_rsa.pub
    
  • .ssh/rd_rsa.pub内容添加到github

  • 测试是否添加成功

    ssh -vT git@github.com
    

参考

  1. https://help.github.com/articles/generating-ssh-keys/
阅读此文

2014-12-01
MinGW编译wxWidget

  • WXWIN:源代码根目录
  1. 解压源码

  2. 进入到%WXWIN%\build\msw

  3. 清理项目

    mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=release clean
    
  4. 编译

  • 动态库,发行版

    mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=release
    
  • 动态库,调试版

    mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=debug
    
  • 静态库,发行版

    mingw32-make -f makefile.gcc SHARED=0 UNICODE=1 BUILD=release
    
  • 静态库,调试版

    mingw32-make -f makefile.gcc SHARED=0 UNICODE=1 BUILD=debug
    

    :

    1. 可以添加-j N(N指当前CPU核心数),加快编译速度

    2. 每种版本可以根据需要编译

    3. 动态库对应的目录(%WXWIN%\lib\gcc_dll),静态库对应的目录(%WXWIN%\lib\gcc_lib)

    4. Debug版的库名称会有d后缀,UNICODE版的库名称会有u后缀

阅读此文

2014-12-01
hexo博客添加图片

markdown中,插入图片的语法为:

![图片名称](链接地址)
阅读此文

2014-11-11
log4cpp编译安装

下载

官网

编译

  • 解压
  • 找到对应工程配置文件(vs2010:msvc10)
  • 打开msvc10.sln
  • 生成log4cppLIB(静态库版本),debug版和release版
  • 新建目标目录如log4cpp-1.1.1
  • include目录复制到目标目录下
  • 将生成的lib(log4cppD.lib,log4cppLIB.lib)放到目标目录的子目录lib

最终目录结构:

└─log4cpp-1.1.1
    ├─include
    │  └─log4cpp
    │
    └─lib

配置解决方案属性

  • 【VC++目录】,添加include目录和lib目录
  • Debug版,添加【附加依赖项】,log4cppD.lib
  • Release版,添加【附加依赖项】,log4cppLIB.lib
阅读此文