Skip to content

Instantly share code, notes, and snippets.

View gouvermxt's full-sized avatar
:electron:

Marcio Gouvea Silva gouvermxt

:electron:
View GitHub Profile
@gouvermxt
gouvermxt / default.rb
Created February 24, 2011 19:43
default app template
if yes?("Use mysql?")
gem("mysql2")
end
class ObjectGroup < ActiveRecord::Base
has_and_belongs_to_many :users
has_and_belongs_to_many :object_items
strip_attributes!
validates :description, :presence => true, :uniqueness => true, :allow_blank => true
#Search
class Notifier < ActionMailer::Base
#emails omitidos propositalemnte para este gist
default :from => "xxx@xxxxx", :to => "xxx@xxxxx",
:subject => I18n.t("notifier.contact_message.subject")
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.notifier.contact_message.subject
@gouvermxt
gouvermxt / cpf_cnpj_validators.rb
Created June 3, 2011 00:39
validação de CPF e CNPJ em Ruby
#------------------------------------------------------------------------------
# Rotinas para verificação de CPF e CNPJ
# Linguagem: Ruby
# Escrito por: André Camargo < andre@boaideia.inf.br > http://blog.boaideia.inf.br
# Use, copie, melhore a vontade! Patches são bem-vindos...
#------------------------------------------------------------------------------
def check_cpf(cpf=nil)
return false if cpf.nil?
nulos = %w{12345678909 11111111111 22222222222 33333333333 44444444444 55555555555 66666666666 77777777777 88888888888 99999999999 00000000000}
$(function($) {
init_clock();
setInterval(function() {
update_clock();
}, 1000);
//Inits the clock with date from server
function init_clock() {
@gouvermxt
gouvermxt / Vagrantfile
Last active August 15, 2017 12:11
Setups an Ubuntu machine for Rails development.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "10.2.2.2"
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.network :forwarded_port, guest: 5432, host: 5432
sudo -u postgres psql
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
DROP DATABASE template1;
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
\c template1
VACUUM FREEZE;
sudo /etc/init.d/postgresql restart
@gouvermxt
gouvermxt / cloud9-postgresql-rails-howto.md
Created August 3, 2017 22:23 — forked from eliotsykes/cloud9-postgresql-rails-howto.md
How to setup PostgreSQL & Rails on Cloud9

How to setup PostgreSQL & Rails on Cloud9

At time of writing, Cloud9 has PostgreSQL pre-installed, so you won't need to install it yourself. However, its not running by default, so you will need to start it with this command in the terminal:

sudo service postgresql start

Change the PostgreSQL password to 'password' (or choose a different password):

======= Prolbem =================================================================================================================
I have installed : ruby-2.0.0,postgres-9.2 , now in rails app when I execute:
rake db:create , command I get:
PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT: Use the same encoding as in the template database, or use template0 as template.
: CREATE DATABASE "my_db_name" ENCODING = 'unicode'.......
bin/rake:16:in `load'
@gouvermxt
gouvermxt / Vagrantfile
Created August 17, 2017 18:23
Vagrant file for Ruby environment
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "10.2.2.2"
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.network :forwarded_port, guest: 5432, host: 5432