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
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) { |
#!/usr/bin/env bash | |
python -c 'open("/tmp/teste-dir/ultimos-primeiro.txt", "w").writelines(sorted(open("/tmp/teste-dir/so_diretorios.txt").readlines(), key=lambda s: s.count("/"), reverse=True))' |
"""Useful functions to handle the class attribute of DOMNode. | |
Usage: | |
``` | |
>>> el = document['someid'] | |
>>> add_class(el, 'class-one') | |
>>> add_class(el, 'old-class') | |
>>> change_class(el, 'old-class', 'new-class') | |
>>> remove_class(el, 'class-one') | |
>>> print(el.class_name) |
# create the tables | |
db.define_table('person', | |
Field('name'), | |
Field('gender'), | |
Field('birthdate', 'date')) | |
db.define_table('animal', | |
Field('name'), | |
Field('gender'), |