9 karma · joined Sep 19, 2024 (2y ago) · 12 submissions
comment 3w ago · link · parent
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
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
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
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
comment 1y ago · link · parent
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
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
Of course, accusations of public value to society are not libel in Japan. Everything is judged on a case by case basis.