Skip to content

Instantly share code, notes, and snippets.

View devinrhode2's full-sized avatar
😀

Devin Rhode devinrhode2

😀
View GitHub Profile
@devinrhode2
devinrhode2 / safeCall.ts
Last active December 30, 2022 20:23
safely call function, and return `returnValue | Error` https://www.swyx.io/errors-not-exceptions
/**
* Calls `callback`, catches any errors and returns `returnValue | Error`
*
* TODO: create npm package
*
* See: https://dev.to/devinrhode2/comment/1fcga
*/
export const safeCall = <
TCallback extends (
...args: unknown[]
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

in response to https://www.patreon.com/posts/worst-place-to-74324982

ci/cd pipeline stuff is not AS shareable as git hooks. Every ci provider has their own .yml flavor... But even a pre-commit hook can be too late in the process in some situations. I think it'd be really cool to:

  1. Have tests/eslint/tsc running while you develop
  2. Somehow, have your live reload/dev server "vouch" for certain changes you are staging in git 2.1 Unfortunately this may mean that dirty working directory changes needs to be stashed when you are committing, and then un-stashed when verification succeeds
@devinrhode2
devinrhode2 / example-apps-as-submodules.md
Last active November 1, 2022 14:23
Example apps as automated tests, in a separate git repo.

Let's imagine you produce an sdk, an npm package named @crazy/foo,

Scenario:

You like monorepos, but you have example apps in separate repos, and those example apps can't be brought into the monorepo for some reason.

You want those example apps to also function as automated tests, and, you want them to be updated in lockstep with @crazy/foo sdk changes.

Devin finds monorepos are always better, and believes it's best to work from first principles to solve any problem you have, in a way that does not involve multiple git repos.

declare module "redux" {
/** Replace `compose(a, b, c)` with `(...args)=>a(b(c(...args)))` */
function compose(
/** Replace `compose(a, b, c)` with `(...args)=>a(b(c(...args)))` */
a: never,
/** Replace `compose(a, b, c)` with `(...args)=>a(b(c(...args)))` */
b: never,
/** Replace `compose(a, b, c)` with `(...args)=>a(b(c(...args)))` */
c: never,
/** Replace `compose(a, b, c)` with `(...args)=>a(b(c(...args)))` */
@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'
* >}
*/

I would DIE for a gui

here's the thing

I create lots of well-sequenced, very intentional commits. They are small and repeatable, so it makes it easy to handle rebase conflicts. Just read commit message, see original diff, and 80-90% of the time I believe anyone should be able to see what the original commit was doing and resolve conflict such that same thing is being accomplished on new base. Almost each commit could be one PR, but maybe sometimes it's better to group few commits into one PR.

I'd like to create a PR stack so that it's easy for others to review my changes, but, I don't want to mess around with git branches locally at all. I'm already a surgeon with rebase.

Ideally, I have a gui tool.

@devinrhode2
devinrhode2 / Ellipsis.md
Created August 17, 2012 00:26
Stop the text overflow madness. Add .ellipsis and cut off overflow with a '...'
.ellipsis {
  white-space: nowrap;
  text-overflow: ellipsis;
  width: 100%;
  overflow: hidden;
  display: inline-block;
}

/FUCKING MAGIC/

@devinrhode2
devinrhode2 / foo.md
Created May 13, 2022 04:17
`brew update` not updating brew taps

I was getting a seemingly unrelated error trying to git fetch upstream main where upstream was a "public" "git-protocol-url" like git://github.com/foo/bar. That's been deprecated and we need to use plain ssh urls... like git@github.com:foo/bar

What I probably didn't need to do, is blow away all my ssh stuff and start from scratch. But I did that, found out I just needed to update the url syntax from git:// to git@github.com:

However, it seems like converting from id_rsa to id_edXXXXX fixed an error with brew update failing to get latest data from my brew taps.

https://www.google.com/search?q=test&ie=UTF-8&oe=UTF-8&hl=en&client=safari
http ://www.google.com/search?q=test+&rlz=1Y3TXLS_enUS526US526&aq=f&oq=test+&client=ms-android-google&sourceid=chrome-mobile&ie=UTF-8
https://www.google.com/search?q=test &aq=f &oq=test &aqs=chrome.0.57j61l3j60j0.139&sourceid=chrome&ie=UTF-8
{google:baseURL}search?q=%s &{google:RLZ}{google:acceptedSuggestion}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}ie={inputEncoding}
https://www.google.com/search?q=the+thing+i+want+to+do+i+don't+romans&aq=1&oq=the+thing+I+w&aqs=chrome.2.57j0l3j62l2.7591&sourceid=chrome&ie=UTF-8
{google:baseURL}search?q=%s &{google:RLZ}{google:acceptedSuggestion}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}ie={inputEncoding}
ios, then