Skip to content

Instantly share code, notes, and snippets.

@abernier
abernier / README
Last active September 2, 2023 13:28
$.fn.firework
Simple firework plugin — Play with options!
function rateLimit(limitCount, limitInterval, fn) {
var fifo = [];
// count starts at limit
// each call of `fn` decrements the count
// it is incremented after limitInterval
var count = limitCount;
function call_next(args) {
setTimeout(function() {
@abernier
abernier / README
Last active September 2, 2023 13:24
TransitionAB
unobstrusive transition between A and B DOM elements through a third one C
Principle, for example transition A -> B:
1. make a clone of A
2. hide A and B
3. apply B styles to the clone (with transition)
4. once transition end, remove clone and reveal A and B back
function walkTheDOM(node, func) {
func(node);
node = node.firstChild;
while (node) {
walkTheDOM(node, func);
node = node.nextSibling;
}
}
@abernier
abernier / .gitignore
Last active June 1, 2023 15:45
pie with CSS
node_modules/
@abernier
abernier / index.css
Created January 6, 2012 13:32
CSS 3D cube
/*
variables:
a = 5em
2.5em = a / 2
*/
.cube,
.cube > * {display:block; width:5em; height:5em;}
@abernier
abernier / README
Last active June 6, 2022 11:41
google camera
Moving around google.com
@abernier
abernier / index.md
Last active April 2, 2022 04:47
React cheatsheet

Custom hooks

function useTimeout(ms = 0) {
  const [ready, setReady] = React.useState(false);
  
  React.useEffect(function () {
    const int = setTimeout(() => setReady(true), ms);
    
    return () => clearTimeout(int);
@abernier
abernier / camera.js
Created December 11, 2011 02:22
SVG camera
/** =======================================================================
* Vincent Hardy
* License terms: see svg-wow.org
* CC0 http://creativecommons.org/publicdomain/zero/1.0/
* ======================================================================= */
YUI.add("camera", function (Y) {
/**
* Constructor. A <code>Camera</code> makes it easy to move the
{
"asset" : {
"generator" : "Khronos glTF Blender I/O v1.7.33",
"version" : "2.0"
},
"scene" : 0,
"scenes" : [
{
"name" : "Scene",
"nodes" : [