HNHacker News
TopNewBestAskShowJobs

ekimekim

2,338 karma · joined November 9, 2012

Programmer, gamer, chaser of random interests. github: https://github.com/ekimekim
submissionscomments
ekimekim··on Someone hacked YandexTaxi and ordered all available taxis to the same location
What I love about this is that it's a textbook example of a reflection DoS attack (https://en.wikipedia.org/wiki/Denial-of-service_attack#Refle...) - you send a message with a spoofed reply-to address, such that the message you sent (in this case, a letter) is much cheaper than the response eventually sent to the victim (in this case, tradespeople / goods / dignitaries).
ekimekim··on Nobody wants to teach anymore
Those...sound like reasonable things?

Many students aren't going to learn by rote memorization of completing homework. It it helpful to support different learning styles.

A big problem with math education is that it's too abstract. It's hard to relate mathematical concepts to real life. "When are we going to use this?", people ask. Phrasing your questions in terms of real problems with a narrative can help students learn.

ekimekim··on Brian Kernighan adds Unicode support to Awk
To nitpick: Overstrikes/other combining characters and the multiple possible ways to represent the same glyph are aspects of Unicode, the character set which deals with code points from 0 to 0x10ffff. Whereas UTF-8 is a way of encoding that character set into a sequence of bytes. The things you describe are present in all unicode encodings.
ekimekim··on Shellfirm: Intercept risky patterns at the command line
My solution for this is a script that commits all my changes then tags the resulting commit with a basic descriptive name. Something like this:

    git discard bad-idea-didnt-work
Which creates a tag discarded-bad-idea-didnt-work, then resets back to the previous commit.

I can still find and rescue the changes later by looking at my tags.

Others have suggested using the stash for this but I prefer to keep my stash stack free for shorter-term contexts, eg. if I'm halfway through something but need to go checkout another branch briefly.

ekimekim··on There are no open issues or pull requests on Flask
Flask has historically been used in combination with gevent/eventlet which are greenthreaded async frameworks that predate python's async/await support. These still work and are still a great choice for an async server with many concurrent requests. The big downside is just lack of compatability with the new async ecosystem.
ekimekim··on Cloudflare had a partial outage
Sure you can, but physically rolling back more cable takes a bit longer :P
ekimekim··on Git ignores .gitignore with .gitignore in .gitignore
nitpick: `git commit -a` does not add untracked files:

           -a, --all
           Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.
ekimekim··on Git ignores .gitignore with .gitignore in .gitignore
To add to sibling comments which describe various uses of `git add`, I'll also recommend `git commit -a`, which adds all changes from tracked files (but unlike `git add .`, not untracked files) before committing.
ekimekim··on Git ignores .gitignore with .gitignore in .gitignore
There is value in "making a decision" for each untracked file, of whether to explicitly add it or ignore it. This combines well with things like a PS1 that indicates if you have any unclean state (including both changes and untracked files). Every single time I find myself with an untracked file, I can either add it because I want it tracked, put it in .gitignore if it's something generated that I want my whole team to ignore, or put it in .git/info/exclude if it's something I've done locally that doesn't fit either of the above.
ekimekim··on Post-incident review on the Atlassian April 2022 outage
This reminds me of how useful it is to make your ids include the type of the thing they're identifying as part of the value. This could be as simple as something like "u<random digits>" for users, "p<random digits>" for projects, etc. Or it could be a full-blown URN scheme like some of the big cloud providers use (though please, whatever you pick, BE CONSISTENT about using that form and only that form. If there's an operation to exact "just the id" from your larger value, and you need to use the full thing in some places and "just the id" in others, then you've missed the point).
ekimekim··on Google, Meta, others will have to explain algorithms under new EU legislation
> - They have a history of not paying off their debts.

If only. In practice it's more like "They don't have a history of paying off their debts", which crucially means if you don't have a history of being in debt then you have no history of paying it off, and therefore you're considered high risk. Thus you get otherwise-nonsencial behaviours like taking out a loan only for the reason of paying it off.

ekimekim··on Firefox on Ubuntu 22.04 from .deb (not from snap)
I stopped using ubuntu on my servers and in my containers the day I tried to install a package, and it "succeeded", but then at runtime the binary I thought I'd installed just printed "This is now provided by a snap package, use that instead" and exited.

I consider ubuntu completely unsuitable for server and cloud. I don't think there is any use case they are suitable for anymore. Which is definitely sad.

ekimekim··on Geniuses of the past were aristocratically tutored
Leo Szilard [1] is generally credited as coming up with the concept of a fission bomb. He enlisted the help of Einstein, who had political clout, to bring it to the attention of the US government [2].

[1] https://en.wikipedia.org/wiki/Leo_Szilard [2] https://en.wikipedia.org/wiki/Einstein%E2%80%93Szil%C3%A1rd_...

