Skip to content

Instantly share code, notes, and snippets.

View bradennapier's full-sized avatar

Braden Napier bradennapier

View GitHub Profile
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-shadow */
// Credits to @bnjmnt4n (https://www.npmjs.com/package/postgrest-query)
import type { GenericSchema } from '@supabase/supabase-js/dist/module/lib/types';
// https://twitter.com/mattpocockuk/status/1622730173446557697
type Prettify<T> = { [K in keyof T]: T[K] } & {};
type Whitespace = ' ' | '\n' | '\t';
@bradennapier
bradennapier / info.md
Last active June 24, 2022 21:09
event loop example for project9

abc

@bradennapier
bradennapier / AnotherClassComponent.ts
Last active June 27, 2020 22:28
Typescript Mixins Example
import type { MainClass } from './MainClass';
export abstract class AnotherClassComponent {
async anotherFn(
this: MainClass,
) {
// is fully aware of this.someFn and other parts but generally should try
// to be self contained
}
@bradennapier
bradennapier / CSSVariableProvider.tsx
Created June 7, 2020 20:56
CSS Variable Provider for React for dynamic styling with potential to cascade
import React from 'react';
import { CSSVariableContext } from './components/Context';
import { useVariableContext } from './utils/useVariableContext';
type Props<V> = {
vars: V;
children: React.ReactNode;
};
@bradennapier
bradennapier / globals.d.ts
Last active January 19, 2023 10:42
Typescript type resolution utility
/**
* Types declared in this file will be globally available throughout the project. These should
* be used sparsely and mainly for utility types (such as $Debug) that are likely unused outside
* of being helper utilities.
*
* @note
* If needing to `import` in this file, the global types must all be wrapped in
* `declare global` or they will no longer be seen as global.
*/
@bradennapier
bradennapier / ManjaroV20ParallelsGuide.md
Last active January 12, 2024 05:52
Manjaro v20 w/ Parallels Tools

So getting Parallels to work with Manjaro v20 (and probably v19 since parallels only says they support v18) was a pain in the butt and it took a lot of resources from a lot of places to figure it all out. I figured I would post some information here on things that I ran into and how to fix each of them.

This is from a completely fresh installation from the v20 isos but steps may be applicable in places for upgrades if you run into similar issues.

I got this all working finally:


Manjaro Version: 20.0 Desktop Environment: KDE

@bradennapier
bradennapier / recursive-install.js
Last active December 7, 2023 15:44
Recursively find and install dependencies in subdirectories
const path = require('path');
const { promises: fs } = require('fs');
const cp = require('child_process');
/*
Recursively iterates and finds subdirectories which have a `package.json` file and does a dependency installation based
on the given configuration.
- can be setup to use yarn or npm
- can be setup to determine the command to use based on lock files so that if you set it to use yarn but a directory only
@bradennapier
bradennapier / validateCognito.js
Last active August 27, 2019 08:43
Just a rough sketch for validating cognito tokens
/* @flow */
import axios from 'axios';
import jose from 'node-jose';
import day from 'dayjs';
const AWS_REGION = '<AWS_REGION>';
const AWS_POOL_ID = '<POOL_ID>';
const AWS_APP_CLIENT_ID = '<APP_CLIENT_ID>';
const AWS_TOKEN_PUBLIC_KEYS_URL =
`https://cognito-idp.${AWS_REGION}.amazonaws.com/${AWS_POOL_ID}/.well-known/jwks.json`;
@bradennapier
bradennapier / aurad-startup.md
Last active April 4, 2019 18:52
Aurad Startup Alias

Startup Alias Tip

When using infura, our aura start command requires a flag --rpc <url> each time we start it up. It can become tedious to do this on every startup, so here is a simple trick to simplify this!


  1. Login to your staking server

  2. Type vi ~/.bashrc into terminal then Enter to enter vim

@bradennapier
bradennapier / aurad-amazon-linux-2.md
Last active April 3, 2019 22:45
AuraD on Amazon Linux 2

Install the Essentials

# Install Docker and start the daemon
sudo amazon-linux-extras install docker
sudo service docker start

# Allow running docker without sudo
sudo usermod -a -G docker ec2-user