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
/** | |
* Fancy ID generator that creates 20-character string identifiers with the following properties: | |
* | |
* 1. They're based on timestamp so that they sort *after* any existing ids. | |
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs. | |
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly). | |
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the | |
* latter ones will sort after the former ones. We do this by using the previous random bits | |
* but "incrementing" them by 1 (only in the case of a timestamp collision). | |
*/ |
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
# Get root: | |
sudo su | |
# Install prerequisites: | |
apt-get install build-essential pkg-config checkinstall git avahi-daemon libavahi-client-dev libcrack2-dev libwrap0-dev autotools-dev automake libtool libdb-dev libacl1-dev libdb5.1-dev db-util db5.1-util libgcrypt11 libgcrypt11-dev | |
# Build libevent from source: | |
cd /usr/local/src |
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
pt-BR: | |
devise: | |
confirmations: | |
confirmed: "Sua conta foi confirmada com sucesso. Você está logado." | |
send_instructions: "Dentro de minutos você receberá um e-mail com instruções para confirmar a sua conta." | |
send_paranoid_instructions: "Caso seu e-mail exista em nossa base, você receberá um e-mail em poucos minutos com instruções sobre como confirmar sua conta." | |
failure: | |
already_authenticated: "Você já está logado." | |
inactive: "A sua conta não foi ativada ainda." | |
invalid: "E-mail ou senha inválidos." |
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
module Facebook | |
# | |
# Facebook request tools | |
# | |
class Request | |
class << self | |
def parse_signed_request(signed_request, secret, max_age=3600) | |
encoded_sig, encoded_envelope = signed_request.split('.', 2) | |
envelope = JSON.parse(base64_url_decode(encoded_envelope)) | |
algorithm = envelope['algorithm'] |
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
#!/usr/bin/env ruby | |
#-*- coding: utf-8 -*- | |
def √(n) | |
Math::sqrt(n) | |
end | |
class Numeric | |
def ±(n) | |
r = [self + n, self - n] |