Skip to content

Instantly share code, notes, and snippets.

View haroldao's full-sized avatar
🎯
Design + Dev

Harold AO haroldao

🎯
Design + Dev
View GitHub Profile
@panoply
panoply / wishlist.md
Last active July 4, 2024 10:13
Client Slide Wishlist for Shopify

Usage

The function invokes as an IIFE and is exposed in global scope (i.e, window.wishlist or simply, wishlist). This means that you simply drop it in via <script>. It provides several methods for usage. By default, it will not do anything until you wire it up. Firstly, let me explain the main methods:

// use render method to optionally create a virtual wishlist, more on this later
wishlist.render((product) => `<a href="#"><img class="img" src="${product.img}"></a>`);

// If you need to listen for wishes
wishlist.on('wished', (args) =&gt; console.log(args));

How to show/hide the macOS Dock instantly

Open Terminal.app from Applications > Utilities Copy-paste one of the following commands & confirm it

On Intel-based Macs:

defaults write com.apple.dock autohide-delay -float 0 && killall Dock

On Apple Silicon-based Macs:

@steven-tey
steven-tey / title-from-url.ts
Last active July 9, 2023 19:48
Get Title from URL
// Note: this gist is a part of this OSS project that I'm currently working on: https://github.com/steven-tey/dub
export default async function getTitleFromUrl (url: string) {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 2000); // timeout if it takes longer than 2 seconds
const title = await fetch(url, { signal: controller.signal })
.then((res) => {
clearTimeout(timeoutId);
return res.text();
})
@dcchambers
dcchambers / mac-fixes.md
Last active June 28, 2024 21:27
Improve your MacOS Experience

Fixes for Various Mac Issues

A couple of things that may improve your experience using MacOS.

Many of these settings can be configured via the command line (and thus, scripted) using the MacOS defaults tool.

defaults help
defaults read   # list all defaults
defaults write ...
@khooz
khooz / js-only-age-restriction.js
Created September 29, 2021 08:52
Simple age restriction guard that only relies on js-cookie.
// Make sure js-cookies are loaded before this code
function verifyAge(gaurdingPage = "./age-verification.html") {
if (!Cookies.get("age-verification"))
{
Cookies.set("intended", window.location.href);
window.location.replace(gaurdingPage);
}
}
function checkAge(homePage = "./index.html", awayPage = "https://www.google.com/?q=") {
@atikju
atikju / related-articles.liquid
Created February 25, 2021 11:24
Show related articles based on article tags - Shopify
@pablogiralt
pablogiralt / shopify-brooklyn-theme-size-guide.md
Last active February 19, 2021 17:44
Add a size guide to Shopify Brooklyn Theme

Add Size Guide to Shopify Brooklyn Theme

This is what you get:

1- A link to below the variant selector which will open the size guide:

Shopify Brooklyn Theme Size Guide

2- The size selector modal:

@adamwooding
adamwooding / product-template-enquiry.liquid
Created November 6, 2020 22:18
Shopify Minimal Theme - sections template with no prices and enquiry form
<div itemscope itemtype="http://schema.org/Product" id="ProductSection" data-section-id="{{ section.id }}" data-section-type="product-template" data-image-zoom-type="{{ section.settings.product_image_zoom_type }}" data-show-extra-tab="{{ section.settings.show_extra_tab }}" data-extra-tab-content="{{ section.settings.extra_tab_content }}" data-enable-history-state="true">
{% case section.settings.add_to_cart_width %}
{% when 'small' %}
{%- assign btn_class = 'btn--wide' -%}
{%- assign productform_class = 'product-form--wide' -%}
{% when 'medium' %}
{%- assign btn_class = 'btn--wide' -%}
{%- assign productform_class = 'product-form--wide' -%}
{% when 'large' %}
@joePichardo
joePichardo / shopify-use-case-option-selection.html
Created September 28, 2020 14:27
Shopify option_selection.js usage
{{ 'option_selection.js' | shopify_asset_url | script_tag }}
<script>
// <![CDATA[
var selectCallback = function(variant, selector) {
if (variant) {
if (variant.available) {
// Selected a valid variant that is available.
$('#add-to-cart-button').removeClass('disabled').removeAttr('disabled').html('Add to Cart');
} else {