爬虫抓取问题

2013年6月05日 13:59

前几天把我经常看的一些视频和小说用Nokogiri抓了下,感觉Nokogiri还挺好用。不过刚放上去了一天,服务器的CPU和内存以及IO全部报警,最开始以为是代码写的有问题。逐行查了一遍,发现没问题。后来意识到可能是Whenever的抓取间隔时间太短了,初始设置为2分钟一次,当时写的时候,只抓一个网站,2分钟内完全能抓完,后来又加了几个网站,2分钟就抓不完了,结果就一直堵塞了。后来只能重启服务器,把时间间隔改为1小时抓一次,现在运行OK。

继续阅读 »

判断手机有没有被root

2013年5月31日 16:53

原文链接

http://code.google.com/p/roottools/

if (RootTools.isRootAvailable()) {
    // your app has been granted root access
}
if (RootTools.isAccessGiven()) {
    // your app has been granted root access
}

继续阅读 »

whenever执行时一直报错

2013年5月29日 21:35

在rails项目中使用使用whenever时,一直报各种找不到命令,如:zsh: command not found: Gemfile,等等等。。。。。。
查了好多资料,一直没解决,今天在unbuntu上新建了一个空项目能正常使用,于是把笔记本上的项目拷到ubuntu上,还是报错,/usr/bin/env :ruby.exe 找不到指令或文件,最开始没注意到,后来一看,ubuntu上怎么会用到exe?于是网上又查找,把项目中/script/rails文件中的#!/usr/bin/env ruby.exe修改成#!/usr/bin/env ruby,果然好了。原来的项目是在windows下生成的,所以才会有这种问题。真尼玛。
Mac上的项目执行whenever还是报错env: ruby: No such file or directory,不过手动执行脚本可以运行。
于是把/script/rails中的#!/usr/bin/env ruby 改成了 #!/Users/username/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
Mac上也可以运行了。

继续阅读 »

登陆时增加了验证码

2013年5月29日 16:00

效果图如下

继续阅读 »

这段时间记录的一些杂七杂八的笔记

2013年5月28日 17:06

ruby代码

1.upto 10 do |i|
    puts i if i==3..i==5
end

sql代码

--方法1 慢。。。。。
select postby,(select count(*) from articles where status=1 and postby=ar.postby) as art_num,(select count(*) from articles where status=1 and isgood=1 and postby=ar.postby) as goodart_num,title from articles as ar group by postby order by goodart_num desc,art_num desc limit 10

--方法2 快。。。。。
select postby,sum(case when status=1 then 1 else 0 end) as art_num,sum(case when status=1 and isgood=1 then 1 else 0 end) as goodart_num,title from articles group by postby order by goodart_num desc,art_num desc limit 10;

继续阅读 »

What's the difference between .bashrc, .bash_profile

2013年5月28日 10:26

/bin/bash
       The bash executable
/etc/profile
       The systemwide initialization file, executed for login shells
~/.bash_profile
       The personal initialization file, executed for login shells
~/.bashrc
       The individual per-interactive-shell startup file
~/.bash_logout
       The individual login shell cleanup file, executed when a login shell exits
~/.inputrc
       Individual readline initialization file

继续阅读 »

Python and MongoDB: A Quick Reference to PyMongo

2013年5月23日 11:09

Installing the MongoDB Library

$ easy_install pymongo
or
# sudo easy_install pymongo

Importing the MongoDB Library

from pymongo import MongoClient

Connecting to MongoDB

client = MongoClient("192.168.1.1", 27017)

Selecting a Database

client = MongoClient("192.168.1.1", 27017)
db_instance = client["database_name"]

继续阅读 »

博客皮肤换了~哈哈

2013年4月08日 22:26

把博客新整了下

旧版:

新版:

继续阅读 »

The 100 Words That Will Get You Hired Anywhere

2013年3月07日 11:08

You should hire me because I will work harder than anyone else you’re going to talk to. On Sunday evenings I process all of my email and write out my goals for the week. I show up an hour before everyone else each morning to make the coffee and get my most important task for the day done. I spend as many lunches and breakfasts as possible with prospective or current clients. And I take the local train instead of the express so I can write thank you cards or notes to clients. That’s why you should hire me.

继续阅读 »

个人博客终于上线了

2013年3月06日 00:56

个人博客终于上线了,以后可以在这上边记一些东西了。

继续阅读 »