Skip to content

Instantly share code, notes, and snippets.

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

Tim Lucas toolmantim

:shipit:
🎉
View GitHub Profile
<!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;
# 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
#
# 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)
#!/usr/bin/env ruby
require 'rubygems'
gem = Gem.cache.search(Gem::Dependency.new(ARGV.first, '> 0')).last
system "mate #{gem.full_gem_path}"
# 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
#header
.state{:title => "Not Logged in"}
%a{:href => "#"} Login
or
%a{:href => "#"} Register
.state{:title => "Logged in"}
Welcome Tim!
# Some fish things for @markryall
// Adds controller methods to elements
$$ = function(elem, methods) {
if (methods) $(elem).data("controller", methods);
return $(elem).data("controller");
}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Really annoying IE6/7 radio name bug</title>
<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(function() {
namespace :gems do
desc "Install missing gem dependencies"
task :install do
File.read("#{File.dirname(__FILE__)}/.gems").each do |gem_decl|
gem_name, version, source = gem_decl[/^([^\s]+)/,1], gem_decl[/--version ([^\s]+)/,1], gem_decl[/--source ([^\s]+)/,1]
begin
version ? gem(gem_name, version) : gem(gem_name)
rescue Gem::LoadError
puts "Installing #{gem_name} #{version}..."
cmd = "gem install #{gem_name}"