Skip to content

Instantly share code, notes, and snippets.

View jerome's full-sized avatar

Jérôme Lipowicz jerome

View GitHub Profile
# -- coding: utf-8
require "rubygems"
require "grill"
Grill.implant <<-GEM
source :rubygems
gem 'capybara', :require => ["capybara", "capybara/dsl"]
gem "capybara-webkit"
gem "headless"
# -- coding: utf-8
require "rubygems"
require "grill"
Grill.implant <<-GEM
source :rubygems
gem 'capybara', :require => ["capybara", "capybara/dsl"]
gem "capybara-webkit"
gem "headless"
# 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...
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"
# 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...
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"
@jerome
jerome / ghkey.rb
Created May 17, 2009 18:49 — forked from fcoury/ghkey.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'octopi'
require 'choice'
include Octopi
Choice.options do
header ''
# Installing ruby mysql gem in OSX 10.5 (Leopard)
$ sudo gem install mysql -- --with-mysql-config=`which mysql_config`
$ sudo install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle
class MigrateProductsToPaperclip < ActiveRecord::Migration
def self.up
# Rename the old "image" column to "old_file_name", since Product.image will now try to do Paperclip stuff
rename_column :products, :image, :old_file_name
# Rename asset directories to pluralize
File.rename("public/system/product","public/system/products")
File.rename("public/system/products/image","public/system/products/images")
module WordTruncateHelper
def word_truncate(text, *args)
options = args.extract_options!
unless args.empty?
options[:size] = args[0] || 75
options[:omission] = args[1] || "..."
end
options.reverse_merge!(:size => 75, :omission => "...")
text.scan(/(\S+)(\s+)/)[0..options[:size]].flatten.join << options[:omission] if text