Skip to content

Instantly share code, notes, and snippets.

View MatejBransky's full-sized avatar
💭
I may be slow to respond.

Matej Bransky MatejBransky

💭
I may be slow to respond.
View GitHub Profile
@urob
urob / git_for_zmk.md
Last active March 29, 2024 23:18
Maintaining a personal ZMK fork
@enagy27
enagy27 / tables.test.tsx
Last active February 14, 2024 22:35
React testing library table queries
import React from 'react';
import { render } from '@testing-library/react';
import { queryAllByTableHeader } from './tables';
describe('table testing utils', () => {
it('test', () => {
render(
<div role="region" aria-labelledby="caption-id">
<table>
@mjackson
mjackson / composing-route-in-react-router-v6.md
Last active March 12, 2024 08:39
Notes on route composition in React Router v6, along with a suggested improvement you can make today to start upgrading

Composing <Route> in React Router v6

Composition of <Route> elements in React Router is changing in v6 from how it worked in v4/5 and in Reach Router. React Router v6 is the successor of both React Router v5 and Reach Router.

This document explains our rationale for making the change as well as a pattern you will want to avoid in v6 and a note on how you can start preparing your v5 app for v6 today.

Background

In React Router v5, we had an example of how you could create a element](https://github.com/remix-run/react-router/blob/320be7afe44249d5c025659bc00c3276a19f0af9/packages/react-router-dom/examples/Auth.js#L50-L52) to restrict access to certain routes on the page. This element was a simple [wrapper around an actual element that made a simple decision: is the user authenticated or not? If so, ren

@lancethomps
lancethomps / close_notifications_applescript.js
Last active April 8, 2024 07:43
AppleScript to close all notifications on macOS Big Sur, Monterey, and Ventura
function run(input, parameters) {
const appNames = [];
const skipAppNames = [];
const verbose = true;
const scriptName = "close_notifications_applescript";
const CLEAR_ALL_ACTION = "Clear All";
const CLEAR_ALL_ACTION_TOP = "Clear";
@DanielMSchmidt
DanielMSchmidt / update-renovate.js
Created September 3, 2020 14:40
Generates renovate config to fix @types and package running out of sync
#!/usr/bin/env node
// Generates renovate config to fix @types and package running out of sync
// See https://github.com/renovatebot/renovate/issues/4893
const path = require("path");
const fs = require("fs");
// This script lies under scripts/update-renovate.js, therefore the ..
const renovatePath = path.resolve(__dirname, "../renovate.json");
@jaredpalmer
jaredpalmer / forwardRefWithAs.tsx
Created February 26, 2020 14:56
forwardRefWithAs
import * as React from 'react';
/**
* React.Ref uses the readonly type `React.RefObject` instead of
* `React.MutableRefObject`, We pretty much always assume ref objects are
* mutable (at least when we create them), so this type is a workaround so some
* of the weird mechanics of using refs with TS.
*/
export type AssignableRef<ValueType> =
| {
#!/bin/bash
#
# Inspects branch name and checks if it contains a Jira ticket number (i.e. ABC-123).
# If yes, commit message will be automatically prepended with [ABC-123].
#
# Useful for looking through git history and relating a commit or group of commits
# back to a user story.
#
import { Machine, assign } from 'xstate';
import firebase from './firebase';
const chart = {
id: 'auth',
context: {
auth: null,
error: null,
loggedoutTime: null
},
@loilo
loilo / idb-backup-and-restore.md
Last active April 29, 2024 06:40
Back up and restore an IndexedDB database

Back up and restore an IndexedDB database

This gist is an ES module which provides functions to import and export data from an IndexedDB database as JSON. It's based on Justin Emery's indexeddb-export-import package, but applies some adjustments that reflect better on the current browser landscape (i.e. better developer ergonomics but no support for Internet Explorer).

Usage

For each of the provided functionalities, you need a connected IDBDatabase instance.

Export Data

import { idb } from 'some-database'
@loganfsmyth
loganfsmyth / .babelrc
Created December 1, 2017 23:16
Short description of Babel's config merge for `.env`
{
sourceMaps: false,
comments: false,
plugins: [
["plg-one", {}],
["plg-two", {opt: false}],
],
env: {
development: {
sourceMaps: true,