Provide SHOPIFY_SUBDOMAIN
, SHOPIFY_EMAIL
and SHOPIFY_PASSWORD
environment variables, and discount.rb
will configure itself.
Supported APIs are
Discount.find(:all)
Discount.find(:first)
Discount.create(...)
Discount#destroy
# Gemfile
group :development, :test do
gem 'minitest-rails'
gem 'fabrication'
end
import hashlib, base64, hmac, json, settings | |
def shopify_webhook(f): | |
""" | |
A decorator thats checks and validates a Shopify Webhook request. | |
""" | |
def _hmac_is_valid(body, secret, hmac_to_verify): | |
hash = hmac.new(body, secret, hashlib.sha256) | |
hmac_calculated = base64.b64encode(hash.digest()) |
<div class="container"> | |
<div class="row"> | |
<div class="col-sm-6 col-md-4 col-md-offset-4"> | |
<h1 class="text-center login-title">Sign in to continue to Bootsnipp</h1> | |
<div class="account-wall"> | |
<img class="profile-img" src="https://lh5.googleusercontent.com/-b0-k99FZlyE/AAAAAAAAAAI/AAAAAAAAAAA/eu7opA4byxI/photo.jpg?sz=120" | |
alt=""> | |
<form class="form-signin"> | |
<input type="text" class="form-control" placeholder="Email" required autofocus> | |
<input type="password" class="form-control" placeholder="Password" required> |
# Elastic search grouping solution | |
# As at present ElasticSearch does not provide a group_by equivalent, here's my attempt to do it manually. | |
# In the example we have articles made by some authors and I'd like to have relevant docs, but not more than one per author. | |
# Assumption. | |
# | |
# 1) I'm looking for relevant content | |
# 2) I've assumed that first 300 docs are relevant, | |
# So I consider only this selection, regardless many of these are from the same few authors. | |
# 3) for my needs I didn't "really" needed pagination, for me it was enough a "show more" button updated through ajax |
def find_blog | |
case request.host | |
when "www.#{Setting.host}", Setting.host, nil | |
@current_blog = Blog.find_by_subdomain(request.subdomain) | |
else | |
if request.host.index(Setting.host) | |
@current_blog = Blog.find_by_subdomain(request.host.split('.').first) | |
else |
# -*- encoding : utf-8 -*- | |
class Subdomain | |
def self.matches?(request) | |
case request.host | |
when Setting.host, "www.#{Setting.host}", nil | |
false | |
else | |
true | |
end |
Assume that we want to create a bucket called foo.mydomain.com, and you have already mydomain.com
1. Create the bucket.
- go to AWS console, s3, select the s3 region that you want.
- name the bucket foo.mydomain.com
- save and then select -> click actions-> properties
-> in properties click permissions -> add permissions add VIEW for EVERYBODY (s3 files are unguessable urls)
2. Create the CNAME
function openAndReuseOneTabPerURL(url) { | |
window.chrome.tabs.query({url: url + '*'}, function (tabs) { | |
console.log(tabs); | |
if (tabs.length > 0) { | |
window.chrome.tabs.update(tabs[0].id, {active: true, highlighted: true}); | |
} else { | |
window.chrome.tabs.create({url: url, active: true}); | |
} | |
}); | |
} |