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 / 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 / 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 / install_sublime_ppa.sh
Last active October 11, 2015 19:28 — forked from vshvedov/gist:1370650
Sublime Text Edit 2 - Ubuntu (from PPA)
#!/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
#!/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
#
#!/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
#!/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
#