This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):003:0> a = Account.first | |
~ SELECT `id`, `register_number`, `created_at`, `updated_at` FROM `accounts` ORDER BY `id` LIMIT 1 | |
=> #<Account id=1 register_number=nil created_at=nil updated_at=nil> | |
irb(main):004:0> c = Contact.first | |
~ SELECT `id`, `title`, `first_name`, `middle_name`, `last_name`, `suffix`, `company_name`, `created_at`, `updated_at`, `account_id`, `veterinarian_id`, `groomer_id`, `clinic_id` FROM `contacts` ORDER BY `id` LIMIT 1 | |
=> #<Contact id=1 title=nil first_name=nil middle_name=nil last_name=nil suffix=nil company_name=nil created_at=nil updated_at=#<DateTime: 212096641211/86400,-1/4,2299161> account_id=1 veterinarian_id=nil groomer_id=nil clinic_id=nil> | |
irb(main):005:0> c.account = a | |
=> #<Account id=1 register_number=nil created_at=nil updated_at=nil> | |
irb(main):006:0> c.save | |
=> true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Application | |
before :back_navigation | |
# maintain a back trace stack in session[:page_history], removing | |
# any path loops. back_resource() in global_helper will then | |
# use session[:page_history]. | |
def back_navigation | |
session[:page_history] ||= [] | |
previous_page = request.env['HTTP_REFERER'].to_s | |
current_page = (request.env['rack.url_scheme'] + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# divorce specs | |
# | |
# A divorce will dissolve the relationship between two objects, leaving | |
# the objects intact. Usage is symmetrical for all relationships | |
# | |
# Usage: | |
# | |
# 1:1 class Alpha belongs to Beta | |
# a.beta = b | |
# a.beta.divorce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=week_layout | |
:margin 0 | |
:padding 0 | |
:width 700px | |
:border 2px solid #333 | |
:background-color #ddd | |
ol | |
li | |
:list-style none | |
:list-style-position inside |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Merb::Template | |
class << self | |
# overwrite the load_template_io to look in app/views/templates if the | |
# given path is not found | |
def load_template_io(path) | |
io = super | |
Merb.logger.debug "Merb's load_template_io(#{path}) => #{io.inspect}" | |
if io.nil? | |
if path =~ %r((.*/app/views/).*(/[^/]+)$) | |
template_path = $1 + 'templates' + $2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
helpers/global_helpers.rb | |
# select_belongs_to('State', @address, :state_id, State, :name) | |
def select_belongs_to(title, base, base_attr_id, type, text_method) | |
selected = base.send(base_attr_id).to_s | |
# Merb.logger.info " selected => #{selected}" | |
select base_attr_id.to_sym, | |
:label => "#{title}: ", | |
:text_method => text_method.to_sym, | |
:value_method => :id, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nvidia-settings: X configuration file generated by nvidia-settings | |
# nvidia-settings: version 1.0 (root@royw-gentoo) Mon Oct 13 11:25:18 CDT 2008 | |
# gentoo ~x86 | |
# ms Natural keyboard Pro | |
# Logitech MX-1000 mouse | |
# Gyration wireless mouse & keyboard & MCE remote | |
# ms IntelliMouse Explorer | |
Section "ServerLayout" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# quick hack to show all devices on the local lan | |
subnet = '192.168.80' | |
range = 1..254 | |
range.each do |i| | |
str = `host #{subnet}.#{i}` | |
unless str =~ /NXDOMAIN/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> RestClient.post 'http://localhost:4000/commands', :command => {:process => 'Scan', :name => 'testing', :parameter => 'Movies'} | |
RestClient::ResourceNotFound: RestClient::ResourceNotFound | |
from ./bin/../lib/restclient/request.rb:187:in `process_result' | |
... | |
>> RestClient.get 'http://localhost:4000/commands/1' | |
=> "<command><id type='datamapper::types::serial'>1</id><parameter type='datamapper::types::text'>Movies</parameter><name>testing</name><finished_at type='datetime'>2009-05-27T19:57:41-05:00</finished_at><schedule type='datamapper::types::text'/><process>Scan</process><started_at type='datetime'>2009-05-27T19:57:41-05:00</started_at><watchdog_timeout type='integer'/><status type='datamapper::types::text'>Completed</status></command>" | |
And excerpts from the console log: | |
merb : worker (port 4000) ~ **** create **** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
royw-macbook:dm-core royw$ gem dependency merb -v 1.0.11 | |
Gem merb-1.0.11 | |
merb_datamapper (= 1.0.11, runtime) | |
merb-core (= 1.0.11, runtime) | |
merb-more (= 1.0.11, runtime) | |
dm-core (~> 0.9.11, runtime) | |
do_sqlite3 (~> 0.9.11, runtime) | |
dm-timestamps (~> 0.9.11, runtime) | |
dm-types (~> 0.9.11, runtime) | |
dm-aggregates (~> 0.9.11, runtime) |
OlderNewer