Skip to content

Instantly share code, notes, and snippets.

BOBO!!!
IT WORKS!!!!
hello
@rwilcox
rwilcox / services.markdown
Created September 21, 2011 20:26
How to create a new gist from OS X Service

How to create a Public Gist Service:

Step 0: Open Automator, New Service.

Step 1: Drag out Run Shell Script action. Pass Input to STDIN

Step 2: This code:

open `gist`
@rwilcox
rwilcox / v2_presenter.rb
Created September 23, 2011 03:10
Revised Presenter pattern
def primary_comment
if self.visits.count > 1
output = s"<details class='primary_comment'>"
output << helpers.content_tag(:summary, {}, nil, false) {
s("<h3>", Present(self.comments.last).url_span, " (and #{self.comments.count - 1} others)</h3>")
}
output << helpers.content_tag(:ul) do
self.comment[0...-1].collect { |comment| s(Present(comment).comment_li) }.join("\n")
@rwilcox
rwilcox / presenter_s_implementation.rb
Created September 23, 2011 03:19
Implement the s presenter helper
def s(*args)
output = "".html_safe
args.each {|current_arg|
output << current_arg.html_safe
}
output
end
# The Specs for said function
This is a test
Hello world
this is a long gist
well kind of, I'm testing something
@rwilcox
rwilcox / businesses_controller.rb
Created October 20, 2011 13:57
undefined helper_method
# Info: Rails 3.1.1
class BusinessesController < ApplicationController
helper_method :business
# [snip controller crap]
def business
@business ||= Business.find(params[:id])
end
#!/usr/bin/env ruby
print ARGF.read.match(/<#(.+)#/)[1]