Skip to content

Instantly share code, notes, and snippets.

View bensie's full-sized avatar

James Miller bensie

View GitHub Profile
@bensie
bensie / Mod-Rails on Ubuntu
Created October 16, 2008 19:42
Step by step commands for getting mod_rails installed on Ubuntu
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get autoremove
sudo apt-get install build-essential
sudo apt-get install mysql-server mysql-client libmysqlclient15-dev libmysql-ruby1.8 ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby irb1.8 libdbd-mysql-perl libdbi-perl libmysql-ruby1.8 libmysqlclient16-dev libmysqlclient16 libnet-daemon-perl libopenssl-ruby libopenssl-ruby1.8 libplrpc-perl libreadline-ruby1.8 libruby1.8 mysql-client mysql-client-5.1 mysql-common mysql-server mysql-server-5.1 rdoc1.8 ri1.8 ruby1.8 ruby1.8-dev zlib1g-dev
sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
function validateField(fieldId, alertMessage) {
if (document.getElementById(fieldId).value == "") {
alert(alertMessage);
document.getElementById(fieldId).focus();
return false;
} else {
return true;
}
}
require 'httpclient'
module EnomApi
def self.included(base)
base.send :extend, ClassMethods
end
module ClassMethods
def manage_with_enom
send :include, InstanceMethods
end
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base
@bensie
bensie / gist:45331
Created January 10, 2009 00:39 — forked from dhh/gist:45076
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName example.com
# ServerAlias *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
# Examples of Nesting Associated Attributes
# This is a look at the various ways to set associated attributes through
# nested parameters. For example, let's say Project has_many :tasks and
# we want to update the tasks the same time we edit a project. There are
# several ways this interface could be handled, and here are a few.
#
# For these examples, we're trying to create two new tasks and update an
# existing task (with id 3) through a project.
# Approach 1
@bensie
bensie / mail_handler.rb
Created January 30, 2009 00:19
Handle piped email from a MTA without loading the Rails stack (and push to a RESTful resource)
#!/usr/bin/ruby
require 'net/http'
require 'uri'
require 'yaml'
SUCCESS = 0
TEMPORARY_FAIL = 75
UNAVAILABLE = 69
ENV['RAILS_ENV'] ||= 'production'
@bensie
bensie / gist:55208
Created January 30, 2009 18:58
Configure Postfix to handle all email for a domain/subdomain and forward to a rails app
/etc/postfix/main.cf:
mydestination = localhost.localdomain, localhost, list.domain.com
virtual_maps = hash:/etc/postfix/virtual
alias_maps = hash:/etc/aliases
/etc/postfix/virtual:
@list.domain.com rails_mailer
/etc/aliases:
rails_mailer: "|/path/to/app/lib/mail_handler.rb http://www.example.com/emails 298cc9dceb1f3cac91fef8b42be624c07843fc8e"
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
require "digest/sha1"
module AuthenticationModel
def self.included(base)
base.send(:include, InstanceMethods)
base.send(:extend, ClassMethods)
base.send(:validates_presence_of, :email, :message => "L'indirizzo email &egrave; richiesto.")
base.send(:validates_presence_of, :password, :if => :password_required?, :message => "La password &egrave; richiesta.")
base.send(:validates_uniqueness_of, :email, :case_sensitive => false, :message => "Questo indirizzo email &egrave; gi&agrave; presente.")