Skip to content

Instantly share code, notes, and snippets.

=begin
datamapper threaded repository sample with multiple mysql databases
modelling mysql => User table can be used administering mysql
=end
require 'dm-core'
Servers = {
:mysql1 => 'mysql1.foo.com',
:mysql2 => 'mysql2.foo.com',
diff --git a/configure b/configure
index 2f48a9a..1314b70 100755
--- a/configure
+++ b/configure
@@ -30,7 +30,12 @@ class Configure
@llvm_default = File.join(root, "vm", "external_libs", "llvm")
if @os =~ /linux/
- @llvm_system_name = `lsb_release -irs`.split.join("-").downcase
+ begin
@selman
selman / init.el
Created July 4, 2010 18:54
ruby flymake
(require 'ido)
(ido-mode t)
(add-to-list 'load-path "~/.emacs.d/plugins/textmate")
(require 'textmate)
(textmate-mode)
;; Rinari
(add-to-list 'load-path "~/.emacs.d/plugins/rinari")
(require 'rinari)
[slmn@azrael cbtohtml]$ time ./cbtohtml.rb &>/dev/null
real 0m0.726s
user 0m0.313s
sys 0m0.043s
require 'yaml'
s = "a string"
a = %w(a array)
puts "Before setting instance variable:\n#{s.to_yaml}\n#{a.to_yaml}\n"
s.instance_variable_set(:@test, 'test')
a.instance_variable_set(:@test, 'test')
source :rubygems
# Project requirements
gem 'rake'
gem 'rack-flash'
gem 'thin' # or mongrel
# Component requirements
gem 'haml'
gem 'dm-sqlite-adapter'
@selman
selman / heroku.rb
Created September 7, 2010 23:08
Padrino heroku template
RAKEFILE = <<-RAKEFILE
require File.dirname(__FILE__) + '/config/boot.rb'
require 'thor'
require 'padrino-core/cli/rake'
PadrinoTasks.init
RAKEFILE
PV = Padrino.version
GEMFILE = <<-GEMFILE
class List
attr_reader :list
def initialize *args
args.each do |a|
if a.kind_of? Range
@list = parse(args, args.index(a))
end
end
end
require 'yaml'
class Plugin
class << self; attr :plugins; end
@plugins = []
def initialize opts = nil
if opts
opts.each do |k,v|
instance_variable_set('@' + k, v)
@selman
selman / dmassoc.rb
Created December 17, 2010 15:32
self referential relationship
require 'data_mapper'
DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, "sqlite:memory:")
class Person
class Link
include DataMapper::Resource