ekimekim··on Building Password Purgatory with Cloudflare Pages and Workers
One of the major reasons all these kinds of services use javascript is that it can be reliably sandboxed (it needs to be, so it can run in a browser without every random website getting control of your machine). While there's nothing in theory preventing you from doing a similar thing with python, an implementation with the same hardening just doesn't exist. CPython sandboxes have been broken over and over again, to the point that conventional wisdom is "the only way to sandbox python is to run it in a VM". The only other language I can think of offhand that has similar levels of sandboxing is Lua.
ekimekim··on Roblox October Outage Postmortem
IMO looking at the root causes here isn't that helpful. Software is complicated and there will always be some unknown bottleneck or bug lurking to knock you over on a bad day. The important lessons here are about:

* How their system architecture made them particularly vulnerable to this kind of issue

* Their actions to diagnose and attempt to mitigate the issue

* The whole later part about effectively cold-starting their entire infrastructure, all while millions of users were banging on their metaphorical door to start using the service again.

ekimekim··on Game-makers creating new Game Boy games (2021)
I had similar feelings when I first saw it. My response was to focus on making things that you can't using GB Studio - pushing the hardware to its limits, playing with novel control/graphics schemes, doing things that make people say "you can do that on a gameboy?". I was never really much of a game designer so I enjoy this "technical challenge" work more anyway.
ekimekim··on Keyboard lets people type so fast it’s banned from typing competitions
> chorded typing allows the users to input several letters at the same time and have a computer program generate a predicted word. Instead of typing h e l l o, a chorded typer mashes h, e, l, and o to produce the word.

It sounds like it relies heavily on autocomplete, which means it's unlikely to be useful for coding instead of just English text.

ekimekim··on Endianness, API Design, and Polymorphism in Rust
About this section:

> Unfortunately, as the ??? shows, the different output arrays have different lengths – a u16 would be 2 bytes and a u64 8 bytes – and so the Rust trait system at the time of this writing is (to my knowledge) not powerful enough to represent this trait as is.

It seems to me that this is possible using const generics. If you define your EndianBytes like this:

    trait EndianBytes<const N: usize> {
        fn be_bytes(self) -> [u8; N];
        fn le_bytes(self) -> [u8; N];
    }
Then provide a concrete length with each impl:

    impl EndianBytes<4> for u32 {
        fn be_bytes(self) -> [u8; 4] {
            self.to_be_bytes()
        }
        fn le_bytes(self) -> [u8; 4] {
            self.to_le_bytes()
        }
    }
