Skip to content

Instantly share code, notes, and snippets.

View gavinhughes's full-sized avatar

Gavin Hughes gavinhughes

View GitHub Profile
# Add js functions to the page on document.ready. Arguments as strings.
# Ex: <% ready("hideDiv('div1');", "toggleFields();)")
#
def ready(*functions)
content = functions.each{ |fx| fx << ';' }.join(' ')
content_for(:head, javascript_tag("$(function() { #{content} });"))
end
module ActiveRecord
module Associations # :nodoc:
module ClassMethods # :nodoc:
class JoinDependency # :nodoc:
class JoinAssociation < JoinBase # :nodoc:
def association_join
connection = reflection.active_record.connection
join = case reflection.macro
when :has_and_belongs_to_many
" #{join_type} %s ON %s.%s = %s.%s " % [
Gavin@Gavin blog$ cat /Users/Gavin/.rvm/log/ruby-1.8.7-p249/make*.log
[2010-02-07 06:56:18] make
eval.c: In function 'rb_eval_string_wrap':
eval.c:1744: warning: assignment discards qualifiers from pointer target type
eval.c: In function 'rb_eval_cmd':
eval.c:1885: warning: assignment discards qualifiers from pointer target type
eval.c: In function 'call_trace_func':
eval.c:2736: warning: assignment discards qualifiers from pointer target type
eval.c: In function 'rb_raise_jump':
eval.c:4770: warning: assignment discards qualifiers from pointer target type
Gavin@Gavin gb (master)$ rvm 1.8.7 ; rvm info
rvm 0.1.14 by Wayne E. Seguin ([email protected]) [http://rvm.beginrescueend.com/]
system:
uname: "Darwin Gavin.local 10.2.0 Darwin Kernel Version 10.2.0: Tue Nov 3 10:37:10 PST 2009; root:xnu-1486.2.11~1/RELEASE_I386 i386 i386"
shell: "bash"
version: "3.2.48(1)-release"
ruby:
~$ rvm list
rvm rubies
=> ruby-1.9.2-rc1 [ x86_64 ]
~$ rvm list gemsets
rvm gemsets
/* Beautiful cross-browser CSS buttons
Source: http://technology.posterous.com/make-css3-buttons-that-are-extremely-fancy
Example ussage:
<div class="fancy_button">
<a href="#">
<span style="background-color: #070;">Post</span>
</a>
</div>
@gavinhughes
gavinhughes / Conversation
Created November 23, 2010 11:59
Conversation: concept for a internal messaging gem
= conversation
Conversation is a Ruby gem that gives your Rails 3 application messaging and commenting features.
Messages and comments can be configured to be either threaded or unthreaded. Any number of models
can be messageable, commentable, or both. You make a model messageable like this
class User < ActiveRecord::Base
messageable
end
@gavinhughes
gavinhughes / Slugify
Created July 9, 2011 01:18
Convert string to underscored slug
module Slugify
def slugify(string)
# Strip the string
ret = string.strip
# Blow away apostrophes
ret.gsub! /['`]/,""
@gavinhughes
gavinhughes / rails31init.md
Created October 28, 2011 07:58 — forked from docwhat/rails31init.md
Rails 3.1 with Rspec, Factory Girl, Haml, Simple Form, Database Cleaner, Spork, and Guard

Install Rails 3.1

gem install rails

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@gavinhughes
gavinhughes / gist:1323987
Created October 29, 2011 01:57
Cucumber web steps
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
require 'uri'
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))