News for hackers. Stuff that matters.

aastronaut

Fixed a bug on how the browser wasn't closing TCP connections/Motion JPEG video streams properly in a responsive behavior. Took me about 3+ hours reading through various specs and that resulted to around 20 LOC changed. I then wrote a blog post about it[0], which took me about 10 days.

[0]: https://blog.whilenot.dev/posts/cool-bugs-vs-shitty-bugs-par...

Re:Raspberry Pi 5 on Thursday September 28, 2023 @02:44AM (#37686157)
I think it should be "The art of buying single-board computers and never running them once". I think the "once" is needed in the case of computers. They are as machines not directly comparable to books...

A book, like any media, fulfilled its initial purpose after it has been "consumed" - anything else (looks nice, feels nice, smells nice) are physical, subjective qualities attached to it. You might even buy it solely for these physical qualities, but that's besides the point.

A machine has its purpose in its usage, and that usage requires known resources that should not be carelessly wasted. I personally buy them to enable a utility for myself and have fun discovering it. It fulfilled its initial purpose even if it was powered on just once.

Even those single-board computers that were put to "good use", as building blocks for new devices (eg. [0]), are still not in use the whole time.

[0]: https://www.creativeapplications.net/objects/paragraphica-co...

Re:The human Y chromosome has been completely sequenced on Friday August 25, 2023 @03:18AM (#37259011)
> If you had a list of all the genomes of all the people in the world, and all their phenotypes (height, eye color, hair type, etc), you could take all their genomes as input variables and treat all their phenotypes as output variables, and make embeddings or other models that mapped from genomes to phenotypes. The result would be a predictive model that could take a human genome, and spit out a prediction of what that person looks like and other details around them (up to the limits of heritability).

Would such a predictive model really be possible? As far as I'm aware there is contradicting research whether a specific phenotype distinctly originates from a SNP/genotype.

I'm honestly a bit confused by this statement, as "React env variables" can mean various things, depending on your setup.

Backend and frontend can be separate runtimes... The backend could be an API-only-server and an OS process with all permissions that come with it (reading env vars during execution as it pleases). The frontend, eg. a React SPA, could just be a bunch of built HTML/CSS/JS-files (type-checked, bundled, minified, etc.), served through a static file server (separate backend, nginx?) and interpreted through a browser engine on the client.

Are you asking for nginx to parse the served HTML/CSS/JS-files and replace unknown placeholders with env var values? If so you are prob asking for a SSR framework[0], meaning a backend that treats a React project similar to template files, and is able to inject env vars?

[0]: Next.js - https://nextjs.org/docs/app/building-your-application/config...

Re:Ode to the M1 on Sunday August 13, 2023 @05:08AM (#37108071)
> HTML/CSS/JS are successful because of the same reason electron exists. The success of the web means there’s a huge developer base that knows how to work with HTML/CSS/JS

The actual reason is a different one IMHO. The implementation of web standards enabled cross-platform engines that provide every UI customization one could possibly need for a SaaS product. This decision included many benefits for businesses and developers alike, such as:

- User data stays in the walled garden

- Users most probably already have a web-browser installed

- Responsibility to keep the runtime (web-browser) up-to-date is on the user side

- Automated updates (POV user)

- No installation instructions

I think it as much as a business decision as it was the decision from developers to bet on HTML/CSS/JS instead of GTK, QT, etc.

Re:At this company, we are family on Tuesday July 25, 2023 @03:46PM (#36868294)
Correction: you cannot get fired ("Entlassung") without any reason in Austria, you need rather strong reasons to fire somebody[0], but your employment contract can be terminated with a notice period anytime* ("Kündigung")[1]. The notice period is 6 weeks at minimum by law (6-12 weeks is common in startups by employment contract) and includes "Postensuchtage"[2], which allow you to use 20% of your time during the notice period however you want.

*: every 1st or 15th of the month is common

[0]: https://www.usp.gv.at/en/mitarbeiter/beendigung-arbeitsverha...

[1]: https://www.usp.gv.at/en/mitarbeiter/beendigung-arbeitsverha...

[2]: https://www.wko.at/service/arbeitsrecht-sozialrecht/Anspruch...

Re:Gauge Block on Tuesday July 25, 2023 @01:45PM (#36866327)
Had those in heavy use during my work on a surface grinder[0], I can remember it had an ancient digital interface with 0.0001mm precision. We used the blocks to calibrate our measuring table[1] constantly. Later in life I got to see the machines to measure the quality of photomasks[2] in the production line of modern CPUs, and I was just blown away when I heard about those tolerances.

[0]: https://en.wikipedia.org/wiki/Surface_grinding

[1]: https://www.bafasan.com/en/images/kke/kke2.png

[2]: https://www.zeiss.com/semiconductor-manufacturing-technology...

Re:Ask HN: Could you share your personal blog here? on Wednesday July 05, 2023 @02:12AM (#36596119)
https://blog.whilenot.dev

I should write more.

Re:Robyn – A Python Web Framework with a Rust Runtime on Sunday June 11, 2023 @03:26PM (#36284725)
Maybe a link to the project would be better: https://github.com/sansyrox/robyn
> [...], written in TypeScript and accelerated with C++ bindings to BLAS and LAPACK

C++ addons for Node.js are not part of the JavaScript runtime.

Re:Cities Aren't Loud: Cars Are Loud on Friday May 19, 2023 @08:53AM (#36001314)
The level of noise is the predominant parameter in my selection for a living place. I always consult the noise map[0] before moving anywhere in Vienna/AT. I hope other governments offer the same information.

[0]: https://maps.laerminfo.at/

Re:To Type or Not to Type? on Wednesday April 26, 2023 @01:32PM (#35717293)
> my gut is screaming no

seems like you already made up your mind, so why bother?

TypeScript is helpful (or at least meant to be) for teams as it aims to block the cleverness of its individual contributors. Especially people only familiar with dynamic type systems are rather fighting a static type checker at first and "it's not helping them". A "strong" type checker should enforce everyone to write stuff in a simpler form and that gets in the way of productivity for some people.

If you can maintain your mindset and write your code in a simple form that could easily satisfy a type checker (coming from rust), then why bother with additional tooling if it won't provide more value to you? Or to phrase it differently: if you can maintain a strong mindset with confidence, bringing in additional tooling for that project later on, when it will be become plausible, won't be that hard. But if you doubt your mindset, it might be a helpful choice to let a type checker look over your shoulder from the beginning.

To add to this, for me personally the difficult part in automated test isn't the definition of expected output, but the retrieval of actual output in an automated way. Test frameworks can and will only focus on a limited set of interaction (Playwright for DOM, detox for mobile etc.).

I think Brendan Gregg's books[0][1] are quite inspiring for an understanding of a system with its inner workings, and provide information about various tools one can use to dissect a system and get some actual output in an automated way.

[0]: https://www.brendangregg.com/systems-performance-2nd-edition...

[1]: https://www.brendangregg.com/bpf-performance-tools-book.html

just patch inputs and outputs to audacity (or your recording software of choice). for pipewire theres helvum[0] or qpwgraph[1]. for JACK there's Catia[2].

[0]: https://gitlab.freedesktop.org/pipewire/helvum

[1]: https://gitlab.freedesktop.org/rncbc/qpwgraph

[2]: https://kx.studio/Applications:Catia

i think

> language enables intelligence

was just a poor choice of words here. i understood GP as "the structure of a language influences its speakers' worldview or cognition, and thus people's perceptions are relative to their spoken language"[0]

[0]: https://en.wikipedia.org/wiki/Linguistic_relativity

Re:Keycloak with PostgreSQL on Kubernetes on Tuesday April 11, 2023 @02:31AM (#35521572)
there's the repository with examples: https://github.com/ory/examples
> "now you have two problems"

Interesting take. I always look at it like "now you have a better solution for your modeling needs".

Re:Ask HN: Why are so many PHP projects moving to Node? on Friday January 27, 2023 @03:02AM (#34543750)
You're question seems more on the side of "Why use a micro framework when you can use a mature full-fledged one?". I feel a lot if new ideas in the web development space are first available as "micro" packages, so that's just what you use when you want to stay on the edge. I feel there is still so much momentum in the JS/TS community. Would you genuinely pick PHP for anything else besides Laravel?

I would also question you're mentioned frequency to update packages tbh. Just pin a stable version with a lock file, track the required node engine and use an OCI image to provide just enough reproducibility. I never had to do anything more than cd-ing into a directory and run npm ci after coming back to a project for a few years now.

Re:Stop lying to yourself – you “fix it later” on Monday November 21, 2022 @03:31AM (#33690229)
Maybe I understand it wrong, but I can't agree with this analogy as is...

An organized home means to do things right away. If the laundry is done and dried, then I'll put them away (organize them) immediately. I don't wait for other things (eg. the dishwasher) that need to be tidied up. If I service my bicycle in one room and leave a mess, then I'll clean it up right away and don't necessarily include other rooms in that cleaning cycle. But on the other hand, if I spot some dust in one room, I'll just grab the hover and go through the whole flat.

Actions can be separate, and so can scope and effort.

I feel a house is best managed when effort and scope are low, so it is in my best interest to keep it that way. If my task becomes the action to tidy my home, then I know something went wrong.

As much as I like some historical reference like the next person, I think this discussion here takes a wrong turn through comments like these, sarcastic or not. I think OP is free to criticize the process of registering a company, but should rather give suggestions to improve said process instead of ranting about the official language of a nation.

People are different, aren't they? On one side I have a friend living in Austria for about a decade now and he still complains that quite some information isn't available in English. He doesn't even see the irony as an Italian, makes no attempt to learn the official language (German) and continuously makes fun of any explanation I'm trying to give on why a specific German term would be used in a certain context. On the other hand there are people like me, who moved to Norway for about a year and frequently felt like shit that I didn't make a proper attempt to learn its official language (started a course there next to my study, but didn't finish it). I was amazed that every Norwegian I encountered was able to speak English on a very high level. Me not learning the official language, but still trying to achieve some kind of future there, really made me feel foreign and my failed attempt to learn that nations official language remained a lasting feeling of lost time. I would never consider to complain that some documents aren't available in English.

Re:Why Would Anyone Need JavaScript Generator Functions? on Monday November 07, 2022 @01:48PM (#33510302)
> Can you give some specifics about what that means in your case?

react-query has a default behavior to cancel a fetch when the component unmounts (AFAIK), eg. the user changes to another view and the data of the previous view aren't needed anymore. I prefer to only have those fetches pending which are actually needed and seem likely to succeed, as otherwise my SPAs would just add unnecessary load on the API gateway. I specifically had such a case when the backend team was in transition to a microservice architecture, hence the timeouts.

But thanks, will join the discord then after I created a repo to play around.

Re:Why Would Anyone Need JavaScript Generator Functions? on Monday November 07, 2022 @01:07PM (#33509609)
there goes my evening, that's what I like about HN. thanks for the refs!
Re:Why Would Anyone Need JavaScript Generator Functions? on Monday November 07, 2022 @12:36PM (#33509139)
I didn't lay out a bait =)

It would also look more readable to me with a default return value. An exhaustiveness check just keeps your mapping functionally pure and the type checker can catch it.

Re:Why Would Anyone Need JavaScript Generator Functions? on Monday November 07, 2022 @12:35PM (#33509116)
the reply button wasn't there and I assumed the reach of a depth limit... guess I just needed to wait a bit ¯\_(ツ)_/¯

Moving the case for a default value to the caller is a weird choice IMHO. Types should reflect the assumed state about a program, but we all know the runtime can behave in unexpected ways. Assume an SPA and the response of an API call was typed with CountryCode in some field, then somebody just worked on the API - I prefer to crash my world close to were my assumption doesn't fit anymore, but YMMW.

Your implementation (and safety from the type checker) only helps at build time and puts more responsibility and care on the caller. That implementation could prolong the error throwing until undefined reaches the database, mine could already crash at the client. Either TS or JS will do that.

Re:Why Would Anyone Need JavaScript Generator Functions? on Monday November 07, 2022 @11:59AM (#33508535)
@lolinder

...you just removed the default case and just introduced undefined as return value at runtime, so it isn't the same functionality.

Re:Why Would Anyone Need JavaScript Generator Functions? on Monday November 07, 2022 @11:30AM (#33508020)
Thanks for the example! I guess we consider switch/case in different situations then. I usually make use of switches in simple mappings and switch/case seems more readable and idiomatic to me there:

  type CountryCode =
    | "CH"
    | "US";

  function nameFromCountryCode(countryCode: CountryCode): string {
    switch (countryCode) {
      case "CH": return "Switzerland";
      case "US": return "United States of America";
      default: // exhaustiveness checking
        ((val: never): never => {
          throw new Error(`Cannot resolve name for countryCode: "${val}"`);
        })(countryCode);
    }
  }
...instead of...

  type CountryCode =
    | "CH"
    | "US";

  function nameFromCountryCode(countryCode: CountryCode): string {
    return ({
      'CH': (() => 'Switzerland'),
      'US': (() => 'United States of America'),
    }[countryCode] || (() => {
      throw new Error(`Cannot resolve name for countryCode: "${countryCode}"`);
    }))();
  }
Re:Why Would Anyone Need JavaScript Generator Functions? on Monday November 07, 2022 @11:15AM (#33507768)
Thanks for the example!

I assume the identical performance just comes from the optimization of the JIT, as allocating objects in the heap seems quite overkill for such a control flow. I only fall back to this when switch/case isn't available in the language, eg. in Python.

Is this a thing in the JS community?

Re:Why Would Anyone Need JavaScript Generator Functions? on Monday November 07, 2022 @11:10AM (#33507686)
I'll use your nice response for an actual question/remark, gotcha! =)

Recently I had a look at the kubeshop-dashboard repo[1] and their use of the RTK Query API[2]. When I write the boilerplate for any SPA nowadays, I usually like to merge any fetching logic with the lib-specific notification/toast-methods, in order to render something to the user about any reached warning- or error-timeouts for each ongoing fetch by default. Meaning:

- every new fetch would start a timer

- after 10secs a warning-notification is shown "a fetch takes longer than expected..."

- and after 30secs the AbortController signals the cancelling of the ongoing fetch and an error-notification is shown "fetch took to long. click to try again."

The implementation of react-query, its "hook-yfied" nature, makes it super easy to wrap it and merge it with the component-lib to create such a thing. I just need to wrap its provided hooks (useQuery, useMutation) with "hook-creators" (I usually call them createQueryHook and createMutationHook) and don't need to dive into any of its implementation specific details. But createApi, as provided by RTK Query API, makes this quite a bit harder, or so it seems to me at least. How would you wrap createApi to provide such a functionality for every fetch by default?

[1]: https://github.com/kubeshop/testkube-dashboard

[2]: https://github.com/kubeshop/testkube-dashboard/tree/main/src...

Older »