60% of the time it works EVERY time!
gem 'ny_address', git: 'git://gist.github.com/1672379.git'| require "benchmark" | |
| COUNT = 1000 | |
| Benchmark.bmbm do |test| | |
| test.report "class eval" do | |
| class ClassEvalClass;end | |
| COUNT.times do |i| | |
| ClassEvalClass.send :class_eval, "def method_no_#{i}; return #{i} ;end" |
| body{ | |
| /* styles that apply globally go here */ | |
| .hidden{ | |
| display: none; | |
| visibility: hidden; | |
| } | |
| } | |
| body.blog{ | |
| /* styles that only apply to blog pages go here |
| module ApplicationHelper | |
| # call this method in the view | |
| # name should be a unique ID for this page, condition should be either truthy or falsey | |
| def show_dialog_if(name, condition) | |
| if condition | |
| content = | |
| link_to("click", "##{name}", | |
| id: "#{name}_popup", class: "hidden", | |
| data: {rel: "dialog", theme: "a"}) |
| string = ["b", "c", "d"].inject("a") { |result, element| result + element } | |
| puts string |
| # ~/.tm_properties | |
| softTabs = true | |
| tabSize = 2 | |
| showInvisibles = true | |
| fontName = 'Bitstream Vera Sans Mono' | |
| fontSize = 20 | |
| spellingLanguage = 'en_GB' |
| class UsersController < ApplicationController | |
| # This can be moved to ApplicationController if | |
| # every action within the application should respond to these MIME Types | |
| respond_to :html, :json, :xml | |
| def index | |
| respond_with users | |
| end |
| ... | |
| <aside id="right"> | |
| <nav id="tag_cloud"> | |
| <h3>Browse by topic:</h3> | |
| <% tag_cloud(tags, %w(tag1 tag2 tag3 tag4 tag5 tag6)) do |tag, tag_class| %> | |
| <%= link_to tag.name, tagged_blog_posts_path(tag: tag.name), :class => "tag #{tag_class}" %> | |
| <% end %> | |
| </nav> | |
| </aside> |
| [Time, Date].map do |klass| | |
| klass::DATE_FORMATS[:variable] = lambda do |t| | |
| date = | |
| case | |
| # display today's date as "today" | |
| when t >= Date.today then "today" | |
| # display yesterday's date as 'Yesterday' | |
| when (t >= Date.yesterday and t <= Date.today) then "yesterday" | |
| # otherwise, display date: eg. Mon 4th June | |
| else |