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
# From http://www.neeraj.name/blog/articles/810-validating-non-activerecord-models-in-rails-2-2 | |
# Modified as said comment 1 - (changed self_and_descendents_from_active_record by self_and_descendants_from_active_record) | |
module Validateable | |
[:save, :save!, :update_attribute].each{|attr| define_method(attr){}} | |
def method_missing(symbol, *params) | |
if(symbol.to_s =~ /(.*)_before_type_cast$/) | |
send($1) | |
end |
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 Contact | |
include Validateable | |
attr_accessor :name,:phone, :email, :body | |
def initialize(options = {}) | |
unless options.nil? | |
@name = options[:name] if options[:name] | |
@email = options[:email] if options[:email] |
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 ContactController < ApplicationController | |
def index | |
# render index.html.erb | |
end | |
def create | |
@contact = Contact.new(params[:contact]) | |
if @contact.valid? | |
Notifications.deliver_contact(params[:contact]) | |
#flash[:notice] = 'Email enviado correctamente' |
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
# Create and apply patch with subversion | |
svn diff > ~/fix_ugly_bug.diff | |
patch -p0 -i ~/fix_ugly_bug.diff |
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
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} \.svn | |
RewriteRule ^.*$ - [F] |
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
# Show maintenance page if it exists | |
ErrorDocument 503 /system/maintenance.html | |
RewriteEngine On | |
RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$ | |
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f | |
RewriteCond %{SCRIPT_FILENAME} !maintenance.html | |
RewriteRule ^.*$ - [redirect=503,last] |
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
// Tip: You can go to any result in preview by pressiong ctrl+alt+[result number] | |
CmdUtils.makeSearchCommand({ | |
name: ["rails","rails-search"], | |
homepage: "http://rafagarcia.net/", | |
author: { name: "Rafa Garcia", email: "[email protected]"}, | |
license: "GPL", | |
url: "http://apidock.com/rails/search/?query={QUERY}", | |
description: _("Searches Ruby on Rails terms in Apidock.com"), | |
icon: "http://apidock.com/images/rails_icon_16.png", | |
parser: { |
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/sh | |
# /etc/cron.daily/house-cleaning | |
# RGO - not commented in rc.M | |
# Update all the shared library links: | |
#if [ -x /sbin/ldconfig ]; then | |
# echo "Updating shared library links: /sbin/ldconfig &" | |
# /sbin/ldconfig & | |
#fi |
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 | |
# | |
# Instructions and dependencies: | |
# You must run it with admin privileges | |
# You need src2pkg to generate packages | |
# Working directory is where src and packages will be stored | |
# | |
# Based on scripts read in http://aldeby.org/blog/index.php/how-to-update-alsa-to-latest-version-easily.html | |
# Credits: | |
# 2007 Bob Nelson [email protected] |
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 | |
# Show disk usage in directories | |
for file in `ls`; do sudo du -sh $file; done |