This document is divided into 2 main parts:
- Concepts and Diagrams: lists and comments important sections to get used with AWS EB concepts.
- Hands-on: let's make something useful. :-P
# create the tables | |
db.define_table('person', | |
Field('name'), | |
Field('gender'), | |
Field('birthdate', 'date')) | |
db.define_table('animal', | |
Field('name'), | |
Field('gender'), |
#!/usr/bin/env bash | |
# Makes sed a recursive in place substitution and | |
# create backup of original files with .bkp extension. | |
old=$1 | |
new=$2 | |
sed -i.bkp "s/${old}/${new}/g" $(grep -ril "${old}" .) |
class Pessoa(object): | |
def __init__(self, nome, endereco): | |
self.nome = nome | |
self.endereco = endereco | |
def __eq__(self, outra): | |
if self.nome == outra.nome: | |
return True | |
else: | |
return False |
This document is divided into 2 main parts:
# Do I have root privileges? | |
# Also known as: Am I running with sudo? | |
if [ $EUID -ne 0 ]; then | |
echo "You must run the script as root or using sudo" | |
exit 1 | |
fi | |
# Am I inside the Vagrant VM? |
from unicodedata import normalize | |
def tira_acentos(s): | |
return normalize("NFKD", s.decode("utf-8")).encode("ASCII", "ignore") |
var map_which_fields_are_filled_or_not = function (form_id) { | |
/* for each field on form, recognize if it's filled or not. | |
Returns: | |
- { | |
"field_a": true, // filled | |
"field_b": false // empty (not filled) | |
} | |
*/ |
# -*- coding: utf-8 -*- | |
'''Transforma um dicionario unicode em json e tira os acentos de tudo.''' | |
import json | |
from unicodedata import normalize | |
dados_em_utf8 = {u'texto': u'n\xe3o sei de nada.'} | |
print '- Dados que vieram do form em utf-8:', dados_em_utf8 |
/* | |
* Exemplos de como usar e resultados: | |
* - data_eh_valida("25/01/2014") => true | |
* - data_eh_valida("25/01/14") => false - ano precisa ter 4 digitos | |
* - data_eh_valida("29/02/2015") => false - 29/02 em ano nao bisexto | |
* - data_eh_valida("32/07/2014") => false - dia invalido | |
* - data_eh_valida("25/13/2014") => false - mes invalido | |
*/ | |
var data_eh_valida = function (data_str) { |