This file contains hidden or 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
| #!/bin/bash | |
| # update_gfwlist.sh | |
| # Author : VincentSit | |
| # Copyright (c) http://xuexuefeng.com | |
| # | |
| # Example usage | |
| # | |
| # ./whatever-you-name-this.sh | |
| # | |
| # Task Scheduling (Optional) |
This file contains hidden or 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
| import socket | |
| HOST, PORT = '', 8000 | |
| listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | |
| listen_socket.bind((HOST, PORT)) | |
| listen_socket.listen(1) | |
| print 'Serving HTTP on port %s ...' % PORT | |
| while True: |
This file contains hidden or 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 datetime import datetime | |
| @app.template_filter() | |
| def natural_time(dt, default="just now"): | |
| """ | |
| Returns string representing "time since" e.g. | |
| 3 days ago, 5 hours ago etc. | |
| """ | |
| now = datetime.utcnow() |
This file contains hidden or 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
| #include <iostream> | |
| using namespace std; | |
| int main() | |
| { | |
| unique_ptr<int> up1(new int(10)); // 不能复制的unique_ptr | |
| // unique_ptr<int> up2 = up1; // 这样是错的 | |
| cout<<*up1<<endl; | |
| unique_ptr<int> up3 = move(up1); // 现在up3是数据唯一的unique_ptr智能指针 |
This file contains hidden or 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
| #include<stdio.h> | |
| #include <cstdlib> | |
| int main() | |
| { | |
| int *ptr_one; | |
| ptr_one = (int *)malloc(sizeof(int)); | |
| if (ptr_one == 0) |
This file contains hidden or 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
| #! /usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # @Last Modified time: 2016-07-04 19:58:30 | |
| from greenlet import greenlet | |
| def test1(): | |
| print "gr1 ", greenlet.getcurrent() |
This file contains hidden or 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
| #! /usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # @Last Modified time: 2016-06-28 10:50:58 | |
| import urllib2 | |
| import time | |
| from threading import Thread | |
| # 在大量访问url的时候,多线程很有优势,实际上也是空间换时间 | |
| URLs = ["http://www.baidu.com", |
This file contains hidden or 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
| #! /usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # @Last Modified time: 2016-06-27 17:03:42 | |
| import requests | |
| import os | |
| def get_speed_test(src_path, result_path, timeout=10): | |
| all_sites = _get_sites_(src_path) | |
| results = [] |
This file contains hidden or 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
| #! /usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # @Last Modified time: 2016-06-27 17:03:25 | |
| from gevent import monkey | |
| monkey.patch_all() | |
| import time | |
| import requests | |
| from lxml import html as HTML | |
| import gevent | |
| from os.path import isfile |