Skip to content

Instantly share code, notes, and snippets.

View BDQ's full-sized avatar
💥

Brian Quinn BDQ

💥
View GitHub Profile
@BDQ
BDQ / bogo.rb
Created February 10, 2012 16:59 — forked from anonymous/bogo.rb
module Spree
class Calculator::Bogo < Calculator
preference :number_to_buy, :integer, :default => 1
preference :number_to_get, :integer, :default => 1
def self.description
"Buy One Get One"
end
def compute(order)
@BDQ
BDQ / resolver.transformer.ts
Last active September 2, 2021 12:19
AWS S3 Object Lambda CDK (1.18.0) Example
const { S3 } = require("aws-sdk");
const axios = require("axios").default;
exports.handler = async (event: any) => {
console.log(event);
const s3 = new S3();
// Retrieve the operation context object from event. This has info to where the WriteGetObjectResponse request
// should be delivered and a presigned URL in `inputS3Url` where we can download the requested object from.
// The `userRequest` object has information related to the user which made this `GetObject` request to S3OL.
@BDQ
BDQ / Import
Created December 3, 2008 21:37
namespace :spree do
desc "Export Products to CSV File"
task :export_products => :environment do
require 'fastercsv'
products = Product.find(:all)
puts "Exporting to #{RAILS_ROOT}/products.csv"
FasterCSV.open("#{RAILS_ROOT}/products.csv", "w") do |csv|
csv << ["id", "name", "description","sku", "master_price" ]
@BDQ
BDQ / gist:3164364
Created July 23, 2012 15:55
Create Spree::Promotion for free shipping via console.
p = Spree::Promotion.create(event_name: "spree.checkout.coupon_code_added", name: "Free Shipping", code: "FREESHIPBD")
p.promotion_actions << Spree::Promotion::Actions::CreateAdjustment.create()
pa = p.promotion_actions.first
pa.calculator = Spree::Calculator::FreeShipping.new
<% if !current_page?("/") && @taxon.present? %>
<% seperator = raw("&nbsp;&raquo;&nbsp;") %>
<div id="breadcrumbs" data-hook>
<ul>
<li data-hook="home"><%= link_to t(:home) , root_path %><%= seperator %></li>
<li data-hook="products"><%= link_to(t('products') , products_path) %><%= seperator %></li>
<% @taxon.ancestors.each do |taxon| %>
<li data-hook="ancestor"><%= link_to taxon.name , seo_url(taxon) %><%= seperator %></li>
<% end %>
<li data-hook="taxon"><span><%= @taxon.name %></span></li>
@BDQ
BDQ / 1-request.json
Last active December 26, 2015 05:29
Shipment confirmation polling.
{
"message_id": "88af1dc5fe53543f1200f517",
"message": "ctl:shipment:confirmation:poll",
"payload": {
"parameters": [
{
"name": "ctl.last_confirmation_shipment",
"value": "H00000000001"
},
{
@BDQ
BDQ / endpoint.json
Last active December 24, 2015 10:19
VPD endpoint.json
{
"name": "vpd",
"display": "VPD Endpoint",
"description": "Shipping integration with VPD",
"help": "http://guides.spreecommerce.com/integration/vpd_integration.html",
"icon_url": "vpd.png",
"services": [
{
"name": "shipments",
"path": "/service/spree_order.p",
'notifications' => [
{
'level' => 'info',
'subject' => 'product exists' ,
'description' => 'product exists in the database'
}
]
object @address
attributes *address_attributes
child(:country) do |address|
attributes *country_attributes
end
child(:state) do |address|
attributes *state_attributes
end
@BDQ
BDQ / import.json
Last active December 19, 2015 12:39 — forked from schof/import.json
{
"message": "order:new",
"payload": {
"order": {
"channel": "Amazon",
"email": "test1@test.com",
"currency": "USD",
"line_items": [
{
"price": 19.99,