TIL is my collection of short, technical daily learnings. 188 and counting.
Python String Interpolation
Python string interpolation is available via few of interfaces, as Chris at Hashrocket taught me. ...
TIL is my collection of short, technical daily learnings. 188 and counting.
Python string interpolation is available via few of interfaces, as Chris at Hashrocket taught me. ...
I needed to replace an “A19” light bulb. What does “A19” mean? ...
In Vim Normal mode, * searches forward for the next occurrence of word. But what goes back? ...
If I’ve defined a function in the Python REPL, I can read its definition with inspect.getsource. ...
In the Python REPL, the help function provides a help message about its argument. ...
Jira does have a “Start Standup” button, but it’s hidden and not well documented. ...
I have a cron job that opens a program every day at a certain time. How can I also close it with a cron job? ...
My friend Josh recently wrote about a common mistake using pbcopy, Apple’s pasteboard utility. ...
Anytime Chrome loads a webpage, you can pause script execution without a debugger. ...
Sometimes in TypeScript we’d like to say a function can either have one typed prop, or the other, never both and never neither. This can be achieved with a union type and type never: type Props = { markdown: string, copy?: never } | { markdown?: never, copy: string} }; const component = ({ markdown, copy }: Props) => markdown ? parseMarkdown(markdown) : <>copy</>; console.log(component({ markdown: "### Important" })) // <h3>Important</h3> console.log(component({ copy: "Just information" })) // <>Just information</> console.log(component({ copy: "Just information", markdown: "### That conflicts })) // ❌ Type error console.log(component({})) // ❌ Type error Our component can receive a string of markdown, which it will parse, or raw copy, which it will not parse. Always just one, never both, and never neither.
Don’t miss my next essay
Hear from me immediately when I post: no ads, unsubscribe anytime.