Skip to content

Instantly share code, notes, and snippets.

Avatar
⚠️
TypeError: Cannot read property 'status' of undefined.

Christian Petersen fnky

⚠️
TypeError: Cannot read property 'status' of undefined.
View GitHub Profile
@fnky
fnky / BetterFixedLazyExample.jsx
Last active Nov 29, 2019
Lazy conditionals and refs
View BetterFixedLazyExample.jsx
function BetterFixedLazyExample({ lazyValue }) {
// Initialize with null value.
const myRef = useRef(null);
useLayoutEffect(() => {
console.log(myRef.current); // => HTMLDivElement DOM node
}, []);
// Make sure the ref setter is not blocked by conditionals.
return (
@fnky
fnky / history-with-outer.jsx
Last active Nov 27, 2019
History provider with useState / useRef
View history-with-outer.jsx
import React from 'react';
import { createBrowserHistory } from 'history';
export const historyContext = React.createContext(null);
const HistoryContextProvider = historyContext.Provider;
// This is initialized at the time the file/module is imported, and not on component mount.
const history = createBrowserHistory();
export function History(props) {
@fnky
fnky / fonts.md
Created Oct 18, 2019
Cheap-ish fonts
View fonts.md

Cheap-ish fonts

A list of cheap-ish fonts, that doesn't put a dent in my wallet.

@fnky
fnky / variable-fonts.md
Last active Mar 27, 2021
Awesome Variable Fonts
View variable-fonts.md

Awesome Variable Fonts

A list of open source and free* variable fonts.

* Some fonts may require a license to be used for commerical use.

Open Source

@fnky
fnky / serialization-tools.md
Created Oct 16, 2019
Binary serialization frameworks, libraries and tools
@fnky
fnky / stripe-keys-and-ids.tsv
Last active Apr 6, 2021
Stripe keys and IDs
View stripe-keys-and-ids.tsv
Prefix Description Notes
sk_live_ Live secret key Secret key in a live environment.
pk_live_ Live public key Public key in a live environment.
pst_live_ Live Connection token Connection token in a live environment.
sk_test_ Test secret key Pecret key in a test environment.
pk_test_ Test public key Public key in a test environment.
pst_test_ Test Connection token Connection token in a test environment.
ac_ Platform Client ID Identifier for an auth code/client id.
acct_ Account ID Identifier for an Account object.
ch_ Charge ID Identifier for a Charge object.
View query-order.graphql
# Query order pattern from GitHub GraphQL API
# Can be used in conjunction with Relay pagination.
"""
Possible directions in which to order a list of items when provided an `orderBy` argument.
"""
enum OrderDirection {
"""
Specifies an ascending order for a given `orderBy` argument.
"""
View mark-closed-as-read.js
/**
* Marks all closed issues and pull reuqest notifications as read.
*/
(() => {
const closedIssueNodes = document.querySelectorAll('.js-notification .type-icon-state-closed, .js-notification .type-icon-state-merged');
closedIssueNodes.forEach(node => {
node.offsetParent.querySelector('button.delete-note').click();
});
@fnky
fnky / Example.tsx
Last active Jan 31, 2019
A React Hook to set persisted state, similar to useState
View Example.tsx
import React from 'react';
import ReactDOM from 'react-dom';
import usePersistedState from './usePersistedState';
function App() {
const [count, setCount, unsetCount] = usePersistedState(
0,
'count',
sessionStorage
);
@fnky
fnky / ANSI.md
Last active Apr 7, 2021
ANSI Escape Codes
View ANSI.md

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1b
  • Decimal: 27