Better HN
topnewbestaskshowjobs
Log inSign up

fushihara

9 karma · joined Sep 19, 2024 (2y ago) · 12 submissions

Submissions

comment 3w ago · link · parent

When building a system to download content locally, the first thing everyone tries to do is use the content's title as the filename. But this causes a surprising number of problems.

You should use a whitelist of allowed characters. In particular, make sure to test every ASCII character. There aren't even 100 non-alphanumeric ASCII characters. I keep a list of ASCII symbols in my notes, and whenever I build a system like this, that's one of the first things I test.

Make sure you explicitly remove all control characters.

Unicode has some great features, but it's perfectly fine to strip out anything that isn't considered a "normal character" in your region. Some titles might end up looking a little strange, but fewer than 1% of videos use unusual characters anyway. Unicode simply has too many possible characters to deal with.

Explicitly normalize filenames to either NFC or NFD. Otherwise, you can run into problems when viewing content uploaded by Mac users on Windows.

Sometimes, removing invalid characters can leave you with an empty video title. Having a filename that consists of nothing but an extension can cause all sorts of problems, so make sure to include a fixed prefix or suffix in the filename. Personally, I always append the resolution, duration, and video ID to the end of the filename.

On Windows, you also need to be careful about filename length. For historical reasons, the limits are measured in UTF-16 code units, and there are restrictions on both individual filenames and full paths.

Don't get greedy and try to use the full 250 characters allowed for a filename. I'd recommend limiting filenames to around 100 characters at most. Full paths should also stay within 256 characters.

You may have heard that Windows supports full paths of up to around 30,000 characters with long path support enabled, but don't rely on that unless you've verified that every tool in your workflow supports it.

Before downloading any actual content, generate a list of titles from the latest 1,000 or 10,000 items in your system. Then try creating zero-byte files locally using the filenames your system generates, and verify that everything works correctly.

comment 3w ago · link · parent

If it could write 10TB in 5 hours and the tapes cost $10 each, it would probably become popular among consumers.

50GB? Is that a joke?

comment 3w ago · link · parent

Are there any online cloud storage services that cost less than $1 per TB per month?

I have several thousand video files totaling several TB that I store as a hobby.

This is purely for backup purposes, so I almost never need to retrieve the files. That said, I'd hesitate to use a service that charges something like $100 to retrieve a 1 GB file.

My understanding is that with AWS S3, you can retrieve up to 1 TB of data almost for free by using CloudFront.

I'm currently storing my files in the us-east-1 region.

comment 8mo ago · link · parent

I wish SQLite would add a bool type and proper date/time types. Is there really no plan to add them?

For bool, it could just be an alias of a numeric type. Something equivalent to number check(col = 0 or col = 1) would be perfectly fine.

Date/time handling is pretty weak. Having to store values as GMT text is just inconvenient.

When retrieving values in Node.js, I ended up using new Date(val), which caused the classic bug where a GMT-stored value gets interpreted in the local timezone.

The correct approach was new Date(val + ".Z"), but I really don’t want to deal with that kind of hassle anymore.

comment 8mo ago · link · parent

I’m not sure whether this applies globally, but in Japan, around 2015, some mobile carriers deployed a “traffic optimization” feature that would lossily compress images in transit.

On the platforms of NTT Docomo and KDDI (au), users could opt out of this behavior. However, with SoftBank, it could not be disabled, which led to controversy.

As you might expect, this caused issues—since the image data was modified, the hash values changed. As a result, some game apps detected downloaded image files as corrupted and failed to load them properly.

Needless to say, this was effectively a man-in-the-middle attack, so it did not work over HTTPS.

Within a couple of years, the feature seems to have been quietly discontinued.

There were also concerns that this might violate the secrecy of communications, but at least the government authorities responsible for telecommunications did not take any concrete action against it.

There is a Japanese Wikipedia article about this: https://ja.wikipedia.org/wiki/%E9%80%9A%E4%BF%A1%E3%81%AE%E6...

comment 9mo ago · link · parent

Then, out of respect for your view that children’s safety must be the absolute top priority and that false positives must never, ever be tolerated, let’s require people to personally visit Discord’s office in the United States with a government-issued ID, have it inspected, and formally swear an oath. Of course, Discord will retain the ID and the person’s facial photograph for a semi-permanent period. Naturally, that’s perfectly acceptable—after all, it’s for the safety of the children, right?

comment 1y ago · link · parent

I just want to display the last updated time in the corner of a blog post. Overwriting local innerText with JavaScript for that is nonsense.

Displaying relative time like “1 day ago” is especially foolish. Does that mean between 0s–23:59:59? Or 24:00:00–47:59:59? Or perhaps 24:00:00–6d 23:59:59?

When you have multiple browser tabs open and switch between them, and you see “just now” — is it really just now? You last looked at that tab an hour ago. Maybe two hours? Maybe it’s been open since yesterday.

Sometimes I wonder why the Accept-Timezone header doesn’t exist in web browser requests. Using Accept-Language to switch webpage language based on the same URL is now commonplace.

There would likely be demand for a feature where the <html> contains a Unix timestamp, and the browser renders it using the client’s local time zone:

<time epochMs="1234567890123" format="YYYY/MM/DD HH:mm:ss" />

Just write it into static HTML and you’re done. No need for the server to compute relative times, and no need to rewrite it dynamically with JavaScript.

What happened to the movement to abolish daylight saving time? A few years ago, I kept hearing that the US and EU were moving toward ending it. Yet here we are, still observing DST this year.

comment 2y ago · link · parent

As is obvious in the case of a company, it is illegal to disclose a trade secret, even if it is true, If it is judged by a court to have a positive impact on society, such as by leaking information about illegal activities, it becomes legal. I don't think this is particularly strange in Japan, but is it different in the U.S. or the West?

However, in recent years, it has become routine in Japan to identify and punish employees who have leaked wrongdoings. In the evening news this evening, a government employee leaked information about a fraud, and the elected governor identified and pressured the employee, and the employee committed suicide. Public opinion is overwhelmingly blaming the governor, but the police and other authorities show no signs of acting. Despite this current situation, anyway, it is legally true that “even the truth can be sued,” and is this different in the US or in the West?

comment 2y ago · link · parent

If you read the patent carefully, item 7 states that cd-rom is an absolute requirement. C64 is not cd-rom, is it?

However, I agree that it is objectionable that it is a patent on a different medium. I doubt if they were able to get all of them for dvd and blu-ray!

https://patents.google.com/patent/JP2742394B2/en

comment 2y ago · link · parent

I would like to know about the laws of the United States, We all have secrets that we don't want people to know. Is it illegal in the U.S. or in the West to outing someone else if you have the logic that it is a fact? I am Japanese, but I am very surprised.

Of course, accusations of public value to society are not libel in Japan. Everything is judged on a case by case basis.