Example inputs:
Variable | Value |
---|---|
key | the shared secret key here |
message | the message to hash here |
Reference outputs for example inputs above:
| Type | Hash |
[ | |
{ | |
"USD" : { | |
"symbol" : "$", | |
"name" : "US Dollar", | |
"symbol_native" : "$", | |
"decimal_digits" : 2, | |
"rounding" : 0, | |
"code" : "USD", | |
"name_plural" : "US dollars" |
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.
# Redis Cheatsheet | |
# All the commands you need to know | |
redis-server /path/redis.conf # start redis with the related configuration file | |
redis-cli # opens a redis prompt | |
# Strings. |
package main | |
import ( | |
"bytes" | |
"crypto/aes" | |
"crypto/cipher" | |
b64 "encoding/base64" | |
"errors" | |
"fmt" | |
"log" |
These are the Kickstarter Engineering and Data role definitions for both teams.
var async = require('async'); | |
module.exports = waitFor; | |
/** | |
* waitFor port used with | |
* @see {@link https://github.com/ariya/phantomjs/blob/master/examples/waitfor.js} | |
* @see {@link https://github.com/sgentle/phantomjs-node} | |
* @callback testFx - Test function, will repeat until true or timeout limit is reached | |
* @callback onReady - Fires if/when `testFx` passes. |
var page = require('webpage').create(); | |
var url = 'http://phantomjs.org/quick-start.html'; | |
//SPECIFY VIEWPORT SIZE OF THE SCREENCAPTURE | |
page.viewportSize = { | |
width: 1280, | |
height: 900 | |
}; |