Skip to content

Instantly share code, notes, and snippets.

View panoply's full-sized avatar
🥛
Rich in the hood

ΝΙΚΟΛΑΣ panoply

🥛
Rich in the hood
View GitHub Profile
@0x15f
0x15f / readme.md
Last active November 7, 2024 02:46
Bundled section rendering

Usage

import { prefetchSection, loadSection } from "./section-rendering";

// hover / mouseover
function variantHover(newVariantId: number) {
  prefetchSection("product-form", `/products/current-product`, newVariantId);
}
@aspirantzhang
aspirantzhang / searchTree.test.ts
Created May 7, 2021 09:08
[function] searchTree - find a node in a tree
import { searchTree } from '../searchTree';
const validTree = [
{
id: 1,
parent_id: 0,
title: 'Level 1',
value: 1,
children: [
{
@colllin
colllin / Readme.md
Last active February 21, 2024 14:55
FaunaDB User Token Expiration (for ABAC)

Auth0 + FaunaDB ABAC integration: How to expire Fauna user secrets.

Fauna doesn't (yet?) provide guaranteed expiration/TTL for ABAC tokens, so we need to implement it ourselves if we care about it.

What's in the box?

3 javascript functions, each of which can be imported into your project or run from the command-line using node path/to/script.js arg1 arg2 ... argN:

  1. deploy-schema.js: a javascript function for creating supporting collections and indexes in your Fauna database.
@hopsoft
hopsoft / prefetch.js
Last active March 4, 2025 02:01
Turbolinks Prefetching
const hoverTime = 400
const fetchers = {}
const doc = document.implementation.createHTMLDocument('prefetch')
function fetchPage (url, success) {
const xhr = new XMLHttpRequest()
xhr.open('GET', url)
xhr.setRequestHeader('VND.PREFETCH', 'true')
xhr.setRequestHeader('Accept', 'text/html')
xhr.onreadystatechange = () => {
@jeromecoupe
jeromecoupe / webstoemp-gulpfile.js
Last active March 13, 2025 03:37
Gulp 4 sample gulpfile.js. For a full explanation, have a look at https://www.webstoemp.com/blog/switching-to-gulp4/
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
@asissuthar
asissuthar / gulpfile.js
Last active June 12, 2020 15:04
Gulp V4 - RollUp - Babel - Stylus - Pug
let gulp = require('gulp')
let rev = require('gulp-rev')
let concat = require('gulp-concat')
let rename = require('gulp-rename')
let replace = require('gulp-replace')
let clean = require('gulp-clean')
let uglify = require('gulp-uglify')
let autoprefixer = require('gulp-autoprefixer')
let cssnano = require('gulp-cssnano')
let htmlmin = require('gulp-htmlmin')
@leobossmann
leobossmann / ee_funnel.js
Last active September 3, 2020 05:25
Checkout Steps for Enhanced Ecommerce labelling, originally by Rob Edlin, https://ecommerce.shopify.com/c/shopify-discussion/t/checkout-labelling-417229
var step_number = 0;
switch (Shopify.Checkout.step) {
case "contact_information":
step_number = 1;
break;
case "shipping_method":
step_number = 2;
break;
@yomotsu
yomotsu / gulpfile.js
Last active October 18, 2018 14:10
rollup /w gulp
'use strict';
const browserSync = require( 'browser-sync' ).create();
const gulp = require( 'gulp' );
const gulpif = require( 'gulp-if' );
const rename = require( 'gulp-rename' );
const uglify = require( 'gulp-uglify' );
const rollup = require( 'rollup' );
const rollupStream = require( 'rollup-stream' );
@Warsaalk
Warsaalk / mutationlistener-test.html
Last active February 5, 2024 08:34
A Javascript class that observes DOM changes for a single target. It allows listening to ID's, Classes and Node names and returns the nodes if they are added to the DOM.
<!doctype html>
<html>
<head>
<title>Mutation Listener</title>
<script src="mutationlistener.js"></script>
</head>
<body>
<div id="test">
Existing content
</div>