HNHacker News
TopNewBestAskShowJobs

zaidhaan

47 karma · joined December 17, 2020

submissionscomments
zaidhaan··on Play snake in the URL address bar
I am not aware of any approaches that work consistently across all major browsers. This matter is nothing new -- there's a Bugzilla report[0] from 13 years ago about this behavior that remains open.

Since there's no spec for global history and it's unlikely one will be introduced, the most practical solution to avoid flooding the browser history would be to debounce the changes.

This is the approach taken by Google Maps -- with maps being a well-known case where URL updates would clutter the history, as noted in the Bugzilla report.

[0] https://bugzilla.mozilla.org/show_bug.cgi?id=753264

zaidhaan··on Play snake in the URL address bar
One thing to note about these two APIs is that they affect how the session history (the back/forward stack) behaves, but the global browser history (entries shown in the History tab) is separate.

Most browsers record every change in the global history regardless of whether `history.pushState` or `history.replaceState` is used. The HTML Spec[0] is explicit about session history but does not define how global history should behave.

I can understand why the spec makes no mention of this -- global history is a user-facing UI feature, similar to address bar autocomplete, and it makes sense for browsers to control this behavior. That said, I'm always annoyed when I look into my history tab after visiting a page like this (e.g. Vercel Domains[1]), and see my global history flooded with entries for each individual keystroke I've made, all in the name of "user experience".

In this particular case, it's just a fun gimmick, but for everyday websites I'd much prefer if they just debounced the updates to the URL to avoid cluttering the global history.

[0]: https://html.spec.whatwg.org/#navigation-and-session-history

[1]: https://vercel.com/domains

zaidhaan··on I Made an Extended Version of Vimtutor – Introducing Vimtutor Sequel
I too share your sentiment about VS Code. Its extension API[0] is extensive and approachable, often with examples[1] for each API.

Just a small anecdote: At work, I found it frustrating not being able to quickly locate where views for Django API endpoints were, so I wrote a simple extension that took the output of django-extensions' show_urls, parsed it, and displayed a quick pick list of all API endpoints, upon which selecting an endpoint would open the file and reveal the exact line in which the view for it was defined.

Implementing this did not take much effort (in fact, TypeScript and JSDoc make everything a lot simpler as it's clear to see what each function in the API does and what arguments they accept), and now this is something I use almost every day and greatly improves my satisfaction when navigating the codebase if not my productivity in general.

I have tried looking into implementing something similar in Neovim and came across the API for telescope.nvim[2], but found it a lot less intuitive to use. I do think Vim/Neovim shines when it comes to text manipulation and extensions built around it, but when it comes to more complex UI that often deals a lot more with graphical elements (e.g. tree views, hover text, notifications), it's hard to beat VS Code.

[0]: https://code.visualstudio.com/api/references/vscode-api

[1]: https://github.com/microsoft/vscode-extension-samples

[2]: https://github.com/nvim-telescope/telescope.nvim/blob/master...

zaidhaan··on Ugrep – a more powerful, fast, user-friendly, compatible grep
A little off-topic, but I'd love to see a tool similar to this that provides real-time previews for an entire shell pipeline which, most importantly, integrates into the shell. This allows for leveraging the completion system to complete command-line flags and using the line editor to navigate the pipeline.

In zsh, the closest thing I've gotten to this was to bind Ctrl-\ to the `accept-and-hold` zle widget, which executes what is in the current buffer while still retaining it and the cursor position. That gets me close (no more ^P^B^B^B^B for editing), but I'd much rather see the result of the pipeline in real-time rather than having to manually hit a key whenever I want to see the result.

zaidhaan··on Rep and Ren: A new approach to CLI find, replace, and renaming
Honestly, upon further thought I think it should be fine as long as the diffs look good.

I just personally would feel more confident with using perl for anything to do with multi-file substitutions. In theory, ripgrep with `--passthru` and `-r` should work.

zaidhaan··on Rep and Ren: A new approach to CLI find, replace, and renaming
It might be worth noting that while ripgrep doesn't support in-place file editing, it's still possible to replace matches using the `-r` flag, couple that with a tool like `sponge` from moreutils[0] and you can effectively perform search and place like such:

    $ rg --passthru search -r replace file.txt | sponge file.txt
And preview changes like this:

    $ rg --passthru search -r replace file.txt | diff -u file.txt -
Of course, this is only practical when working with a single file. Though I'd imagine if one threw in the `--files-with-matches -0` flags together and piped that into `xargs`, something similar to `rep` could be be achieved. (Not that I'd encourage anyone to do this at all)

[0] https://joeyh.name/code/moreutils/

zaidhaan··on Zsh tricks you may not know
The author has also written a few other similar articles[0] that are also worth taking a look at.

[0] https://hn.algolia.com/?q=zsh%20tricks%20you%20may%20not%20k...

