This file contains hidden or 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 BigDecimal | |
def self.do_cool_stuff | |
puts "cool stuff done" | |
end | |
end |
This file contains hidden or 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
# all my bigdeciamls going into this have been .round(2) beforehand | |
dollar[1] = dollar[1].split[1] | |
dollar[1] = "#{dollar[1][0, dollar[1].length-2].gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")}.#{dollar[1][dollar[1].length-2,2]}" | |
# credit where credit is due, I stole the gsub part from merb numeric helper - thanks merb!! | |
# the rest was bigdecimal docs :) |
This file contains hidden or 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 War | |
class War::Character | |
include DataMapper::Resource | |
property :id, Serial | |
has n, :raid_participations, :class_name => 'War::RaidParticipants' | |
has n, :raids, :class_name => 'War::Raid', :through => :raid_participations, :child_key => [:character_id] | |
end |
This file contains hidden or 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 Znq | |
module Dm;end | |
end | |
class Znq::Dm::DealGroup | |
include DataMapper::Resource | |
property :id , Serial | |
has n, :deals, :through => Resource, :class_name => "Znq::Dm::Deal", :child_key => [:deal_id] |
This file contains hidden or 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
**After the fact** | |
namelessjon pointed me in the right direction. | |
map /asdasdasd do | |
run app | |
end | |
request.env['SCRIPT_NAME'] = "/asdasdasd" | |
also this is all in gem form: http://github.com/emk/sinatra-url-for/tree/master | |
I needed a way to have my apps be under scm and all config stuff be somewhere else. |
This file contains hidden or 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
.onsalesidebar <= sidebar { | |
/* extends .sidebar */ | |
background-color: #FFA500; | |
} |
This file contains hidden or 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 Post < BaseCouchRestModel | |
end | |
class Person < BaseCouchRestModel | |
end | |
class Tag < BaseCouchRestModel | |
end | |
This file contains hidden or 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
Merb::BootLoader.before_app_loads do | |
# Hash extension for parsing form names into useable hash/object | |
class Hash | |
def expand_hash | |
sub_keys = self.keys.map { |key| key.to_s.match(/^[^-]+/).to_a.first if key.to_s.match(/-/) }.compact.uniq | |
result = {}; | |
self.each do |key, value| | |
result[key] = value unless sub_keys.include?( key.to_s.match(/^[^-]*/).to_a.first ) | |
end | |
This file contains hidden or 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
# is there a "proper" way to do this? | |
# I want to return a pdf via prince if it is a pdf requested | |
# Otherwise return html reponse | |
class RefCove < Application | |
def show(id, cove_id) | |
provides :pdf, :html | |
@cove = Cove.get(cove_id) | |
raise NotFound if @cove.nil? |
This file contains hidden or 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
#!/bin/sh | |
# | |
# couchdb - this script starts and stops the couchdb server | |
# | |
# chkconfig: - 85 15 | |
# description: Apache CouchDB document database server. | |
# processname: beam | |
# pidfile: /opt/couchdb/var/run/couchdb/couchdb.pid | |
# Source function library. |