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
""" | |
a alguns dias acompanhei pela lista brasileira do Web2py que alguns usuários estavam | |
com dificuldades com envio de email no GAE, hoje passei por isso :( segue dica para | |
quem também estiver com dificuldades no envio de email pelo GAE. | |
Em um modelo ex: "models/db.py" inclua o código abaixo: | |
""" | |
from gluon.tools import Mail |
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
Um método para otimizar as conexões com o banco de dados é estabelecer um pool de conexão, caso sua aplicação | |
não faça isto nativamente você pode usar alguma ferramenta como o pgbouncer [1]. | |
O principal motivo para manter um pool de conexões ativas com o banco de dados, é que o processo | |
de criar uma conexão com o banco de dados e posteriormente elimina-la gasta recursos e leva algum tempo, | |
o que pode ser pouco para uma conexão, mas para apps onde a conexão / desconexão ocorre com muita | |
frequência (como em aplicações web) manter um pool de conexões ativas, pode economizar algum tempo | |
entre cada solicitação. | |
Um pool de conexões trabalha de maneira muito simples, após a aplicação criar e usar a conexão com o |
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
print gravatar_image_tag('[email protected]', 32, {'class' : 'avatar', 'alt' : 'your gravatar'}) | |
<img src="http://www.gravatar.com/avatar/3b4d33514d78047bf86307ab354658df?size=32" alt="your gravatar" class="avatar" /> |
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 | |
def output_config | |
puts <<-END | |
graph_category App | |
graph_title passenger status | |
graph_vlabel count | |
sessions.label sessions | |
max.label max processes |
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 | |
# put in /etc/munin/plugins and restart munin-node | |
# by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin | |
# NOTE: you might need to add munin to allow passwordless sudo for passenger-memory-stats | |
def output_config | |
puts <<-END | |
graph_category App | |
graph_title Passenger memory stats | |
graph_vlabel count |
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
# to use this gist execute: $ rm -f 1506695 && wget https://raw.github.com/gist/1506695 && sh 1506695 | |
# refs to http://www.alfajango.com/blog/how-to-monitor-your-railspassenger-app-with-munin/ | |
echo "Installing munin..." | |
sudo apt-get install munin munin-node -y | |
echo ; | |
echo "Removing previous links for passenger_status and passenger_memory_stats..." | |
sudo rm /etc/munin/plugins/passenger_memory_stats | |
sudo rm /etc/munin/plugins/passenger_status |
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
# sem linhas em branco, código não tão junto | |
if current_user.has_role('admin') | |
cases = cases.of_product(product) | |
elif current_user.has_role('employee') | |
cases = cases.of_product_accessible_by_employee(product, current_user) | |
elif current_user.has_role('customer') | |
cases = cases.of_product_accessible_by_customer(product, current_user) |
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
// jquery | |
var $checkboxes = $("input[type='checkbox']"); | |
$checkboxes.change(function(){ | |
$checkboxes.not(this).removeAttr('checked'); | |
}); |
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
find -type f -iname "*~" -exec rm -f {} \; |
OlderNewer