This file contains hidden or 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 hidden or 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
namespace :db do | |
namespace :fixtures do | |
# by default it task load records from development env, | |
# to change send the RAILS_ENV var, eg: $ rake db:fixtures:dumps RAILS_ENV=production | |
desc 'dumps the database data into test fixtures.' | |
task :dumps => :environment do | |
sql = "SELECT * FROM %s" | |
skip_tables = ['schema_info', 'schema_migrations'] |
This file contains hidden or 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 hidden or 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 hidden or 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 get the ids from the process that still connected to db | |
$ psql -d db_name -c "select procpid from pg_stat_activity where datname='db_name' and waiting is not false;" | |
# after, kill the process that still connected to db | |
$ kill procpid_returned_from_query | |
$ dropdb db_name |
This file contains hidden or 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 |
This file contains hidden or 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
# rails_app/config/locales/pt-BR.yml | |
'pt-BR': | |
simple_form: | |
labels: | |
form_name: | |
name: 'Nome' | |
city: 'Cidade' | |
placeholders: |
This file contains hidden or 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
source "http://rubygems.org" | |
gem 'nokogiri' |
This file contains hidden or 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
# /config/initializers/setup_mail.rb | |
# ... | |
ActionMailer::Base.default :from => "Company Name <[email protected]>" |
This file contains hidden or 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
Typeahead is a javascript plugin from Twitter Bootstrat [1] that allows quickly creating typeaheads with any | |
form text input element. | |
[1] http://twitter.github.com/bootstrap/javascript.html#typeahead |