Skip to content

Instantly share code, notes, and snippets.

View michelarteta's full-sized avatar
:octocat:

Michel Arteta michelarteta

:octocat:
View GitHub Profile
@michelarteta
michelarteta / compress.liquid
Created March 30, 2020 23:18 — forked from JimmyRittenborg/compress.liquid
HTML Compressor in Shopify Liquid
{% comment %}
Input
{% endcomment %}{% capture _content %}{{ content }}{% endcapture %}{% comment %}
Remove redundant closing tags
{% endcomment %}{% assign _endings = "html head body li dt dd p rt rp optgroup option colgroup caption thead tbody tfoot tr td th" | split: " " %}{% for _element in _endings %}
{% capture _end %}</{{ _element }}>{% endcapture %}
@michelarteta
michelarteta / items-in-cart-discount.rb
Last active March 9, 2020 12:54
Shopify Shopping Cart Discount for Products in Bundle.
VALID_PRODUCTS = [32513342570627, 32513342603395, 32513345060995]
DISCOUNT = 10
CART_VARIANTS = Input.cart.line_items.map{|li| li.variant.id}
message ='Enjoy 10% OFF on us!'
if (CART_VARIANTS & VALID_PRODUCTS).length == VALID_PRODUCTS.length
Input.cart.line_items.each do |line_item|
line_item.change_line_price(
line_item.line_price * (Decimal.new(1) - DISCOUNT.to_d / 100),
message: message,
@michelarteta
michelarteta / ssl-check
Created March 5, 2020 20:56
Generate a local SSL certificate. Make sure to install mkcert first [brew install mkcert]
function ssl-check() {
f=~/.localhost_ssl;
ssl_crt=$f/server.crt
ssl_key=$f/server.key
b=$(tput bold)
c=$(tput sgr0)
local_ip=$(ipconfig getifaddr $(route get default | grep interface | awk '{print $2}'))
# local_ip=999.999.999 # (uncomment for testing)
@michelarteta
michelarteta / code-sample.js
Created February 13, 2020 21:46
Code Sample
import { isTouchDevice } from './detect-touch-device';
const $win = $(window);
const $doc = $(document);
const $navDropdownParent = $('.nav .has-dropdown');
/**
* Show nav dropdowns for mobile devices
* @param { Object } $clickedElement DOM Element - clicked element
* @return { Void }
@michelarteta
michelarteta / kassatex-gulp.js
Created February 13, 2020 21:41
Gulp JS Code Example
/**
* The module dependencies.
*/
const del = require('del');
const path = require('path');
const gulp = require('gulp');
const sass = require('gulp-sass');
const utils = require('./utils');
const gulpif = require('gulp-if');
const rename = require('gulp-rename');
@michelarteta
michelarteta / single-image.liquid
Created February 13, 2020 21:39
Code Sample from kassatex.com
{%- assign _section = section.settings -%}
{%- comment -%} Style of Section {%- endcomment -%}
{%- if _section.color != blank -%}
<style type="text/css">
.section-image[data-section-id="{{ section.id }}"] .section__title,
.section-image[data-section-id="{{ section.id }}"] .section__subtitle,
.section-image[data-section-id="{{ section.id }}"] .btn--link
{
color: {{ _section.color }};
<div class="product-template__container page-width"
id="ProductSection-{{ section.id }}"
data-section-id="{{ section.id }}"
data-section-type="product"
data-enable-history-state="true"
data-ajax-enabled="{{ settings.enable_ajax }}"
>
{% assign products = product.metafields.global.grid-products | split: "," %}
{% assign variants = '' | split: '' %}
{
"id":4342845472823,
"title":"Sham",
"handle":"sham",
"description":"",
"published_at":"2019-11-09T21:49:00-05:00",
"created_at":"2019-11-09T22:06:26-05:00",
"vendor":"B2B Kassatex",
"type":"Bedding",
"tags":[
@michelarteta
michelarteta / gist:d0c0ae4941037463d6b52a21ddaf0ac8
Created August 31, 2019 11:10
WP Replace Old with New URL
UPDATE wp_options SET option_value = replace(option_value, 'Existing URL', 'New URL') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'Existing URL','New URL');
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'Existing URL','New URL');
UPDATE wp_links SET link_url = replace(link_url, 'Existing URL','New URL');