Skip to content

Instantly share code, notes, and snippets.

View dpie's full-sized avatar

David Piehler dpie

  • Basics Group
  • Providence, RI
View GitHub Profile
@elijahmanor
elijahmanor / _snippet.html
Created February 6, 2012 04:51
Differences Between jQuery .bind() vs .live() vs .delegate() vs .on() Methods
<ul id="members" data-role="listview" data-filter="true">
<!-- ... more list items ... -->
<li>
<a href="detail.html?id=10">
<h3>John Resig</h3>
<p><strong>jQuery Core Lead</strong></p>
<p>Boston, United States</p>
</a>
</li>
<!-- ... more list items ... -->
@parndt
parndt / _menu_branch.html.erb
Created August 19, 2011 04:59 — forked from michaelward82/_menu_branch.html.erb
Limit menu rendering in Refinery CMS
<%
if !!local_assigns[:apply_css] and (classes = menu_branch_css(local_assigns)).any?
css = "class='#{classes.join(' ')}'".html_safe
end
# dom_id DEPRECATED: REMOVE AT 1.1, serves no purpose same with css attributes 'first' and 'last'
dom_id = "id='item_#{menu_branch_counter}'".html_safe if menu_branch.parent_id.nil?
-%>
<li<%= ['', css, dom_id].compact.join(' ').gsub(/\ *$/, '').html_safe %>>
<%= link_to menu_branch.title, menu_branch.url -%>
<% if ( (children = menu_branch.children unless hide_children).present? &&
@parndt
parndt / gist:1011435
Created June 7, 2011 00:32
How to cache pages and clear them in Refinery CMS
# put in config/application.rb
config.to_prepare do
::PagesController.module_eval do
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
end
::Page.module_eval do
after_save :clear_static_caching!
after_destroy :clear_static_caching!
@parndt
parndt / gist:988127
Created May 24, 2011 04:09 — forked from djones/gist:720672
4 views in Refinery that use a new type of content_page
rendering a custom plugin
<% content_for :page_title do %>
<%= @destination.title %>
<% end %>
<% content_for :page_body do %>
<section>
<h1>Choose from our most popular recommended itineraries below</h1>
</section>
@thomasmaas
thomasmaas / fragment caching refinerycms menu
Created March 12, 2011 00:30
Fragment caching the refinerycms menu to speed things up dramatically. On Heroku, make sure to use memcached store if you use more than 1 dyno.
# views/layouts/shared/_menu.html.erb
hide_children = RefinerySetting.find_or_set(:menu_hide_children, false) if hide_children.nil?
+ cache('site_menu') do
collection ||= @menu_pages.includes(:slugs)
</nav>
# Usage example:
#
# Main.register Sinatra::UserAgentHelpers
#
# -# haml
# %body{class: browser.body_class}
#
# - if browser.ios?
# %script{:language => 'text/javascript', :src => '/js/jqtouch.js'}
# %p Download our mobile app in the iTunes store!
@rstacruz
rstacruz / helpers.rb
Created October 19, 2010 23:28
cc_html.rb
# Implements the world-famous Paul Irish IE conditional comments HTML tag--in HAML.
# http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
class Main
helpers do
def cc_html(options={}, &blk)
attrs = options.map { |(k, v)| " #{h k}='#{h v}'" }.join('')
[ "<!--[if lt IE 7 ]> <html#{attrs} class='ie6'> <![endif]-->",
"<!--[if IE 7 ]> <html#{attrs} class='ie7'> <![endif]-->",
"<!--[if IE 8 ]> <html#{attrs} class='ie8'> <![endif]-->",
# How to re-use the menu partial for a submenu in Refinery CMS >= 0.9.8.5 and < 0.9.9.22
# header menu (main menu) which hides its children.
<%= render :partial => "/shared/menu",
:locals => {
:dom_id => 'menu',
:css => 'menu',
:collection => @menu_pages,
:hide_children => true
} -%>