Instantly share code, notes, and snippets.

James Miller bensie

View GitHub Profile
View Mod-Rails 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
View gist:34023
function validateField(fieldId, alertMessage) {
if (document.getElementById(fieldId).value == "") {
return false;
} else {
return true;
View gist:39523
require 'httpclient'
module EnomApi
def self.included(base)
base.send :extend, ClassMethods
module ClassMethods
def manage_with_enom
send :include, InstanceMethods
View gist:44453
# 1) Point * in your DNS setup to your server.
# 2) Setup an Apache vhost to catch the star pointer:
# <VirtualHost *:80>
# ServerName *
# </VirtualHost>
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base
View gist:45331
# 1) Point * in your DNS setup to your server.
# 2) Setup an Apache vhost to catch the star pointer:
# <VirtualHost *:80>
# ServerName
# ServerAlias *
# </VirtualHost>
# 3) Set the current account from the subdomain
View nesting_association_attributes_examples.rb
# 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
View mail_handler.rb
require 'net/http'
require 'uri'
require 'yaml'
ENV['RAILS_ENV'] ||= 'production'
View gist:55208
mydestination = localhost.localdomain, localhost,
virtual_maps = hash:/etc/postfix/virtual
alias_maps = hash:/etc/aliases
/etc/postfix/virtual: rails_mailer
rails_mailer: "|/path/to/app/lib/mail_handler.rb 298cc9dceb1f3cac91fef8b42be624c07843fc8e"
View gist:55224
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
View authenticated_model.rb
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.")