Skip to content

Instantly share code, notes, and snippets.

View limboinf's full-sized avatar
🎯
Focusing

limbo limboinf

🎯
Focusing
View GitHub Profile
@limboinf
limboinf / READEME.md
Created April 8, 2017 02:57
Form Validation and Processing in Go
.
├── main.go
└── templates
    ├── confirmation.html
    └── index.html
@limboinf
limboinf / READEME.md
Last active April 6, 2017 15:33
A snippet collection illustrating some common HTTP responses for Go web applications.
├── golang-response-snippets.go
├── images
│   └── had.jpg
├── templates
│   ├── index.html
│   ├── layout.html
│   └── render_string.html
@limboinf
limboinf / READEME.md
Created April 6, 2017 03:09
Python mock

Scaling your API with rate limiters

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.

Request rate limiter

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.

@limboinf
limboinf / tmux-cheatsheet.markdown
Created March 27, 2017 08:00 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@limboinf
limboinf / app_with_sqlalchemy.py
Created March 5, 2017 03:22
Mysql SLow Query for Flask.
# 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
@limboinf
limboinf / __init__.py
Created February 8, 2017 09:10
Api Key + Security Key + Sign.
# 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
@limboinf
limboinf / auth-token-api.py
Last active February 8, 2017 08:56
Flask 实现简单的Restful APi
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
:Author: beginman.cn
:Mail: pythonsuper@gmail.com
: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.
"""
@limboinf
limboinf / 二叉树链式存储与遍历.c
Created January 18, 2017 04:14
重点就是:递归和链表的运用。
//
// Created by 方朋 on 2017/1/4.
//
#include <stdio.h>
#include <stdlib.h>
#define OK 1
#define ERROR 0
@limboinf
limboinf / 二叉树之顺序存储.c
Created January 17, 2017 15:08
顺序存储,代码中有几个TODO需要搞明白。
//
// Created by 方朋 on 2017/1/6.
//
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define OK 1
#define ERROR 0
#define TRUE 1