Skip to content

Instantly share code, notes, and snippets.

@richgcook
richgcook / *.css
Last active September 22, 2023 15:35
CSS/JS to learn/try/use
:has
:nth-child(even of .noted)
:empty
rotate and translate rather than transform: translate etc
@container (min-width: 700px) {}
https://scroll-driven-animations.style/
@richgcook
richgcook / countriesA.json
Created October 27, 2020 22:47
Stripe two-letter ISO country codes
["AC","AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CV","CW","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MK","ML","MM","MN","MO","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SZ","TA","TC","TD","TF","TG
@richgcook
richgcook / menu.js
Created October 14, 2020 12:58 — forked from chaance/menu.js
Recursive menu component (React + Next.js)
import React, { Component } from 'react';
import Link from 'next/link';
import { uniqueId } from 'lodash';
import PropTypes from 'prop-types';
class Menu extends Component {
renderSubMenu = (children) => {
if (children && children.length > 0) {
return (
<ul className="menu__submenu">{this.renderMenuItems(children)}</ul>
@richgcook
richgcook / apiData.php
Last active May 4, 2020 14:42
rich-hugo #1
array ( 0 => array ( 'id' => 4958163927177, 'title' => 'Lining Family', 'body_html' => '', 'vendor' => 'A Practice for Everyday Life', 'product_type' => '', 'created_at' => '2020-04-28T17:34:06+01:00', 'handle' => 'lining-family', 'updated_at' => '2020-04-28T17:37:23+01:00', 'published_at' => '2020-04-28T17:34:06+01:00', 'template_suffix' => '', 'published_scope' => 'web', 'tags' => '', 'admin_graphql_api_id' => 'gid://shopify/Product/4958163927177', 'variants' => array ( 0 => array ( 'id' => 33593936052361, 'product_id' => 4958163927177, 'title' => 'Desktop 1–3 users', 'price' => '90.00', 'sku' => NULL, 'position' => 1, 'inventory_policy' => 'deny', 'compare_at_price' => NULL, 'fulfillment_service' => 'manual', 'inventory_management' => NULL, 'option1' => 'Desktop 1–3 users', 'option2' => NULL, 'option3' => NULL, 'created_at' => '2020-04-28T17:34:07+01:00', 'updated_at' => '2020-04-28T17:37:22+01:00', 'taxable' => true, 'barcode' => NULL, 'grams' => 0, 'image_id' => NULL, 'weight' => 0, 'weight_unit' => 'lb'
@richgcook
richgcook / a.js
Last active March 25, 2019 16:42
For Rob
var $content = $('main.page > div.content'),
userScrollPosition = 0;
if (Modernizr.history) {
$(document).on('click', 'a[data-ajax]', function(event) {
event.preventDefault();
var $this = $(this),
url = $this.attr('href');
window.history.pushState(url, null, url);
replacePage(url);
@richgcook
richgcook / gist:194ec67edcc2fe14f54f216e5cfc8b1f
Created October 31, 2016 23:34
mySQL replace file extension
UPDATE field_insitu_featured_image
SET data = REPLACE(data, '.gif', '.jpg')
UPDATE _TABLE_NAME_
SET _COLUMN_ = REPLACE(_COLUMN_, '.gif', '.jpg')
@richgcook
richgcook / gist:151b3eea59445d35f9c8e50916a2237f
Created July 13, 2016 16:17
Get form entries (PW) in a template
foreach ($forms->get("contact-form")->entries->find() as $e) {
echo "<p>{$e['e_mail']}</p>";
}
$(function(){
var canvas = document.getElementById('aub');
var $canvas = $(canvas);
var ctx = canvas.getContext('2d');
var DPR = window.devicePixelRatio || 1;
var sounds = [];
var $window = $(window);
#element {
justify-content: flex-start, flex-end, center, space-around, space-between; // Aligns left/right
}
#element {
align-items: flex-start, flex-end, center, baseline, stretch; // Aligns top/bottom
}
#element {
align-content: flex-start, flex-end, center, space-around, space-between, stretch; // Aligns all content top/bottom
@richgcook
richgcook / overlays.js
Created February 4, 2016 16:09
Cookie with modal
function overlays() {
if (!Cookies.get('mailing_list')) {
$('.mailing-list-popup').show();
} else {
$('.mailing-list-popup').hide();
}
$('.mailing-list-popup .close').on('click touchstart', function(e) {
Cookies.set('mailing_list', '1', { expires: 7 });
$('.mailing-list-popup').fadeOut(250, function() {
$('.mailing-list-popup').removeAttr('style');