Skip to content

Instantly share code, notes, and snippets.

View tmarshall's full-sized avatar

Tim Marshall tmarshall

View GitHub Profile
[2023-01-01 23:25:00] DELETE /logout 453
[2023-01-11 20:56:00] GET /settings 121
[2023-01-08 18:51:00] POST /dashboard/85 11
[2023-01-12 11:00:00] DELETE /settings 68
[2023-01-12 11:00:00] WARNING Memory usage is high.
[2023-01-12 11:00:00] DETAILS Current usage: 85%, Threshold: 80%
[2023-01-11 20:06:00] GET /profile 278
[2023-01-04 17:19:00] GET /dashboard/12/overview 65
[2023-01-04 00:16:00] GET /home 477
[2023-01-01 04:18:00] POST /settings 434
@tmarshall
tmarshall / useHashCode.js
Last active October 15, 2021 21:10
stateful string hash code hook
import { useEffect, useState } from 'react'
/*
takes in a string and returns a hash int code
which can be useful for generating react keys
base on input strings, that may or may not change
const [hashCode, setHashCodeString] = useHashCode()
*/
@tmarshall
tmarshall / useTabTrap.js
Last active April 22, 2021 14:35
Tab trap hook modal (or other) react components.
/*
This hook will trap tabbing within a component.
A common usecase is a Modal, in which you want tabbing to keep focus within the modal.
This assumes that any custom `tabindex` prop is either `0` (should be tabbable, no order preference)
or `-1` (not tabbable, should skip). Anything like `tabIndex={2}` will not get ordered correctly.
It will skip over disabled inputs.
---
@tmarshall
tmarshall / settings.json
Created December 30, 2020 19:03
personal vscode config
{
"editor.tabSize": 2,
"window.zoomLevel": 0,
"editor.snippetSuggestions": "none",
"editor.parameterHints.enabled": false,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"html.suggest.html5": false,
"editor.hover.enabled": false,
"editor.codeActionsOnSave": null,
"javascript.autoClosingTags": false,
@tmarshall
tmarshall / .vimrc
Created December 16, 2020 21:51
personal .vimrc config
syntax on
colorscheme desert
set encoding=utf8
filetype plugin on
filetype indent on
" Avoid garbled characters in Chinese language windows OS
let $LANG='en'
set langmenu=en
@tmarshall
tmarshall / settings.json
Created December 16, 2020 21:28
minimal vscode settings
{
"editor.tabSize": 2,
"window.zoomLevel": 0,
"editor.snippetSuggestions": "none",
"editor.parameterHints.enabled": false,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"html.suggest.html5": false,
"editor.hover.enabled": false,
}
@tmarshall
tmarshall / .env
Created December 10, 2020 19:27
streetmerchant ps5 & xbox env config (US)
INCOGNITO=false
LOW_BANDWIDTH=true
PLAY_SOUND="/your/mp3.mp3"
SHOW_ONLY_SERIES="sonyps5c,sonyps5de,xboxss,xboxsx"
STORES="target,walmart,xbox,amazon,antonline,bestbuy,playstation"
@tmarshall
tmarshall / lazy-template-files-javascript.md
Created September 24, 2020 16:34
Lazy Template Files in JavaScript

Lazy Template Files in JavaScript

Template Literals

JavaScript has Template Literals (or Template Strings) built-in. This results in a string, after evaluating replacement expressions.

const name = 'Tim'
const job = 'Eng'
@tmarshall
tmarshall / base58.js
Created May 10, 2020 02:28 — forked from inflammable/base58.js
Base58 (and other) Encoding and Decoding in Javascript
/*
* (c) 2012 inflammable/raromachine
* Licensed under the MIT License.
* ---
* this is a refactored version of https://gist.github.com/inflammable/2929362
*/
const alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
const base = alphabet.length
@tmarshall
tmarshall / useUnloadBeacon.js
Last active June 18, 2022 02:39
React hook for unload beacons
/*
see https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
```jsx
const MyComponent = ({ children }) => {
// will get fired if the page unloads while the component is mounted
useUnloadBeacon({
url: 'https://api.my.site/route',
payload: () => {
return 'something'