Skip to content

Instantly share code, notes, and snippets.

View rodrigopinto's full-sized avatar

Rodrigo Pinto rodrigopinto

  • Berlin, Germany
  • 07:49 (UTC +02:00)
View GitHub Profile
#
# Validates format to CNH ( category permission to drive on Brazil)
#
validates_format_of :license_category, :with => /(^[ABCDE]{1}$)|(AB)/
#
# Validates format to License Plate format to Brazil
#
validates_format_of :license_plate, :with => /([A-Z]{3})\-([0-9]{4})/
#
# Generating theme from web-app-theme
#
#
# Commnad to generate theme
#
script/generate theme --theme=name_theme
-module(fact). %% Definição do namespace, deve ter o mesmo nome do arquivo fact.erl
-export([fac/1]). %% Exporta a função, ou seja, torna a função acessível fora do módulo.
fac(0) -> 1; %% Define uma cláusula para o fatorial quando parâmetro passado for 0
fac(N) -> N * fac(N-1). %% Define uma cláusula para o fatorial quando parâmetro passado for diferente de 0
rpinto@rpinto-desktop:~$ erl
Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false]
Eshell V5.7.2 (abort with ^G)
1>
Eshell V5.7.2 (abort with ^G)
1> c(factorial).
{ok,factorial}
2> factorial:fac(0).
1
3> factorial:fac(5).
120
4>
-module(factorial). %% Definição do namespace, deve ter o mesmo nome do arquivo factorial.erl
-export([fac/1]). %% Exporta a função, ou seja, torna a função acessível fora do módulo.
fac(N) -> N * fac(N-1); %% Define uma cláusula para o fatorial quando parâmetro passado for diferente de 0
fac(0) -> 1. %% Define uma cláusula para o fatorial quando parâmetro passado for 0
Eshell V5.7.2 (abort with ^G)
1> c(factorial).
./fact.erl:5: Warning: this clause cannot match because a previous clause at line 4 always matches
{ok,factorial}
2>
#!/bin/bash
echo "Automated Setup for Ubuntu 10.04 LTS(Lucid) - REE + Rails with Nginx + Mercurial + postfix"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
#!/bin/bash
echo "Automated Setup for Ubuntu 10.04 LTS(Lucid) - REE + Rails with Nginx "
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
echo "------------------------------------------------------------------"
#...
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
if html_tag =~ /<label/
%|#{html_tag} <font class="error">#{[instance.error_message].join(', ')}</font>|
else
error_class = 'fieldWithErrors'
nodes = Hpricot(html_tag)
nodes.each_child do |node|
unless !node.elem? || node[:type] == 'hidden' || node.classes.include?(error_class)