zaidhaan··on Learning Some Logarithms
I'm very fond of looking at problems in a different light to come up with solutions or approximations that can be computed with ease mentally. Do any folks here have pointers to related techniques or resources?
zaidhaan··on Ask HN: What's a good open-source alternative to Cloudflare?
One thing I really appreciate about Wikimedia is the openness and quality of documentation for their infrastructure (which can be found at https://wikitech.wikimedia.org/wiki/Wikimedia_infrastructure).

It's an excellent resource for anyone curious to learn about their systems. I wish more organizations would embrace transparency and open-source principles as much as Wikimedia does.

zaidhaan··on Diff Models – A New Way to Edit Code
They do note that the models "tend to do better when prompted with longer code generation tasks".

But yes, the choice of scales for the graph was rather peculiar.

zaidhaan··on Show HN: GPT-3 Powered Shell
Pretty cool! Does anyone know how open-source alternatives like GPT-J compare to ChatGPT? I've heard that it's comparable to GPT-3, but nothing close to GPT-3.5. I'd much prefer using a tool that I know won't eventually be put behind a paywall.
zaidhaan··on Swing Ratio
The brython appears to only have been used for SVG manipulation. I would have been more interested in seeing the audio being generated dynamically based on the swing ratio, but instead it just plays pre-rendered mp3s.
zaidhaan··on Actually Portable Perl
What do you typically use perl for? I thought it was most commonly used for scripting and running cgi scripts. I find bash to be much more readable and tend to use it or python for most of my scripts
zaidhaan··on Crows are capable of recursion, scientists claim
Thanks for the clarification. That seems fair, I suppose the title of the article gave me the impression that they were claiming such an ability would be widespread in all crows (despite the study being done on two carrion crows), when in fact it seems the intention was to state that the ability can exist in any crow given that they proved it exists for those two specific crows.
zaidhaan··on Crows are capable of recursion, scientists claim
Not sure why I got downvoted. If my assumption is wrong then I'd be really curious to hear from someone that knows better.
zaidhaan··on Crows are capable of recursion, scientists claim
> Adapting the protocol used in the 2020 paper, the team trained two crows to peck pairs of brackets in a center-embedded recursive sequence.

> Two of the three monkeys in the experiment generated recursive sequences more often than nonrecursive sequences ...

I'm no academic but aren't those extremely small sample sizes to make any reasonable deductions from? This looks to be even addressed in one of the papers cited...

> While a sample size of two is not enough to infer that any crow in the population may generate center-embedded recursive sequences, we present a "proof of existence" showing that this cognitive capacity is, in principle, within the reach of carrion crows.[0]

[0] https://www.science.org/doi/10.1126/sciadv.abq3356

zaidhaan··on Katamari Hack (2011)
To get it to work, I just copied the contents of both the scripts using the command below and ran it in the developer console.

    wget -q -O - http://kathack.com/js/kh.js http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js | xclip -sel c
zaidhaan··on Tupper's Self-Referential Formula
Link to the paper: https://www.dgp.toronto.edu/~mooncake/papers/SIGGRAPH2001_Tu...
zaidhaan··on Ask HN: What are some good tech magazines?
Hackaday is also great for folks interested in hardware hacking or electronics in general.

https://hackaday.com/

zaidhaan··on Ask HN: Why the $200 Overhead on Dell XPS Laptops with Linux?
Yep, totally. I had some issues with Bluetooth coexistence on my Realtek WiFi card, tried installing various different drivers but nothing fixed it. Replaced it with an Intel one and it worked flawlessly.
zaidhaan··on Ask HN: Why the $200 Overhead on Dell XPS Laptops with Linux?
Exactly. I feel like the costs of swapping out such components for better ones likely wouldn't exceed $200.

Maybe pwg is right and the discounted price with Windows is due to the paid pre-installed software. But that still leaves the customer with complete freedom to install something else on it.

zaidhaan··on Ask HN: Why the $200 Overhead on Dell XPS Laptops with Linux?
A bit off-topic, but if that's the case, then why don't you just buy the Windows version, then wipe the disk and install Linux on it. You effectively save yourself $200.

Is there something I'm missing? Does selecting the developer version use different hardware that has better Linux support?

zaidhaan··on PCI-Sig Releases 256GBps PCIe 6.0 X16 Spec
As someone without a background in EE I find it fascinating how we are able to build hardware that operates and deals with data at high speeds that it needs to be debugged using statistical analysis.

How is it even possible to have correctly functioning circuits at such high speeds? I'm guessing at the very bottom of the Phy layer there several transistors switching at incredibly fast speeds. I understand that these transistors have several parameters such as their delay, rise, and fall time. Things most certainly don't happen instantaneously, a few logic ICs I played with also have a propagation delay time specified in their data sheets lasting a few nanoseconds.

Take the deserializer for an example, happening at 16Gb/s, which if I understand correctly equates to 1 bit every 62.5ps (0.0625ns). How does any circuit affected by the parameters I just talked about handle signals at such high speeds?

(Please go easy on me, I know some of my assumptions are probably wrong or oversimplified but I would love to learn more)

zaidhaan··on Linuxgems – A succinct cheat sheet for newbie Linux coders and sysadmins
This is a pretty decent cheat sheet. It might be worth noting that not all these commands may be available on every Linux distribution. In fact, there is no set of commands or packages guaranteed to be installed on every distro.

Though I'd guess that most distros should have bash[0], coreutils[1], findutils[2], util-linux[3], procps[4], as well as the usual text wrangling commands such as grep(1), sed(1), and awk(1).

From there on, browsing through man pages is a great way of gaining a deep understanding of a specific command. However, man pages are often too verbose and technical for those unfamiliar with the command. So prior to viewing man pages I find it useful to use cheat.sh[5] to see what my typical use cases of a command are, I then consult the manuals to figure out what each option means.

Eg.

    $ curl cht.sh/tldr:tar
    ...
    # Create an archive from files:
    tar cf target.tar file1 file2 file3

    # Create a gzipped archive:
    tar czf target.tar.gz file1 file2 file3
    ...
[0] https://www.gnu.org/software/bash/

[1] https://www.gnu.org/software/coreutils/

[2] https://www.gnu.org/software/findutils/

[3] https://en.wikipedia.org/wiki/Util-linux

[4] https://gitlab.com/procps-ng/procps

[5] https://github.com/chubin/cheat.sh