Skip to content

Instantly share code, notes, and snippets.

View dazulu's full-sized avatar
💻
codepen.io/dazulu

Adrian Payne dazulu

💻
codepen.io/dazulu
View GitHub Profile
@dazulu
dazulu / .zshrc
Created May 17, 2021 09:42
.zshrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export GPG_TTY=$(tty)
# AUTORUN NVM USE ON DIRECTORY CHANGE
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
@dazulu
dazulu / useWindowFocus.ts
Last active October 3, 2020 22:16
Hook for detecting if page loses/regains focus
import React from "react";
const useWindowFocus = () => {
const [focused, setFocused] = React.useState(false);
const callback = ({ type }: FocusEvent) => {
const value = type === "blur" ? false : true;
setFocused(value);
};
@dazulu
dazulu / webpack.config.js
Created November 12, 2019 13:04
A webpack config for Storybook against Nuxt (vue, typescript)
const path = require('path')
const rootPath = path.resolve(__dirname, '../')
module.exports = ({ config }) => {
config.module.rules.push(
{
test: /\.(ts|tsx)$/,
use: [
{
loader: 'babel-loader'
@dazulu
dazulu / imageLoader.md
Last active March 21, 2018 14:46
Lazy Person's Lazy Image Lazyloader

Lazy Person's Lazy Image Lazyloader

Though you could probably do it EVEN MORE lazily if you wanted #justsaying #doesntreallymatter.

I mashed this in here from a Vue component where I had a little bit more going on with props etc. but the same end result. If I open up the devtools Network tab I can see the high resolution images loading in after the rest of the page. Big perf wins!

If you want a challenge, it wouldn't be too much of a stretch to extend this to achieve something like what Medium does with the blurred image fading to the highres image. I haven't done it but it would be more or less along the lines of adding another image element, a wrapping container, and some sexy CSS.

In HTML...

<!-- Let the page render an image with a low res version (read: tiny file size). -->
@dazulu
dazulu / inclusive-design-summary.md
Last active July 11, 2017 07:11
Inclusive Web Design Summary

Inclusive Web Design Summary

This summary is an amalgamation of a few sources linked below and by no means an exhaustive authority. It should be treated as a developer guide and more detailed sources should be consulted when developing any web features. For example, the book and links mentioned below also include practical examples and more detail on ARIA roles and markup etc.

Define Page Language

Defining the correct language in an HTML page helps assistive technology to choose the correct voice profile or character set, besides the