Skip to content

Instantly share code, notes, and snippets.

@calvinf
calvinf / useNavigationLock.ts
Created December 27, 2022 21:28
Next.js Page Navigation Lock
import { useEffect } from 'react';
import { useRouter } from 'next/router';
// helpful issues/posts when building this
// https://github.com/vercel/next.js/issues/2694#issuecomment-732990201
// https://github.com/vercel/next.js/issues/2476#issuecomment-850030407
// https://github.com/vercel/next.js/discussions/32231#discussioncomment-1766752
// https://github.com/vercel/next.js/issues/2476#issuecomment-843311387
/**
@calvinf
calvinf / github-docker-build-and-push.yml
Created January 8, 2022 17:57
Github Action for Docker Build and Push to Google Artifact Registry
name: CI
on:
push:
branches:
- main
pull_request:
env:
# Github Container registry
@calvinf
calvinf / .babelrc.js
Last active April 24, 2018 02:51
Example Babel 7 config (Preact server-side, JSX, works with Jest)
// Example Babel 7 config
// Server-Side Preact Rendering
// with esm (most of the time)
// but Babel handles modules in test
// so Jest works
// target node version for Babel transpilation
const NODE_TARGET = 9;
// default settings for preset-env
@calvinf
calvinf / Highlight-Code-In-Keynote.md
Created July 19, 2017 18:07
Highlighting Code in Keynote

How to highlight code in Keynote slides

Install Highlight

On Mac, if you have Homebrew installed, run:

> brew install highlight

Add to your shell config or .aliases file:

@calvinf
calvinf / add-classes.html
Created July 1, 2017 02:07
Add Classes (without using classList or jQuery)
<!doctype html>
<html>
<head>
<title>Add Classes (without using classList or jQuery)</title>
<meta charset="utf-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.4.2/mocha.css">
</head>
<body>
@calvinf
calvinf / multiply.html
Created June 24, 2017 15:46
Curried Multiply
<!doctype html>
<html>
<head>
<title>Multiply</title>
<meta charset="utf-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.4.2/mocha.css">
</head>
<body>
@calvinf
calvinf / vs-code-user-settings.json
Last active October 10, 2017 00:02
Visual Studio Code - User Settings
// Place your settings in this file to overwrite the default settings
{
"editor.acceptSuggestionOnEnter": "off",
"editor.minimap.enabled": true,
"eslint.options": {
"configFile": "eslintrc.js"
},
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"flow.pathToFlow": "/usr/local/bin/flow",
@calvinf
calvinf / keymap.cson
Last active September 30, 2016 18:07
Atom settings (keymap, favorite plugins, etc.)
'atom-text-editor':
'cmd-alt-l': 'editor:auto-indent'
'html atom-workspace':
'cmd-n': 'tree-view:add-file'
'cmd-shift-o': 'fuzzy-finder:toggle-file-finder'
'body':
'ctrl-tab ^ctrl': 'unset!'
'ctrl-tab': 'pane:show-next-item'
@calvinf
calvinf / install-apparix.sh
Last active September 13, 2016 21:33 — forked from glombard/install-apparix.sh
Setting up Apparix for directory bookmarks on Mac OS X
brew install -v apparix
# Installed to: /opt/foo/Cellar/apparix/11-0/bin/apparix
# Add bm/to Bash functions from man page to .bashrc or .local.bash:
man -P cat apparix | awk '/BASH-style functions/{p=1} /---/{if(p==1)p=2; else p=0; next} p>1{print}' >> ~/.bash_profile
# Reload my bash config:
source ~/.bash_profile
# Now create a bookmark:
@calvinf
calvinf / Enhance.js
Created November 10, 2015 04:22 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {