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
#pdf_link a:after { | |
content: "<" attr(href) ">"; | |
} |
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
resource_path_name = Rails.root + 'config' + 'properties.xml' | |
resource_properties = java.util.Properties.new | |
resource_properties.load_from_xml(java.io.FileInputStream.new(resource_path_name.to_s)) | |
# resource_properties['my.key'] # => 'value' | |
resource_properties.store_to_xml(java.io.FileOutputStream.new(resource_path_name.to_s), 'jruby rulez') |
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
# java resource bundles initializer | |
if defined?(JRUBY_VERSION) | |
# include config directory in the class path | |
$CLASSPATH << "file:///#{File.expand_path(File.join(RAILS_ROOT, 'config'))}/" | |
# because ResourceBundle.getBundle doesn't seem to use the JRuby class loader, | |
# we need to pass it explicitly. | |
def load_resource_bundle(basename, lang = java.util.Locale::ENGLISH) |
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
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') | |
describe 'Machinist' do | |
models = Dir[File.expand_path(File.dirname(__FILE__) + '/../app/models/*.rb')]. | |
map{|file| File.basename(file, '.rb') } - %w{mailer} | |
models.map{ |model| model.classify.constantize }.each do |model| | |
it "should have a blueprint for the #{model} model" do | |
model.make.should be_instance_of(model) | |
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
# jhbuild on macos | |
git clone git://git.gnome.org/jhbuild --depth=1 | |
cd jhbuild | |
./autogen.sh | |
make | |
make install | |
export PATH=$PATH:~/.local/bin |
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
tar -cvjR --remove-files -f backup.tbz2 backup/ |
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
# Implements the "missing action" route by default | |
# see http://thelucid.com/2010/03/15/rails-can-we-please-have-a-delete-action-by-default/ | |
ActionController::Resources::Resource.class_eval do | |
def add_default_actions_with_delete_action | |
add_default_actions_without_delete_action | |
add_default_action(member_methods, :get, :delete) | |
end | |
alias_method_chain :add_default_actions, :delete_action |
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
def random_string(length) | |
(0...length).inject("") { |m,n| m << (?A + rand(25)).chr } | |
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
class PaypalPayment | |
def initialize(hash=nil) | |
hash.each_pair { |k,v| self.instance_variable_set("@#{k}".to_sym, v) } if hash.respond_to? :each_pair | |
end | |
attr_accessor :payment_gross, :mc_gross, :mc_currency, :payment_status, :pending_reason, #payment | |
:discount, :tax, | |
#transaction | |
:txn_type, :transaction_subject, | |
# payer |
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
#!/usr/bin/env ruby | |
class Usually | |
undef_method *instance_methods.grep(/^(?!__|object_id)/) | |
def initialize(usual) | |
@usual = usual | |
end | |
def unless(cond, &unusual) |