Skip to content

Instantly share code, notes, and snippets.

View DylanFM's full-sized avatar

Dylan Fogarty-MacDonald DylanFM

View GitHub Profile
module Merb
module GlobalHelpers
# helpers defined here available to all views.
def scaled_image_tag(max_width, img, opts={})
#I only need this for scaling with a max width
if opts.has_key? :height
h = (opts[:height].to_f*(max_width.to_f/opts[:width].to_f)).round
opts[:height] = h-(h%18) #For 18px baseline. Distorts.
end
#Mailer's controller method
def contact
if request.post?
@contact = Contact.new(params[:contact])
if @contact.valid?
send_mail(ContactMailer, :notify, {
:from => @contact.email,
:to => 'email',
:subject => "New enquiry from website"
}, { :contact => @contact })
@DylanFM
DylanFM / gist:83416
Created March 23, 2009 03:41
Sitemap.xml rake task
namespace :sitemap do
desc "Builds the sitemap XML file"
task :build => :merb_env do
domain = 'jeanmarie.local'
pages = ['','about','products','contact','sitemap']
Category.all.each do |category|
pages << "products/#{category.slug}"
# >> [["\\n\\rHeat # 1\n\t\t\t\t\t\t\t\t\t\tRip Curl Pro\n\t\t\t\t\t\t\t\t\t\tRound 1\n\t\t\t\t\t\t\t\t\t\t\\n\\rMore info ...\n\t\t\t\t\t\t\t\t\t\t\\n\\r\\n\\rHeat Scores\n\t\t\t\t\t\t\t\t\t\t\\n\\r\\n\\rWave/Wave",
# >> "singlet",
# >> "plc",
# >> "pts",
# >> "name",
# >> "from",
# >> "\\n\\rYellow",
# >> "1",
# >> "13.00",
# >> "David Weare",
export dev='/Users/dylanfm/Development'
export devwork='/Users/dylanfm/Development/Work'
# Quick links to client projects
# Only directories
for DIR in `ls -l $devwork | awk '/^d/ { print $NF }'`
do
export $DIR=$devwork/$DIR
done
# http://www.xcombinator.com/2008/02/22/ruby-inject-and-the-mandelbrot-set/
require 'complex'
def mandelbrot(a)
Array.new(50,a).inject(a) { |z,c| z*z + c }
end
(1.0).step(-1,-0.05) do |y|
(-2.0).step(0.5,0.0315) do |x|
1056,64,1152,4608,2432,0,16,16,512,0,2368,2048,0,1600,32,2064
Processing UploadsController#thanks (for 127.0.0.1 at 2009-09-04 15:51:13) [GET]
Parameters: {"member_id"=>"dylanfm", "gallery_id"=>"2-onthecoast"}
Site Columns (3.6ms) SHOW FIELDS FROM `sites`
Site Load (1.2ms) SELECT * FROM `sites` WHERE (`sites`.`domain` = 'dev.humude.com') LIMIT 1
Member Columns (8.4ms) SHOW FIELDS FROM `members`
Member Load (0.3ms) SELECT * FROM `members` WHERE (`members`.`username` = 'dylanfm') LIMIT 1
Gallery Columns (2.2ms) SHOW FIELDS FROM `galleries`
Gallery Load (0.4ms) SELECT * FROM `galleries` WHERE (`galleries`.`id` = '2-onthecoast') AND (`galleries`.member_id = 1) LIMIT 1
Rendering template within layouts/em
Rendering uploads/thanks
LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so
PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.5
# PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
# Use RVM 1.8.6 ruby
PassengerRuby /Users/dylanfm/.rvm/bin/ruby-1.8.6-p383
*** Passenger ERROR (ext/common/SpawnManager.h:232):
Could not start the spawn server: /Users/dylanfm/.rvm/bin/ruby-1.8.6-p383;: No such file or directory (2)
[ pid=14394 file=ext/apache2/Hooks.cpp:725 time=2009-09-07 10:58:50.89 ]:
Unexpected error in mod_passenger: Cannot spawn application '/Users/dylanfm/Development/Work/plus2/v5': The spawn server has exited unexpectedly.
Backtrace:
in 'virtual boost::shared_ptr<Passenger::Application::Session> Passenger::ApplicationPoolServer::Client::get(const Passenger::PoolOptions&)' (ApplicationPoolServer.h:471)
in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:521)