This file contains 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 '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, |
This file contains 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
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, ..", |
This file contains 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 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") |
This file contains 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 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 |
This file contains 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
* { | |
margin: 0 auto; | |
} | |
body { | |
background-color: #fff; | |
color: #333; | |
} | |
body, p, ol, ul, td { |
This file contains 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 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 |
This file contains 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
#!/bin/bash | |
wget http://blog.anantshri.info/content/uploads/2010/09/add-apt-repository.sh.txt | |
sudo mv add-apt-repository.sh.txt /usr/sbin/add-apt-repository | |
sudo chmod o+x /usr/sbin/add-apt-repository | |
sudo chown root:root /usr/sbin/add-apt-repository |
This file contains 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
#!/usr/bin/env ruby | |
# | |
# Put this script in your PATH and download from onemanga.com like this: | |
# onemanga_downloader.rb Bleach [chapter number] | |
# | |
# You will find the downloaded chapters under $HOME/Documents/OneManga/Bleach | |
# | |
# If you run this script without arguments, it will check your local manga downloads | |
# and check if there are any new chapters | |
# |
This file contains 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
#!/bin/bash | |
#script extraido de: http://paulocassiano.wordpress.com/2008/08/29/deixando-o-gedit-com-a-cara-do-textmate/ | |
#tip for better "resolution" here: http://blog.siverti.com.br/2008/05/22/fonte-monaco-no-ubuntugedit/ | |
cd /usr/share/fonts/truetype/ | |
#TODO: put validation if folder already exists | |
sudo mkdir ttf-monaco |
This file contains 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
#!/usr/bin/env ruby | |
# | |
# Put this script in your PATH and download from onemanga.com like this: | |
# onemanga_downloader.rb Bleach [chapter number] | |
# | |
# You will find the downloaded chapters under $HOME/Documents/OneManga/Bleach | |
# | |
# If you run this script without arguments, it will check your local manga downloads | |
# and check if there are any new chapters | |
# |
OlderNewer