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
| # This shell script uploads a video to Vimeo Service. | |
| # | |
| # Usage : | |
| # $> ruby vimeo_upload.rb ~/my_video.avi | |
| # Video uploaded id = 2052244 | |
| # | |
| # The video URL is then http://www.vimeo.com/2052244 | |
| # | |
| require "easy_vimeo_upload" |
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 ActionController::Request # ActionController::AbstractRequest in Rails < 2.3 | |
| # Returns true if the request seems to come from a bot | |
| def bot? | |
| user_agent =~ /\b(Baidu|Gigabot|Googlebot|libwww-perl|lwp-trivial|msnbot|SiteUptime|Slurp|WordPress|ZIBB|ZyBorg)\b/i | |
| end | |
| end | |
| # | |
| # Then in your controllers you can do : | |
| # |
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
| This : | |
| <%= link_to "Delete", @comment, :method => :delete %> | |
| With Rails 2 : | |
| <a href="/comments/1" onclick="var f = | |
| document.createElement('form'); f.style.display = 'none'; | |
| this.parentNode.appendChild(f); f.method = 'POST'; f.action = | |
| this.href;var m = document.createElement('input'); |
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
| DOC : | |
| Workling / Starling | |
| Workling / Starling | |
| How to use/test Workling / Starling in development mode (ONLY) ? | |
| First, install the gems : | |
| $> sudo gem install eventmachine memcache-client |
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
| # in app/workers/testing_worker.rb | |
| class TestingWorker < Workling::Base | |
| def this_is_a_test(options) | |
| File.open(options[:id], "w") { |f| 1.upto(30) { f.write "."; f.flush; sleep(1) } } | |
| end | |
| end | |
| # in any controller... |
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
| namespace :workling do | |
| namespace :client do | |
| desc "Starts workling client" | |
| task :start, :roles => :app, :only => { :primary => true } do | |
| run "sudo -u #{app_user} bash -c 'cd #{current_path} && export RAILS_ENV=#{rails_env} && ./script/workling_client stop'" | |
| run "sudo -u #{app_user} bash -c 'cd #{current_path} && rm -f log/workling.output'" | |
| run "sudo -u #{app_user} bash -c 'cd #{current_path} && export RAILS_ENV=#{rails_env} && ./script/workling_client start'" | |
| end | |
| desc "Stops workling client" |
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 ActionView::Helpers::TextHelper | |
| def truncate(text, *args) | |
| options = args.extract_options! | |
| # support either old or Rails 2.2 calling convention: | |
| unless args.empty? | |
| options[:length] = args[0] || 30 | |
| options[:omission] = args[1] || "..." | |
| end | |
| options.reverse_merge!(:length => 30, :omission => "...") |
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
| Rails::Initializer.run do |config| | |
| # ... | |
| config.gem 'thoughtbot-paperclip', :version => '>= 2.2.9.1', :lib => 'paperclip', :source => "http://gems.github.com" | |
| config.gem 'mbleigh-subdomain-fu', :version => '>= 0.0.5', :lib => "subdomain-fu", :source => "http://gems.github.com" | |
| # ... | |
| 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
| root@ec2-72-44-38-243:~# cd /mnt/keldelice-production/current && sudo -u rails RAILS_ENV=production rake data_import:process | |
| (in /mnt/keldelice-production/releases/20090624101854) | |
| Processing of pending operations... | |
| Done! |
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 relateds_around | |
| product_id = self.id | |
| organization_id = self.organization.id | |
| Relationship.find(:all) do | |
| any do | |
| all do | |
| left_type == "Product" | |
| left_id == product_id | |
| right_type == "Place" | |
| end |