Why Nushell?

We can do better than POSIX

I work on a command-line shell called Nushell (Nu for short) with some internet friends, and I think it’s pretty cool. To convince you that it’s cool (or at least worth a try), here’s a whirlwind tour.

Basic Querying

Let’s start by taking a look around the filesystem. We’ll use ls to take a look at the files in /usr/bin:

Why does Vancouver have 895 zoning districts?

"Comprehensive Development"

If you try to do any kind of analysis of Vancouver’s urban planning, you quickly run into a problem:

Vancouver has a lot of zoning districts. 895 of them, to be exact1. That works out to roughly 1 zoning district for every 740 residents; I hope you weren’t planning on reading every one.

For a long time, my mental model of urban planning was basically “there are written rules about what you can build, and to build something you just follow the rules.” Unfortunately, this is not an accurate way to think about Vancouver.

I get alerts for new rezoning+development applications (using a small tool I wrote), and this little snippet shows up over and over:

…the application is “conditional” so it may be permitted. However, it requires the decision of the Director of Planning.

You can see this on virtually any type of housing proposed in Vancouver, here’s a selection:

I’ve been tracking rezoning+development applications for about a year and a half, and my data set has 599 items with the words “Director of Planning”.

thonk
OK, but… why? Doesn’t the Director of Planning have better things to do than approve individual houses and small apartment buildings?
Reilly
I’ll defer that question to a senior planner at the City of Vancouver:

Windows UI in 2022

Things are weird.

Like many other people, I unexpectedly found myself stuck at home without much to do in early 2020. To stay sane, I set about answering a question I’d had for a while: what’s the deal with native GUI frameworks on Windows these days?

It’s rarely obvious which of Microsoft’s several supported technologies is the best choice for a new project, and Windows doesn’t have the same culture of idiomatic+consistent native GUIs as macOS. After months of obsessive escapism focus I emerged with a decent understanding of the problem space; let’s start with an overview of the technologies in use today:

Win32

This is kind of a catch-all term for the old-school way to build a Windows application using arcane, less-than-ergonomic C APIs. This is unpleasant and your application will look ugly, but one big advantage is that the Win32 APIs will live forever and they underpin all the other UI frameworks.

It’s well worth your time to learn a bit of this (read Charles Petzold’s book ), but it’s rare to see people building pure-Win32 GUIs these days.

Say you want to host some files in an S3 bucket, under your own custom subdomain with nice short HTTPS URLs. For example, you own foo.com and you want files to be accessible at URLs like https://files.foo.com/bar.txt.

This is a lot more complex than it should be! It involves configuring 3 separate AWS services and I’m already forgetting the boring details, so let’s write them down for future reference.

cloud
Cloud is the future… wait, 3 separate AWS services?
Reilly
YEP.
expressionless

Creating the S3 bucket

Naming is important here - the S3 bucket must have the same name as the subdomain it will be accessed at. Open up S3 in the AWS console, and:

  1. Create a new bucket named files.foo.com.
  2. Disable “Block all public access”.
  3. Under the bucket’s Permissions tab, add a bucket policy to make all objects public by default (replace files.foo.com with the name of your bucket):
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AddPerm",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::files.foo.com/*"
        }
    ]
}

Certificate Creation+Config

Next up, we need to create a certificate in AWS Certificate Manager.

Hot Tip
Certificates must be created in the us-east-1 region to work properly with CloudFront. Learn from my mistake, make sure you’re in the right region when performing this step.
headshot

Cities & Code

Top Categories

View all categories