Skip to content

Instantly share code, notes, and snippets.

View steveclarke's full-sized avatar

Steve Clarke steveclarke

View GitHub Profile
@steveclarke
steveclarke / _flash_messages.html.erb
Created March 28, 2012 02:48
Flash Messages Partial
<% flash.each do |name, message| %>
<%= content_tag("p", message, class: name) %>
<% end %>
$ ->
# Handle focus on the Contact Form
$('#email').focus -> $(this).val('') if $(this).val() == 'E-mail Address'
$('#email').blur -> $(this).val('E-mail Address') if $(this).val() == ''
$('#phone').focus -> $(this).val('') if $(this).val() == 'Telephone Number'
$('#phone').blur -> $(this).val('Telephone Number') if $(this).val() == ''
$('#message').focus -> $(this).val('') if $(this).val() == 'Message'
$('#message').blur -> $(this).val('Message') if $(this).val() == ''
require 'open-uri'
require 'net/http'·
sourcefile = "http://s3.amazonaws.com/*redacted*/old_site_product_images/product1.jpg"
open(sourcefile) do |f|
puts File.basename(f)
end
# outputs: open-uri20120330-58981-1mny2cc
@mixin rounded($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
border-radius: $radius;
}
div {
@include rounded(5px);
}
@steveclarke
steveclarke / tire_update_index.rb
Created April 3, 2012 18:52
Update ElasticSearch index using Tire
Product.all.each { |p| p.tire.update_index }
@steveclarke
steveclarke / gist:2307178
Created April 5, 2012 01:26
class << self
# Shorthand way of declaring Class/Module methods without having to def self.bar, self.baz, etc.
module Foo
class << self
def bar
end
def baz
end
end
def banner
banner_text = "----------\n"
banner_text << yield
banner_text << "\n----------\n"
banner_text
end
banner_text = banner do
"foo"
"bar"
@steveclarke
steveclarke / reminders.md
Created April 10, 2012 13:53
Vim Reference

Movement

Move in screen: L low, M middle, H high

{ and } jump by paragraph

t<char> — Move forward until the next occurrence of the character.

f — Move forward over the next occurrence of the character.

@steveclarke
steveclarke / capybara.md
Created April 10, 2012 17:32
RSpec Matchers

Capybara

save_and_open_page

Matchers

have_button(locator)
class Banner
def initialize(&block)
@lines = []
instance_eval &block
end
def line(str)
@lines << str
end