Skip to content

Instantly share code, notes, and snippets.

View toolmantim's full-sized avatar
:shipit:
🎉

Tim Lucas toolmantim

:shipit:
🎉
View GitHub Profile
#header
.state{:title => "Not Logged in"}
%a{:href => "#"} Login
or
%a{:href => "#"} Register
.state{:title => "Logged in"}
Welcome Tim!
# An example of the simplest possible Capfile. Useful for redeploying small
# apps hosted with mod_rails. It doesn't import the standard cap recipes
# (such as setting up the app on the server) it simply handles redeployment.
#
# I was meant to show it at the RORO Sydney May meetup during my preso:
# http://www.slideshare.net/toolmantim/roro-may-lightning-preso-madness
#
# This was taken pretty much straight from the Capfile for
# http://byjodiemcleod.com
#!/usr/bin/env ruby
require 'rubygems'
gem = Gem.cache.search(Gem::Dependency.new(ARGV.first, '> 0')).last
system "mate #{gem.full_gem_path}"
# Chuck this in config/initializers for view-first validations
ActionView::Base.default_form_builder.class_eval do
def error(field)
case err = object.errors.on(field)
when String: err
when Array: err.first
end
end
def errors(field)
case err = object.errors.on(field)
# Example of simplifying Cucumber stories by assuming you can read simple Ruby structures
#
# Used in my presentation:
#
# http://www.slideshare.net/toolmantim/roro-may-lightning-preso-madness
#
# Use them like so:
#
# Feature: Feedback form
#
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Weird floatin</title>
<style type="text/css" media="screen">
body {
font-family: arial, sans-serif;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>IE float bug</title>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
<style type='text/css'>
body {
font-family: Helvetica, sans-serif; }
#container, #left, #right1, #right2 {
%a{:href => name, :class => (@category == name ? "selected" : nil)}
%span= name
HoptoadNotifier.configure do |config|
config.environment = RAILS_ENV
config.application_root = RAILS_ROOT
end
class HoptoadNotifier::Rails
def self.notify(request)
# Do your thang
end
end
# Example of using Hoptoad from a Sinatra app.
#
# This uses the existing Rails plugin with a hacky workaround for RAILS_ENV
# and RAILS_ROOT - better for now than recreating a whole plugin and duplicating
# all the config, backtrace cleaning, etc. I'm hoping this provides an example
# for a future version of the notifier plugin that supports various
# frameworks.
require 'rubygems'