Skip to content

Instantly share code, notes, and snippets.

View limboinf's full-sized avatar
🎯
Focusing

limbo limboinf

🎯
Focusing
View GitHub Profile
@limboinf
limboinf / access.lua
Created September 30, 2017 03:31 — forked from mariocesar/access.lua
Nginx Lua script redis based for Basic user authentication
function password_encode(password)
local bcrypt = require 'bcrypt'
return bcrypt.digest(password, 12)
end
function check_password(password, encoded_password)
local bcrypt = require 'bcrypt'
return bcrypt.verify(password, encoded_password)
end
@limboinf
limboinf / Dockerfile
Last active September 29, 2017 08:05
[Docker Ng Lua With China APT Source] #docekr #ng #lua
# Version 0.0.1
FROM ubuntu:14.04
MAINTAINER Beginman "[email protected]"
ARG CHAINA_APT_SOURCE
RUN /bin/bash -c "if [[ ${CHAINA_APT_SOURCE} == ON ]];then sed -i 's#http://archive.ubuntu.com#http://mirrors.163.com#g' /etc/apt/sources.list; fi"
RUN apt-get update
RUN apt-get install -y lua5.1
RUN apt-get install -y liblua5.1-dev
RUN apt-get install -y git
RUN apt-get install -y nginx
@limboinf
limboinf / Main.java
Created September 28, 2017 15:05
[Java File read] #java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
public class Main {
/**
* ζ­₯ιͺ€οΌš
* 1. File εˆ›ε»Ίζ–‡δ»Άε₯ζŸ„
@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