Skip to content

Instantly share code, notes, and snippets.

View ihorduchenko's full-sized avatar
💭
Working

Ihor Duchenko ihorduchenko

💭
Working
View GitHub Profile
@ihorduchenko
ihorduchenko / entities.html
Created March 16, 2022 13:58
Collection of useful HTML entities
Arrow ➔
Bullet/dot •
@ihorduchenko
ihorduchenko / prod.js
Last active January 25, 2022 21:18
Disable Slate's Webpack javascript minification
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const SlateConfig = require('@shopify/slate-config');
const SlateTagPlugin = require('@shopify/slate-tag-webpack-plugin');
const babel = require('./parts/babel');
@ihorduchenko
ihorduchenko / lazyload-youtube.liquid
Created January 24, 2022 09:52
Lazy-load YouTube videos on click
<div class="lazyVideoLoader">
<a href="javascript:;" data-video-id="VIDEO_ID" class="feature-row__video-trigger lazyVideoTrigger">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 80">
<path d="M40 0a40 40 0 1040 40A40 40 0 0040 0zM26 61.56V18.44L64 40z"></path>
</svg>
</a>
</div>
<script>
var lazyVideoLoader = document.querySelectorAll('.lazyVideoLoader');
@ihorduchenko
ihorduchenko / dynamic-customizer-image-metafield.liquid
Last active January 29, 2022 23:44
Get dynamic image metafield from customizer (OS2)
{{ img_url | file_url }}
@ihorduchenko
ihorduchenko / free-geolocation-detection-endpoint.js
Last active March 22, 2022 21:02
Geolocation detection endpoint
// https://get.geojs.io/v1/ip/geo.json
// https://ipapi.co/country
// http://ip-api.com/json
// https://ipinfo.io/json
// https://extreme-ip-lookup.com/json/?key=E4sAnOeXGIkbh5BLZOCg
// https://geolocation-db.com/json/0f761a30-fe14-11e9-b59f-e53803842572
// ABOVE LOOKS LIKE WASTED
// BELOW ARE FINE
// + https://ipgeolocation.abstractapi.com/v1/?api_key=b3d18485c87a42d1a7a82c0568732f19
@ihorduchenko
ihorduchenko / custom-liquid.liquid
Created December 29, 2021 18:42
Shopify sections - "liquid" section type
{%- if section.settings.boxed -%}
<div class="grid-container contained">
{%- endif -%}
{{ section.settings.liquid }}
{%- if section.settings.boxed -%}
</div>
{%- endif -%}
@ihorduchenko
ihorduchenko / woocommerce>checkout>review-order.php
Created December 23, 2021 20:15
Woocommerce estimated shipping date, based on stock and shipping method
<table class="shop_table mb-4">
<tfoot>
<!-- Skipped top part -->
<!-- Stock part -->
<?php $stock_values = array(); ?>
<?php $max_stock_period = 0; ?>
<?php foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { ?>
<?php $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); ?>
<?php $stock_status = $_product->get_stock_status(); ?>
@ihorduchenko
ihorduchenko / firstVisitCookies.js
Created December 13, 2021 22:16
Get and set cookies on first user visit
function setCookie(name, value, days) {
var expires = '';
if (days) {
let date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = '; expires=' + date.toUTCString();
}
document.cookie = name + '=' + (value || '') + expires + '; path=/';
}
@ihorduchenko
ihorduchenko / strict-content-using-license-key.liquid
Created December 1, 2021 16:48
Strict page content based on license key, stored in Google Sheets
<script defer="defer">
// Format of table is here: http://prntscr.com/219q3nl
const myDomain = window.location.hostname;
const myLicenseKey = '{{ settings.license_key | strip }}';
fetch('https://sheets.googleapis.com/v4/spreadsheets/1JO15y71ImOijJ4rcdMV7avZT5Y5lILkZin6emwg35D0/values/Keys!A2:B10000?key=AIzaSyBxbARr6-hAqdtZXXqSqDPmzap7EULYaFg')
.then(response => response.text())
.then(data => {
let resp = JSON.parse(data);
let respKeys = resp.values;
let allKeys = [];
@ihorduchenko
ihorduchenko / defer-css.html
Created November 26, 2021 13:56
Defer loading CSS file using media attribute trick
<link rel="stylesheet" href="theme.css" media="print" onload="this.media='all'">