This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dave sucks... srsly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How I might test this helper | |
module SomeHelper | |
def title(page_title) | |
content_for(:title) { page_title } | |
end | |
end | |
describe SomeHelper | |
include SomeHelper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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? | |
# } | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⌘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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pathname' | |
class File | |
def self.relative_symlink(old_file, new_file) | |
symlink(relative_path(File.dirname(new_file), old_file), new_file) | |
end | |
def self.relative_path(base_path, file) | |
Pathname.new(File.expand_path(file)).relative_path_from(Pathname.new(File.expand_path(base_path))).to_s | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://facets.rubyforge.org/doc/api/core/classes/Array.html#M000145 | |
require 'rubygems' | |
require 'facets' | |
class Array | |
def permutations(min = 0, max = size + 1) | |
variations = [] | |
(min..max).each do |permutation_size| | |
permutation(permutation_size) do |permutation| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Re: http://twitter.com/danielmorrison/status/1149336565 | |
require 'rubygems' | |
require 'httparty' | |
require 'hpricot' | |
url = 'http://rubyonrails.org' | |
document = Hpricot.parse(HTTParty.get(url)) | |
scrape = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def self_url(options = {}) | |
url_for(request.path_parameters.merge(options)) | |
end | |
end | |
describe ApplicationHelper do | |
describe '#self_url' do | |
before(:each) do | |
# using params we can easily detect a reverse merge with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, re | |
class CachedFileSearch(object): | |
"""Cached File Search""" | |
def __init__(self, dir): | |
self.dir = dir | |
self.all_files = os.popen('find ' + dir).read() | |
self.clear_cache() | |
OlderNewer