Skip to content

Instantly share code, notes, and snippets.

View vroy's full-sized avatar

Vincent Roy vroy

View GitHub Profile
require 'rubygems'
require 'sequel'
require 'time'
DB = Sequel.connect 'sqlite:/'
class Category < Sequel::Model
set_schema do
primary_key :id
text :name
require "rubygems"
require 'sequel'
require "sinatra"
DB = Sequel.connect 'sqlite://blog.db'
class Post < Sequel::Model(:posts)
set_schema do
primary_key :id
varchar :title
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:493:in `const_missing': uninitialized constant ActionView::Base::Haml (NameError)
from /usr/lib/ruby/gems/1.8/gems/haml-2.0.9/lib/haml/helpers/action_view_mods.rb:20
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:510:in `require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:355:in `new_constants_in'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:510:in `require'
from /usr/lib/ruby/gems/1.8/gems/haml-2.0.9/lib/haml/helpers.rb:1
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
... 15 levels...
@vroy
vroy / output
Created July 26, 2009 03:45
how to change the extensions for a templating engine in ramaze
index.asdf
class TrafficLight
def initialize
@colors = ["green", "yellow", "red"]
@index = 0
end
def color
@colors[@index]
end
class Mysql
def proc(str)
DB.query_with_result = false
resultsets = []
no_more_results=false
DB.query( %(call #{str}) )

I want a connection pool for mysql objects that I would use with the mysql C adapter and mysqlplus. But I was also looking to make it as flexible as possible so that it can be a pool of object for more than just mysql connections. I'm looking for advice on how to implement that, I currently have 2 implementations above. I read the sequel connection_pool.rb file but I don't understand everything so stripping the Sequel part is kind of a problem for me. Do you guys have any advice/opinion on how I could achieve this?

require 'rubygems'
require 'ramaze'
# Start this example with `ruby hello.rb`.
# After startup you will be able to access it at http://localhost:7000/
# This should output "Hello, World!" in your browser.
class MainController < Ramaze::Controller
map '/'
vals = {
:album_id => nil,
:mime_type => file[:type],
:description => h(request[:description]),
:real_filename => real_filename,
}
p vals
new = Picture.create(vals)
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server vroy.ca (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost vroy.ca (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost 208.88.124.71 (/etc/apache2/sites-enabled/001-test:1)
Syntax OK