Skip to content

Instantly share code, notes, and snippets.

View bmingles's full-sized avatar

Brian Ingles bmingles

View GitHub Profile
# Seems simpler / better
https://security.stackexchange.com/a/183973
https://stackoverflow.com/a/43665244/20489
@bmingles
bmingles / setup.sh
Last active November 9, 2022 03:27
Git Worktree
git clone --bare <repo_url> .bare
echo "gitdir: ./.bare" > .git
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
@bmingles
bmingles / MyComponent.tsx
Last active October 5, 2022 01:31
MobX with custom React context hook
import React from 'react'
import { observer } from 'mobx-react-lite'
const MyComponent: React.FC = () => {
const { name, age, loadAge, loadName } = useSomeService()
React.useEffect(() => {
loadAge()
void loadName()
}, [loadName])
@bmingles
bmingles / settings.json
Created September 5, 2022 18:48
vscode custom colors
{
"workbench.colorCustomizations": {
"statusBar.background": "#ce6f03",
"titleBar.activeBackground": "#ce6f03"
}
}
@bmingles
bmingles / preview.js
Last active February 17, 2022 22:24
Storybook - Custom Story Sorting
export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
options: {
storySort,
},
}
/** Force example stories to sort last */
function forceExampleLast(id) {
return (id.startsWith('example-') ? '' : '_') + id
@bmingles
bmingles / MyComponent.tsx
Last active January 9, 2022 23:44
Example of using Mobx + React
import React from 'react'
import { observer } from 'mobx-react-lite'
const MyComponent: React.FC = () => {
// I would typically get this from context API with custom hook instead of local useMemo
// e.g. const { name, age, loadAge, loadName } = useSomeService()
const { age, name, loadAge, loadName } = React.useMemo(() => new SomeService(), [])
React.useEffect(() => {
loadAge()
@bmingles
bmingles / Startup script
Last active November 28, 2021 21:35
Azure App Service Config
# Configuration -> General Settings -> Startup Command
pm2 serve /home/site/wwwroot/ --no-daemon --spa
@bmingles
bmingles / namedContext.tsx
Last active September 19, 2021 04:19
React Context Utils and Observable Hooks
import React from 'react'
/**
* Create a React Context that requires a value be provided explicitly (aka. no
* default value). Returns the Context Provider + a useContext hook that
* encapsulates access to the Context.
*/
export function createNamedContext<TValue>(name: string) {
const Context = React.createContext<TValue | null>(null)
@bmingles
bmingles / SomeStory.tsx
Created August 12, 2021 21:44
Storybook hide actions panel and disable controls
parameters: {
controls: {
disable: true,
},
options: { showPanel: false },
}
@bmingles
bmingles / typescript.json
Created August 3, 2021 18:10
vscode snippets
{
// Place your snippets for typescript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",