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 / Notification.js
Created October 14, 2018 14:01
Notification
'use strict';
(function () {
Date.prototype.subDays = function(days) {
date = new Date(this.valueOf())
date.setDate(date.getDate() - days)
return date
}
@michelarteta
michelarteta / flatteting-array.js
Created November 1, 2018 20:16
Flattering Array
// case [[1,2,[3]],4]
// case [[1, 2],[3, 4, 5], [6, 7, 8, 9]];
var array = [[1, 2],[3, 4, 5], [6, 7, 8, 9]];
function flattenArray(value) {
const stack = [...value];
const res = [];
@michelarteta
michelarteta / shopify-render-blocking.js
Last active May 8, 2022 20:52
Boost your Shopify page loading speed 🚀with this simple approach.
function loadjscssfile(filename, filetype) {
if (filetype == "js") { //if filename is a external JavaScript file
var fileref = document.createElement('script')
fileref.setAttribute("type", "text/javascript")
fileref.setAttribute("src", filename)
} else if (filetype == "css") { //if filename is an external CSS file
var fileref = document.createElement("link")
fileref.setAttribute("rel", "stylesheet")
fileref.setAttribute("type", "text/css")
@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');
{
"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":[
<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: '' %}
@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 }};
@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 / 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 }