Skip to content

Instantly share code, notes, and snippets.

View candelatech's full-sized avatar
🔥

Candela candelatech

🔥
View GitHub Profile
{% comment %}
Firstly, we can't comment inside liquid tags, so this turned into a mess pretty quickly.
In order to somewhat document this mess, I'll do my best without writing the comments inline :(
This snippet takes in a string variable called "raw", parses it for markdown, and spits out the
corresponding HTML representation
<!-- this should be on codepen... lets do that instead -->
<svg>
</svg>
<style>
#test svg #anim * {
transition: stroke-dashoffset 1s ease;
{% comment %}
Client wants a realistic inventory gauge displayed on the product page.
Limitations in Shopify are heavy, so this only works with products with a "Size" option that is formatted like {{number}}oz or {{number}}lbs
The idea here is to basically sum up the total number of pounds of product we have remaining, and divide that by the pre-set batch size.
The pre-set batch size is configured with Shopify meta tags, per-product.
{% endcomment %}
@candelatech
candelatech / main.js
Last active September 2, 2021 00:53
Authenticating with the Walmart.io API in Node.js
make_wm_request: async function({method,url,http_body,vendor_id,consumer_id,consumer_pk,channel_type} = {}){
return new Promise(async function(resolve,reject){
//if you don't have a PEM-formatted private key (we didn't), generate one real quick
var pk_chunked = chunkSubstr(consumer_pk, 64).join("\n")
pk_chunked = "-----BEGIN PRIVATE KEY-----\n" + pk_chunked + "\n-----END PRIVATE KEY-----\n"
var epoch_timestamp = Date.now()
@candelatech
candelatech / gwp.rb
Created April 22, 2020 23:02
Shopify Gift With Purchase
Variant_ids = [18334016901, 17782905285 ]
Product_ids = [5782681861, 5620148101 ]
Prices = [2450, 500 ]
Triggers = [15000, 2500 ]
def gwp(product_id, variant_id, product_price, activation_total)
should_trigger_gift = false
@candelatech
candelatech / async.js
Last active April 22, 2020 22:52
JS Anonymous Async Function
//we couldn't find a good example of this anywhere... so here it is!
!(async function(){
//async code here runs immediately
})()