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
| #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
| #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
| 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
| 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
| #!/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
| # Tested with Python 2.7.9, Linux & Mac OS X | |
| import socket | |
| import StringIO | |
| import sys | |
| class WSGIServer(object): | |
| address_family = socket.AF_INET | |
| socket_type = socket.SOCK_STREAM |
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> | |
| #include <fstream> | |
| #include <cmath> | |
| #include <vector> | |
| #include <algorithm> | |
| using namespace std; | |
| //ifstream in_file("/Users/feizhao/Desktop/A-small-practice.in"); | |
| ifstream in_file("/Users/feizhao/Desktop/A-large-practice.in"); | |
| //ifstream in_file("/Users/feizhao/Desktop/demo.in"); |
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
| $(function() { | |
| var fix = $('#toc'); //滚动悬浮块 | |
| var fixTop = fix.offset().top, //滚动悬浮块与顶部的距离 | |
| fixHeight = fix.height(); //滚动悬浮块高度 | |
| $(window).scroll(function() { | |
| $(":header").each(function() { | |
| var id = $(this).attr('id'); | |
| // 跳过标题 | |
| if (typeof id != 'undefined'){ |