Skip to content

Instantly share code, notes, and snippets.

View fnky's full-sized avatar
⚠️
TypeError: Cannot read property 'status' of undefined.

Christian Petersen fnky

⚠️
TypeError: Cannot read property 'status' of undefined.
View GitHub Profile
@fnky
fnky / Example.tsx
Last active January 31, 2019 10:27
A React Hook to set persisted state, similar to useState
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 / mark-closed-as-read.js
Created August 26, 2019 07:30
GitHub Snippets
/**
* 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 / query-order.graphql
Created October 10, 2019 21:14
GraphQL Patterns
# 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.
"""
@fnky
fnky / stripe-keys-and-ids.tsv
Last active March 29, 2024 22:52
Stripe keys and IDs
Prefix Description Notes
ac_ Platform Client ID Identifier for an auth code/client id.
acct_ Account ID Identifier for an Account object.
aliacc_ Alipay Account ID Identifier for an Alipay account.
ba_ Bank Account ID Identifier for a Bank Account object.
btok_ Bank Token ID Identifier for a Bank Token object.
card_ Card ID Identifier for a Card object.
cbtxn_ Customer Balance Transaction ID Identifier for a Customer Balance Transaction object.
ch_ Charge ID Identifier for a Charge object.
cn_ Credit Note ID Identifier for a Credit Note object.
@fnky
fnky / serialization-tools.md
Created October 16, 2019 22:23
Binary serialization frameworks, libraries and tools
@fnky
fnky / variable-fonts.md
Last active April 12, 2024 18:12
Awesome Variable Fonts

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 / fonts.md
Created October 18, 2019 11:15
Cheap-ish fonts

Cheap-ish fonts

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

@fnky
fnky / history-with-outer.jsx
Last active November 27, 2019 10:56
History provider with useState / useRef
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 / BetterFixedLazyExample.jsx
Last active November 29, 2019 13:45
Lazy conditionals and refs
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 / Cargo.toml
Created September 22, 2021 08:29
Rule110 in Rust
[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"