(I've renamed their methods to avoid conflicting with u32::to_be_bytes to make it easier to read)

Then that allows you to use the EndianBytes type as long as you remain generic over both the value type and its length:

    fn write<T: EndianBytes<N>, const N: usize>(val: T) {
        println!("{:?}", val.be_bytes());
    }

    fn main() {
        write(0x1234u16);
        write(0x12345678u32);
    }
This code (plus an impl for EndianBytes<2> for u16) works for me on 1.51 stable.

EDIT: I thought about doing this with an associated constant, ie:

    trait EndianBytes {
        const LENGTH: usize;
        fn be_bytes(self) -> [u8; Self::LENGTH];
        fn le_bytes(self) -> [u8; Self::LENGTH];
    }
However it turns out that this kind of usage is not quite supported yet: https://github.com/rust-lang/rust/issues/60551
ekimekim··on CPython's main branch running in the browser with WebAssembly
Python has always had the ability to do callbacks (ie. first class functions), though admittedly it's not a common pattern and the stdlib doesn't support it for IO (also its anonymous function syntax is poor).

There have been several libraries that provide the concept of a promise, but with modern python these are built into the stdlib with native async/await support, though many interfaces are still sync-only (though you can work around that with things like gevent that monkey-patch those interfaces to work with an event loop under the hood).

I agree that python would be a poor fit for the kind of uses that JS in the browser usually serve, but it's really a matter of ecosystem, not core language design.

ekimekim··on Understanding Python through its builtins
Python assumes that all assignments assign to the current scope. So by default when you reach "x = 22", it would create a new variable called "x" in the inner_function() scope which overrides the variable "x" in the outer_function() scope. So when you print "Inner x" you would only be printing the inner_function() version of x, not the outer_function() version, which would remain at 11.
ekimekim··on Facebook banned me for life because I help people use it less
> What standing would Facebook have to sue me for publishing a chrome extension?

The standing of "actually none, but if you go to court to prove this you risk bankrupcy". Unless you have a major legal organization (like EFF) backing you (or you are a billionare), large corporations are essentially above the law when it comes to interacting with individuals.

ekimekim··on Why is everything so hard in a large organization?
> expects you to implement such a Process as part of "lessons learned".

I sometimes refer to this as "scar tissue" - an over-response to a trauma that causes ongoing issues more so than the initial injury.

ekimekim··on GateBoy – A gate-level simulation of the original Game Boy hardware
The Gameboy CPU is signifigantly less capable than a full z80. It's missing key features like the IX and IY registers (and thus addressing modes), most of the 16-bit ALU, the second set of "shadow" registers intended for interrupt handling (instead, almost all gameboy interrupt routines start by pushing all the current registers onto the stack), and a bunch of other things I forget.

There's also some stuff it adds, such as the swap instruction (swapping the upper and lower nibbles of a byte) and the stop instruction (puts the gameboy into a low-power state until it is woken by a keypress).

ekimekim··on There is no such thing as a “glibc based alpine image”
I want to use alpine for my containers because it's a minimalist distro with a nice package manager with up-to-date packages. Reasons I don't like common alternatives:

* ubuntu - Increasingly hostile to container usage (I tried to install a package recently, the install "succeeded" but at runtime the installed binary simply printed 'oh actually this is a stub, use snap instead' and exited), along with all the other downsides of debian (see below)

* debian - Very old packages if you're running a supported version. There's a ton of boilerplate to make apt behave itself in a container environment, something like "apt-get update && DEBIAN_FRONTEND=non-interactive apt-get install --assume-yes --no-install-recommends PACKAGE", compare to "apk --update add PACKAGE".

* distroless - More work to create and manage, can't install things ad-hoc in a running container for debugging purposes

As it is, I use debian and put up with the annoyances and need to occasionally install things from source to get a modern version. But there's really no good options. Alpine would be amazing, except I've hit too many problems with musl (though I'm sure it's not actually musl's fault). If someone was advertising "alpine but with glibc" and it actually WAS that (not "alpine with glibc tacked on top"), I'd use it in a heartbeat.

ekimekim··on An Introduction to JQ
Personally I find it clearer in many cases to use a format string instead. ie. instead of writing:

    [(.number|tostring), .title] | join(" | ")
I would write:

    "\(.number) | \(.title)"
which IMO is more readable in cases where you have specific values you want to put in specific places, as opposed to a list of unknown length which you want joined (eg. I would still use join("\n") in your example).
ekimekim··on My mouse driver is asking for a firewall exemption (2019)
The driver itself is HTTP, not HTTPS. They were saying they hoped that the HTTPS call which tells it where to download the driver also contained signatures so that the later HTTP request could be verified. spoilers: it does not. So you don't need to mitm the HTTPS request, you just wait until they make the follow-up HTTP request, mitm that and serve whatever you want.
ekimekim··on Apps Getting Worse
The problem is that these apps come with a built-in doomsday. If they ever get popular enough to be meaningfully on the radar of the company whose app they're replacing, they'll be attacked both legally ("you're violating our TOS by using this app") and technically (removing API access or obfuscating internal APIs / pages to prevent scraping).

Efforts like youtube-dl are a constant arms race between google making changes that prevent it working, and the youtube-dl devs pushing fixes. It's a piece of software where "too old to be useful" is measured in months as tons of things don't work anymore.

These companies will never willingly give up control over the user experience (especially if they NEED that control in order to serve ads), and they'll use every method at their disposal in order to do so. Discord already threatens to ban anyone who tries to use a third party client - how long until twitter does the same?

ekimekim··on American Medical Association: Remove Sex from Public Birth Certificates
This is also an argument for including your blood type, ethnicity (risk of certain genetic issues), and known allergies on your birth certificate.

Is this meant to be a medical document, or a legal one? If medical, then it shouldn't be allowed to be required for identification for privacy reasons. If legal, then why does it contain medical information at all?

ekimekim··on Types versus sets in math and programming languages
If you mean "representing values as a pair of integers P, Q, such that the value = P/Q", the answer is that they're very expensive to work with. You generally need to be using arbitrary-length integers for P and Q, because the values get very large very quickly. And as the values get large, operations like finding the lowest common multiple (required for almost any operation between two rationals) get expensive.

As an example of the kinds of runaway increase in P and Q I'm talking about, consider calcuating the sum of x/(x+1) for values of x from 1 to 999, using python's fractions module:

    >>> sum(Fraction(x)/(x+1) for x in range(1000))
    Fraction(7075502361382798268120793110090229940258706389605508780354900641905867818691614397718938054011886551220308728288024788414601821895503124242001568659978565050184167864774563757893457200995977901194872761682228965032590045181707202517783731540396927542180527680245723964874429994374505238893797078720320991788231820649513569449454767125309918934132672543174716802507966087781714014833406311821646176291230132112749836042537756095388477483, 7128865274665093053166384155714272920668358861885893040452001991154324087581111499476444151913871586911717817019575256512980264067621009251465871004305131072686268143200196609974862745937188343705015434452523739745298963145674982128236956232823794011068809262317708861979540791247754558049326475737829923352751796735248042463638051137034331214781746850878453485678021888075373249921995672056932029099390891687487672697950931603520000)
That's a 436-digit P and a 433-digit Q.

Rational types like this can definitely be a good choice in a use-case where accuracy is important, and operations do not compound. But they're a poor default, which is why we generally see float types as the most common non-integer number representation.

ekimekim··on Patching until the COWs come home
The second half of the article is here: https://lwn.net/Articles/849876/
← PreviousPage 4 of 20Next →