HNHacker News
TopNewBestAskShowJobs

aleksandrh

74 karma · joined September 30, 2021

submissionscomments
aleksandrh··on Don't be a meat proxy
"Any non trivial coding task requires a conversation between human and ai."

Does it? Since when? Are we just going to pretend some of the world's best software wasn't written before AI coding tools came along?

aleksandrh··on How we rebuilt Next.js with AI in one week
Weird, I hate Next and I love Vite. We have a big (I mean _really_ big) production app that runs on Next.js at work and it's the slowest thing I've ever worked on. I had to upgrade my machine to an M4 Pro just to get local dev compile times down from 5-8 minutes to ~30-60 seconds per route. And my hot refreshes are down from ~15-20 seconds to 5-10. It's _bad_. All the Next.js team does is give you the run-around and link to their docs and say here, try these steps, you're probably doing something wrong, etc. Nope. The framework is just slow. They use simple toy apps to demo how fast it is, but nobody tells you how slow it is at scale.
aleksandrh··on Ultimate Vocal Remover GUI, a FOSS audio stem splitter
Tried this last night and it works really well so I figured I'd share it here, even though it's a few years old. It can even take advantage of your GPU to run faster. The sample song I tested with is 5:56 and it only took 30 seconds for this tool to split it into separate .wav files for vocals, guitar, piano, bass, etc. I recommend following this guide here: https://www.reddit.com/r/musicproduction/comments/1704kob/co...
aleksandrh··on Mako – fast, production-grade web bundler based on Rust
Time to reset the clock. 0 days since a new web bundler was released (in Rust!!).

So tired of this ecosystem and its ceaseless tide of churn and rewrites and hypechasing.

aleksandrh··on A formula for responsive font-size
> What happens when that fake-100px-but-actually-10em wide element is meant to coexist with something that is actually set in pixels? For instance, a 120px skyscraper ad? The things sized in fake-pixels-but-actually-ems will change proportionally with the user’s font size, but the things sized in real pixels will not. All of a sudden different elements on the page have different ideas about what scale they should be rendered at, and the layout falls apart.

This is technically also working as intended. When a user scales their preferred font size in their browser settings, their expectation is that the font sizes on pages will scale accordingly, not that every element will scale. The latter is what zoom accomplishes, but there's a reason why both zoom and preferred font sizes exist in browser settings.

In your example, the ad (or image, or whatever) should only be sized in rems/ems if it has text. For all other elements that aren't related to text, it makes more sense to size with pixels. If everything is sized in ems/rems, then scaling the preferred font size behaves identically to zoom. This is less than ideal because if I want to increase font sizes, and what you do in response is zoom the whole page, then there is less space for that same text to fit on the page because it competes with other scaled elements. So while I can read the text more easily because the glyphs are larger, I can read _less_ of the text within the same amount of space than if text were the only scaled element.

Also, at least in my experience, designers aren't the ones thinking in ems; they typically hand us Figma compositions that use pixels, and we translate to rems in our code base. Designers design for the base experience, and we are responsible for coding it in a way that scales proportionally/in a way that respects user preferences.

aleksandrh··on A formula for responsive font-size
> The browser might default to 16px font size, but users can pick something else. So if somebody had poor vision and increased their default font size; or if they had a small laptop screen and decreased their default font size, 1em * 62.5% != 10px, everything the designer set in ems was a different size than they intended, and a lot of their page layouts disintegrated into an unholy mess.

Howdy, author of the article you're responding to (but not the person who originally discovered/pioneered this trick). This is not true, and my article explains why.

The 62.5% trick is rarely used on its own, but people often cite it this way, leading to confusion. In practice, you set the root font size to 62.5% (of the user agent font size) and then also scale all body text back up to 1.6rem so it's not stuck at 10px. From here on out, all font sizes remain proportional no matter what, even if a user changes their preferred root font size in browser settings. Play around with the math if you doubt it (the article offers examples).

> everything the designer set in ems was a different size than they intended

