Skip to content

Instantly share code, notes, and snippets.

View pwfisher's full-sized avatar

Patrick Fisher pwfisher

View GitHub Profile
@claus
claus / _app.js
Created May 14, 2020 05:35
Restore scroll position after navigating via browser back/forward buttons in Next.js
import useScrollRestoration from "utils/hooks/useScrollRestoration";
const App = ({ Component, pageProps, router }) => {
useScrollRestoration(router);
return <Component {...pageProps} />;
};
export default App;
@OwenMelbz
OwenMelbz / whenDefined.js
Created April 14, 2016 18:12
Helper function that fires when an object becomes avaiable
//Inspired by http://fokkezb.nl/2016/04/14/how-to-wait-for-a-javascript-variable-to-be-defined/
//var console = document.getElementById('console');
//console.innerText = 'not loaded';
var whenDefined = function($context, $variable, $callback){
if( $context[$variable] ){
$callback();
} else {
@jedilando
jedilando / gist:3489392
Created August 27, 2012 15:13 — forked from AndrewRayCode/gist:825583
recursive read directory in node.js returning flattened list of files and directories. Added support for empty dirs
// original gist: https://gist.github.com/825583
// I've added support for empty directories
// i.e. when `start` dir was empty callback was not fired,
// now it is fired like this: callback(null, {dirs: [], files: []})
function readDir(start, callback) {
// Use lstat to resolve symlink if we are passed a symlink
fs.lstat(start, function(err, stat) {
if(err) {
return callback(err);
}
@villiger
villiger / sinuswave.html
Created October 11, 2011 08:25
Animate letters on screen with JavaScript along a sinus wave
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Sine Wave</title>
<style type="text/css">
.letter {
font-family: sans-serif;
font-size: 40px;
font-weight: bold;
<?php
/**
* CommandLine class
*
* @package Framework
*/
/**
* Command Line Interface (CLI) utility class.
*
* @author Patrick Fisher <patrick@pwfisher.com>