HackerTrans
TopNewTrendsCommentsPastAskShowJobs

zaidhaan

no profile record

Submissions

Rosetta Code

rosettacode.org
1 points·by zaidhaan·3 anni fa·0 comments

Zsh tricks you may not know

leahneukirchen.org
1 points·by zaidhaan·3 anni fa·1 comments

Tupper's self-referential formula

en.wikipedia.org
1 points·by zaidhaan·4 anni fa·1 comments

comments

zaidhaan
·10 mesi fa·discuss
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
·10 mesi fa·discuss
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
·2 anni fa·discuss
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
·3 anni fa·discuss
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
·3 anni fa·discuss
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
·3 anni fa·discuss
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
·3 anni fa·discuss
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
·3 anni fa·discuss
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
·3 anni fa·discuss
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
·3 anni fa·discuss
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
·4 anni fa·discuss
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
·4 anni fa·discuss
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
·4 anni fa·discuss
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
·4 anni fa·discuss
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
·4 anni fa·discuss
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
·4 anni fa·discuss
> 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
·4 anni fa·discuss
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
·4 anni fa·discuss
Link to the paper: https://www.dgp.toronto.edu/~mooncake/papers/SIGGRAPH2001_Tu...