linux 工具: htop

1.

Similar to the top command, the htop command also shows memory usage along with various other details.

htop memory ram usage

The header on top shows cpu usage along with RAM and swap usage with the corresponding figures.

 

参考: http://www.binarytides.com/linux-command-check-memory-usage/

Domain redirecting to /cgi-sys/defaultwebpage.cgi

1. 当改成nginx后,打开youtube 总是跳转到
http://www.youtube.com/cgi-sys/defaultwebpage.cgi

2.

a) Click the Chrome menu Chrome menu on the browser toolbar.
b) Select Tools.
c) Select Clear browsing data.
d) In the dialog that appears, select the checkboxes for the types
of information that you want to remove.
e) Use the menu at the top to select the amount of data that
you want to delete. Select beginning of time to delete everything.
f) Click Clear browsing data.

解决方法:https://productforums.google.com/forum/#!topic/chrome/BVKcXIvyBCY

wordpress 迁移:从apache2 到 nginx

终于换成nginx了

1.安装FastCgi
sudo apt-get install spawn-fcgi

2. 编辑 /etc/nginx/sites-available/default

server {
 listen 80;

 root /var/www;
 index wordpress/index.php index.php index.html index.htm;

 server_name localhost;

 location / { 
 try_files $uri $uri/ /index.php?q=$uri&$args;
 } 

 location /doc/ {
 alias /usr/share/doc/;
 autoindex on; 
 allow 127.0.0.1;
 deny all;
 } 

location ~ \.php$ {
 include fastcgi_params;
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_index index.php;
 }
}

 

参考:
http://wiki.ubuntu.org.cn/Nginx#.E5.AE.89.E8.A3.85nginx 【主要】

android studio : Failure [INSTALL_FAILED_OLDER_SDK]

参考: http://www.reddit.com/r/androiddev/comments/297xli/howto_use_the_v21_support_libs_on_older_versions/

编辑 build.gradle ,修改minSdkVersion  ,将19改成15,代码如下

apply plugin: ‘com.android.application’

android {
compileSdkVersion 21
buildToolsVersion “21.1.1”

defaultConfig {
applicationId “com.example.chenwei.testexcuteshell”
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName “1.0”
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
}
}
}

dependencies {
compile fileTree(dir: ‘libs’, include: [‘*.jar’])
compile ‘com.android.support:appcompat-v7:21.0.3’
}

注意1: android studio 里有两个build.gradle,如下图,正确的路径是

*Path\Your_Application\app\build.gradle*

Selection_029

Selection_030

 

参考: http://www.4byte.cn/question/234362/android-studio-what-is-the-right-way-to-change-targetsdkversion.html

android studio 使用

问:高亮所有相同变量
答:
OS X : Command+Shift+F7
Windows Or Linux:Ctrl+Shift+F7
Esc可以取消高亮。
—————————————————
问:bookmarks
答:
Toggle Bookmark with Mnemonic(添加/移除带标记的书签): Ctrl +Shift+F11
Show Bookmarks(显示书签列表): Shift + F11
参考:http://2dxgujun.com/post/2014/09/05/Android-Studio-Shortcuts.html [重要]
—————————————————
问:Can’t find “Sync Project with Gradle Files” button in IntelliJ 13.0.1
答:Open Gradle tool window with View -> Tool Windows -> Gradle

参考: http://stackoverflow.com/questions/20815998/cant-find-sync-project-with-gradle-files-button-in-intellij-13-0-1
—————————————————
问:Error:No such property: GROUP for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer
答: Remove this line
apply from: ‘https://raw.github.com/twotoasters/gradle-mvn-push/master/gradle-mvn-push.gradle’

参考:http://stackoverflow.com/questions/28450549/errorno-such-property-group-for-class-org-gradle-api-publication-maven-intern
—————————————————
问:项目导入,出现错误, Gradle DSL method not found: ‘runProguard’
答:minifyEnabled
参考:http://stackoverflow.com/questions/27078075/gradle-dsl-method-not-found-runproguard
—————————————————
问: 不想重新运行app,也可以debug
答: Attach the debugger to a running process
参考:https://developer.android.com/tools/debugging/debugging-studio.html
—————————————————
问:获取SHA1或MD5的方法
答:第一步、打开Android Studio的Tools->Open Terminal…
第二步、输入命令:keytool -v -list -keystore keystore.jks
【一定要记得加上 -v 参数,不然只能看到SHA1,没有MD5】【keystore.jks,需要替换为你自己的密钥所在路径和文件名】
—————————————————
问:debug.keystore 密码 是 android
答:keytool -v -list -keystore ~/.android/debug.keystore
—————————————————
问:remove jar包
答:
Go to 【Project Structure】 > 【Modules】 > 【Your module name】 > Dependencies and click on the + button to add a new dependency. Choose Maven dependency from the list:

smn6g

参考:http://stackoverflow.com/questions/20241765/adding-external-library-in-android-studio-0-3-6