That's working as intended—your design will scale up or down, according to the user's preferred font size. If you don't like this, your only option is to set font sizes in pixels, which [you shouldn't be doing anyway](https://www.aleksandrhovhannisyan.com/blog/use-rems-for-font...) (disclaimer: also written by me).

aleksandrh··on Elon Musk sues Sam Altman, Greg Brockman, and OpenAI [pdf]
> Indeed, as the November 2023 drama was unfolding, Microsoft’s CEO boasted that it would not matter “[i]f OpenAI disappeared tomorrow.” He explained that “[w]e have all the IP rights and all the capability.” “We have the people, we have the compute, we have the data, we have everything.” “We are below them, above them, around them.”

Yikes.

This technology definitely needs to be open source, especially if we get to the point of AGI. Otherwise Microsoft and OpenAI are going to exploit it for as long as they can get away with it for profit, while open source lags behind.

Reminds me of the moral principles that guided Zimmermann when he made PGP free for everyone: A powerful technology is a danger to society if only a few people possess it. By giving it to everyone, you even the playing field.

aleksandrh··on A cautionary tale about software dependencies during major geopolitical events
And then claimed his GitHub was "hacked" to save his ass. And was somehow not banned by GitHub despite clearly violating their TOS.
aleksandrh··on Things you forgot (or never knew) because of React
Web dev here working with React for ~4 years now. I really don't enjoy it as much as I used to. It has made me dislike JavaScript in general, and I often find myself wishing things were simpler and more performant. I can't emphasize how relatable this part is:

> We shouldn’t need to do that—especially for a framework that so often claims it’s “just JavaScript.” If it’s just JavaScript, then it should just work with anything that’s actually just JavaScript.

And this:

> I have a confession to make: I’m still not exactly sure what the difference between useMemo and useCallback is—or when you should and shouldn’t use them—even though I literally read multiple articles on that exact topic earlier today. (No joke.) > > I have a second confession: it’s still not intuitive to me what should and shouldn’t go into the useEffect dependency array, or why. I feel like every time I write a useEffect call, I spend like 15 minutes refactoring my code to be in a shape the linter likes, even when I’m 99% certain it’s actually fine and it’s not going to suck my app into an infinite abyss.

aleksandrh··on The Great SameSite Confusion
Great article all around.

TL;DR: A cross-origin request can still be same site. Also, SameSite cookies do not prevent cookies from being included in malicious requests originating from subdomains because "site" is by definition scheme (e.g., https) plus eTLD+1 (e.g., example.com).

Example: https://subdomain.example.com can submit a malicious POST to https://example.com/delete-account and the user's session cookie would still get included in the request headers. This is why CSRF tokens are commonly employed on top of SameSite cookies as an added layer of protection.

aleksandrh··on No AI here, thanks very much
This is something I've been mulling over for a while now. Folks who've been writing before the inception of ChatGPT have a historical record of their work, so one can probably trust that they will continue to author their own content. But how will the next generation of writers convince others that their writing is truly their own work and not the product of AI? It's going to be one big struggle for validation. If you can't beat 'em...
aleksandrh··on Who owns private home security footage, and who can get access to it?
Police: We suspect your neighbor committed a crime...

You: Okay

Police: ...so we're going to need all the footage from inside your home

You: Wait wha—

Judge: Sure, I'll sign a warrant for this. That sounds perfectly reasonable.

aleksandrh··on AI Art Panic
> I don't think anyone expects AI to displace "name brand" art

The problem isn't for existing artists (except in terms of ethical issues)—it's for new/budding artists, who will have to contend with challenges to the authenticity of their work. How can they prove that they put their blood and sweat into making a piece of artwork by hand when an AI could've generated something equally passable?

aleksandrh··on Open Library
I love Open Library (and the internet archive project in general)—I've read so many good books through them! I really hope they don't get shut down.

They're also truly open source: https://github.com/internetarchive/openlibrary/

aleksandrh··on Show HN: Copy React code from any site
> If you use the components to create a new design then there is no copyright.

This is false. You can't copy a site's code and just change the design and poof, no copyright infringement.

aleksandrh··on Dentistry is less scientific and more gratuitous than people think (2019)
> The business of dentistry is unfortunately antithetical to conservative treatment, which is almost always in the interest of the patient, because it results in significantly lower patient lifetime value.

Isn't this the case with other healthcare providers too, and not necessarily just dentists? For example, physicians will regularly make you wait at least 15 minutes—even in an empty office—so they can bill insurance for that extra time. They'll bill patients for "emotional/grief counseling" and lots of other unrelated charge codes as well. I've seen from firsthand experience how doctors will exploit patients and try to milk as much money as they can from them, rather than prioritizing their wellbeing and health.

aleksandrh··on Dentistry is less scientific and more gratuitous than people think (2019)
#2 is terrible advice. Acidic food weakens your enamel. Brushing after eating will make things worse. It's actually recommended that you wait after eating acidic foods to brush. Rinsing (with water) is totally safe, though.
aleksandrh··on Ask HN: What do you think of the Wordle guy not monetizing it?
What do you mean? Flappy Bird made a crap ton of money.
aleksandrh··on Marak's GitHub account suspended after he erased his faker project
> breaking lots of people's builds

Why would it break people's builds? I can only see this happening if they upgraded faker.js.

Besides, best practice says to check each package's repo before upgrading because of 1) malware, and 2) potentially breaking changes.

Also, many forks exist, and you can point to GitHub versions of a package.

aleksandrh··on A Guide to Twitter
Good read, but I don't believe it's possible to make friends online in the true sense of that term. I've been doing things online for a majority of my life. Forums, gaming, chatting with strangers. I've made many "friends" this way, but they're not people I know. We've lost touch over the years, and I wouldn't ever turn to them for help because we don't know each other that well anyway.

Twitter is the same. The best you can have is acquaintances, peers/colleagues, or followers.

aleksandrh··on Compromised NPM packages of ua-parser-JS (0.7.29, 0.8.0, 1.0.0)
User error, 0.7.28 is safe
aleksandrh··on Compromised NPM packages of ua-parser-JS (0.7.29, 0.8.0, 1.0.0)
I have 0.7.28 as a dependency of a dependency and the miner is running on my system. So it may not just be 0.7.29?
aleksandrh··on How I built a modern website in 2021
I don't understand this sentiment. TypeScript is fantastic, and I can't help but think that all of the people hating on it are frustrated because they haven't taken the time to properly learn it or understand why it's constantly complaining about the code they write.

I used to get annoyed by TypeScript too when I first started using it—I felt like it was slowing me down and making me unproductive. But this is only because I tried to use TypeScript without really understanding how to use it effectively (which will make you unproductive with _any_ tool).

Once you work long enough with TypeScript, going back to pure JavaScript feels like hell.

aleksandrh··on Ocean drone captures video from inside a hurricane
I really hope drones continue to be used for good, rather than blowing people up from the comfort of a gaming chair.