Skip to content

Instantly share code, notes, and snippets.

@ehoch
ehoch / gist:1761304
Created February 7, 2012 19:12
Spam Action on the Fly
config.actions do
member :spam do
link_icon 'icon-ban-circle'
bulkable? { true }
controller do
Proc.new do
if params[:bulk_ids]
params[:bulk_ids].each {|id| @abstract_model.model.find(id).spam }
flash[:success] = "#{params[:bulk_ids].size} Spammed"
else
@ehoch
ehoch / gist:1960548
Created March 2, 2012 19:17
Puma / DJ Procefile on Heroku
web: bundle exec puma -p $PORT
worker: bundle exec rake jobs:work
@ehoch
ehoch / gist:3189712
Created July 27, 2012 18:42
writecapture2 mutex
var mutex = false;
function load_ads()
{
if (mutex) {
setTimeout("load_ads()", 100); // try again in 100 ms?
return;
}
mutex = true;
if (!$('#pushdown').html()) {
@ehoch
ehoch / taxon_decorator.rb
Created January 25, 2013 19:56
How Alarm Grid (https://www.alarmgrid.com) created a flat taxon structure.
module Spree
Taxon.class_eval do
def set_permalink # No longer add in parent
self.permalink = name.to_url if permalink.blank?
end
end
end
@ehoch
ehoch / Canonical URLS.md
Last active December 11, 2015 17:49
Alarm Grid, a home security store, shows you how to set canonical urls in Spree.

Alarm Grid will show you how to create canonical urls in Spree Commerce. This is only an example for products show. You must implement EVERYWHERE.

@ehoch
ehoch / Full Site SSL.md
Last active December 11, 2015 17:49
Full Site SSL in Spree

Curious how Alarm Grid went full site-wide SSL using Spree? Just create the one decorator below and you're good to go!

Note: This gist will not redirect .xml files so that our feeds do not error out on iPhones which do not support RSS feeds in https.

@ehoch
ehoch / gist:5388489
Last active December 16, 2015 05:59
Schema.org markup example from "Paperman Full Movie" page at Movie Fanatic
<div class='video' itemscope itemtype='http://schema.org/VideoObject'>
<meta content='http://www.viddler.com/simple/8ab66a9e/' itemprop='embedUrl'>
<meta content='http://images.moviefanatic.com/iu/v1364992012/video/paperman-full-movie.jpg' itemprop='thumbnail'>
<meta content='429' itemprop='height'>
<meta content='741' itemprop='width'>
<h1 itemprop='name'>Paperman Full Movie</h1>
<iframe id="viddler-66183713" src="http://www.viddler.com/embed/8ab66a9e/?autoplay=1&player=simple" width="741" height="429" frameborder="0" mozallowfullscreen="true" webkitallowfullscreen="true" scrolling="no" style="overflow:hidden !important;"></iframe>
</div>
<div class='caption' itemprop='description'>The full short film Paperman. The beautiful black and white Disney short played ahead of Wreck-It Ralph.</div>
<div itemprop='aggregateRating' itemscope itemtype='http://schema.org/AggregateRating'>
@ehoch
ehoch / post_config.rb
Last active December 24, 2015 16:19
Gist of our rails_admin mountable engine config solution
module RailsAdmin
module PostConfig
def self.extended(base)
base.class_eval do
rails_admin do
weight -10
list(&base.rails_admin_list_fields)
edit(&base.rails_admin_edit_fields)
class Spree::Calculator::TaxCloudCalculator < Spree::Calculator
NEXUS_STATES = ['FL']
def self.description
"Tax Cloud Calculator"
end
def compute(object)
# given an order, we need to lookup the taxes from TaxCloud by using the hard-coded origin
return 0 unless object.is_a?(Spree::Order) and object.ship_address and object.line_items.size > 0 and NEXUS_STATES.include?(object.ship_address.state.abbr)