[HN Gopher] I Implemented /dev/printerfact in Rust
___________________________________________________________________
I Implemented /dev/printerfact in Rust
Author : todsacerdoti
Score : 100 points
Date : 2021-04-17 16:15 UTC (6 hours ago)
(HTM) web link (christine.website)
(TXT) w3m dump (christine.website)
| Grollicus wrote:
| How does this /dev/printerfacts react to partial reads? Does it
| mix multiple facts?
| xena wrote:
| If your buffer is too small it will just fail. It ends the file
| after a fact is returned. I think I forgot to shout that out in
| the article. Oops.
| Grollicus wrote:
| Ah yes because `write_slice` fails. That's actually nice and
| quite ergonomic with the ?.
|
| Well, thanks for the quick intro for how to actually use this
| new rust-in-kernel stuff and also for showing how to easily
| test it with nix. That's a great article, so thank you for
| sharing!
| xwx wrote:
| > Printers have been domestiprintered for half as long as
| scanners have been.
| malf wrote:
| > Printer facts were originally made by a very stoned person
| that had access to the Cat Facts API and sed. As such instances
| like indiprintere are features.
| gerdesj wrote:
| https://printerfacts.cetacean.club/ Follow the various links.
| See if you can jump to the same conclusion as me regarding
| who forgot to anchor their regexes when playing with Cat
| Facts 8)
| xena wrote:
| It's a feature.
| wildmanx wrote:
| It took me a sadly too-long time to realize that this had nothing
| to do with any printer API.
|
| Like, I read the whole post, and all the comments here on HN. And
| only _then_ did it dawn on me.
| xena wrote:
| Author of the post here, I love those kinds of slow burns. I'm
| really glad you managed to experience one.
| iudqnolq wrote:
| > "Printers can judge within 3 inches the precise loprinterion of
| a sound being made 1 yard away."
|
| > Printer facts were originally made by a very stoned person that
| had access to the Cat Facts API and sed. As such instances like
| indiprintere are features.
|
| I love this.
| whateveracct wrote:
| this is one of my favorite Nix blogs out there! the NixOS systemd
| timer one was great - I used it when I had to make my first timer
| and it was the best resource out there.
|
| The narrative style made it a fun read too. Feels like someone
| explaining things to me personally off the cuff.
| xena wrote:
| Author of the post here. That's the style I try to go for, that
| balance of serious, shitpost and interesting side notes you'd
| get from DMing a particularly sarcastic coworker that means
| well on Slack. The Mara interludes add into this because it
| allows some blending in of the Socratic method to make some
| more complicated things something closer to a dialogue. I have
| plans to take this further though. If you have any suggestions
| on how I should skew these plans please let me know.
| iudqnolq wrote:
| Is Mara meant to be Mara Bos of Rust twitter shitposting
| fame? It almost fits.
| xena wrote:
| I have never heard of that person. Mara's name comes from a
| DnD like session for a trollish character. In hindsight
| it's quite ironic that Mara is now used to help explain
| things.
| amluto wrote:
| > It's really annoying to contribute to the Linux Kernel Mailing
| list with my preferred email client (this is NOT an invitation to
| get plaintext email mansplained to me, doing so will get you
| blocked).
|
| Heh. I really wish the kernel list would detect that a post has
| valid text and html content and just throw away the html rather
| than rejecting the whole thing. Plain text is, sadly, not a first
| class feature of most non-terminal email clients these days.
| nolok wrote:
| > this is NOT an invitation to get plaintext email mansplained
| to me
|
| That person can reassure herself, there are just as many women
| know-it-all-better-than-you as there are men, arrogance and
| condescension are sadly not strictly male traits.
|
| It tends to more often be guys in the tech world, sure, but
| then it's just https://xkcd.com/1138/
| globular-toast wrote:
| Odd to see this casual sexism thrown in at the end of a
| technical article. Imagine if I just randomly threw in how long
| women take to get ready or something at the end of a technical
| article. It would be completely bizarre and my sanity would
| probably be called into question.
| readingnews wrote:
| > I really wish the kernel list would detect that a post has
| valid text and html content and just throw away the html
|
| Because. https://stackoverflow.com/questions/1732348/regex-
| match-open...
|
| Honestly, I am not trying to put on my old-man hat, but I
| despise anything other than plain text in email. I agree with
| the KML. Email should not have binaries, html, tags, etc... of
| course, M$ and others will happily render them, so why not,
| right?
| iudqnolq wrote:
| Email can have multiple parallel payloads in different
| formats (see MIME). It's part of the spec, not a hack.
|
| The OP is suggesting that if LKML gets multiple payloads
| where it can understand one of them it just selects the one
| it can understand. This is what other text-only clients do.
|
| They're not suggesting parsing html into text (tangentially,
| if they were, there are much better approaches than the one
| you linked. One of the most commonly used ones is originally
| by Aaron Schwartz https://github.com/aaronsw/html2text )
| seniorgarcia wrote:
| I'm kinda curious which client makes writing plain text
| emails hard though.
| xena wrote:
| Article author here. Gmail and Apple Mail
| (macOS/iOS/iPadOS). I had to install aerc on a server to
| subscribe and post to the list.
| seniorgarcia wrote:
| I don't post to this specific list, so there might be
| weird issues I'm not aware of but...
|
| Gmail has the plain text option behind the 3dot menu in
| the bottom right corner. Apple Mail deserves to die a
| fiery death and I refuse to support it but "Format" ->
| "Make plain text" *may* send a plain text message, or not
| depending on the OS X lottery. You can force Apple Mail
| with "Preferences" -> "Composing" -> "Message Format" ->
| "Plain Text" to compose plain text messages. Or you can
| use an actual mail client.
| kelnos wrote:
| > _Or you can use an actual mail client._
|
| An "actual mail client" is any mail client that speaks
| SMTP. This "use a real X" or "real programmers always do
| X this way" stuff is why many tech communities are
| considered hostile and toxic, especially to newcomers.
| It's childish in personal settings and unprofessional in
| work settings.
|
| The funny thing is that most of the people who continue
| to hold these attitudes weren't even around or on the
| internet when it was slow and expensive to sling around
| rich text or binaries. I mean, I was born in the 80s and
| got an account with my local ISP in the early 90s, after
| spending a few years hanging out on BBSes playing door
| games (anyone remember Virtual Sysop?). I agree that
| binaries or anything other than plain text was a pain to
| deal with back then; I had a 2400 baud modem, and even
| when I managed to get something faster, the phone lines
| in my area were too noisy to give me anything faster than
| 19.2kbps. And I'm not some greybeard either; I wasn't
| around when 300 baud was state-of-the-art.
|
| But we've moved on from that time. It feels like the
| height of arrogance and gatekeeping to look down on
| someone who just wants to be able to italicize or bold
| some text in their emails sometimes.
| xena wrote:
| > Or you can use an actual mail client.
|
| For those of you wanting an explanation of what I meant
| here, this is a perfect example of it. I do actually have
| aerc installed now. I just think it's annoying that I had
| to change my perfectly good workflow that is enough to
| get me hired at large companies for this.
|
| > (this is NOT an invitation to get plaintext email
| mansplained to me, doing so will get you blocked)
| seniorgarcia wrote:
| Was my comment mansplaining? I'm genuinely curious.
|
| Apple Mail sucks and I'm always shocked how many people
| think it's "good enough". All the Apple apps are barely
| functional but fall short when it comes to replace
| groupware (or actual standard compliant clients. Don't
| even get me started what Apple Contacts does to vCard).
|
| >>I just think it's annoying that I had to change my
| perfectly good workflow that is enough to get me hired at
| large companies for this.
|
| I don't get what workflow you are talking about.
| zerocrates wrote:
| The translation/context of the passage in the article was
| "look, I know how to send plaintext email, I just wish I
| didn't have to jump through these hoops, so please don't
| come and try to teach me how to do it" and that _is_ kind
| of what your comment does.
| seniorgarcia wrote:
| Which is why I asked what the issue was and the author
| replied he/she was using Gmail/Apple Mail. I can see
| using the lkml with Apple Mail being difficult since
| Apple Mail sucks but sending plain text mails with Gmail
| should just work and nobody should have to change their
| email client if they are fine with using Gmail.
|
| Even not using lkml, it's a standard conforming mailing
| list that (presumably) will accept any plain text mail
| just fine and I do not see why anybody would need to
| install a separate email client like aerc just to use
| this mailing list. So, to me it read "I know how
| plaintext emails work but for some reason my workflow
| does not work so I changed it to include something else"
| and I was curious as to why... Curse me for asking? Curse
| me for damning Apple Mail? Idk... I guess curse me for
| being curious and trying to help a fellow nerd out while
| shitting on Apple Mail at the same time.
| kelnos wrote:
| This might be out of date, but IIRC GMail, in plain text
| mode, will break lines at 72 or 80 characters or
| something like that, which will mangle inline patches.
| LKML's policy prefers (requires?) that you send patches
| inline and not as attachments.
| kelnos wrote:
| > _Email should not have binaries, html, tags, etc._
|
| That's like saying postal mail should only allow you to send
| letters typed on a typewriter.
|
| This "email should be plaintext only" idea was reasonable
| when bandwidth was limited and metered and expensive. While
| that's still the case in some parts of the world, most of us
| here are not in that situation. If you, personally, want to
| reject emails that have attachments or are not plaintext,
| you're free to do so, of course, but don't suggest that the
| rest of us are doing it wrong.
| j-krieger wrote:
| I enjoy christines style of writing very much. I can only
| recommend it to anyone out there interested in dev ops, rust or
| nix. Her narrative style and different characters may be a bit
| jarring at first, but I got used to it pretty fast.
| O_H_E wrote:
| I know I am being pedantic, but it is a bit weird to editorialize
| "How I Implemented /dev/printerfact in Rust" to "I
| Implemented...", make the author come off a little more boastful
| than they intended to.
| pcr910303 wrote:
| HN strips out prefix 'How's by default. I guess that was
| applied here as well...
| [deleted]
| O_H_E wrote:
| Ummm...I dont think so
|
| https://hn.algolia.com/?dateRange=pastYear&page=0&prefix=tru.
| ..
| scrollaway wrote:
| These titles you linked are re-edited to add the "How"
| back.
| [deleted]
| iudqnolq wrote:
| The author implemented /dev/printerfact. Someone else came up
| with printerfact. If someone said they implemented /dev/null I
| wouldn't think they came up with the concept of null.
|
| Also printerfact was implemented by a high person with sed and
| a list of cat facts. While excellent, it's not an incredible
| achievement we need to defend the integrity of.
| a_t48 wrote:
| "I reimplemented" might be better
| xena wrote:
| Author of the article here, I think "I Implemented" is the
| least wrong way to phrase it. I didn't reimplement it because
| it didn't exist before I implemented it.
| a_t48 wrote:
| Didn't realize it was only a web thing before - that's
| fair.
|
| Edit: I hadn't had my coffee yet, reading comprehension
| wasn't yet active. :)
___________________________________________________________________
(page generated 2021-04-17 23:01 UTC)