Skip to content

Instantly share code, notes, and snippets.

@ehoch
ehoch / application_controller.rb
Created December 19, 2014 22:22
Fastly ESI CSRF Token for Spree
...
def csrf_meta_tags
render layout: false
end
...
@ehoch
ehoch / gist:c28bd9a57c22b1a9a74f
Created November 14, 2014 21:41
I suck at gists
Verifying that +ehoch is my openname (Bitcoin username). https://onename.io/ehoch
5f38b581c31e477d91cd
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)
@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)
@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 / 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 / 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 / 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