This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DOMAIN_SUFFIX = ( | |
'.gov.cn', | |
'.com.cn', | |
'.edu.cn', | |
'.net.cn', | |
'.org.cn', | |
) | |
def get_root_domain(domain): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randrange | |
def generateIP(): | |
blockOne = randrange(0, 255, 1) | |
blockTwo = randrange(0, 255, 1) | |
blockThree = randrange(0, 255, 1) | |
blockFour = randrange(0, 255, 1) | |
if blockOne in (10,172, 192): | |
return generateIP() | |
return str(blockOne) + '.' + str(blockTwo) + '.' + str(blockThree) + '.' + str(blockFour) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rq import Queue, Worker, Connection | |
if __name__ == '__main__': | |
with Connection(): | |
q = Queue() | |
Worker(q).work() |
- iPhone Tutorials http://www.raywenderlich.com/tutorials
- Programming with Objective-C https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html
- iCodeBlog http://www.icodeblog.com/tag/beginner/
- coco with love http://www.cocoawithlove.com/
- Try objective-c http://tryobjectivec.codeschool.com/
- iOS Prework http://iosprework.flatironschool.com/
- What are the best resources to learn iOS development? http://www.quora.com/iOS-Development/What-are-the-best-resources-to-learn-iOS-development
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pid_age(){ | |
pid=$1 | |
start=`stat -t /proc/$pid | awk '{print $14}'` | |
now=`date +%s` | |
count=`expr $now - $start` | |
echo $count | |
} | |
pid_age $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KEY_FILE=/root/.ssh/authorized_keys | |
add_ssh_key(){ | |
key=$@ | |
name=`echo $@ | cut -d " " -f3` | |
grep $name $KEY_FILE || { | |
echo "$@" >> $KEY_FILE | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-startup | |
../../../plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar | |
--launcher.library | |
../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.200.v20120913-144807 | |
-product | |
com.android.ide.eclipse.adt.package.product | |
-showsplash | |
com.android.ide.eclipse.adt.package.product | |
--launcher.XXMaxPermSize | |
512m |
参考:
- http://stackoverflow.com/questions/12040880/how-to-avoid-blocking-code-in-python-with-gevent?rq=1
- http://blog.pythonisito.com/2012/07/gevent-and-greenlets.html
- http://blog.pythonisito.com/search/label/gevent
gevent的所有greenlets是在操作系统的同一个进程、同一个线程内运行,所以一些阻塞的操作需要被替换为不阻塞的,这也就是monkey.patch_all()的作用。
spawn一个greenlet之后,它并不立即运行,gevent.sleep() 会yield到下一个greenlet。
gevent.joinall()会等待所有greenlets完成才退出。