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
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<script src="jquery-1.3.min.js" type="text/javascript"></script> | |
</head> | |
<body> | |
FireUnit Fun! | |
<input type="text" id="blah" name="blah" value="blah" /><br/> | |
<div id="some_div">some div</div> | |
</body> | |
</html> |
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
#Examples: | |
# modalbox_spawn(:link_text=>"content", :content=>"Content for light box", :width=>1000) | |
# modalbox_spawn(:link_text=>"partial render", :partial=>"partials/education_component", :locals=>{:key=>"value"}) | |
# modalbox_spawn(:link_image=>"icons/pedigree_button1.gif", :content=>"<h2>COMING SOON: Pedigree Viewer. w00t!</h2>") | |
# modalbox_spawn(:link_text=>"View Pedigree", :classes=>"black_link other1 other2", :content=>"<h2>COMING SOON: Pedigree Viewer. w00t!</h2>") | |
# modalbox_spawn(:link_text=>"View Pedigree", :id=> person_being_viewed, :content=>"some content") | |
def modalbox_spawn(options={}) | |
link_path = options[:link_path] || root_path | |
link_display = options[:link_text] || image_tag(options[:link_image]) |
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
#RUBYISMS | |
a = b.foo | |
if a.empty? | |
a = b.bar | |
else | |
a.reverse! | |
end | |
#can be simplied a little by assigning and |
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
########################################## | |
#Ruby idioms | |
######################################## | |
#old school | |
breakfast = nil | |
if !breakfast | |
breakfast = "bacon" | |
end | |
#cool but is there a better way? | |
breakfast = "bacon" unless breakfast |
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
#todo use select | |
def self.getDnaLab(lab_name) | |
DnaLabs.each do |lab| | |
if lab.name == lab_name | |
return lab | |
end | |
end | |
return nil | |
end | |
#todo: use select |
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 self.getDnaLab(lab_name) | |
DnaLabs.detect{|lab| lab.name == lab_name} | |
end | |
def self.getLabDisplayName(labName) | |
getDnaLab(labName).try(:display_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
module Sortable | |
def sort(options={}) | |
attributes = options[:attributes].inject("["){|attribute_string, attribute| attribute_string << "object.#{attribute},"} + "]" | |
options[:collection].sort_by{|object| eval(attributes)} | |
end | |
end | |
class Person | |
extend Sortable | |
attr_accessor :firstname,:lastname,:age |
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 AttributesSort | |
def self.included(receiver) | |
Array.class_eval do | |
def do_sort(options = {}) | |
type = self.first.class | |
type.instance_eval do | |
def do_attributes_sort(collection, options={}) | |
attributes = options[:sort_by].inject("["){|attribute_string, attribute| attribute_string << "object.#{attribute},"} + "]" | |
collection.sort_by{|object| eval(attributes)} | |
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
require 'image_size' #imagesize.rubyforge.net | |
=begin | |
This is a small test script that I wrote to play around with Ruby's directory | |
and file handling. | |
The scenario is this... I have a directory structure as follows: | |
/rename.rb |
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 AttributesSort | |
def self.included(receiver) | |
receiver.instance_eval do | |
def build_attributes(attributes) | |
"[" + attributes.map!{|a| "object.#{a}"}.join(",") + "]" | |
end | |
def do_attributes_sort(collection, options={}) | |
attributes = build_attributes(options[:sort_by]) | |
collection.sort_by{|object| eval(attributes)} |
OlderNewer