HNHacker News
TopNewBestAskShowJobs

hannibalhorn

1,029 karma · joined January 3, 2010

submissionscomments
hannibalhorn··on Port of the TypeScript compiler, checker and lsp to Rust, by LLM
In the real world project section, compile times vs tsc7 were 1-3s less. Sometimes the percentages are far more impressive than absolutes.
hannibalhorn··on Vinyl Cache and Varnish Cache
Did not know this had happened, but does seem PHK (the original author of Varnish) is now with of the Vinyl Cache project, so this is not just a typical fork.
hannibalhorn··on A year of uv: pros, cons, and should you migrate
If there's a language that does this right, all ears? But I havn't seen it -

The use case described is for a small one off script for use in CI, or a single file script you send off to a colleague over Slack. Very, very common scenario for many of us. If your script depends on

    a => c
    b => c
You can pin versions of those direct dependencies like "a" and "b" easy enough, but 2 years later you may not get the same version of "c", unless the authors of "a" and "b" handle their dependency constraints perfectly. In practice that's really hard and never happens.

The timestamp appraoch described above isn't perfect, but would result in the same dep graph, and results, 99% of the time..

hannibalhorn··on Using ARG in a Dockerfile – beware the gotcha
That's an interesting link and an argument I hadn't seen before.

In my "real world" usage, I've found "bash strict mode" incredibly useful, especially when scripting things that others will be modifying. It just avoids all of the "somebody forgot an error check", "there's a typo in a variable name", etc., type errors. And pouring through logs to figure out what actually went wrong in CI/CD is brutal.

Looking at the examples:

- I don't generally do arithmetic in bash, that's a sign of "time to change language" - Also generally use `if ...; then ...; fi` instead of `test ... && ...`

If you do the advanced type of scripting that somebody who writes a Bash FAQ does, I'm sure `set -e` can be annoying. But once you learn a couple simple idioms y(covered on the original "bash strict mode" page) you don't have to know much more to have fairly robust scripts. And future maintainers will thank you for it!

hannibalhorn··on Pandas 2.0 and the Arrow revolution
I do the same. Sounds like arrow is being implemented as an alternative, and you'll have to explicitly opt in via a dtype or a global setting, so numpy isn't going away.
hannibalhorn··on LXD containers on macOS at near-native speeds
I've been really impressed with what I can accomplish with lima-vm, beyond just "replace docker desktop". The latest pre-release supports Virtualization.framework, including virtiofs.
hannibalhorn··on Not Your Grandfather’s Perl
Perl actually predates both of those!
hannibalhorn··on Show HN: WakaQ - a Python distributed task queue
I really like the overall design and ethos, but a new project without typehints, pydoc, and at least some tests just isn't the kind of thing I'd bring into my stack. Hope it gets a little bit of polish!
hannibalhorn··on Is everything falling apart?
Even well managed funds can result in someone getting the shaft. My dad's pension (Delphi Salaried) was cut to 50% of what it was supposed to be after the events of '08, and it was funded to something like $0.86 on the dollar, above the national average.

The hourly workers (i.e., unionized) still got 100%, which was pretty unfair.

hannibalhorn··on Show HN: Flight Penguin – Like Hipmunk, but a browser extension
That makes total sense, and glad to hear that it could be on the table when the time is right!
hannibalhorn··on Show HN: Flight Penguin – Like Hipmunk, but a browser extension
My gut reaction was that as a browser extension, you would have the ability to add airlines that refuse to participate in the current travel sites, e.g., Southwest? But I don't see them in the results...
hannibalhorn··on IRS to ditch biometric requirement for online access
I actually gave it a try, and couldn't successfully signup due to the phone number check, even though my name is on the line. Figure I've wasted a couple hours on it in total. Unnecessary friction.
hannibalhorn··on PyGaze – open-source eye-tracking software and more
Usually the disabled get the hardware through insurance or grants - in Texas, the state provides grants for assistive communication devices out of a fund sourced from a phone bill tax. My dad's Tobii i16 came out to ~$15k. Ex-USA, I'm sure the cost of these things is ... unreasonably prohibitive.

I'm actually kinda excited to find PyGaze, we might play with it and see if I can tweak a few things to improve his experience.

hannibalhorn··on Python interpreter written in rust reaches 10000 commits
I believe Python C-API compatibility isn't a really a goal for this implementation anyway. [1] HPy sounds like the best path forward?

1. https://github.com/RustPython/RustPython/issues/1940

