Skip to content

Instantly share code, notes, and snippets.

View rx's full-sized avatar
👾
Bit twiddling

Russell Edens rx

👾
Bit twiddling
View GitHub Profile
@rx
rx / gist:99555
Created April 22, 2009 02:52
Required paramters in a multi parameter method
def drequiredopts(*names)
names.each do |name|
if self.send(name).nil?
devfail("%s is a required option for %s" % [name, self.class])
end
end
end
# Iterate over a hash, treating each member as an attribute.
def set_options(options)
def post_xml( xml, path)
url = URI.parse("http://[login]:[password]@[domain]/#{path}")
req = Net::HTTP::Post.new(url.path)
userinfo = url.userinfo.split(':')
req.basic_auth(userinfo[0], userinfo[1])
req['Content-Type'] = "text/xml"
req.body = xml
@response = Net::HTTP.start(url.host, url.port) do |http|
http.request(req)
end
$ gem install hobo
ERROR: Error installing hobo:
hobo requires mislav-will_paginate (>= 2.2.1, runtime)
Fixed with:
$ gem install mislav-will_paginate -s http://gems.github.com
Great articles on setting up postgres:
http://articles.slicehost.com/postgresql
http://rubytester.com/blog/2009/08/12/using-local-watir-with-local-gem.html
@rx
rx / gist:267225
Created January 1, 2010 19:39 — forked from JonCrawford/gist:44415
Multitenent subdomain controller
# 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
@rx
rx / schema seperation in postgresql
Created January 1, 2010 19:55
Multitenent presentation
http://aac2009.confreaks.com/videos/06-feb-2009-14-30-writing-multi-tenant-applications-in-rails-guy-naor-small.mp4
Skip ahead to 22:55
Here is my retype of the application control logic to switch schemas using search paths in postgresql.
class ApplicationController < ActionController::Base
before_filter :set_account
after_filter :clear_account
@rx
rx / Blog on Multi-Tenant design decisions
Created January 1, 2010 21:18
Active multitenet design discussion
http://ayende.com/Blog/archive/2008/08/13/Mutli-Tenancy--multi-tenant-apps-and-frameworks.aspx
How to enable Java in Ubuntu
Hi,
here is a short recipe how to enable Java applets and the Java console in Ubuntu (and others with the same installation tool set), compiled from a previous contribution and another hint somewhere:
sudo -i
apt-get update
apt-get install sun-java6-jre sun-java6-jdk sun-java6-plugin sun-java6-fonts
rails_root/
accounts/apps/
controllers/
models/
views/
helpers/
specs/
lib/
users/apps/
controllers/