Skip to content

Instantly share code, notes, and snippets.

@travishaynes
travishaynes / rtml.lang
Created June 28, 2011 01:15
Yahoo! RTML syntax highlighting
<?xml version="1.0" encoding="UTF-8"?>
<!--
Author: Travis Haynes <[email protected]>
Syntax highlighting for Yahoo! RTML
-->
<language id="rtml" _name="RTML" version="2.0" _section="Markup">
<metadata>
<property name="mimetypes">x-rtml</property>
<property name="globs">*.rtml</property>
<property name="block-comment-start">&lt;!--</property>
@travishaynes
travishaynes / Cakefile
Created December 26, 2011 22:36
Cakefile with tasks for watch, build, and docs (using docco)
fs = require 'fs'
{exec} = require 'child_process'
util = require 'util'
projectName = "PROJECT_NAME" # TODO: change to your project's name
appFiles = [
# TODO: add your project's source files in the order they should be concatenated
"src/#{projectName}.coffee"
]
@travishaynes
travishaynes / blog.rb
Created January 4, 2012 19:43
Middleman Blog Helper
require 'sqlite3'
require 'active_record'
require 'slim'
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => ":memory:"
)
class CreateBlogsTable < ActiveRecord::Migration
@travishaynes
travishaynes / blog.rb
Created January 4, 2012 19:43
Middleman In Memory Blog
require 'sqlite3'
require 'active_record'
require 'slim'
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => ":memory:"
)
class CreateBlogsTable < ActiveRecord::Migration
@travishaynes
travishaynes / google_fonts_helper.rb
Created January 10, 2012 18:51
Google Fonts Rails helper
module GoogleFontsHelper
# generates a link tag for Google fonts
# @param [Hash] fonts contains the font families and weights
# @return [String] The generated link tag
# @example Droid+Sans in weights 400 and 700, and Yanone+Kaffeesatz in 300 and 400
# = google_fonts_link_tag :droid_sans => [400, 700], :yanone_kaffeesatz => [300, 400]
def google_fonts_link_tag(fonts = {})
family = fonts.inject([]) do |result, (font, sizes)|
# convert font into a String
font = font.to_s
@travishaynes
travishaynes / progress.js
Created January 28, 2012 19:46
Pull shop's progress
var goal = 10000.00, // without a goal it will return the total purchase amount after the school percentage is applied
shop_id = 1195332, // this can be found in the top-right corner of the metafields app when logged into a shop
server = "http://localhost:3000"; // set this to the location of the metafields app
// get the shop's percentage using a JSONP AJAX call
// Note: This must use JSONP to avoid raising a cross domain access error
$.ajax({
url : server + "/progress/" + shop_id + ".json",
type : "get",
data : "goal=" + goal,
@travishaynes
travishaynes / sessions_controller.rb
Created February 21, 2012 04:50
Shopify Sessions Controller
class SessionsController < ApplicationController
skip_authorization_check
def new
unless params[:shop].present?
@shop = Shop.new
return
end
@session = ShopifyAPI::Session.new(params[:shop], params[:t], params)
@travishaynes
travishaynes / routes.rb
Created February 24, 2012 21:06
Shopify session controller & specs
resource :shopify_session, only: [:new, :create, :destroy]
@travishaynes
travishaynes / client.js
Created April 12, 2012 20:37
Using EasyXDM in Shopify to access the cart
window.Shopify = new EasyXDM.Rpc({
remote: "http://domain.myshopify.com/cart"
}, {
remote: {
getCart: {}
}
});
@travishaynes
travishaynes / Gemfile
Created April 13, 2012 17:56
Shopify OAuth2 Authentication
gem 'shopify_api'
gem 'omniauth-shopify-oauth2'
gem 'slim-rails'