Skip to content

Instantly share code, notes, and snippets.

View base-Berksfile
site :opscode
metadata
cookbook 'locale',
git: "https://github.com/hw-cookbooks/locale.git",
tag: "v1.0.0"
@avit
avit / rfc822.rb
Created Sep 19, 2014
Regular expression for parsing email addresses
View rfc822.rb
#
# RFC822 Email Address Regex
# --------------------------
#
# Originally written by Cal Henderson
# c.f. http://iamcal.com/publish/articles/php/parsing_email/
#
# Translated to Ruby by Tim Fletcher, with changes suggested by Dan Kubb.
#
# Licensed under a Creative Commons Attribution-ShareAlike 2.5 License
@avit
avit / pipes.rb
Created Sep 26, 2014
Simple ruby pipelines
View pipes.rb
class Object
def | other
case other
when Proc
if self.is_a?(Proc)
proc { |input| other.call( self.call(input) ) }
else
other.call(self)
end
else
View application.css
/* rules generated by blueprint typography mixin: */
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #333333;
font-size: 75%;
background: #f9f9ee;
height: 100%; }
body h1 {
font-weight: normal;
View gist:71394
class Role < ActiveRecord::Base
def self.[] (key)
find_by_name key.to_s
end
end
@user.role = Role['admin']
View README
ToadMate Bookmarklet
Adds clickable links to open the file/line from the
stacktrace on Hoptoad (http://hoptoadapp.com) into TextMate.
INSTALL:
Change the lpd variable to your local project directory.
It relies on your project folders being named after the main part
of your domain name (example.com => /example/).
View sass_template_handler.rb
module ActionView
class ErSass < ActionView::TemplateHandler
include ERB::Util
SASS_ENGINE_OPTS = {
:load_paths => Compass.configuration.sass_load_paths + ["#{Rails.root}/app/stylesheets"]
}
def self.call(template)
"ActionView::ErSass.new(self).render(template, local_assigns)"
View compass_initializer.rb
# Set up rendering of sass through ERB in ActionView
require 'ersass_template_handler'
ActionView::Template.register_template_handler :sass, ActionView::TemplateHandlers::ErSass
ActionView::Template.exempt_from_layout :sass
View delegate_model_attributes.rb
class ProductData < ActiveRecord::Base
belongs_to :product
def self.attribute_column_names
return @@attr_columns if defined?(@@attr_columns)
readers = content_columns.map { |n| n.name.intern } - [:created_at,:updated_at]
@@attr_columns ||= readers.map { |k| [k, "#{k}=".to_sym] }.flatten
end
end
View stylesheets_test.rb
require File.dirname(__FILE__) + '/../test_helper'
require 'compass/test_case'
class StylesheetsTest < Compass::TestCase
class << self
def sass_files(path)
Dir.glob(File.join(path, "**", "[^_]*.sass"))
end
def test_stylesheet(sass_file, &block)