Skip to content

Instantly share code, notes, and snippets.

View dallas's full-sized avatar

Dallas Reedy dallas

View GitHub Profile
@dallas
dallas / syntax highlighting for Rails builders in TextMate
Created June 24, 2009 23:42
Syntax highlighting for Rails builders in TextMate (add to the Ruby on Rails language)
# This is now part of the Ruby on Rails bundle in my textmate_paraphernalia repository
{ match = '(\b(xml|css)\b\.)(\b\w+\b!?)?';
captures = {
2 = { name = 'variable.other.builder.rails'; };
3 = { name = 'function.other.builder.rails'; };
};
},
@dallas
dallas / try.rb
Created July 8, 2009 21:24 — forked from CodeOfficer/try.rb
TryProxy by CodeOfficer from heypanda.com
# courtesy of http://heypanda.com/
class TryProxy
def initialize(receiving_object)
@receiving_object = receiving_object
end
def method_missing(meth, *args, &block)
@receiving_object.nil? ? nil : @receiving_object.send(meth, *args, &block) rescue nil
end
@dallas
dallas / rails_template.rb
Created July 8, 2009 21:29 — forked from henrik/rails_template.rb
Rails template for v2.3 by henrik
# Rails template for Rails 2.3. Work in progress.
# By Henrik Nyh (http://henrik.nyh.se) 2009-03-29. Public domain.
# Usage: rails myapp -m http://gist.github.com/87341.txt
META_AUTHOR = "Henrik Nyh (http://henrik.nyh.se)"
JQUERY_VERSION = "1.3.2"
APP_NAME = File.basename(Dir.pwd)
git :init
@dallas
dallas / to_word.rb
Created August 9, 2009 04:26
implementation of Integer#to_word
class Integer
@@singles ||= ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
@@teens ||= ['ten', 'eleven', 'twelve', 'thirteen', '', 'fifteen']
@@tens ||= ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
@@places ||= [ 'hundred', 'thousand', 'million', 'billion', 'trillion', 'quadrillion', 'quintillion',
'sextillion', 'septillion', 'octillion', 'nonillion', 'decillion', 'undecillion',
'duodecillion', 'tredecillion', 'quattuordecillion', 'quindecillion', 'sexdecillion',
'septendecillion', 'octodecillion', 'novemdecillion', 'vigintillion'] # etc.
# (QUICKLY) Converts a number into English words.
@dallas
dallas / html_examples.html
Created August 10, 2009 20:44
HTML elements—like, all of 'em
<!-- Got this from inside the gridz_app files
http://github.com/tschmidt/gridz_app
Other than that, I don't know where it's from, but I like it! -->
<h1>This document shows various HTML elements</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit Lorem ipsum dolor sit amet, volutpat. </p>
<h2>This is 2nd level heading bh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi luptatum zzril delenit Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam no</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </p>
@dallas
dallas / easy_columns.css
Created August 13, 2009 17:10
thoughts on CSS columnar grids in TextMate
/* Need to make a columnar CSS layout (for a 960-grid, say)?
Have a fixed width base to work off of (like 960 pixels)?
Want it in all kinds of sizes (2,3,4,5,6,8,10 & 12, say)?
Then this is the snippet for you!
In TextMate, you can just select all
of the following lines and press:
Ctrl + Shift + E (evaluate as ruby).
This snippet is based on a 960px base,
@dallas
dallas / fun with Fib.rb
Created August 13, 2009 22:01
having fun with Hash initializer and the Fibonacci Sequence
# Having some fun with a simple Fibonacci sequence Hash!
fibonacci = Hash.new {|hash, key| hash[key] = hash[key - 1] + hash[key - 2]}
#=> {}
# Gotta get things started here…
fibonacci[1] = 1
#=> 1
@dallas
dallas / gist:176414
Created August 27, 2009 16:27 — forked from laserlemon/gist:175993
software install directions by laserlemon
# Leopard Development Environment (from clean installation)
# Replace USERNAME with your OS X short name.
# Replace PASSWORD with your MySQL root password.
# Install XCode Tools
# Install MacPorts
# Install Textmate
# Generate an SSH key
ssh-keygen
@dallas
dallas / gist:178685
Created August 31, 2009 20:18
IRb enhancements & settings
We couldn’t find that file to show.
@dallas
dallas / flash_message.rb
Created December 3, 2009 22:06
The beginnings of Flashtastic!
# Create a ViewHelper class or module (whatever) for dealing with flash messages in an easy-to-use format
# the current way:
<%- if flash[:error] -%>
<p class="error"><%= flash[:error] %></p>
<%- end -%>
<%- if flash[:notice] -%>
<p class="notice success">
<%= flash[:notice] %> <%= link_to('View Now', view_post_path) if post_created %>
</p>