Skip to content

Instantly share code, notes, and snippets.

# Detects what server your Rails app is running under.
# Either passenger, fastcgi, mongrel, webrick or thin
def running_under
# For passenger, IN_PHUSION_PASSENGER is key
is_passenger = (defined?(IN_PHUSION_PASSENGER) and IN_PHUSION_PASSENGER)
# Not sure about fastcgi, but this should do the trick
is_fastcgi = (Kernel.const_get('RailsFCGIHandler') if defined?(FCGI)) rescue false
First things first, Dreamhost can be a complete nightmare, so be prepared to loose your sanity over this.
1. I need gem x
Follow the instructions at http://wiki.dreamhost.com/index.php/RubyGems to make your own gem installation, then add the following to the top of your config/environment.rb
ENV['GEM_PATH'] = "/home/username/.gems:/usr/lib/ruby/gems/1.8"
2. Out of date RedCloth
# Simple script to consolidate multiple colloquy transcripts into a single HTML log
# Reads from logs/*.colloquyTranscript
# Outputs to out.html
# Have multiple logs of conversations with a user who uses multiple nicknames
# in colloquy, each in separate files?
#
# Well here is the solution. Now you'll never get confused over which important
# piece of information is in which transcript ever again, as it will all be
@jamesu
jamesu / barcamp_parse.rb
Created January 7, 2009 19:57
Parses dates from barcamp.org. Outputs to ical calendar
# Simple script to parse dates of Barcamp events from barcamp.org
#
# Outputs to barcamp.ics
#
require 'rubygems'
require 'nokogiri'
require 'fileutils'
require 'date'
require 'time'
##
# Calendar helper with proper events
# http://www.cuppadev.co.uk/webdev/making-a-real-calendar-in-rails/
#
# (C) 2009 James S Urquhart (jamesu at gmail dot com)
# Derived from calendar_helper
# (C) Jeremy Voorhis, Geoffrey Grosenbach, Jarkko Laine, Tom Armitage, Bryan Larsen
# Licensed under MIT. http://www.opensource.org/licenses/mit-license.php
##
##
# Posting stuff to EchoWaves using httparty
#
# Note: protect_from_forgery needs to be disabled
##
require 'httparty'
class Echowaves
# Allows embedded YouTube videos in EchoWaves.
# Simply replace mark_up in app/helpers/messages_helper.rb with the following
# NOTE: Ignores the rest of the message with the YT url in it, so ideally needs to be merged with the line splitting conversion of url's.
def mark_up(message)
return message.message if message.system_message == true # no markup for system_messages
content = message.message
# Youtube?
@jamesu
jamesu / deploy
Created February 25, 2009 15:13 — forked from peterc/deploy
#!/bin/bash
REMOTE_HOST='whatever'
USERNAME='whatever'
git push origin master && ssh ${REMOTE_HOST} "cd /home/${USERNAME}/www/rails;git pull origin master;chown -R ${USERNAME}:${USERNAME} *"
//
// MYAnimationView.h
// http://www.cuppadev.co.uk/iphone/animated-images-on-the-iphone-sans-memory-leaks
//
// A UIView control which animates an image by simply transforming a slide image
// containing frames of the animation inside a clipped subview.
// (in other words, like a flip book except instead of flipping pages,
// you move them around in a viewport)
//
// Requirements:
# Some people have been emailing me complaining that my calendar_helper code
# (http://gist.github.com/54116) doesn't work properly.
#
# So for all of you who can't perform a little bit of problem solving to get the code working correctly in your app, here is the code as used in a fork of RuckSack.
# Enjoy.
#==
# Copyright (C) 2009 James S Urquhart
#
# Permission is hereby granted, free of charge, to any person