.
βββ main.go
βββ templates
βββ confirmation.html
βββ index.html
This file contains 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 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 |
This file contains 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
# 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 |
This file contains 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 java.io.BufferedReader; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.InputStreamReader; | |
public class Main { | |
/** | |
* ζ₯ιͺ€οΌ | |
* 1. File εε»Ίζδ»Άε₯ζ |
βββ golang-response-snippets.go
βββ images
βΒ Β βββ had.jpg
βββ templates
βΒ Β βββ index.html
βΒ Β βββ layout.html
βΒ Β βββ render_string.html
link: http://www.alexandrejoseph.com/blog/2015-08-21-python-mock-example.html
Directory structure:
pyqueue
βββ README.md
βββ pyqueue
βΒ Β βββ __init__.py
βΒ Β βββ queue.py
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.
This file contains 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
# 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 |
This file contains 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
# 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 |