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
class Instalment < ActiveRecord::Base | |
# set para valores | |
def amount=(value) | |
# ex. value = "1.200,00" | |
value = value.gsub('.','') # value = "1200,00" | |
value = value.gsub(',','.') # value = "1200.00" | |
write_attribute(:amount, value.to_f) # salva 1200.00 | |
end |
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
<!-- Arquivo shared/_error_messages.html.erb --> | |
<% unless record.errors.empty? %> | |
<dl class="error-messages"> | |
<dt>Não esta salvando essa porra porque:</dt> | |
<% record.errors.full_messages.each do |message| %> | |
<dd><%= message %></dd> | |
<% end %> | |
</dl> | |
<% end %> |
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
class Empregado { | |
private $name; | |
public function __construct($name){ | |
$this->name = $name; | |
} | |
public function pe_na_porta(){ | |
echo "Le wild {$this->name} segunda dizendo bye!"; | |
} | |
} |
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
<!-- Atual --> | |
<td width="14%"> | |
<span> | |
<%= i.date_select :expiration_date, {:order =>[:day, :month, :year], :default => Time.now + (60*60*24*30*number)}, {:class => 'select' } %> | |
</span> | |
</td> | |
<!-- Alterar para: --> | |
<td width="14%"> | |
<span> |
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
require 'rubygems' | |
require 'yaml' # Adicionar esta linha | |
YAML::ENGINE.yamler = 'syck' # Mais esta e testar ^_^ | |
# Set up gems listed in the Gemfile. | |
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | |
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) |
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
SQLite – Comandos mais comuns (parte 2) Agosto 10, 2006 | |
Posted by mjollnir in Linux, Tutoriais. | |
trackback | |
Este post vai servir para explorar os comandos mais comuns do SQLite, e familiarizar o utilizador com a linha de comandos. | |
Se não souber o que é o SQLite e de como instala-lo por favor ve-ja aqui, SQLite – Introdução (parte 1) . | |
Começando com o básico: | |
Para criar uma base de dados em SQLite basta digitar o comando “sqlite3″ seguido no nome da base de dados a criar (ou a abrir, para o caso desta já existir). Por exemplo, para criar uma base de dados com o nome “teste.db” basta digitar o seguinte: |
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
É importante notar que há uma indicação visual de quem está usando a máquina: o símbolo do prompt muda, indicando se o utilizador é qualquer usuário ou se é o adminstrador: | |
# = modo super-usuário (root) | |
$ = modo usuário | |
Esta convenção indica o estado de permissões em qualquer sistema Linux / Unix. | |
No Ubuntu, com a interface GNOME, clicar em Aplicativos - Acessórios - Terminal ( ou Consola ) | |
Na tela do Terminal simplesmente digite su - |
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
TERMINAL: CTROL + ALT + T | |
Abre o terminal. | |
NOVA ABA: CTROL + SHIFT + T | |
Abre uma nova aba, muito útil, quando se torna necessário varias instancias do terminal, possibilitando centralizar tudo em uma única janela. | |
FECHAR ABA: SHIFT + CTROL + W | |
Fecha a aba atual do terminal. | |
ALTERNAS ENTRE ABAS: ALT + NUMERO DA ABA |
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
numeros = [1,2,3,4,5,6,7,8,9] | |
total = 0 | |
numeros.each do |n| | |
total += n | |
end | |
puts total.to_s | |
# ou |
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
<%= form_for @interested, :url => interested_contact_save_path(@interested) do |w| %> | |
<ul> | |
<%= w.fields_for :interested_contacts do |i| %> | |
<% if i.object.id.nil? %> <!-- Acrescentar isso aqui --> | |
<li> | |
<label> | |
<span>Data: </span><br/> | |
<%= i.text_field :date, :class => "select" %> | |
</label> | |
</li> |