Skip to content

Instantly share code, notes, and snippets.

View resistorsoftware's full-sized avatar

David Lazar resistorsoftware

View GitHub Profile
// ---------------------------------------------------------
// POST to cart/update.js returns the cart in JSON.
// To clear a particular attribute, set its value to an empty string.
// Receives attributes as a hash or array. Look at comments below.
// ---------------------------------------------------------
Shopify.updateCartAttributes = function(data, callback) {
var params = {
type: 'POST',
url: '/cart/update.js',
data: data,
SHELL = /bin/sh
#### Start of system configuration section. ####
srcdir = .
topdir = /usr/lib/ruby/1.8/x86_64-linux
hdrdir = $(topdir)
VPATH = $(srcdir):$(topdir):$(hdrdir)
exec_prefix = $(prefix)
prefix = $(DESTDIR)/usr
[main]
cachedir=/var/cache/yum
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
distroverpkg=redhat-release
tolerant=1
exactarch=1
obsoletes=1
gpgcheck=1
delete '/destroy' do
authorize!
@product = ShopifyAPI::Product.find(params[:id])
unless @product.metafields.empty?
@product.metafields.each do |mf|
if mf.key = 'monkey_bile'
ShopifyAPI::Metafield.delete(mf.id)
end
end
end
#
# Create a new repo on Github and directly push your initial commit with this shell script
#
url=https://github.com/api/v2/json/repos/create
username=$(git config github.user)
token=$(git config github.token)
name=${1-$(basename $(pwd))}
curl -F login=$username -F token=$token $url -F name=$name -F public=1 1>/dev/null
@resistorsoftware
resistorsoftware / Order Total
Created December 1, 2010 20:06
sum up orders for Shopify
sum = 0.0
page = 1
start_date = "2010-11-11"
end_date = "2010-12-11"
count = ShopifyAPI::Order.count({:fulfillment_status => 'unshipped', :created_at_max => "#{end_date} 23:59", :created_at_min => "#{start_date} 00:00"})
if count > 0
page += count.divmod(250).first
while page > 0
orders = ShopifyAPI::Order.find(:all, :params => {:page => page, :fulfillment_status => 'unshipped', :limit => 250, :created_at_max => "#{end_date} 23:59", :created_at_min => "#{start_date} 00:00", :financial_status => 'paid'})
orders.each do |order|
@resistorsoftware
resistorsoftware / OpenID
Created December 8, 2010 14:33
WHat happens on authenticate
Started GET "/server?openid.assoc_handle=%7BHMAC-SHA1%7D%7B4cfd44f7%7D%7BN2m%2BzA%3D%3D%7D&openid.identity=http%3A%2F%2Flocalhost%3A3000%2Fdlazar&openid.mode=checkid_setup&openid.return_to=http%3A%2F%2Flocalhost%3A3001%2Fconsumer%2Fcomplete%3Fopenid1_claimed_id%3Dhttp%253A%252F%252Flocalhost%253A3000%252Fdlazar%26rp_nonce%3D2010-12-08T14%253A32%253A35Zx92dI4&openid.trust_root=http%3A%2F%2Flocalhost%3A3001%2Fconsumer" for 127.0.0.1 at Wed Dec 08 09:32:35 -0500 2010
Processing by ServerController#index as HTML
Parameters: {"openid.return_to"=>"http://localhost:3001/consumer/complete?openid1_claimed_id=http%3A%2F%2Flocalhost%3A3000%2Fdlazar&rp_nonce=2010-12-08T14%3A32%3A35Zx92dI4", "openid.mode"=>"checkid_setup", "action"=>"index", "openid.identity"=>"http://localhost:3000/dlazar", "openid.trust_root"=>"http://localhost:3001/consumer", "openid.assoc_handle"=>"{HMAC-SHA1}{4cfd44f7}{N2m+zA==}", "controller"=>"server"}
SQL (0.7ms) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnu
@resistorsoftware
resistorsoftware / Grape
Created December 15, 2010 02:45
Simple grape eg
require 'grape'
class Foo < Grape::API
version '1'
resource :services do
get :language_detector do
["english", "french"]
end
end
end
run Foo
@resistorsoftware
resistorsoftware / Liquid snippet for theme.liquid
Created February 25, 2011 13:55
How to add Meta Descriptions to a Product
{% if template == 'product' %}
{% assign mf = product.metafields.meta_description %}
{% unless mf == empty %}
{% for mf in product.metafields.meta_description %}
<meta name="Fubar2 Ronnie James Dio" content="{{mf.last}}" />
{% endfor %}
{% endunless %}
{% endif %}
// ---------------------------------------------------------
// POST to cart/update.js returns the cart in JSON.
// To clear a particular attribute, set its value to an empty string.
// Receives attributes as a hash or array. Look at comments below.
// ---------------------------------------------------------
Shopify.updateCartAttributes = function(attributes, callback) {
var data = '';
// If attributes is an array of the form:
// [ { key: 'my key', value: 'my value' }, ... ]
if (jQuery.isArray(attributes)) {