Skip to content

Instantly share code, notes, and snippets.

@tomfa
tomfa / urls.test.ts
Last active May 20, 2024 10:58
NextJS route vs pathname matcher
describe('matchesPath', () => {
const matches = [
['/cake', '/cake'],
['/cake', '/cake/'],
['/cake', '/cake?frige=warm'],
['/cake', '/cake?frige=warm&freezer=cold'],
['/[id]', '/cake'],
['/[anything-goes]', '/cake'],
['/c/[id]/practitioner/[pid]/[anything-goes]', '/c/1/practitioner/2/3'],
['/[...rest]', '/cake'],
@daniele-rapagnani
daniele-rapagnani / dump_google_spaces.js
Created March 1, 2017 10:55
Quick and dirty snippet for exporting links from Google Spaces
/**
* This dirty, dirty script, allows you to export links from google spaces
* so that you don't have to do it manually before April 17th.
* I could not find any official way to do this so I quickly threw this script
* together.
*
* USAGE:
* 1. Place yourself on the space page you want to export
* (such as: https://spaces.google.com/space/XXXXXXXXXXXXXXX)
*
@ebidel
ebidel / fancy-tabs-demo.html
Last active March 8, 2024 23:08
Fancy tabs web component - shadow dom v1, custom elements v1, full a11y
<script src="https://unpkg.com/@webcomponents/custom-elements"></script>
<style>
body {
margin: 0;
}
/* Style the element from the outside */
/*
fancy-tabs {
margin-bottom: 32px;
@ray-peters
ray-peters / gist:228b825d3fb4be6b22e1
Last active September 8, 2015 15:52
Patient Zero
// HOW TO USE: Click start from scratch and be looking at the "Add Block" box
// CONFIGURATIONS
var SPLIT_TEST_INDEX = 0;
var optEditor = ontraport.window.panel.currentPane.components.editor_component,
optEditorModel = optEditor.options.model,
BlockStylesModel = ontraport.Models.Objects.getModel( 131 ),
BlockTypes = ontraport.Models.Objects.getModel( 132 ),
_def = $.Deferred();
@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@ericelliott
ericelliott / essential-javascript-links.md
Last active May 17, 2024 03:38
Essential JavaScript Links
@jcgregorio
jcgregorio / How_to_use.html
Last active July 17, 2023 14:44
HTML Templating using the HTML <template> element and exactly 100 lines of JS. A cleaned up version of this code is now available at https://github.com/jcgregorio/stamp/.
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script src="templating.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<template id=t>
@codler
codler / css-supports.js
Last active October 8, 2022 09:32
CSS.supports() Polyfill
/*! CSS.supports() Polyfill
* https://gist.github.com/codler/03a0995195aa2859465f
* Copyright (c) 2014 Han Lin Yap http://yap.nu; MIT license */
if (!('CSS' in window)) {
window.CSS = {};
}
if (!('supports' in window.CSS)) {
window.CSS._cacheSupports = {};
window.CSS.supports = function(propertyName, value) {
@dogoku
dogoku / A README.md
Last active December 29, 2022 02:58 — forked from tiffon/Find Results.hidden-tmLanguage
Search result syntax highlighting for Sublime Text

#ST2/3 Search result syntax highlighting

##Introduction and disclaimer

This is gist contains an edited Find Results.hidden-tmLanguage which adds syntax highlighting to your ST search results. As far as I know, there is no plugin that does this and for that reason it needs to be done via config.

DISCLAIMER: Use this HACK at your risk and backup the original files you are about to mess with.

##Usage Guide for Sublime Text 2

@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active April 2, 2024 02:45
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");