Skip to content

Instantly share code, notes, and snippets.

View RyKilleen's full-sized avatar

Ryan Killeen RyKilleen

View GitHub Profile
@think-john
think-john / how-fast-is-fast-notes.md
Last active April 1, 2020 18:19
"How Fast is Fast" notes

"How Fast is Fast" notes

These are notes that Brian McElaney and Amanda Kalk will be using to answer questions in our webinar chat. You may have been given this link directly -- welcome! Feel free to add comments with your questions below, and we will follow up with you!

-- John Young

How to measure the speed index using Lighthouse

First: set up a clean profile

@reecelucas
reecelucas / useScrollBlock.js
Last active May 15, 2024 07:58
React hook to enable/disable page scroll
import { useRef } from 'react';
const safeDocument = typeof document !== 'undefined' ? document : {};
/**
* Usage:
* const [blockScroll, allowScroll] = useScrollBlock();
*/
export default () => {
const scrollBlocked = useRef();
@rafaelrozon
rafaelrozon / mock_axios_storybook.jsx
Last active April 26, 2023 12:29
Mock Axios requests in Storybook
import React from 'react';
import { storiesOf } from '@storybook/react';
// 1. import axios and MockAdapter
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
// 2. create the mock
const mock = new MockAdapter(axios);
@tomhodgins
tomhodgins / css-overlay.js
Last active September 21, 2018 00:34
Paste this into your console for an easy-to-edit, live-updating CSS overlay. Demo: http://i.imgur.com/VWcK8RA.gif
// CSS Overlay
var overlay_styles = document.createElement('style')
var virtual_stylesheet = document.createElement('style')
var textarea = document.createElement('textarea');
overlay_styles.textContent = `
[data-css=overlay] {
box-sizing: border-box;
margin: 0;
padding: 1em;
@sanusart
sanusart / localStorage.js
Last active August 1, 2020 09:03
Jest mock localStorage #test #jest
// ./__mocks__/localStorage.js
let mockStorage = {};
module.exports = window.localStorage = {
setItem: (key, val) => Object.assign(mockStorage, {[key]: val}),
getItem: (key) => mockStorage[key],
clear: () => mockStorage = {}
};
@barneycarroll
barneycarroll / README.md
Last active August 29, 2022 12:02
Lock and unlock a page's scroll position.

jquery.scrollLock.js

Useful for when a blocking user experience is needed (in my case, didn't want people unwittingly loosing their place by scrolling while a modal required their attention): $.scrollLock() locks the body in place, preventing scroll until it is unlocked.

// Locks the page if it's currently unlocked
$.scrollLock();

// ...or vice versa
@afrex
afrex / Trailing Comma of Death regex
Created September 4, 2013 08:03
Use this regex in a search to retrieve trailing comma's of death within your application. This comma's will cause inconsistent behaviour in Internet Explorer browsers.
,\s*?\]|,\s+}