Add External Dependencies to Python Scripts with uv

Ever wanted to share a Python script that uses external packages without making the recipient set up a virtual environment? With uv, you can embed dependencies directly in the script. The Command uv add --script example.py 'requests<3' 'rich' This adds inline metadata to your script: # /// script # dependencies = [ # "requests<3", # "rich", # ] # /// import requests from rich.pretty import pprint resp = requests.get("https://peps.python.org/api/peps.json") data = resp.json() pprint([(k, v["title"]) for k, v in data.items()][:10]) Running It Anyone with uv installed can now run the script directly: ...

April 19, 2025 · 1 min · Jamal Hansen
Tracking ideas for writing prompts in Obsidian

Tracking ideas for writing prompts in Obsidian

I’ve committed to writing three blog posts a week and, to support this, I’ve been logging my ideas for posts in Obsidian. I’ve got the Tasks plugin installed, so I’ve set up a little system that is loosely based on the Jeff Goins three bucket writing system. To facilitate this, I’ve added a section to my daily note under a header called Writing. This doesn’t mean that I come up with ideas every day, but I want to have a spot where it’s easy to record the ideas when I get them and also remind myself to capture ideas when I’m in the daily note. ...

February 21, 2025 · 3 min · Jamal Hansen
I installed dBeaver today

I installed dBeaver today

Today, I downloaded a community copy of dBeaver and installed it. Well technically I did this a while back, but today I opened it for the first time. I’ve been meaning to write about sql and relational databases for a while now. Some sort of beginner posts to help get people started. I’ve even started doing it once or twice, but it has fizzled out for all the typical reasons: ...

February 17, 2025 · 2 min · Jamal Hansen

Stop querying found elements when testing react

I’ve been working through Stephen Grider’s React Testing Library and Jest course and stumbled on something that will clean up my tests: the within() function. There are many times when I find myself drilling into a part of a component to test something nested inside another element. I might take two or three hops to get there: import { within, screen } from '@testing-library/react' const table = screen.getByRole("table") const rows = within(table).getAllByRole("row") This takes two lines and, more importantly: It isn’t immediately clear what I am doing I declare the table constant when it isn’t relevant to anything With within(), you can shorten this to a single readable line: ...

February 15, 2025 · 1 min · Jamal Hansen

Group JUnit Tests with @Nested

I really like the way that I can nest my JavaScript tests using describe blocks. This keeps my tests nicely organized and grouped together in functional blocks which can be super useful when you get a whole lot of tests created. describe("my component", () => { describe("validation", () => { it("ensures that user name is provided", () => { // test here }) it("ensures that password is valid", () => { // test here }) }) describe("when saved", () => { it("displays an indication that mutation is in progress", () => { // test here }) it("provides feedback of success", () => { // test here }) it("provides an error message on failure", () => { // test here }) }) }) I was not aware that you can do something like this in Java with JUnit. Reading through Pragmatic Unit Testing in Java with JUnit I found that this functionality is available by making an inner class and using the @Nested annotation. ...

February 14, 2025 · 2 min · Jamal Hansen
Symbolic links for fun and profit

Symbolic links for fun and profit

As a former Ubuntu user turned Mac user, I enjoy the bash terminal and POSIX command line that my Mac comes with. I also like the polished user interface that my Mac GUI provides for the times that I don’t want to think about what my computer is doing, I just want it to work I use iCloud on my Mac to store files and access them across multiple devices. One thing that I noticed early on is there there is a Local and an iCloud version of folders like Documents and that accessing the iCloud version is not-so simple from your home directory. ...

February 10, 2025 · 2 min · Jamal Hansen

You don't need a 'B' suffix for byte literals in Java

Today I was coding in Java and I came across a part of the code where I was using a byte literal. I’ve been using Java for a while, so I knew that you have to suffix long literals with an ‘L’ otherwise Java complains. long myLong = 3000000000L; // Java is happy long myOtherLong = 3000000000; // Java is sad (too big for int) So when I went to create my byte literal I figured I would need to put a suffix on the number, like I do with long literals. But when I tried it, it turns out I didn’t need to. ...

February 7, 2025 · 2 min · Jamal Hansen
How to custom style your VS Code markdown preview

How to custom style your VS Code markdown preview

I like writing notes. I like writing them in markdown. There is something wonderful about the power and simplicity of markdown formatting to transform my readable text files into elegant pages. VS Code is a great tool and has markdown editing and preview bundled in for free. If you haven’t tried it, open a Markdown file and choose Markdown: Open Preview to the Side. This will open up a preview window to the side that will show you a transformed version of your markdown. ...

February 6, 2025 · 3 min · Jamal Hansen