1. 1

    My .vim directory is published at github.com/roryokane/dotvim/. Its vimrc file is 1143 lines long. I based it off the 150-line Vim Tips wiki example vimrc when I started using Vim 9 years ago, and added to it over time.

    My config has a simple structure: it’s a .vim folder containing vimrc and gvimrc files that you can link to your home folder using the commands in the README. Though my vimrc is one big file, headers in comments organize it into sections: must-have features, Vundle plugins, plugin settings, options, indentation options, mapping and commands, mappings that rely on other mappings, autocommands, and a todo list.

    Every setting change in my vimrc is accompanied by a descriptive comment. I also have many comments that explain the reason for the change or are TODOs for ways I could improve the behavior of that setting in the future.

    I use Vundle for plugin installation. Though dein.vim is newer and some praise it, I’m not convinced that the extra verbosity it requires is worth the small performance improvement.

    I do opt into Vim 8’s new defaults with source $VIMRUNTIME/defaults.vim (see :help defaults.vim), but I haven’t removed the redundant settings from my vimrc yet because I haven’t checked which of those defaults Neovim also provides. Though the only client I currently use is MacVim, which is based on Vim 8, I want to keep my vimrc compatible with Neovim to ease migration to it whenever a good GUI for it is finally available.

    Though I love Vim’s system of keybindings, I’m getting tired of living without or reimplementing common features of newer text editors, such as easy-to-use Find and Replace and proportional-width fonts. Because of the limitations of Vim I have been noticing, I haven’t been updating my Vim config much recently. (Emacs has similar problems – for example, unlike all other editors, it has no concept of untitled files with no location on disk, so I would have to set up that feature myself.) For large projects I would rather use one of the JetBrains IDEs and the excellent IdeaVim plugin for it, which can understand mappings in my vimrc. For small files that I want to quickly open, I am trying out VS Code. Its modern conveniences may make up for the lack of Vim-compatibility in its Vim keybinding emulations, which makes its Vim emulation worse than the editor’s regular keybindings.

    1. 2

      I can’t reach this page at all, and the cached version doesn’t seem to work either. It fails saying “The page isn’t redirecting properly / An error occurred during a connection to www.ispreview.co.uk. / This problem can sometimes be caused by disabling or refusing to accept cookies.” But I turned off my ad blocker and “enhanced tracking protection” in Firefox and got the same error.

      Brave threw a slightly different error saying “This page isn’t workingwww.ispreview.co.uk redirected you too many times. Try clearing your cookies. ERR_TOO_MANY_REDIRECTS”

      1. 2

        Both the live page and the cached version are loading fine for me. If they still aren’t working for you, try the Wayback Machine, which also loads for me.

        1. 1

          Interesting, the Wayback Machine works, but neither the live page nor archive.is are working. At least I can read the article now!

          1. 5

            Are you using cloudflare DNS? I remember a recent post here about an issue with archive.is

            1. 2

              Wow, you’re psychic! I am indeed using 1.1.1.1.

      1. 3

        I think these alerts would look better if the grow-in animation were shorter. The bounce effect is so slow and large (compared to other UI animations) that the movement distracts me for a moment from the content of the alert. This makes the alert feel slow and unsteady instead of fluid.

        1. 4

          Can we stop describing software as “beautiful” already?

          1. 2

            Yeah, every time I see a headline like this, I kind of don’t want to click, because I will be like “meh, nice, but beautiful??”..

            Went through and had a look on these. The popups look nice. Author did a good job.

            1. 1

              I’ve never heard any other software describe itself as beautiful before, but I don’t think calling software beautiful is always bad. For example, I like to think that the code of my Bad Code Rocks contest entry is beautiful in how convoluted it manages to be. However, I agree that when trying the demo of this alerts library, I don’t find the alerts beautiful compared to other modal dialog libraries. Maybe “beautiful” is supposed to be relative to the browser’s built-in alert dialogs?

              1. 0

                Every 2nd app on AppStore says it does the same thing as all other apps in its category, but THIS one is beautiful.

                edit: OK, maybe not exactly every 2nd, but there are a lot of those apps.

              2. 1

                I agree with you. So I changed to “Cool”. Cool is cool? ^^

              1. 5
                My own email troubleshooting story

                I had a similar problem with my Gmail account a few months ago. All email sent (by others) to my personal email on my own domain is forwarded to a Gmail address, from where I read it. At some point, without me having changed my email habits or anything, I noticed that my inbox was missing emails that should have been sent. The emails weren’t in my spam folder – they were just missing. After a few weeks of mild confusion, I checked the mail forwarding logs on my web host and saw that Google was rejecting the forwarded mail.

                I went through the same troubleshooting journey as in the post – finding troubleshooting steps only for G Suite owners, and signing up for Postmaster Tools only to be told that they can’t tell me anything about my domain because I’m not a mass email sender.

                Then, somewhere, I read that Gmail should accept the incoming emails if you verify ownership of that custom-domain address such that you can send email “From” that address. I already had such an authorization from long ago, but I tried deleting it and adding it again, once again verifying my ownership of that address.

                A week or two later, I checked my inbox, and I had received all the emails that I should have received in that period. A week after that, I checked the logs, and found no more bounces. The bounce problem went away as silently as it had arrived. I don’t know if that last re-verification step helped fix the problem or if Google merely improved their spam detection algorithm, but re-verification is worth trying if you haven’t.

                On switching email providers

                I considered switching email providers after that, but eventually decided to stick with Gmail. My main reason was its large amount of free storage for attachments. Another significant reason was that many of the alternative providers (including Fastmail) did not support categorizing emails with (multiple) labels, only with (single) folders. I’m surprised that support for labels is still so rare this long after Gmail popularized the concept.

                I’ve stopped looking for alternative providers for now, but ProtonMail sounds like a good option if you’re willing to pay at least €48.00 / yr for email. It supports labels, its web client is open source, and it has a free plan on which you can try the service first.

                1. 0

                  I went through the same troubleshooting journey as in the post – finding troubleshooting steps only for G Suite owners, and signing up for Postmaster Tools only to be told that they can’t tell me anything about my domain because I’m not a mass email and sender.

                  This so much. It’s no mistake that not assuming that I’m a G Suite customer is one of the points in my post. Every other commenter on Reddit somehow assumed the very same thing, even though it’s mentioned in my post right away in the second paragraph!


                  Then, somewhere, I read that Gmail should accept the incoming emails if you verify ownership of that custom-domain address such that you can send email “From” that address. I already had such an authorization from long ago, but I tried deleting it and adding it again, once again verifying my ownership of that address.

                  This is a very bad advice, because they don’t let you add any From email addresses any longer. If you delete yours, you won’t be able to add it back, without giving authentication credentials. And I’m just a bit too lazy to setup separate account just for Google here; and obviously won’t be giving them access to the main ones.

                  1. 2

                    This is a very bad advice, because they don’t let you add any From email addresses any longer. If you delete yours, you won’t be able to add it back, without giving authentication credentials.

                    I’m not sure what you mean by this. I deleted and re-added my custom domain’s email in the middle of June, and Google authenticated my ownership by sending me an email “Gmail Confirmation - Send Mail as roryokane@example.com”. The email contained a numeric confirmation code that I could paste into the appropriate section of Gmail’s settings. I don’t remember having to deal with anything I would call “authentication credentials”. Has the process changed in the last four months?

                    1. 2

                      Google Mail has started requiring SMTP credentials for any new From addresses since a few years ago or so. It’s not possible to add a new From address without providing the SMTP credentials anymore. It’s quite a bummer, really, because some alias addresses from certain services (like the various OSS projects) don’t even come with outgoing SMTP access.

                1. 16

                  Alternatively, you can use repostatus.org’s “Abandoned” or “Unsupported” badges:

                  • Abandoned – Initial development has started, but there has not yet been a stable, usable release; the project has been abandoned and the author(s) do not intend on continuing development.
                  • Unsupported – The project has reached a stable, usable state but the author(s) have ceased all work on it. A new maintainer may be desired.

                  repostatus.org is a similar project that defines eight statuses you can mark repos with: Concept, WIP, Suspended, Abandoned, Active, Inactive, Unsupported, or Moved. Each badge links to a short summary such as the ones above.

                  It looks like No Maintenance Intended might explain the project status better with its dedicated web page, while repostatus.org is better for being able to categorize the state of all of one’s projects.

                  1. 8

                    Repostatus sure feels more thought out. “No Maintenance Intended” is vague and open to interpretation, see this HN thread for the same submission.

                    Shouldn’t the badge have a green checkmark to show everything’s ok? Or is no maintenance intended supposed to imply your code is broken?

                    1. 1

                      Seems like ‘no maintenance intended’ means ‘don’t bother me about it’ – i.e., if it’s broken then fork it.

                  1. 2

                    A description of Hedgewars and screenshots were harder to find than they should have been.

                    Hedgewars is a turn based strategy, artillery, action and comedy game, featuring the antics of pink hedgehogs with attitude as they battle from the depths of hell to the depths of space.

                    Basically, it’s an open-source clone of Worms.

                    1. 5

                      Textual summary:

                      • With the Bottle web framework on the back end:

                        • Define a route GET /viewcounter?url=… that reads that page’s viewcount from the website.viewcount column in a database and returns it in a JSON response.
                        • Define a route POST /viewcounter?url=… that increments the viewcount for that page.
                          • The view count is updated probabilistically – incremented by 10, with a 1 in 10 chance. This is presumably to make it harder to detect exactly when other users view the page.
                      • In the layout HTML file with the template for all pages, put a script tag that runs at page load. In that script:

                        • Read the current URL from window.location to pass to the subsequent requests.
                        • Use fetch to hit the GET route defined above, then read the views field from the returned JSON data and put its text on the page inside the #views element.
                        • Use navigator.sendBeacon to hit the POST route defined above. (Since this runs on page load, just loading the page registers a view.)
                      1. 2

                        Thanks for getting it onto writing.

                        • Just to give some more info, the data is stored in a Postgresql server.
                        • The Bottle web app is running on AWS Lambda, using a custom WSGI wrapper I wrote.
                      1. 1

                        Note that this new heuristic is not consistent – it will overestimate the distance of paths that cross more chunk boundaries. A* is only guaranteed to give an optimal path when used with a consistent heuristic. With the new heuristic, units will sometimes take suboptimal paths.

                        This performance improvement is probably still worth it though, because the gameplay doesn’t require units to have perfectly optimal pathing to be fun.

                        1. 43

                          I would guess that a very substantial proportion of the people who read Lobsters have heard of Timsort.

                          1. 22

                            That, and TimSort really only makes sense in certain situations:

                            • Comparisons have to be extremely expensive. Think dynamic dispatch. This is because TimSort itself performs a bunch of branches and integer comparisons to keep track of galloping scores and the stack invariant.

                            • You need a stable sort. If you don’t need a stable sort, pattern defeating quicksort will probably do better.

                            1. 11

                              Quicksort is the Achilles of sorting algorithms: unbeatably fast, easy to implement, in-place; but with the vulnerable heel of bad worst-case performance (the worst case being pre-sorted data in the naïve implementation) and instability.

                              1. 5

                                There’s a fairly easy fix to that, called introsort: start with quicksort, but bail out to a guaranteed O(n log n) sort like heapsort if it takes too long. In the bail-out case, you lose constant-factor performance compared to if you had used heapsort in the first place, but you avoid quicksort’s O(n^2) worst case, while still getting its good performance in non-pathological cases. It’s used in practice in .NET and some C++ STL implementations.

                                1. 3

                                  Quicksort -> Heapsort is method I used. It worked fine in practice. I love solutions like that. Another, unrelated one was sklogic’s trick of using a fast, dumb parser first to see if it’s correct. If it wasn’t, he switched to one that made error messages easier.

                                  I bet there’s more of this stuff waiting to be found for situations where people are shoving every case into one algorithm.

                              2. 4

                                Comparisons have to be extremely expensive. Think dynamic dispatch.

                                That explains why Python uses it as it’s standard sort.

                                1. 9

                                  Yeah. That’s exactly why Python uses TimSort.

                                  More tellingly, where Rust uses an algorithm that’s related to TimSort for its stable sorting algorithm, they didn’t implement “galloping” because it’s not worth it. https://github.com/rust-lang/rust/blob/7130fc54e05e247f93c7ecc2d10f56b314c97831/src/liballoc/slice.rs#L917

                              3. 10

                                I consider myself relatively knowledgeable about many different topics of CS and had not heard of Timsort until this article. What’s the point of your comment? That the article is not worth posting as you presume that it is widely known?

                                1. 4

                                  The point is that the title of the article, and of this submission, is inaccurate. I would call the title clickbait because for most readers, the article doesn’t deliver what it promises – a sorting algorithm “you’ve” never heard of. I think the article itself is fine; it’s just the title that is a lie.

                                  1. 5

                                    That seems to be a really low-value comment. For whom is the remark actually intended? For other crustaceans to look at, nod and agree, thinking, “yes, I too possess the superior knowledge”? Does every submission with a title that invokes “you” need to be correct and ‘deliver on its promise’ for all possible “you”s? C’mon.

                                    1. 4

                                      Yes, I suppose jgb could have been more explicit in why they brought up their guess. (I wrote an explanation of my interpretation of the comment, not the original comment.)

                                      Does every submission with a title that invokes “you” need to be correct and ‘deliver on its promise’ for all possible “you”s?

                                      I think every article with a title that invokes “you” needs to be correct and ‘deliver on its promise’ for the majority of possible “you”s in its audience. If a title says “you’ll love this” and most readers don’t love it, the title was wrong, and it wasted people’s time by getting them to open the article on false pretenses. It is up to article authors to adhere to that principle or not.

                                      As for titles of submissions of articles with clickbait titles, there can be a conflict between submission titles that reflect the author’s intent and titles that accurately describe the article. I don’t have a simple answer as to when submission titles should differ from the article title.

                                      1. 3

                                        I think every article with a title that invokes “you” needs to be correct and ‘deliver on its promise’ for the majority of possible “you”s in its audience.

                                        I think I agree with this, and I think my concern comes down to disagreeing instead with the notion that the majority(/“a very substantial proportion”) of Lobsters readers have heard of Timsort. Short of a poll there’s not an actual answer to that; I just felt particularly rankled because I hadn’t, and presumably if I had I wouldn’t have bothered or thought to comment myself.

                                        I err on the side of preserving the article title in the submission, which I think is pretty common. Accordingly, I think most Lobsters are primed to see submission titles that aren’t necessarily addressing them as Lobsters readers, but in some context that might be quite removed.

                                2. 2

                                  I thought it played a pretty big role in the Oracle vs. Google lawsuit too, making it one of the more famous algorihtms.

                                  However see “rangeCheck” mentioned a lot, which is a trivial part of TimSort.

                                  https://en.wikipedia.org/wiki/Oracle_America,_Inc._v._Google,_Inc.

                                  Here it seems to cite TimSort. But for some reason I can’t find a lot of sources that talk about TimSort and the lawsuit, even though at the time I remember it being a prominent thing.

                                  https://forums.appleinsider.com/discussion/149435/google-engineers-defend-source-code-email-in-oracle-lawsuit-over-java/p4


                                  edit: here’s another one mentioning TimSort and the lawsuit.

                                  https://majadhondt.wordpress.com/2012/05/16/googles-9-lines/

                                  Googling “rangeCheck timsort lawsuit” digs up some results.

                                1. 3

                                  I like the idea of the unit testing feature, as can be seen in the time.rpl example:

                                  hour =  { [01] [0-9] } /
                                          { "2"  [0-3] } 
                                  -- test hour accepts "00", "15", "20", "23"
                                  -- test hour rejects "", "0", "5", "24", "99"
                                  
                                  …
                                  
                                  rfc2822_time = { hour ":" minute {":" second}? }
                                  -- test rfc2822_time accepts "00:00:00", "12:00", "23:59:60", "16:08:33", "01:55", 
                                  -- test rfc2822_time rejects "", "24:10:10", "33:40", "17:28:33.0", "00:00:00.00000", "10:30:02.125"
                                  

                                  I’m not convinced that Rosie Pattern Language is worth the complexity it adds compared to using a PEG parsing library for my preferred language. But I don’t know of any language-specific parsing library that makes tests-as-documentation as easy to write as the above. It makes me wonder how to port that feature to those other libraries.

                                  1. 1

                                    This website has already been posted three months ago, though not that part in particular. Is this a new part of the site?

                                    1. 1

                                      The Sidebar page existed three months ago; it is not new. Evidence: this third-party Sidebar implementation written the day of that post.

                                    1. 6

                                      According to @pushcx two months ago, there is currently no page that lists all of your comments: https://lobste.rs/s/cgtc2w/happy_7th_anniversary_lobsters#c_hfknb5.

                                      Approaches for implementing this feature

                                      Around the time of that thread, I looked into how to edit the Lobsters source code to add this feature, though I didn’t get as far as a patch. The “Your Threads” page runs the CommentsController#threads action. That action includes a call @showing_user.recent_threads(20, …, …). In that call to #recent_threads, 20 is the amount argument, which is used as a LIMIT clause in the query. So one way to implement this would be to paginate the “Your Threads” page and change User#recent_threads to take an offset as well as a limit.

                                      Another way to allow seeing your old comments would be to introduce new UI to the Comments page, which is different from Your Threads in that it shows comments without the context of the whole thread, and it already supports pagination. The /comments and /comments/page/2 URLs could be made to accept a user parameter like /comments/shawn and /comments/shawn/page/2, similar to the existing /threads/:user route. The user parameter would filter the displayed comments to only those by that user. Implementing that would require changing CommentsController#index to filter the comments if that parameter exists. UI to set that URL parameter would be nice but probably not necessary for the first version.

                                      I stopped short of implementing one of these approaches and making a pull request because I ran into difficulties setting up a local version of Lobsters to test changes on. If I get Lobsters running locally, there is another, smaller code change I would contribute first, to make sure I have the process down. So if anyone wants to try implementing one of the approaches above, please, go ahead.

                                      Can any Lobsters maintainer comment on whether the “paginated full comment history” feature would be accepted if a pull request were made? Right now other users’ comment history is limited to their last 20 comments – that isn’t a deliberate design decision, right?

                                      1. 3

                                        Can any Lobsters maintainer comment on whether the “paginated full comment history” feature would be accepted if a pull request were made? Right now other users’ comment history is limited to their last 20 comments – that isn’t a deliberate design decision, right?

                                        I do not understand limiting comment history to the last 20 comments to be a deliberate design decision, and I have from time to time wanted to look further back in my own comment history. Consistent with the PR being of sufficient quality to merge I don’t see a prima facie reason this specific feature would be rejected.

                                        1. 2

                                          IIRC the issue stems from a desire to Do Pagination In Lobsters Correctly And Consistently Errywhere, but my data is at best many months old.

                                        2. 2

                                          Thanks for the detailed and correct post. The page has always had the last 20 threads a user has commented on, and the lack of pagination is not considered a feature.

                                          @friendlysock is correct below that this is a “perfect is the enemy of good” thing. I attempted a fix with pagy (seemed appropriately small with a straightforward API) but it had a bug with bad user input the maintainer wontfixed saying it’s OK if a site 500s because a user edited a URL. I’d also like the pagination to be stable, so oldest stuff has the lowest page number and doesn’t change page number as new stories/comments come in. I dunno how to handle the latest pages like /comments when they aren’t a “full page” of 20 comments, though, as having that page list one or two comments is lousy and having it list 20-39 is weird. So I figured I’d like it simmer in the background and see if I had any better idea in a few more months.

                                          1. 1

                                            I have discovered an existing GitHub issue about this feature: #394 “Feature: paginate all comments”

                                          1. 8

                                            There are arguments made that social media causes harm to others (e.g. polarization, isolation, and anxiety). Futhermore, many believe they are harmed by a loss of privacy from the advertising strategies of Google, Facebook, and others. The EU has taken these concerns very seriously and the US has been in a heated debate on the role of social media companies in society. A fair amount of open-source contributors are employed by such companies.

                                            The point I’m making is not whether social media and advertising causes harm, but that what causes harm is highly politicized and subjective. Software development is not the same as practicing medicine.

                                            1. 0

                                              It is true that harm is subjective, but that doesn’t seem to be a problem for this license as currently written. Subjectivity isn’t a problem for the license because it implicitly uses the software user’s definition of harm (not the licensor’s or anyone else’s).

                                              How I came to that conclusion: the restriction on use of the software only applies to “systems or activities that actively and knowingly” harm someone’s well-being. In my interpretation, “knowingly” means that the user of the software must think they are causing harm for that rule to apply. So even if most people think that, for example, social media software is harmful, the license wouldn’t forbid a Facebook employee from using the licensed software as long as that employee personally doesn’t “know” that social media is harmful.

                                              Of course, enforcing that could be difficult, because if you accuse the software user of causing harm and they respond that they didn’t think they were causing harm, there is no way to know whether they are telling the truth about their thoughts. But that’s a separate problem.

                                              1. 2

                                                In my interpretation, “knowingly” means that the user of the software must think they are causing harm for that rule to apply.

                                                What you said may be textually correct, but it is easily weaponized. It can be argued that Google and Facebook are lying, like Big Tobacco. Sean Parker, a Facebook founder, said they knowingly created an addictive platform. Other executives and developers have made similar statements about ‘knowing’. There are also studies that can be cited. Therefore, it could be argued that such employees knowingly cause harm.

                                                Again, I’m not making this argument. I’m just making a point.

                                                If the open-source community advocates this license, many could argue that is not Hippocratic but instead hypocritical. The open-source community is sponsored to a great extent by social media and advertisers.

                                                EDIT: ‘many could argue that this is not Hippocratic but instead hypocritical.’

                                            1. 9

                                              There was an argument on Twitter about whether this actually protects people: if I decide an oil company that’s harming the environment is using my software, can I yank it from them under this license? I’d be harming their economic well-being.

                                              1. 12

                                                What happens when this gets weaponizes by someone who doesn’t want to support homosexuality or companies supporting it. Same for gun control or health insurance or the issue of the day. I don’t like putting kids in cages but I worry that this carve out idea has major flaws.

                                                What if someone decides that my Judaism and its Zionism should exclude me? I feel personally threatened by this.

                                                1. 1

                                                  Sadly I think this is more likely than say, a human rights violating military giving a shit about it.

                                                  Strangely enough complying with licences is not high on the agenda for torturers.

                                                  I know from The Bad Old days of Apartheid the sanctions only applied to innocent governmental activities like water supply… the military honestly didn’t give them a seconds thought.. if they needed software or a machine or whatever they’d lie, steal, put up fronts conceal whatever.

                                                  1. 2

                                                    Many kinds of entity are able to ignore these clauses.

                                                    However, there’s at least one growing group that can’t: companies who are selling to foreign governments (eg US companies selling tech to the Chinese government).

                                                    The US government isn’t going out of its way protect them, and the Chinese government can’t offer much protection from US courts.

                                                    1. 1

                                                      US companies selling tech to the Chinese government

                                                      You mean US companies openly selling tech to the evil entity that is openly using it.

                                                      In the Bad Old Days, US arms dealers quite liked sanctions…

                                                      US government regulations don’t mean “you cant do a deal”.

                                                      They mean the deals have to be done “at arms length” with a bit of forgery in the middle.

                                                      Meaning the salesdroids get to clip the ticket several times instead of just once.

                                                      Unsurprisingly, arms dealers are not very nice people.

                                                      1. 1

                                                        It sounds like you are saying (in a very roundabout way) “Yes, using this licence will increase the price paid by Bad Guys for technology, since they’ll have to do their deals at arms length”.

                                                        1. 1

                                                          That is an optimistic interpretation of what I’m saying, yes.

                                                          In practice since they are breaking (or bending to near breaking) some laws…. they tend to break any that will cost money. (eg. Getting export permits, paying tax… etc.)

                                                2. 3

                                                  The most relevant part of the license for that question would be this:

                                                  The software may not be used by individuals … for … activities … that actively and knowingly … harm … the … economic … well-being of groups in violation of the United Nations Universal Declaration of Human Rights.

                                                  But revoking a license is not using the software. The restriction doesn’t apply to the license holder’s activities of licensing. So my answer is yes, you could revoke the license in that situation.

                                                  (I am not a lawyer.)

                                                1. 1

                                                  C++: I like the elegance of the idea that you can wrap { } around any group of statements to be able to write it where a single statement is syntactically required.

                                                  1. 13

                                                    I use the Fish shell’s abbr (abbreviation) feature for my typing-saving Git aliases. Because Fish replaces the abbreviation with the full command before the command is logged and run, I can more easily spot when I ran certain Git commands when I browse my shell session or search through my command history.

                                                    For example, after defining this abbreviation:

                                                    abbr --add gitst "git status"
                                                    

                                                    I can type gitst in my prompt:

                                                    $ gitst
                                                    

                                                    But after pressing Enter, my session looks like this:

                                                    $ git status
                                                    …
                                                    nothing to commit, working tree clean
                                                    

                                                    Then, if I leave my shell and go back to it later, I can see that I just ran git status. I don’t have to remember what gitst stands for.

                                                    Along the same lines, I can see the long form of flags in my history while spending as much time typing as if I had written their short forms. My gitspu abbreviation expands to git stash push --include-untracked, which is easier to read than git stash push -u.

                                                    1. 7

                                                      I recommend against implementing a drop-down as described in the article, even for simple use-cases. The resulting drop-down doesn’t support keyboard shortcuts such as pressing Tab to focus the drop-down, or pressing Space to open the drop-down and select a value, up/down arrows to select a value, or typing the first letter of a value to select it. This lack of functionality will slow advanced users down, and will prevent users with certain disabilities from using the page.

                                                      If the styling available for the built-in select and option is not enough, I recommend one of those existing “javascript libraries and css frameworks, which have own implementation for custom select dropdowns” mentioned by the article.

                                                      I would expect an article about implementing custom form elements to at least mention the technique of using a label to make your custom elements control an actual select element behind the scenes. With how useless this article is and how many ads are on the linked page, this submission is dangerously close to spam.

                                                      1. 1

                                                        The work-around I found is console.log("x: " + JSON.stringify(x));

                                                        1. 1

                                                          If you need to explicitly convert the object to a string like this, the output will be easier to read if you pretty-print it. You can do this by passing JSON.stringify a value such as 2 or '\t' for its third argument, space:

                                                          console.log("x: " + JSON.stringify(x, null, 2));
                                                          
                                                        1. 1

                                                          Nice tip ! Still I don’t get what differs between the two ways of calling console.log. Does someone has a deeper explanation ?

                                                          1. 3

                                                            This console.log call logs a string:

                                                            console.log("user: " + user);
                                                            

                                                            This string is defined by "user: " + user. The + operator with a string on the left implicitly calls .toString() on its right argument, user in this case. But the default implementation of toString for all objects, such as this user object, returns only the string [object Object]`.

                                                            Both of the following console.log calls log an object:

                                                            console.log(user);
                                                            console.log({user});
                                                            

                                                            No strings are involved here. console.log doesn’t call toString to show user; it uses the JavaScript runtime to reflect on the object keys and values directly and shows a special UI for browsing them.

                                                            As others have mentioned, you can also call console.log like this, which logs a string and then separately logs an object on the same line, with no + operator causing .toString() to be called:

                                                            console.log('user:', user)
                                                            
                                                            1. 1

                                                              That makes perfect sens to me, thank you for the anwser :)