Skip to content

Instantly share code, notes, and snippets.

View dasdennis's full-sized avatar

Dennis A. Silva dasdennis

  • Concrete
  • São Paulo
View GitHub Profile
@dasdennis
dasdennis / galeria.css
Created April 6, 2012 20:31
Codigo CSS3 de Galeria
<div class="corpo">
<div class="galeria">
<div class="foto"><img src="Assas1.jpg"></div>
<div class="foto"><img src="Assas2.jpg"></div>
<div class="foto"><img src="Assas3.jpg"></div>
<div class="foto"><img src="Assas4.jpg"></div>
</div>
@dasdennis
dasdennis / user.rb
Created April 13, 2012 20:53 — forked from rbarazi/user.rb
[Beginning Rails 3] Listing 5-37. Current User Model, in app/models/user.rb
require 'digest'
class User < ActiveRecord::Base
attr_accessor :password
validates :email, :uniqueness => true,
:length => { :within => 5..50 },
:format => { :with => /^[^@][\w.-]+@[\w.-]+[.][a-z]{2,4}$/i }
validates :password, :confirmation => true,
:length => { :within => 4..20 },
:presence => true,
@dasdennis
dasdennis / seeds.rb
Created April 13, 2012 20:59 — forked from ccjr/seeds.rb
[Beginning Rails 3] Listing 5-38. Current Seeds File in db/seeds.rb
user = User.create :email => 'mary@example.com',
:password => 'guessit',
:password_confirmation => 'guessit'
Category.create [{:name => 'Programming'},
{:name => 'Event'},
{:name => 'Travel'},
{:name => 'Music'},
{:name => 'TV'}]
user.articles.create :title => 'Advanced Active Record',
:body => "Models need to relate to each other. In the real world, ..",
@dasdennis
dasdennis / article.rb
Created April 13, 2012 21:05 — forked from rbarazi/article.rb
[Beginning Rails 3] Listing 5-28. Adding the published? method in app/models/article.rb
class Article < ActiveRecord::Base
validates :title, :presence => true
validates :body, :presence => true
belongs_to :user
has_and_belongs_to_many :categories
has_many :comments
scope :published, where("articles.published_at IS NOT NULL")
scope :draft, where("articles.published_at IS NULL")
@dasdennis
dasdennis / users_controller.rb
Created April 13, 2012 21:26 — forked from rbarazi/users_controller.rb
[Beginning Rails 3] Listing 7-2. Updated app/controllers/users_controller.rb
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to articles_path, :notice => 'User successfully added.'
else
@dasdennis
dasdennis / application.css
Created April 14, 2012 19:34 — forked from rbarazi/application.css
[Beginning Rails 3] Listing 7-37. The public/stylesheets/application.css file
* {
margin: 0 auto;
}
body {
background-color: #fff;
color: #333;
}
body, p, ol, ul, td {
@dasdennis
dasdennis / Shoes_on_Ubuntu
Created June 2, 2012 20:19
Building Shoes on Ubuntu
# Install dependencies
sudo apt-get install git-core libcairo2-dev libpixman-1-dev libpango1.0-dev libgif-dev libjpeg-dev libgtk2.0-dev vlc libvlc-dev portaudio19-dev libsqlite3-dev libcurl4-openssl-dev libxslt1-dev makeself curl libxslt-dev libxml2-dev
@dasdennis
dasdennis / users_controller.rb
Created July 30, 2012 00:19 — forked from rbarazi/users_controller.rb
[Beginning Rails 3] Listing 7-2. Updated app/controllers/users_controller.rb
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to articles_path, :notice => 'User successfully added.'
else
@dasdennis
dasdennis / eliminar_warning.txt
Created August 18, 2012 00:46
Eliminando o Warning do Ruby 1.9.3
# Resolvendo o erro:
/usr/local/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
# No terminal do Ubuntu 11.10 rode:
cd ext/psych
ruby extconf.rb
@dasdennis
dasdennis / grub_repair.txt
Created September 16, 2012 17:51
Ubuntu 12.09 GRUB Repair (Reparando o Grub no Ubuntu)
# Reparando o GRUB no Ubuntu 12.09 LTS
# For this error:
error: no such device: 4cfe3cc0-370e-48ed-82cd-7cd2ca7a0414.
grub rescue >
# Solution:
# Installation and use: