Skip to content

Instantly share code, notes, and snippets.

@rgo
rgo / house-cleaning
Created September 9, 2009 23:33
Services moved from rc.M to cron.daily/house-cleaning (Improve boot time)
#!/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
@rgo
rgo / ubiquity.tmp-4.js
Created August 15, 2009 14:13
Ubiquity commands to search at apidock.com
// 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: {
@rgo
rgo / gist:157111
Created July 28, 2009 10:54
503 for maintenance pages
# 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]
@rgo
rgo / gist:153049
Created July 23, 2009 15:03
Protect access to .svn directories.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} \.svn
RewriteRule ^.*$ - [F]
@rgo
rgo / gist:144598
Created July 10, 2009 16:22
Create and apply patch with subversion
# Create and apply patch with subversion
svn diff > ~/fix_ugly_bug.diff
patch -p0 -i ~/fix_ugly_bug.diff
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'
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]
@rgo
rgo / validateable.rb
Created July 6, 2009 14:59
Validating non AR models in Rails 2.3
# 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
@rgo
rgo / next_previous_records.rb
Created June 24, 2009 22:10
next and previous record methods
# You need to call the next and previous records. Just put the following in your model.
# From http://snippets.dzone.com/posts/show/7163
def next
self.class.find :first,
:conditions => ["created_at > ? ",self.created_at],
:order => "created_at DESC"
end
def previous
self.class.find :first,
@rgo
rgo / GIT_NOTES
Created June 18, 2009 10:50
Git Notes
FORK - PUSH - PULL - KEEPING THE TRACK
======================================
FORK
====
Le doy a fork en el repositorio y luego uso "Your clone URL".
$ git clone [email protected]:rgo/drgtest.git