—————————————————
问:加载jar包
答:
1. Put the Gson jar (in my case, gson-2.2.4.jar) into the 【libs】 folder
2. Right click it and hit ‘【Add as library】’
3. Ensure that compile files(‘libs/gson-2.2.4.jar’) is in your 【build.gradle】 file

参考: https://stackoverflow.com/questions/16608135/android-studio-add-jar-as-library/16628496#16628496


—————————————————
问: 自动生产get/set方法
答:方式一:Code–>Generate
方式二:通过快捷键Alt+Insert
—————————————————
问:搜索。。
答:ctrl+n
—————————————————
问: 搜索类中的方法
答:ctrl+F12
—————————————————
问: 设置字体
答:
【File】—-【Settings】—> 【Editor】 –>【 Colors & Fonts】,
in the right side, then click “save as…”, this will create a new Scheme, we name it such as “Custom”, then all fields become to editable, font, space, color, etc.

参考:http://stackoverflow.com/questions/16590216/how-to-increase-the-font-in-android-studio-in-windows-8-or-mac-book-pro-retina
—————————————————
答: 当写代码提示错误时,使用快捷键 alt+Enter

!!!!!!!!!!!【start】!!!!!!

验证码识别 (一) 【TODO】

1.在写12306离线脚本的时候,遇到验证码识别问题

2.花了两天查了下【自动识别验证码】的问题,调试了几个项目,
大体了解原理和简单的实现方式,要建立基本字库,要自己提示算法,
暂时没时间,(TODO),mark一下,以后再深入研究
(mark一下,机器学习,图像分析)

3. 本地识别的方法放弃,使用在线识别验证码,当12306工具遇到验证码的时候,
将验证码图片发送到在线识别平台,等待响应,然后继续运行。

4. pytesseract 能识别数字

参考:http://www.uuwise.com/ 【在线识别验证码】
http://www.cnblogs.com/jmk92/p/3415213.html 【12306Bypass 抢票工具】
http://vipscu.blog.163.com/blog/static/18180837220134234528457/
http://denger.me/2013/03/hack-sina-weibo-verify-code/ 【这个作者是牛人】

12306 抢票软件

1. 用python 模拟登陆12306进行抢票
2. 用旧版的python程序(https://github.com/huzhifeng/py12306)运行时,会出现
“网络繁忙,请您重试。如正在使用第三方购票软件或插件,请卸载后重试”
3. 用新版的程序解决了这个问题(https://github.com/p1o2p3u1/py12306)
4. 用新版的程序有一行比较关键“import PyV8”,需要安装pyv8
(http://code.google.com/p/pyv8/)
$sudo pip install -v pyv8

这个命令运行不成功,中间出现各种问题
5. 后来自己下载源码,编译安装,
参考:http://xwsoul.com/posts/490 [好像是看这篇,忘了]
6. 编译成功后,我在 /path/pyv8/build/lib.linux-x86_64-2.7下
看到两个关键的文件 PyV8.py 和 _PyV8.so
Selection_028

7. 我将PyV8.py 放到项目中, 将_PyV8.so coyp 到 /usr/bin/python2.7/
8. 运行代码,手动输入验证码就能看到登陆信息了
9. 程序跑起来了,后续分析代码,并定制化(TODO)

参考:
http://www.cnblogs.com/russellwang/p/4173873.html#!comments 【代码分析】
https://github.com/huzhifeng/py12306/issues/3 【登陆失败,问题描述】
https://github.com/huzhifeng/py12306 【旧版】
https://github.com/p1o2p3u1/py12306 【新版】

ubuntu install pyv8

1. $sudo pip install -v pyv8

Error: pip unicodedecodeerror ‘ascii’ codec can’t decode byte 0xe2 in position 42 ordinal not in range(128)

2. 更新pip版本
卸载 python-pip (version: 1.5) ,最新 pip 6.0.7

Remove your system wide installation of pip:
$ sudo apt-get purge python-pip
Then install a fresh copy of pip:
$ curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python

参考:
http://unix.stackexchange.com/questions/36710/how-can-i-upgrade-pip-on-ubuntu-10-04
https://pip.pypa.io/en/latest/installing.html

3.
Error:
src/Exception.h:6:16: fatal error: v8.h: No such file or directory
#include
compilation terminated.
解决:缺少 v8 的头文件,因为没有安装 v8 或其开发文件 ,安装 libv8-dev
参考: http://segmentfault.com/q/1010000000307870

4.
Error:
src/Exception.h:16:28: fatal error: boost/python.hpp: No such file or directory
#include <boost/python.hpp>
compilation terminated.
解决:sudo apt-get install libboost-all-dev
参考:http://stackoverflow.com/questions/12578499/how-to-install-boost-on-ubuntu

5. svn proxy

svn checkout http://pyv8.googlecode.com/svn/trunk/ pyv8-read-only
需要设置svn代理

$ sudo vi /etc/subversion/servers
Edit the file:

[Global]
http-proxy-host=127.0.0.1
http-proxy-port=8888

参考:http://stackoverflow.com/questions/82530/svn-over-http-proxy

6.