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 execute this gist, run the line bellow in terminal | |
\curl -L https://raw.github.com/gist/3875946/install_source_code_pro.sh | sh |
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
# see the current limits | |
$ sysctl -a | grep maxproc | |
# increase it | |
$ sudo sysctl -w kern.maxproc=xxxx | |
$ sudo sysctl -w kern.maxprocperuid=xxx | |
# run at startup | |
$ sudo vim /etc/sysctl.conf |
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
# example of using lookahead assertion to test password strength | |
# test if a given string contains at least a lowercase letter, a uppercase, a digit, a special char and 8+ chars | |
strong = "123ABCabc-" | |
strong[/^(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\W]).{8,}$/] | |
# test if a given string contains at least a lowercase letter, a uppercase, a digit and 8+ chars | |
medium = "123ABCabc" | |
medium[/^(?=.*[a-zA-Z])(?=.*[0-9]).{8,}$/] |
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
Object.prototype.join = function(glue, separator) { | |
var object = this; | |
if (glue == undefined) | |
glue = '='; | |
if (separator == undefined) | |
separator = ','; | |
return Object.keys(object).map(function (key, value) { return [key, value].join(glue); }).join(separator); |
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
brew install https://gist.github.com/raw/4355097/postgresql82.rb --no-python --no-perl --without-ossp-uuid | |
# to execute this gist, just run the line bellow in terminal | |
# \curl -L https://gist.github.com/raw/4355097/install_pg-8.2.sh | sh |
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('some.gravatar.email@foo.com', 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
<%= simple_form_for @product do |f| %> | |
<%= f.simple_fields_for :attributes do |d| %> | |
<% f.object.attributes.try(:each) do |key, value| %> | |
<%= d.input key, :input_html => {:value => value } %> | |
<% end %> | |
<% end %> | |
<% end %> |
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
# This gist will help you using multiple github or bitbucket accounts in the same machine. | |
# 1. create a .ssh/config file, with this content: | |
# use "bitbucket-ieducativa" as git remote host, to use this custom key | |
Host bitbucket-ieducativa | |
HostName bitbucket.org | |
User git | |
IdentityFile ~/.ssh/bitbucket-ieducativa | |
IdentitiesOnly yes |
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
# first convert the utf-8 script to latin1 | |
iconv -f utf-8 -t latin1 file.sql > __latin1-file.sql | |
# after execute the latin1 file | |
psql -d db-name -a -f __latin1-file.sql |
NewerOlder