Skip to content

Instantly share code, notes, and snippets.

View jbutko's full-sized avatar

Jozef Butko jbutko

View GitHub Profile
#!/bin/bash
while true
do
echo "Running"
ore --rpc "$1" --keypair "$2" --priority-fee 1000 mine --threads 4
echo "Exited"
done
@kamilogorek
kamilogorek / _screenshot.md
Last active May 2, 2024 13:48
Clutter-free VS Code Setup
image
@akinncar
akinncar / SnackBarContext.tsx
Created February 1, 2021 16:33
SnackBar Material UI Context Typescript Boilerplate
import { Snackbar } from '@material-ui/core';
import { Alert, Color } from '@material-ui/lab';
import React, { createContext, useContext } from 'react';
type SnackBarContextActions = {
showSnackBar: (text: string, typeColor: Color) => void;
};
const SnackBarContext = createContext({} as SnackBarContextActions);
@exoer
exoer / Accounts store
Last active June 16, 2020 09:47
Mongo Transactions
const AccountCollection = mongoDb.collection('Accounts')
await AccountCollection.createIndex({ userId: 1 });
const accountStore = {
createAccount: async({name, userId, balance=0, id= Id.makeId(), createdAt=Date.now(), updatedAt=Date.now(), isDefault=true}) =>
{
if (!userId) throw new Error('createAccount userId missing')
// npm i axios
const axios = require('axios').default;
axios.interceptors.request.use( x => {
// to avoid overwriting if another interceptor
// already defined the same object (meta)
x.meta = x.meta || {}
x.meta.requestStartedAt = new Date().getTime();
return x;
@kachar
kachar / Link-Next13.tsx
Last active January 21, 2024 11:44
Next.js Link + Material UI Link/Button components bundled with forwardRef
@shilman
shilman / storybook-docs-typescript-walkthrough.md
Last active February 20, 2024 11:37
Storybook Docs Typescript Walkthrough

Storybook Docs w/ CRA & TypeScript

This is a quick-and-dirty walkthrough to set up a fresh project with Storybook Docs, Create React App, and TypeScript. If you're looking for a tutorial, please see Design Systems for Developers, which goes into much more depth but does not use Typescript.

The purpose of this walkthrough is a streamlined Typescript / Docs setup that works out of the box, since there are countless permutations and variables which can influence docs features, such as source code display, docgen, and props tables.

Step 1: Initialize CRA w/ TS

npx create-react-app cra-ts --template typescript
@estorgio
estorgio / prettier-eslint-precommit.md
Last active April 21, 2024 09:52
Setting up Prettier and ESLint with pre-commit hook

Setting up Prettier and ESLint with pre-commit hook

  • Initialize Git repository
    git init
  • Create .gitignore file and add the following:
    node_modules/
    *.env
    
@ghengeveld
ghengeveld / asyncMocks.ts
Last active November 4, 2019 08:34
TypeScript functions to create mock state objects for React Async
export const mockWaiting = (): AsyncInitial<any> => ({
data: undefined,
error: undefined,
initialValue: undefined,
startedAt: undefined,
finishedAt: undefined,
status: "initial",
isInitial: true,
isPending: false,
isLoading: false,
@babakness
babakness / use-interval.ts
Created February 4, 2019 18:54
Typescript version of Dan Abramov's useInterval requiring non-null value for delay
import * as React from 'react'
const { useState, useEffect, useRef } = React
type IntervalFunction = () => ( unknown | void )
function useInterval( callback: IntervalFunction, delay: number ) {
const savedCallback = useRef<IntervalFunction| null>( null )