Discover gists
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
// do as self.isany() | |
self.isa = function(/* args */) { | |
if (arguments.length > 0) { | |
// Prepare arguments and constructors | |
var args = Array.prototype.slice.call(arguments), // args provide an .isany() feature; could do in sep method | |
makers = [] //: list | |
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
ypcmc02106:pages dyoder$ irb | |
>> load 'startup.rb' | |
=> true | |
>> with | |
ArgumentError: wrong number of arguments (0 for 1) | |
from (irb):2:in `with' | |
from (irb):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
self.eq = function(other) { | |
// Is self equal to other? | |
if (self.length !== other.length) return 0 | |
var equal = 1 | |
for (var i=0; i<self.length; i++) { | |
if (self[i] !== other[i]) | |
equal = 0 | |
} | |
return equal | |
} |
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
self.istypeof = function(other) { | |
// Is self the same type as other? | |
} | |
self.isany = function(types) { | |
// take nums, chars, lists and maybe args | |
// can't see any reason to take hashes | |
} |
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
self.same = function(other) { | |
// Is self other? | |
if (no(other)) return self | |
return self === other | |
} |
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
if (results = Parser.new.parse).nil? | |
# parse failure | |
else | |
# displaying help info and exiting is a valid execution method | |
execute_with_options results | |
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
class ActionView::Helpers::FormBuilder | |
include ActionView::Helpers::UrlHelper | |
include ActionView::Helpers::TagHelper | |
include ActionView::Helpers::FormTagHelper | |
def tag_list(method, options={}) | |
return false unless options[:tags] | |
links = options[:tags].map do |tag| | |
link_to_function( tag.to_s, "toggle_tag('#{tag}', '#{@object.class.to_s.downcase}_#{method.to_s.pluralize.downcase}')", :class => ["tag", (@object.send(method).map(&:name).include?(tag.to_s) ? "selected" : "")].compact.join(" "), :id => tag ) | |
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
class String | |
def to_param | |
self.downcase.strip.gsub(/[\/ ]+/, "-").gsub(/[^a-z0-9\-\_]+/i, "").gsub(/\-+/,"-") | |
end | |
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
set :application, "application.url.com" | |
set :repository, "http://svn.#{application}/trunk/" | |
set :runner, ENV['LOGNAME'] | |
set :deploy_to, "/var/www/#{application}" | |
role :app, application | |
role :web, application | |
role :db, application, :primary => true | |
task :after_update_code, :roles => :app do | |
run "ln -s #{deploy_to}/shared/system/mongrel_cluster.yml #{release_path}/config/mongrel_cluster.yml" |
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
Ajax.Responders.register({ | |
onCreate: function() { | |
if($('busy') && Ajax.activeRequestCount>0) | |
Effect.Appear('busy',{duration:0.5,queue:'end'}); | |
}, | |
onComplete: function() { | |
if($('busy') && Ajax.activeRequestCount==0) | |
Effect.Fade('busy',{duration:0.5,queue:'end'}); | |
} | |
}); |