Skip to content

Instantly share code, notes, and snippets.

View devinrhode2's full-sized avatar
😀

Devin Rhode devinrhode2

😀
View GitHub Profile
@devinrhode2
devinrhode2 / breakout-small-pr.md
Created January 18, 2022 16:23
breakout small PR

Add to your .gitconfig:

[alias]
  breakout-small-pr = "!runit() { CURRENT_BRANCH=`git branch --show-current`; echo checkout $1 && git checkout $1 && echo delete $2 locally && git branch -D $2 || true && echo create fresh $2 && git checkout -b $2 && echo force publish && git publish-branch --force && echo back to original branch && git checkout $CURRENT_BRANCH; }; runit"

Then:

git break<TAB> 
git breakout-small-pr
@devinrhode2
devinrhode2 / next.config.js
Last active July 21, 2022 04:11
next.config.js typed with jsdoc, and shared modules. Next 12 + webpack 5. See prior revisions for next 11 support.
const { safeEnv } = require('./src/env')
// Note: NextConfig type allows any keys, so we are plucking the specific keys we want to type-check.
/**
* @type {Pick<
* import('next').NextConfig,
* | 'webpack'
* | 'env'
* >}
*/
/** @type {(...args: any[]) => never} */
const fail = (...args) => {
console.error(...args)
throw new Error(args.join(''))
}
@devinrhode2
devinrhode2 / idea.md
Last active January 24, 2022 17:06
post-rewrite git hook - validate every commit?

Something tells me it wouldn't be insurmountable to help facilitate running quality checks on each commit. While it would be nice for git rebase --continue to simply run the normal git hooks when running pick 12498y feature bug fix (i.e. - treat it like an edit plus undo+redo commit. while also maybe preserving date+author information) - OR maybe there's a good argument to add new hooks around rebase-continue.....

What could absolutely be done, I believe without modifications to git core, would be a pre-push hook that basically creates a worktree in the background, steps though each commit, running the quality checks on each commit. However, if a commit has an issue, you'll have to rebase -> edit that commit anyway.

So, here's something I would consider implementing: 1. pre-push check requires clean git status (seems pretty reasonable to me) 2. pre-push hook will somehow automatically rebase whole branch... but run the commit hooks for each commit for you. It's possible some simple checks could be invoked w

import { execaCommandSync } from 'execa'
/** @type {(cmdString: string, debug?: 'debug') => [string | undefined, string | unknown]} */
export const exec = (cmdString, debug) => {
let exception
let result
try {
result = execaCommandSync(cmdString, {
env: {
// @ts-expect-error - not application code
@devinrhode2
devinrhode2 / smart-auto-rebase.sh
Last active December 16, 2021 02:19
this pre-push check just throws you into rebasing :)
#!/bin/sh
GIT_ROOT="$(git rev-parse --show-toplevel)"
. "$GIT_ROOT/.husky/common/colors.sh"
REMOTE_NAME="$1"
# REMOTE_URL="$2"
STDIN=$(cat -)
echo "REMOTE_NAME: $REMOTE_NAME"
echo "STDIN: $STDIN"
@devinrhode2
devinrhode2 / git stash release notes changelog.txt
Created December 9, 2021 20:40
git stash release notes/changelog
git clone --depth=1 https://github.com/git/git
Searched "stash" in `Documentation/RelNotes/*.txt`
```
190 results - 74 files
Documentation/RelNotes/1.5.3.2.txt:
13 talking over svn:// protocol.
14
15 * git-send-email re-issued the same message-id about 10% of the
@devinrhode2
devinrhode2 / prettier not recusing issue.md
Last active November 24, 2021 19:15
Prettier not recursing into files/folders when given "."

Prettier not recursing into files/folders when given "."

I had a really odd prettier issue.. Using prettier v2.4.1, node 16.13.0, yarn 1.22.15, M1 mac, zsh/iTerm2, with ARM version of zsh..

For some reason prettier was not recursing into all files/folders. I had to change it to "**/*" instead of .

I don't know if reinstalling node_modules would have fixed the issue

@devinrhode2
devinrhode2 / .prettierrc.js
Last active December 8, 2023 20:32
Prettier config settings to reduce merge conflicts
// Prettier config to reduce merge conflicts: https://gist.github.com/devinrhode2/08c84e175c61b282b76f4766a94e4a01
/** @type {import('prettier').RequiredOptions} */
module.exports = {
singleQuote: true,
semi: false,
// avoid even more merge conflicts: https://prettier.io/blog/2020/03/21/2.0.0.html#change-default-value-for-trailingcomma-to-es5-6963httpsgithubcomprettierprettierpull6963-by-fiskerhttpsgithubcomfisker
trailingComma: 'all',
printWidth: 40,
@devinrhode2
devinrhode2 / cloudSettings
Last active November 9, 2021 21:46
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-11-05T18:07:14.610Z","extensionVersion":"v3.4.3"}