Skip to content

Instantly share code, notes, and snippets.

View bryanmtl's full-sized avatar

Bryan Mahoney bryanmtl

View GitHub Profile
@lambtron
lambtron / shopify.md
Last active October 23, 2023 17:48
segment event tracking for shopify
title sidebar
Segment Event Tracking for Shopify
Shopify

Segment makes it simple for Shopify merchants to integrate analytics, email marketing, advertising and optimization tools. Rather than installing all your tools individually, you just install Segment once. We collect your data, translate it, and route it to any tool you want to use with the flick of a switch. Using Segment as the single platform to manage and install your third-party services will save you time and money.

The guide below explains how to install Segment in your Shopify store. All you need to get up and running is copy and paste a few snippets of code into your theme editor. (You don't have to edit the code or be versed in JavaScript.) The following guide will show you how, step by step.


@cmar
cmar / migrations
Created November 29, 2012 16:45
Tax Cloud Spree Integration
class CreateSpreeTaxCloudTransactions < ActiveRecord::Migration
def change
create_table :spree_tax_cloud_transactions do |t|
t.references :order
t.string :message
t.timestamps
end
add_index :spree_tax_cloud_transactions, :order_id
end
end
@timcheadle
timcheadle / README.md
Last active January 26, 2023 00:56
Make /robots.txt aware of the Rails environment

Make /robots.txt aware of the Rails environment

You probably don't want Google crawling your development staging app. Here's how to fix that.

$ mv public/robots.txt config/robots.production.txt
$ cp config/robots.production.txt config/robots.development.txt

Now edit config/routes.rb to add a route for /robots.txt, and add the controller code.

@bryanmtl
bryanmtl / gist:2884362
Created June 6, 2012 20:00
One liner to grab the latest production DB from Heroku
curl $(heroku pgbackups:url --remote production) | pg_restore --verbose --clean --no-acl --no-owner -h localhost -U root -d screening_room_development
@Ranger-X
Ranger-X / product_filters.rb
Created April 27, 2012 17:34
OptionValue filter
def ProductFilters.option_with_values(option_scope, option, values)
# get values IDs for Option with name {@option} and value-names in {@values} for use in SQL below
option_values = Spree::OptionValue.where(:presentation => [values].flatten).joins(:option_type).where(OptionType.table_name => {:name => option}).pluck("#{OptionValue.table_name}.id")
return option_scope if option_values.empty?
option_scope = option_scope.where("#{Product.table_name}.id in (select product_id from #{Variant.table_name} v left join spree_option_values_variants ov on ov.variant_id = v.id where ov.option_value_id in (?))", option_values)
option_scope
end
# option scope
@aroop
aroop / GenerateImageThumbnailsJob.rb
Created February 1, 2012 07:45
Dragonfly image processor
class GenerateImageThumbnailsJob < Struct.new(:photo_id)
def perform
photo = Photo.find(photo_id)
photo.medium_image = photo.image.thumb('940x600')
photo.large_image = photo.image.thumb('450x')
photo.small_image = photo.image.thumb('172x167#c')
photo.save
end
@joshnuss
joshnuss / s3_copy.rb
Last active September 27, 2015 00:58
Copy S3 bucket
require 'right_aws'
old_name = "old-bucket"
new_name = "new-bucket"
s3 = RightAws::S3.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'])
old_bucket = s3.bucket(old_name)
new_bucket = s3.bucket(new_name)