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
@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();
})
@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 {
@hobo71
hobo71 / floating-animation-css.markdown
Created July 30, 2020 01:35
Floating Animation - CSS
@rleaf
rleaf / background-noise-canvas.markdown
Created February 8, 2020 05:09
Background Noise - Canvas
@akella
akella / setup.md
Last active May 1, 2024 05:33
My Setup