HNHacker News
TopNewBestAskShowJobs

begriffs

3,039 karma · joined August 10, 2011

submissionscomments
begriffs··on Banned C standard library functions in Git source code
> you can jump anywhere, not limited to the same function

Outside of the current function, yes. Anywhere, no.

Longjmp allows you to return to places you’ve already been and have saved with setjmp. Also attempting to longjmp to a function that has since returned is undefined behavior. Thus longjmp’s usual use case is like exceptions in other languages, going back up the call chain, skipping intermediate functions.

begriffs··on History and Effective Use of Vim
Vim can also edit remote files, with its built-in netrw module. It can do ssh, ftp, dav, fetch, http, rcp, rsync.

vim scp://remoteuser@server.tld//absolute/path/to/document

:help netrw-start

begriffs··on History and Effective Use of Vim
Yes, this is a good idea, although I'd like to note there is more nuance.

* `encoding` is what vim uses internally -- the way buffers and registers are stored in memory. Default value is latin1 as you mention, but it will also pick up on the $LANG environment variable. It's more effective in general to set that variable than directly tweak `encoding`. (Mine is en_US.UTF-8 due to my locale.)

* `fileencoding` is the encoding for the current buffer on disk, how it will be read and written. It is translated in memory to `encoding`. Thus you can manipulate files in encodings other than the one used in-memory. (Although if encoding was latin1 I'm not sure how well the round-trip would go.)

* `termencoding` is how the buffer will be displayed to the screen and how the user input will be read. Once again, it can differ from encoding, and will be translated.

* `fileencodings` is an ordered list of options to try when opening a file. Default value: "ucs-bom,utf-8,default,latin1" when encoding is a unicode value.

If you were editing Japanese text, for instance, choosing UTF-16 encoding would actually make vim use less memory than UTF-8, and would not affect the fileencoding used on disk either.

begriffs··on History and Effective Use of Vim
Thanks for the correction, can you give me a more precise date for nvi? I can update the article.
begriffs··on History and Effective Use of Vim
Sorry, the way I phrased that was sloppy. I should have said, "main author abandoned, saying NeoBundle ripped off code."

http://www.gmarik.info/blog/2014/why-i-stopped-contributing-...

begriffs··on So you think you know C? (2016)
Rather: don't presume anything, read the language specification for the version you are writing (C89, C99, etc).

"Measuring" is exactly the wrong thing to do because often it is indicative of only your specific architecture/compiler.

begriffs··on Unicode programming, with examples in C
Your article mentions:

> Unicode is pretty established, some use it with the wchar_t API in POSIX, some more as non-POSIX via external non-standardized utf-8 libraries

Just wanted to note that wchar_t is not POSIX per se, but comes from the C standard. It also suffers from various problems, see

https://begriffs.com/posts/2019-01-19-inside-c-standard-lib....

begriffs··on Unicode programming, with examples in C
As it says in the article:

> The examples in this article conform to the C89 standard, but we specify C99 in the Makefile because the ICU header files use C99-style (//) comments.

begriffs··on Google launches AMP for email
Good point, there are URIs for other protocols (like FTP, Gopher etc).
begriffs··on Google launches AMP for email
Every email message has a unique identifier called the Message-Id, but SMTP does not host messages with an HTTP URI.

Serving public URIs for messages must be done by separate web servers like a webmail client, or a mail archiving tool such as Pipermail.

begriffs··on Google launches AMP for email
> The promise of AMP for Email is that it’ll turn basic messages into a surface for actually getting things done.

Oh god no, please don't turn email into a "surface."

> That means you’ll be able to do [x, y, z] right from the message, all without leaving your web-based email client.

Quit. Gmail.

Why are so many technical users still on this gross platform that is turning the earliest, most successful decentralized internet protocol into a walled surveillance advertiser garden?

If you use gmail, go register a domain and point your MX records at an honest mail provider like Fastmail, Posteo, or Kolabnow. Or run your own mail server. This way your mail provider is hidden behind your domain and you can change it in the future if desired.

Seriously, stop reading hacker news for a second and make today the day you start migrating away from Google.

begriffs··on Browsing a Remote Git Repository
In a real scenario gitftp would be run remotely. If you're hosting your own git server then you could host the ftp interface too. It won't work with e.g. Github.
begriffs··on Browsing a Remote Git Repository
You have strong opinions about this, which makes me think maybe you can tell me details I didn't know about FTP.

> It's an archaic protocol built around the limitations of early-1980s systems.

What were the limitations, and how did they shape the protocol?

> protocol "feature" of having server responses be human-readable (and not machine-parseable)

The responses are successfully parsed by quite a few clients, no? The fact that I as a person can easily read the output would seem in and of itself to be a positive quality.

> control and data connections ... caused something like 2 decades of security problems, also makes it a nightmare to provision in modern networks

I know little about configuring network security, can you tell me more here? The idea is that in passive mode the server has to pick and listen on a bunch of random ports and so the firewall can't unconditionally block them?

Also you mention "modern networks" -- did it used to be easier to provision networks in the past and something has changed recently?

begriffs··on Browsing a Remote Git Repository
(Author here)

Thanks for reporting this. It looks ok for me in Safari 12.0.3, what version are you on?

The bulk of the work is done by Video.js 5.0.2. Perhaps your browser or plugins are blocking the script?

Can you send me an email with a screenshot? I do try to make the videos work on every browser if possible.

begriffs··on Browsing a Remote Git Repository
Yeah, in this server's case it would respond "502 Unimplemented"
begriffs··on Browsing a Remote Git Repository
One factor that mitigates this a little is the "SYST" command. When a client sends it to gitftp, I have it reply with "215 UNIX" to give them a clue about the format.

I also browsed a few of the FTP mirrors for OpenBSD and took note of how they formatted their response, and tried to make my format match what I observed to be the most common response. It's worked with all the clients I've tried so far: ncftp on mac, ftp on openbsd, Firefox, mac's ftp-finder integration, and Filezilla.

So while there is admittedly ambiguity in FTP servers on the whole, I think my server in particular should work OK. Keeping an open mind though if you know about a problem I haven't foreseen.

begriffs··on Browsing a Remote Git Repository
Author here. I did aim to write the code carefully, for instance doing bounded reads like `fgets(cmd, CLIENT_BUFSZ, conn)` to prevent overflowing my buffer. Also ran the program in Valgrind and exercised different code paths to detect memory leaks and management errors such as use-after-free or double-freeing. Because libgit2 and its memory conventions were new to me, I did actually make mistakes and Valgrind helped me find them. The fix for those mistakes is in commit 59bb39b if you're curious to check it out.

Writing in C requires care, but the modern day "rewrite it in rust" crusade does feel overblown. C programs are nice -- small and fast.

Anyway, I don't mean to be cocky. A code review is welcome, I'd be curious if I did indeed overlook a security issue.

begriffs··on Inside the C Standard Library
> until you mentioned it here there was no indication in the document that you were aware of it

Good point, and thanks for pointing it out. People can't read my mind and the example might give people the wrong idea. I'll add a note to the example.

begriffs··on Inside the C Standard Library
You mean where I'm comparing whether the character is between 'a' and 'z'? Yeah I'm aware that's an ASCII thing, and that the standard was designed to accommodate other encodings such as EBCDIC. My `isalpha` example was more about showing how such a macro ought to be careful to not evaluate its argument more than once.

Did you read the rest of that section? I have arguments about why ctype appears to be insufficient.

begriffs··on Inside the C Standard Library
Thanks for pointing this out.

Can you give an example of the strncpy problem?

Also is there a precaution programs can take to use memset more safely?

begriffs··on Please Google, let us revert to the classic Gmail look
> a huge headache to set up

OK, but "huge headache" is somewhat exaggerated. For many clients, gmail connection settings are a preset option, where you enter a username and application password. It's a one-time configuration.

> outlook

My condolences.

> my 6+ separate computers

You are perhaps an outlier? But I can see how it's a hassle in your particular case.

begriffs··on Please Google, let us revert to the classic Gmail look
Why not use a desktop/mobile mail client of your choice to access gmail over open protocols? Then they can clown up the web UI all they want and it won't matter to you.
begriffs··on Motorola Razr V3 Cellphone: The trend-setter that shouldn't have existed
I had a variation of that mini phone you linked to (the internals get repackaged by various manufacturers). Mine was exactly the height and width of a credit card, and not very thick. It was lovely in my pocket, so unobtrusive. Everyone thought it was a calculator. :) Had to give it up after a while because the battery was really bad. One serious call and it was toast, and the battery got worse with age. If they made a model with a swappable battery it would be more tolerable because I could take some spares with me.
begriffs··on Ask HN: What open source project, in your opinion, has the highest code quality?
OpenBSD

https://www.openbsd.org/goals.html

begriffs··on Airplane Mode: A concrete box designed to seduce you into digital disconnection
Oh, well of course it's because:

"From opening the heavy lid to placing your phone in the cradle, each analog movement becomes an intentional affirmation of the digital sacrifice you are about to make. To complete the gesture, close the box and encapsulate the device."

You can't just turn your phone off or get a dumb phone, you need a ritualized sarcophagus to bolster your decaying willpower.

begriffs··on Elastic TabStops: A Better Way to Indent and Align Code (2017)
I wasn't going to jump into this because arguing tabs vs spaces feels like a parody at this point, but I think you're correct.

I started using spaces for indentation just because I worked with people who did that. I kind of forgot I was even doing it because vim's auto-indent did a lot of the work, but after some time I realized spaces don't make sense.

The familiar arguments for tabs:

* Clean mapping between the concept of scope depth to a single character * Configurable display of indentation width, everyone can see what they want

Tabs have problems only when people use them for alignment, which breaks when tabwidth is changed.

Actually can someone try to change my mind? I know tabs-vs-spaces is an eternal war, yet I feel the problem is completely solved, hence I must be ignorant of the counter arguments.

(The only thing more logical than using tabs might be using no whitespace at all and having the editor determine presentation. But that wouldn't work well with line-oriented tools.)

begriffs··on The advantages of an email-driven Git workflow
> The article describes a lot about the workflow, but only two sentences about the advantages

The article is a good complement to one that I wrote about specifically the advantages - https://begriffs.com/posts/2018-06-05-mailing-list-vs-github...

begriffs··on Are triggers really that slow in Postgres?
> but perhaps not at the expense of keeping business logic in separate places

Perhaps the answer is to consolidate business logic in the database with constraints. This also protects data from manipulation outside of an app, like with scripts or ETL.

Putting more logic in the db often results in terse error messages though, so the app needs to deal with that and make them nicer for the end user. I wrote about one possible approach here - https://begriffs.com/posts/2017-10-21-sql-domain-integrity.h...

> weak version control/deploy solutions

There are solutions that allow you to store migrations in version control, apply them to different database targets, and run consistency checks. For instance http://sqitch.org/ but maybe you're familiar with it already and regard it as one of the weak tools. Thought I'd point it out though.

> a new programming language to the stack

plpgsql is somewhat gnarly, but it is well adapted for the database. You know what it's going to do, compared with managing mappings from some other language. I never tried LINQ though so maybe the mapping would be more pleasant than I'm imagining.

begriffs··on Winds 2.0: It’s Time to Revive RSS
Why has this become so complicated? I use Newsboat https://newsboat.org/ to read RSS, and follow about 100 very interesting authors that way.

I just put the RSS urls into a text file and the self-contained 1.7mb program does the rest. Somehow it gets by without using a combination of Electron, Mongo, Algolia, Redis, machine learning (!), and Sendgrid.

Maybe the comparison with a text-based RSS reader isn't fair and Winds does some crazy cool stuff, but it's hard to see what that is exactly.

begriffs··on Good books for deep hacks
> Now go build something. Want to do something with chat? Sure, go read up on IRC and XMPP and Signal and Wire and all that.

Totally. I guess I should have mentioned that for me, at least, the books will be paired with hands-on hacking.

> The idea of reading 110+ books first in the hope you'll then start your epic hack sounds to me like epic procrastination.

Not planning to read book after book by the fire while the computer collects dust. :) For instance, I'm reading SQL books now and have done experiments that I then wrote about. Like transaction isolation levels, deferrable constraints, types/domains.

Lots of fun stuff to build. I find that the books help to give me a broader idea of the possibilities, that's all.

← PreviousPage 2 of 5Next →