start new:
tmux
start new with session name:
tmux new -s myname
| #include <stdio.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| #define OK 1 | |
| #define ERROR 0 | |
| #define TRUE 1 | |
| #define FALSE 0 | |
| #define MAXSIZE 40 /* 存储空间初始分配量 */ |
| // | |
| // Created by 方朋 on 2017/1/6. | |
| // | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <math.h> | |
| #define OK 1 | |
| #define ERROR 0 | |
| #define TRUE 1 |
| // | |
| // Created by 方朋 on 2017/1/4. | |
| // | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #define OK 1 | |
| #define ERROR 0 |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| """ | |
| :Author: beginman.cn | |
| :Mail: [email protected] | |
| :Created Time: 2017-02-07 16:16:36 | |
| :Last modified: 2017-02-07 16:16:36 | |
| :Copyright: (c) 2016 by beginman. | |
| :License: MIT, see LICENSE for more details. | |
| """ |
| # coding=utf-8 | |
| """ | |
| desc.. | |
| :copyright: (c) 2016 by fangpeng(@beginman.cn). | |
| :license: MIT, see LICENSE for more details. | |
| """ | |
| import hmac | |
| import hashlib | |
| import base64 | |
| import redis |
| # coding=utf-8 | |
| import logging | |
| from logging.handlers import RotatingFileHandler | |
| from flask import Flask, request, jsonify | |
| from flask_sqlalchemy import get_debug_queries | |
| from ext import db | |
| from users import User |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.
link: http://www.alexandrejoseph.com/blog/2015-08-21-python-mock-example.html
Directory structure:
pyqueue
├── README.md
├── pyqueue
│ ├── __init__.py
│ ├── queue.py├── golang-response-snippets.go
├── images
│ └── had.jpg
├── templates
│ ├── index.html
│ ├── layout.html
│ └── render_string.html