Skip to content

Instantly share code, notes, and snippets.

// Place your key bindings in this file to override the defaults
[
// Focus on GitHub Copilot chat pane
{ "key": "f1", "command": "workbench.panel.chat.view.copilot.focus" },
]
@tyhopp
tyhopp / index.mjs
Created December 5, 2022 05:01
await-import-conditional-cjs-exports
const myModule = await import(`./other.cjs`);
// Running node index.mjs writes this out to stdout, top-level `other` property is undefined:
// [Module: null prototype] {
// default: { hello: [Function: hello] },
// hello: [Function: hello],
// other: undefined
// }
console.log(myModule);
@tyhopp
tyhopp / .zshrc
Last active October 31, 2022 07:36
zshrc-prompt
parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
COLOR_DEF='%f'
COLOR_USR='%F{243}'
COLOR_DIR='%F{197}'
COLOR_GIT='%F{39}'
NEWLINE=$'\n'
setopt PROMPT_SUBST
export PROMPT='${COLOR_USR}%n@%m ${COLOR_DIR}%1d ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}${NEWLINE}%% '
@tyhopp
tyhopp / render-to-pipeable-stream-error-handling.js
Last active May 6, 2024 10:23
renderToPipeableStream error handling
const React = require(`react`);
const { renderToPipeableStream } = require(`react-dom/server`);
const { Writable } = require(`stream`);
function MyComponent() {
throw new Error(`My error`);
}
class MyWritableStream extends Writable {
constructor() {