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
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. |
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
ASDF | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. |
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
#!/bin/sh | |
html2haml -r "$TM_FILEPATH" | sed 's/>/>/g' | sed 's/</</g' | sed 's/- end//g' | sed 's/"/"/g' | sed 's/&/\&/g' |
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
>> require 'benchmark' | |
=> [] | |
>> n = 1000 | |
=> 1000 | |
>> Benchmark.bm do |x| | |
> x.report{User.find(:first, :order => "rand()")} | |
>> x.report{User.random} | |
>> end | |
user system total real | |
0.000000 0.000000 0.000000 ( 0.007087) |
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
def get_parent_resource(target_klass, path) | |
# Convert the requested path into hash form | |
hash = ActionController::Routing::Routes.recognize_path(path, :method => :get) | |
# Loop through path keys and see if any end in '_id' | |
# and our child class belongs_to the associated AR Class | |
pair = hash.detect do |k, v| | |
k.to_s.ends_with?("_id") && target_klass.columns_hash.has_key?(k.to_s) | |
end | |
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
<a href="/timesheet/day/1772-04-28">Sun (04/28)</a> | |
<a href="/timesheet/day/2008-11-17">Mon (11/17)</a> | |
<a href="/timesheet/day/2245-06-08">Tue (06/08)</a> | |
<a href="/timesheet/day/2481-12-27">Wed (12/27)</a> | |
<a href="/timesheet/day/2718-07-19">Thu (07/19)</a> | |
<a href="/timesheet/day/2955-02-06">Fri (02/06)</a> | |
<a href="/timesheet/day/3191-08-28">Sat (08/28)</a> |
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
# Usage: | |
# >> User.random | |
# => #<User login: ... | |
class ActiveRecord::Base | |
def self.random | |
begin | |
find(rand(count)) | |
rescue ActiveRecord::RecordNotFound |
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
# application_helper.rb | |
# Generic form label styling | |
def box_label(text) | |
text = "#{text}:" unless text.end_with?(":") | |
"<span class=\"box_label\">#{text}</span>" | |
end | |
# A generic box to encapsulate some text | |
def box(title = nil, *args, &block) |
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
# /some_object/show.html.erb | |
<% box('Name:') do %> | |
<%=h @some_object.name %> | |
<% end %> |
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
<div class="box"> | |
<span class="box_label">Name:</span> | |
J080119 - Technology Department | |
</div> |
OlderNewer