This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post '/signup' do | |
if params[:code_text] == 'baba_black_sheep' | |
a = Mechanize.new | |
a.get('http://private.myshopifysite.com/') do |page| | |
logged_in = page.form_with(:action => '/password') do |f| | |
f.password = 'knock_knock' | |
end.submit | |
end | |
c = a.cookies.collect {|c| {:name => c.name, :value => c.value}} | |
c.each do |cc| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'grape' | |
class Foo < Grape::API | |
version '1' | |
resource :services do | |
get :language_detector do | |
["english", "french"] | |
end | |
end | |
end | |
run Foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// --------------------------------------------------------- | |
// 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)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Rack::Session::Cookie, :secret => 'whatever' | |
use Rack::Flash | |
use Rack::MethodOverride | |
use Warden::Manager do |manager| | |
manager.default_scope = :user | |
manager.scope_defaults :user, :strategies => [:password] | |
manager.scope_defaults :admin, :store => true, :strategies => [:admin] | |
manager.failure_app = Main::App | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveResource::Connection | |
# HACK 1: Add an attr_reader for response | |
attr_reader :response | |
def request(method, path, *arguments) | |
result = ActiveSupport::Notifications.instrument("request.active_resource") do |payload| | |
payload[:method] = method | |
payload[:request_uri] = "#{site.scheme}://#{site.host}:#{site.port}#{path}" | |
payload[:result] = http.send(method, path, *arguments) | |
end |