hannibalhorn··on U.S. government owes over $100M for TSA's patent infringement
So the "invention" is stackable trays on a cart? :-( I guess it's not just software patents that have become problematic.
hannibalhorn··on Andrew Yang Founds the Forward Party
That is actually what he's doing [1]:

    We will support candidates for office who align with our core principles so that we can reform the system and make it more responsive to the American people. This means that we will support Republicans, Democrats, and Independents - as well as candidates identifying themselves as Forward Party members.
1. https://www.forwardparty.com/whyforward
hannibalhorn··on Deep reinforcement learning will transform manufacturing as we know it
So after reading the article I started reading up on deep RL, and came across what is essentially a blog post that shows you how to train a model to play Super Mario Bros [1]. I have of course done all the mNIST handwritten number recognition stuff, and have done quite a bit of real world analysis with scikit-learn, but this is... pretty cool!

1. https://pytorch.org/tutorials/intermediate/mario_rl_tutorial...

hannibalhorn··on Use Touch ID for Sudo on Mac
Kinda close - I use Hammerspoon to setup a hotkey that runs security(1) via popen to retrieve and paste passwords into some apps.

    /usr/bin/security find-internet-password -wgs mydomain.com
It requires the keychain to be unlocked, which can be handled with touch ID, and you can have it confirm with a "are you sure" dialog box every time.

If you really wanted to be prompted for a fingerprint basically every time, you could probably use a separate keychain that locks after 1 minute of inactivity.

hannibalhorn··on Pattern matching accepted for Python
The accepted PEP is 634: https://www.python.org/dev/peps/pep-0634/ and the tutorial has some examples: https://www.python.org/dev/peps/pep-0636/ .
hannibalhorn··on Python 3's F-Strings: An Improved String Formatting Syntax
You really have to understand how it's translated into actual code, and of course it's Python, so there's some legacy syntax to take into account. A `:` just means call format(lhs, rhs), for example.

You can also actually combine those syntaxes - I often use f"{foo:%Y-%m-%d!r}" to get a quoted, properly escaped date in a specific format, for example.

hannibalhorn··on Changes to the pip dependency resolver in 20.3
Then switch to poetry, why break pip?

The dependency I referenced actually uses poetry, and the reason it's borked is because "poetry add pandas" back when 0.25.1 was current meant effectively adding "poetry==^0.25.1" to requirements.txt, even though the one line of actual code that uses pandas works on pretty much any version I've ever seen.

hannibalhorn··on Changes to the pip dependency resolver in 20.3
Definitely not a fan. :-( Sometimes you know what you want and the package itself is wrong.

For example, I have a dependency that specifies pandas at ^0.25.1, and now I can't install it alongside pandas 1.0+ without forking or getting a PR upstreamed (even though I know it works with all versions of pandas just fine.)

In the node ecosystem, yarn actually recognizes that this situation exists and provides a mechanism to override, along with some good descriptions of situations where it's necessary[1].

[1] https://classic.yarnpkg.com/en/docs/selective-version-resolu...

hannibalhorn··on Facebook Container for Firefox
I have a Unifi USG, which has a third party wireguard addon, though of course OpenWRT could work just fine. You setup a wireguard tunnel normally, but disable the default routing (on a Unifi, set route-allowed-ip false), and then explicitly add a route for 10.124.0.0/16 through the wireguard interface. The mullvad servers page[1] has socks 5 proxy addresses for all of their servers - assign one to a firefox container and you're all set. No reason you couldn't have a container for each geographic region you want.

1. https://mullvad.net/en/servers/

On a USG the config looks like this:

    wireguard wg0 {
        address ***/32
        mtu 1420
        peer *** {
            allowed-ips 0.0.0.0/0
            endpoint ***:51820
        }
        private-key ***
        route-allowed-ips false
        up-command "ip route add 10.64.0.1/32 dev wg0 && ip route add 10.124.0.0/16 dev wg0"
    }
hannibalhorn··on Facebook Container for Firefox
tor provides a socks proxy, which you can assign to a container easy enough w/ the container proxy addon.
hannibalhorn··on Facebook Container for Firefox
I use the same setup (mullvad + container proxy) and can't praise it enough. I just keep a mullvad connection open on my router and only route the proxy IPs through it.

Great for all kinds of silly GeoIP restrictions, too - in my part of the world, homedepot.com just spits out "access denied", a foodnetwork.com recipe you find in search results just redirects you to the tudiscovery.com homepage, etc.

hannibalhorn··on Customize Helm charts without modifying them – using Grafana Tanka
This is really cool! I prefer to keep all my in-house stuff in yaml, though of course for many big third party projects (prometheus, grafana, etc.) helm charts are the way to go.

I've long been looking for something that lets me keep my static yaml for my own projects, and helm charts with occasional small tweaks, and Tanka seems to do it!

    local parseYaml = std.native('parseYaml');
    local k = (import 'ksonnet-util/kausal.libsonnet');
    local helm = (import 'helm-util/helm.libsonnet').new(std.thisFile);
    {
      aws_secret: parseYaml(importstr 'k8s/aws-secret.yaml'),
      // etc...
      traefik: helm.template('traefik', '../../charts/traefik', {
        values: parseYaml(importstr 'values/traefik.yaml')[0],
      }) + {
        // traefik requires a /plugins-storage tmpdir
        deployment_traefik+: k.util.emptyVolumeMount('plugins-storage', '/plugins-storage'),
      },
    }
If I had one request, it'd be to be able to run an arbitrary command for manifest generation: jsonnet seems quite capable, but every once in a while you're in a rush and just can't figure out how to do something - that's when being able to generate the manifest dynamically via bash/python/whatever is quite useful.
hannibalhorn··on Tools I use: argparse builder
Have to plug Typer[1] here - it's built on top of click, but uses the info already there type annotations, optional keyword arguments, default arguments, etc., to create the most "common sense" CLI for a function. For all my internal tools, has saved me a ton of time and gruntwork.

[1] https://typer.tiangolo.com/

hannibalhorn··on Python 3.9
I was just thinking that squaring an imaginary number results in a real number - that's a pretty crazy thing for a type system to handle, no? I guess that means the correct annotations would be more along the lines of:

    def square(number: numbers.Complex) -> numbers.Real: ...

    T = typing.TypeVar('T', numbers.Real)
    def square(number: T) -> T:
        return number ** 2
What a rabbit hole!
hannibalhorn··on Python 3.9
There is a numbers.Number for that - but yeah, that's another way in which it's just not a good example..

I think typing_extensions.Protocol helps support the general duck typing "any object that has method x", though there are some implementation issues w/ dataclasses and such..

hannibalhorn··on Python 3.9
I like adding | as an alias for Union, and the PEP has lots of examples of where typing.Union gets gnarly really quick, but that doesn't seem like a great example in the changelog:

    def square(number: int | float) -> int | float:
        return number ** 2
A TypeVar constrained to int and float, T = TypeVar('T', int, float), should be used instead to indicate that the return type is the same as the argument type, no?
Page 1 of 8Next →