1. 6

    I used to use go get for grabbing even non-Go repos but had to stop because of similar workflow breaks over the past few years. I finally wrote a small tool to replace it I call grab https://github.com/jmhodges/grab to take over my “fetch the code and organize it into a tidy directory system” need

    It actually uses the nice VCS library guts that go get does!

    1. 2

      https://github.com/jmhodges/grab

      This is not meant to be a gotcha, but should you update your own install instructions? I.e., tell people who are using go 1.16 or up to run go install github.com/jmhodges/grab@latest rather than go get github.com/jmhodges/grab. I ask—and this is why it’s not meant to be a gotcha—because I’m new to go, and I want to make sure I understand the new recommendations.

      1. 1

        Oh, this got fixed!

      1. 5

        PocketLang - a small, fast and friendly language for scripting and embedding

        From the GitHub page:

        The language is written using Wren Language and their wonderful book Crafting Interpreters as a reference.

      1. 4

        Nice, and simple to edit. My first edit would be to turn text black again, to increase contrast. What purpose does gray text on white background serve?

        1. 3

          My understanding is that black text is harder on the eyes than a very dark gray. E.g.

          https://uxmovement.com/content/why-you-should-never-use-pure-black-for-text-or-backgrounds/

          1. 2

            My thought too — if you feel the contrast is too high, it’s better for legibility to change the background to a faint sepia or very pale green. (Because science.)

            1. 7

              I largely agree with you, but if you justify your argument with science it’s usually better to link articles that support your claim.

          1. 2

            Looks fun. For anyone else who wants to try it out: MAX_TWEET_AGE="" expects a value like MAX_TWEET_AGE="72h". I was only able to figure out that the h was required by looking at the inspiration, ephemeral.

            1. 3

              By the same author: an occasional series on “non-trivial command-line” tips.

              https://www.netmeister.org/rtfmsh/

              1. 7

                TBH this whole article rests on the assumption that units have to be extremely small to count as unit tests. That obviously will lead to brittle and tautological tests. - so don’t do that.

                1. 4

                  There is no formal definition of what a unit is or how small it should be, but it’s mostly accepted that it corresponds to an individual function of a module (or method of an object).

                  Testing individual methods makes little sense to me. Usually there is some protocol for using multiple methods of a class. I would not test the File class methods open, read, write, close individually for example.

                  1. 2

                    I would not test the File class methods open, read, write, close individually for example.

                    To clarify, do you mean you wouldn’t test those methods in code that uses a file class library or that you wouldn’t test each one in the library itself that defines the file class?

                    I wouldn’t (directly) test, say, Python’s pathlib library in calling code, but I would definitely test those methods individually if I were writing pathlib. (I should add that I’m an amateur, so if you have reasons not to test individually, I’d love to hear them. My question is not rhetorical.)

                    1. 2

                      It isn’t even possible to test close without doing open, so you must do a combined test.

                      Methods often come with expectations in what order you use them. You can only read/write/close after open. A getter returns whatever a previous setter got.

                      1. 1

                        Thanks, that makes sense. I didn’t focus enough on individually.

                1. 1

                  I’m curious about the fonts:

                  --sans:1em/1.6 system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Droid Sans, Helvetica Neue, Fira Sans, sans-serif;
                  --mono:'Courier New', Courier, 'Ubuntu Mono', 'Liberation Mono', monospace;
                  

                  Why not include better options for the monospace fonts on Mac and Windows? E.g. SFMono-Regular, Consolas, Menlo, etc.

                  1. 2

                    Sure. Good suggestion.

                    1. 6

                      Git bug is actually amazing. At first I thought it was just a wrapper around GitHub/GitLab issues, but it actually tracks bugs in the git repo itself!

                      1. 1

                        This is really cool. Thanks for the endorsement, I’ll have to give it a try.

                      2. 0

                        Git has readonly web interface: https://git-scm.com/book/en/v2/Git-on-the-Server-GitWeb

                        cgit is also available: https://git.zx2c4.com/cgit/

                        1. 2

                          And there’s also stagit, for a totally static interface.

                          1. 1

                            Thank you! I hadn’t seen that.

                      1. 2

                        It is off by default, but a potentially immense change concerns the handling of nil and a new keyword undef.

                        http://lua-users.org/lists/lua-l/2018-03/msg00155.html

                        btw, I notice that there is a new keyword, “undef”, not mentions in manual, is that just a undocumented feature or the doc just not the latest?

                        I am grad you asked :-)

                        Lua 5.4 has an experimental change that is off by default (to keep compatibility). We plan to keep this off in Lua 5.4 final. You can turn it on by compiling this version with the option -DLUA_NILINTABLE. As the name hints, this option allows nils in tables:

                         t = {nil, nil, nil}
                         #t
                         3
                         for k,v in pairs(t) do print(k, v) end
                        1	nil
                        2	nil
                        3	nil
                        t[#t + 1] = nil
                        for k,v in pairs(t) do print(k, v) end
                        1	nil
                        2	nil
                        3	nil
                        4	nil
                        

                        Once you have nils in tables, t[i]=nil does not remove elements from a table anymore. For that, you need to write t[i]=undef.

                        No, this is not like JavaScript! ‘undef’ is NOT a value.

                        t[i]=undef is a special syntax form that means “remove the key ‘i’ from table ‘t’”. You can only use ‘undef’ in three specific forms:

                          t[i] = undef     -- remove a key from a table
                          t[i] == undef    -- test whether a table has a key
                          t[i] ~= undef    -- test whether a table has a key
                        

                        Any other use of ‘undef’ gives a syntax error.

                        You still can create tables with holes, but you must get out of your way to do it.

                        The nice thing about this syntax is that it is compatible with previous versions of Lua (as long as you do not use ‘undef’ for other stuff). In Lua 5.0/1/2/3, if you write ‘t[i] = undef’, you remove the element from the table. Even if we never change Lua to this new mode, even if you never use Lua 5.4, we think this syntax is a nice way to document whether an assignment is being done to remove an element from a table.

                        (A search for the pattern ‘][ =~]*nil’ finds most of the places in your code where you could/should use undef instead of nil.)

                        – Roberto

                        1. 3

                          Someone on Twitter pointed out to me that this is surprising (and maybe even a bug of sorts): Apparently Apple patches gem in such a way that it doesn’t install binaries to /usr/bin by default any longer.

                          But that is surprising because your post-update gem was trying to install to /usr/bin. Out of curiosity, what is the default install directory for gems in the defaults file (grep for if defined? RUBY_FRAMEWORK_VERSION):

                          /System/Library/Frameworks/Ruby.framework/Versions/<version>/usr/lib/ruby/<version>/rubygems/defaults.rb

                          I’m just wondering if the update to gem overwrote this patch. If so, that seems to be a bug: Apple tried to protect users from this kind of problem, but it should also forbid updating that defaults file.

                          Update A few people tried the same global gem update and reported that the it installs a new defaults.rb file in /Library/Ruby/Gems. That defaults file is then read before the one patched by Apple, and boom: breakage when gem tries to install to /usr/bin. A relatively easy fix might be to patch the new defaults.rb by hand, so that it matches the Apple patch. It’s trivial change. I mention all this for future Googlers, but it may also help you now. Good luck!

                          1. 5

                            I looked into this, found that the /usr/bin/gem update --system isn’t installing anywhere inside /usr/bin or within the system Ruby at /System; it doesn’t have permissions to do that. Instead, the rubygems update is installing a new rubygems at /Library/Ruby/Site/2.0.0/, which is a sudo-writeable location under SIP; that is loaded by Ruby first before the version that comes with the OS, and it includes a version of rubygems/defaults.rb which lists /usr/bin as the default gem bindir. If you remove /Library/Ruby/Site/2.0.0/rubygems and /Library/Ruby/Site/2.0.0/rubygems.rb, gem will go back to using the original system-installed version and all will be fine; alternately, you can patch /Library/Ruby/Site/2.0.0/rubygems/defaults.rb to change the bindir.

                            Before:

                            $ /usr/bin/ruby -e 'require "rubygems/defaults"; puts Gem.default_bindir'
                            /usr/bin
                            

                            After:

                            $ /usr/bin/ruby -e 'require "rubygems/defaults"; puts Gem.default_bindir'
                            /usr/local/bin
                            
                          1. 6

                            Taking something by a master and not reading their code until after a whack at the problem myself. http://norvig.com/ is a good source. Another was Thompson’s regex search paper – I did read it first, but the IBM 709 code was obscure enough to avoid spoilers. I’ve put this one up as a kind of problem set: https://github.com/darius/regexercise

                            If it’s a problem you’re interested in, you can’t really lose: you either get schooled or you find a wrinkle that your chosen master didn’t.

                            1. 4

                              I worked through Little Schemer like this. I would cover their answers and try on my own, then check, compare etc. It was a great experience: humbling in a good way.

                              Another book this works well for is K&R on C. There are tons of solutions to their exercises on Github, Bitbucket and personal websites. Try to solve first, then read around. Problem there, of course, is that the solutions are off very varied quality, and you don’t know in advance which are good, great, meh, terrible. Of course, you can think of that as training for reading real code: You never know what you’ll get.

                              1. 2

                                There’s an old book, The C Answer Book, for just this. (I haven’t read it.)

                            1. 8

                              So I should preface this by saying that I’m very much an amateur and self-taught. These definitely put the toy in toy implementation:

                              • btree: A kind-of, sort-of drop-in replacement for tree in shell. (Twice actually: once taking advantage of bashisms and once using POSIX shell syntax only.)
                              • toy-core: Minimal C implementation of a few basic utilities (cat, tail, head, and echo). I wanted to understand ring buffers better, so I was mostly interested in tail, but the whole thing was useful for practicing C.
                              • llisp: This was inspired by reading Mary Rose Cook’s Little Lisp interpreter. I started a mini-Lisp in Lua. I lost steam after getting the most basic functionality, but would like to go back to it someday.
                              1. 1

                                Also interesting, and partially a follow-up to Barthes' essay, is Michel Foucault’s “What is an author?”. The only copies I can find online are pdfs, but this site has good selections: http://www9.georgetown.edu/faculty/irvinem/theory/Foucault-AuthorFunction.html.

                                1. 2

                                  Part of me wants to complain about bias and write an alternate version of this – a version where (the best of) Analytic philosophy represents sane, clear and clear-eyed realism and (the worst of) Continental is merely dense writing, sound and fury signifying nearly nothing.

                                  But here’s what I hope is a better approach. My favorite philosopher of the 20th century was Bernard Williams. He was certainly British and steeped in the traditions of Oxford (where he was a student) and Cambridge (where he taught). But he doesn’t fit very well at all into the stereotypes of either Analytic or Continental philosophy. He spent much of his life demonstrating how thin and childish academic moral philosophy (of all flavors) was, and when he wrote a book on truth (a very Analytic topic), he used a methodology he derived in part from Nietzsche.

                                  So my more positive contribution is this: I suspect that the best philosophy doesn’t fit neatly into either of the two categories this post describes.

                                  1. 2

                                    There’s actually a lot of debate as to even if that particular dividing line makes lots of sense. For example, most people would consider Continental philosophy to be entirely idealist, but Deleuze was a materialist.

                                    1. 1

                                      Yup. I’m more familiar with the (so-called) Analytic side, and nearly everyone I studied with wanted to disavow the label and/or significantly complicate the division.

                                      Here’s another way to look at it: In my experience “Analytic” or “Continental” are labels you usually use of someone else, and only as an insult.