Skip to content

Instantly share code, notes, and snippets.

@cowboycoded
cowboycoded / gist:909905
Created April 8, 2011 14:07
html5-boilerplate index (comments removed)
<!doctype html>
<!--[if lt IE 7 ]> <html lang="en"> <![endif]-->
<!--[if IE 7 ]> <html lang="en"> <![endif]-->
<!--[if IE 8 ]> <html lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
@cowboycoded
cowboycoded / boilerplate_engine_layout.haml
Created April 8, 2011 15:27
Layout file for boilerplate_engine in HAML
= render "boilerplate/doctype"
= render "boilerplate/html_tag_browser_hacks"
%head
= render "boilerplate/meta_tags"
= render "boilerplate/title_tags"
= render "boilerplate/css"
= render "boilerplate/css_addons" #blank file, override with your addons
= render "boilerplate/head_javascript"
= render "boilerplate/head_javascript_addons" #blank file, override with your addons
= render "boilerplate/body"
@cowboycoded
cowboycoded / engine.rb
Created April 8, 2011 17:48
eager_load! method
#/railties-3.0.5/lib/rails/engine.rb
def eager_load!
config.eager_load_paths.each do |load_path|
matcher = /\A#{Regexp.escape(load_path)}\/(.*)\.rb\Z/
Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
require_dependency file.sub(matcher, '\1')
end
end
end
@cowboycoded
cowboycoded / dependencies.rb
Created April 8, 2011 17:50
dependency methods
#activesupport-3.0.5/lib/active_support/dependencies.rb
def require_dependency(file_name, message = "No such file to load -- %s")
unless file_name.is_a?(String)
raise ArgumentError, "the file name must be a String -- you passed #{file_name.inspect}"
end
Dependencies.depend_on(file_name, false, message)
end
def depend_on(file_name, swallow_load_errors = false, message = "No such file to load -- %s.rb")
@cowboycoded
cowboycoded / autoload_paths.rb
Created April 8, 2011 17:51
auto_load paths
["/rails_apps/my_app/app/controllers",
"/rails_apps/my_app/app/helpers",
"/rails_apps/my_app/app/models",
"/rails_plugins/my_engine/app/controllers",
"/rails_plugins/my_engine/app/helpers",
"/rails_plugins/my_engine/app/models"]
@cowboycoded
cowboycoded / as_dependencies_patch.rb
Created April 8, 2011 17:52
dependencies patch
require 'active_support/dependencies'
module ActiveSupport::Dependencies
alias_method :require_or_load_without_multiple, :require_or_load
def require_or_load(file_name, const_path = nil)
if file_name.starts_with?(Rails.root.to_s + '/app')
relative_name = file_name.gsub(Rails.root.to_s, '')
@engine_paths ||= Rails::Application.railties.engines.collect{|engine| engine.config.root.to_s }
@engine_paths.each do |path|
engine_file = File.join(path, relative_name)
require_or_load_without_multiple(engine_file, const_path) if File.file?(engine_file)
@cowboycoded
cowboycoded / rounded_box_gist.css
Created April 8, 2011 18:13
styles for rounded box gist
.gist{
margin: 15px 0 !important;
}
.gist-file{
border: none !important;
}
.gist-meta{
border: 1px solid #D2d2d2 !important;
@cowboycoded
cowboycoded / yetting.yml
Created April 9, 2011 01:33
Sample Yettings config file
defaults: &defaults
some_api_key: abc123
an_erb_yetting: <%= "erb stuff works" %>
some_array:
- element1
- element2
development:
<<: *defaults
api_key: abc123dev
@cowboycoded
cowboycoded / yettings_example.rb
Created April 9, 2011 01:42
Yettings example - accessing values
# in any environment
Yetting.some_api_key #=> "abc123"
Yetting.an_erb_yetting #=> "erb stuff works"
Yetting.some_array #=> ["element1", "element2"]
# in the development environment
Yetting.api_key #=> "abc123dev"
@cowboycoded
cowboycoded / yettings_example2.rb
Created April 9, 2011 01:46
Yettings example 2 - custom names
MainYetting.api_key
SecondaryYetting.api_key