Skip to content

Instantly share code, notes, and snippets.

View csaunders's full-sized avatar

Christopher Saunders csaunders

View GitHub Profile
def request(data, hmac=nil)
options = {
:method => 'POST',
:input => data,
'X-Shopify-Hmac-SHA256' => hmac || calculate_hmac(data)
}
ActionDispatch::Request.new(Rack::MockRequest.env_for("", options))
end
@csaunders
csaunders / import_action.rb
Created January 18, 2014 17:30
Application code that is needed to do an API import into your local database
class Importer
def import
api_products = ShopifyAPI::Product.find(:all)
ShopProductSink::Product.create_from_resources(api_products)
end
end
module ShopProductSink
module ApiCreatable
extend ActiveSupport::Concern
module ClassMethods
def initialize_from_resource(resource)
attributes = usable_keys.reduce({}) do |result, key|
result[key] = resource.public_send(key) if resource.respond_to?(key)
result
end
@csaunders
csaunders / simplemath_c.rl
Created January 11, 2014 23:10
Simple Math State Machine
#include <string.h>
#include <stdio.h>
%%{
machine simplemath;
number = digit+;
operator = '+';
main := (digit operator digit) 0 @{ res = 1; };
}%%
diff --git a/.gitignore b/.gitignore
index 8b6632c..2a33328 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ rdoc
pkg
doc
.yardoc
+.rbenv-version
diff --git a/Gemfile b/Gemfile
require 'openssl'
require 'base64'
class WebhooksController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :verify_webhook, :fetch_shop
def create
case topic
when 'orders/fulfilled'
shops GET /shops(.:format) shops#index => shops_path
POST /shops(.:format) shops#create => shops_path
new_shop GET /shops/new(.:format) shops#new => new_shop_path
edit_shop GET /shops/:id/edit(.:format) shops#edit => edit_shop_path
shop GET /shops/:id(.:format) shops#show => shop_path(shop)
PUT /shops/:id(.:format) shops#update => shop_path(shop)
DELETE /shops/:id(.:format) shops#destroy => shop_path(shop)
source 'https://rubygems.org'
gem 'shopify_theme'
@csaunders
csaunders / changelog.md
Created November 4, 2013 15:43
Shopify Theme gem changelog

v0.0.11

  • Locks JSON api version which fixed an issue with downloading large binary files -- Tyler Ball
  • Respect API limits when downloading theme assets from Shopify API -- Chris Saunders

Text Editor

The software we'll be using for remote programming has plugins for the following text editors:

  • Emacs
  • Sublime Text
  • Vim

Sublime text allows you to use it for free, with a nag screen; otherwise you can use the online text editor that comes with floobits. The onine editor is alright.