Skip to content

Instantly share code, notes, and snippets.

var formElement = document.getElementById("cart-form");
var formAction = "/cart";
var formMethod = "POST";
var formData = new FormData(formElement);
var file = load_your_file_here;
formData.append('properties[file]', file);
var xhr = new XMLHttpRequest();
@hjblok
hjblok / my_app.rb
Created May 3, 2013 09:46
A rudimentary Shopify App
# We'll use the Ruby library provided by Shopify. You can install this as a gem.
# More info on: https://github.com/shopify/shopify_api
require "shopify_api"
# Next we need some authentication to be able to access our Shop. Lets use a private App for the moment:
# 1. follow the instructions on http://docs.shopify.com/api/tutorials/creating-a-private-app to create one,
# 2. insert the API-KEY and PASSWORD in the url below,
# 3. also change MY-SHOP into your shops subdomain.
ShopifyAPI::Base.site = "https://API-KEY:PASSWORD@MY-SHOP.myshopify.com/admin"
@hjblok
hjblok / aws_s3_website.rb
Created September 13, 2012 06:25
Method to set website configuration on Amazon S3 bucket using aws-sdk
require 'rubygems'
require "aws-sdk"
module AWS
class S3
# Client class for Amazon Simple Storage Service (S3).
class Client < Core::Client
# @overload set_bucket_website(options = {})
# config/environment.rb
require "open-uri"
config.gem "nokogiri"
# app/models/your_model.rb
# Expects postal_code, street and city to be part of your model:
# Address.postal_code = "1222 AX"
# Address.street = "Erfgooiersstraat"
# Address.city = "Hilversum