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
@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 December 27, 2023 02:45
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 January 21, 2024 16:28
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>
@cauerego
cauerego / IndexedDB101.js
Last active January 13, 2023 22:00 — forked from JamesMessinger/IndexedDB101.js
Very Simple IndexedDB Example
// quite untested, adapted from BigstickCarpet's gist, attempt to make it simpler to use
function openIndexedDB (fileindex) {
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
var openDB = indexedDB.open("MyDatabase", 1);
openDB.onupgradeneeded = function() {
var db = {}