Skip to content

Instantly share code, notes, and snippets.

View jqr's full-sized avatar

Elijah Miller jqr

View GitHub Profile
⌘Command, ⇧ Shift, ⌃ Control, ⌥ Option/Alt, ⎋ Escape, ↩ Enter/Return, ⌫ Backspace, ⇥ Tab
Help
⌘? Help
⌃⌘⌥B Bundle Docs/Editor
File
⌘S Save File
⌘W Close File
⌃⌘S Save Project
# Untested, but it should work :)
class Something < ActiveRecord::Base
# Simpler approach available with this small Rails patch:
# http://rails.lighthouseapp.com/projects/8994/tickets/1773-allow-returning-nil-from-a-named_scope-lambda
#
# named_scope :with_town_like, lambda { |term|
# { :conditions => ['town LIKE ?', term] } unless term.blank?
# }
#
# How I might test this helper
module SomeHelper
def title(page_title)
content_for(:title) { page_title }
end
end
describe SomeHelper
include SomeHelper
@jqr
jqr / example.rb
Created August 22, 2008 18:21
Ruby String#to_json with support for html encoding and decoding
# When inserting Javascript in HTML there is a a problem with the
# </script> end tag.
#
# Standard Javascript escaping works fine for most strings, but the
# browser interprets </script> before Javascript is being parsed, so
# it needs to be HTML escaped while the browser is parsing, and then
# unescaped as Javascript parses it.
# Regular to_json
{ 'key' => '</script>' }.to_json
Dave sucks... srsly.