View gmail_sender.rb
require 'pony'
Use gmail's smtp server to send email:
1. Turn on 2-Step Verification (see
2. Sign in using App Passwords (see
or alternative method:
1. Turn off 2-Step Verification (see
2. Allow less secure apps:
from flask import Flask, send_from_directory
app = Flask(__name__)
def base_static(filename):
return send_from_directory(app.root_path + '/../static/', filename)
View nginx-default-conf
vim `/etc/nginx/sites-available/default`
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
View test-cssom.js
const css = require('css');
const crypto = require('crypto');
const assert = require('assert');
var style = `.foo {
color: green;
.bar {
color: red;
View Shadow-DOM.html
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Shadow DOM</title>
span {
color: green;
View kvs.erl
%% API
-export([start_link/0, store/2, lookup/1]).
%% gen_server callbacks
View method_missing.erl
'$handle_undefined_function'(Func, Args) ->
io:format("Called undefined function '~p' with args ~p.~n", [Func, Args]).
View stackexchange.txt
- Format: 7zipped
- Files:
- **badges**.xml
- UserId, e.g.: "420"
- Name, e.g.: "Teacher"
- Date, e.g.: "2008-09-15T08:55:03.923"
- **comments**.xml
- Id
- PostId
- Score
View translation.erl
-module (translation).
-export ([get_translation/1]).
get_translation(Word) ->
io:format("~p ~n", [Word]),
{ok, RequestId} = httpc:request(get, {"" ++ Word, []}, [], [{sync, false}]),
{http, {RequestId, Result}} ->
io:format("~p ~n", [Result])

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.