Threads for kaspar

  1. 5

    I’m a die-hard Vim user but I open markdown files with Emacs to align the tables. I think I might have configured org-mode to do that at some point and never found anything as good for Vim? I’m still completely useless with Emacs for everything else so I generally just open the file (in evil-mode too of course) align the table and get out again.

    1. 4

      Should you also want a solution in Vim, Tabular.vim works very well. For example :Tab /, aligns on comma characters.

      http://vimcasts.org/episodes/aligning-text-with-tabular-vim/

      But going via Emacs works too, of course. (I strongly suspect there is nothing it cannot do.)

      1. 2

        Thanks for the tip, org-mode seems to just automatically handle aligning and adjusting the entire table completely though.

    1. 4

      Going on a random trip to Halifax, literally no reason other than it was cheap and I’d probably never have a real reason to go.

      I think I’m also going to “crunch” my public wiki / “blog” / “journal” into one directory. I think I don’t have enough time capacity to keep shit organized. Putting “tags” into text files is enough to find things instantly.

      OpenSCAD + Libfive is coming. We had a discussion on IRC. Going to implement an “oracle” so we should be able to use any OpenSCAD code to generate SDFs. The main downside is implementing an oracle means no tree optimization from Libfive, and so the final rendering will be slower, but we’ve agreed getting the full power of OpenSCAD is more important than speed right now.

      1. 2

        What is the OpenSCAD + Libfive work? I’m familiar with both projects but not with what you are doing with them.

        1. 2

          Integrating libfive into OpenSCAD. So you can mesh SDFs using OpenSCAD code.

      1. 6

        Sounds like it’s because of COVID-19 infection risk for attendees though they don’t say it explicitly.

        1. 6

          It’s fascinating that this is still such a concern after everyone who wanted (and even more) got their shots.

          1. 7

            It’s not surprising – the Congressseuche was a kind of flu that was common during previous congresses, and while being out sick for a week was already not great, with Covid and the risk of long-term damage, the tradeoff has changed quite a bit. With vaccines, the morbidity risk of Covid is mostly solved and long-term damage has been reduced, but it’s still not entirely gone.

            1. 1

              I guess the bigger issue is COVID is never going away, so the tradeoff at this point is do you want to do something now with reasonable precautions like wearing masks in crowded halls or just never ever do it in person again. The never do it in person option makes sense for lots of things. There are tons of conferences that could just be webinars. But if you think doing it in person is good, the risks from COVID are going to be more or less identical in 2023, 2024, etc. Like I hope they do come out with that vaccine that’s nasal and addresses all variants, but uh, even after that it’s not realistically going to get 100% uptake.

          2. 5

            DEF CON (similar size) in August had close to 700 of 25,000 people report positive cases, but within that group over 12% of volunteer “goons” that had a better reporting rate.

            The main Congress event isn’t held in a wildly different space (big convention center), and while it does have fewer cramped, hot, and sweaty hotel room parties than DC (I’m pretty sure I got COVID at one this year), instead it has more mixing of attendees with the general public in public transport.

            By contrast, Camp is entirely outdoors (to the point that during a thunderstorm there’s nowhere really safe to go), with lots of fresh air and space for everyone.

            1. 3

              Yeah, after Oktoberfest in Munich the numbers were spiking. Hospitals are full and they assume it will only be worse later this year. I think it is the right move, but still I am infinitely sad about it being cancelled

            1. 17

              Looks like a license was added to godiff in response to this.

              1. 7

                interestingly, the author says

                The license issue is a little exaggerated. I never imagined anyone would find use for that code. And two years ago, the original issue was plainly lost in a never-ending stream of notifications. By contacting me directly using my profile’s email address, the problem could be easily resolved.

                personally i would have felt just the opposite - that it would be rude of me to harry the author over email when they had not addressed a request via github bug report.

              1. 2

                Array programming noob here but most of this makes sense to me except the “variant nybble”. This sets three bits as described in section 4.1.1 in the RFC? Could you break down how it works?

                  ⍝ Force the variant nybble to be "RFC 4122".
                  t[19]←'8888888889abbbbb'[h⍳t[19]]⋄
                
                1. 2

                  Sure (and I kinda wrote that off the cuff, so check my math, please).

                  t[19] is the offset into the hex string that has the nybble whose top two bits need to be 10 (the third bit doesn’t matter in the RFC variant).

                  So, that nybble has four possible values: 1000 1001 1010 1011, in other words, 0x8 through 0xb.

                  So we take the index of the hex character (e.g. “f”) in the hex string h, which happens to convert it to its numeric value, and then use that as an index into the ‘8888888889abbbbb’.

                  That string is magic: the indices less than 0x8 are folded to 0x8, and the indices higher than 0xb are folded to 0xb, thus clamping the value in that range.

                  Basically the same as saying min(0xb, max(t[19], 0x8)).

                  Lemme know if that makes sense.

                  1. 3

                    Thanks very much for the explanation. As I understand it though the goal is just to set two bits to 0b10. Is there really no easier way to do that? Here’s what I’m thinking of in some C-like pseudo code:

                    t[19] = t[19] & 0b11110011;
                    t[19] = t[19] | 0b00001000;
                    

                    Does that just not translate well into array languages or am I missing something else?

                    1. 2

                      Nope, you’re not missing anything. Bitwise operations are definitely possible, but doing it that way just seemed more “natural”; to do a bitwise operation would’ve involved converting the character to a number and then the number to a bit vector and then back again (standard APL doesn’t have bitwise ops on arbitrary numbers, only bit vectors). This just did a bit of magic. :)

                      (Many APL implementations do have ways of doing bitwise ops directly on integers, it’s just not standardized. And I’m pretty sure Dyalog is smart about representing bit vectors as packed data in memory, for the record.)

                      1. 1

                        In j, a full complement of bitwise operators is available, specified using a truth table; bitwise and is 2b10001 b. and or is 2b10111 b. (leading 1 means bitwise rather than logical).

                        1. 1

                          It’s not a one-liner but this program could also be written as bitwise operations in Dyalog:

                          version←(4⍴2)∘⊤			⍝ version 4 ←→ 0 1 0 0
                          variant←4↑(⍉⍴⍤0∘1)		⍝ variant 1 ←→ 1 0 0 0
                          mask←⊖4↑((⍉⍴⍤0∘1)3-⊢)		⍝ mask 1 ←→ 0 0 1 1
                          
                          ⍝ returns the string representation of a 4×32 UUID bitmatrix
                          format←{('----',(⎕UCS ⎕UCS '0123456789ABCDEF'[1+2⊥⍵]))[⍋⍋'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx']}
                          
                          MakeRandomUUID←{ u←4 32⍴1=?128⍴2 ⋄ u[;13]←version 4 ⋄ u[;17]∧←mask ⍵ ⋄ u[;17]∨←variant ⍵ ⋄ format u }
                          
                        2. 2

                          8888888889abbbbb

                          isn’t this slightly biasing the randomness in those lower 2 bits? maybe I’m wrong but it seems like each of those bits will come out to 1 only about 37.5% of the time.

                          1. 1

                            …dang it I think you’re right. But it’s such a pretty little hack!

                            1. 2

                              You could’ve used 88889999aaaabbbb to get to right distribution

                          2. 2

                            Sure (and I kinda wrote that off the cuff, so check my math, please).

                            You can validate the uuids easily with python if you want. The crux of the tinyprograms test script is:

                            from uuid import UUID
                            got = UUID(out, version=4).hex
                            if got != out.replace('-', ''):
                              raise Exception
                            
                        1. 1

                          Nice article and timely as I’m just playing around with a parser in Haskell and just had a problem with memory consumption.

                          I think this jumps to recommending bang patterns too quickly. I’m just a dabbling Haskeller but I feel like a better solution to the bang pattern example would be using foldr instead of the recursive function call.

                          add :: [Int] -> Int
                          add = foldr go 0
                            where
                              go :: Int -> Int -> Int
                              go x acc = acc + x
                          

                          That’s basically what I did to solve the memory consumption in my parser. It’s clearer too. I think I first wrote the parser before I really understood how to use folds so now I have to re-write a lot of it using foldr.

                          1. 2

                            In the document, https://hackage.haskell.org/package/base-4.17.0.0/docs/GHC-List.html the only place it mentions space usage is in foldr', and it says

                            Note that if the function that combines the accumulated value with each element is strict in the accumulator, other than a possible improvement in the constant factor, you get the same O(n) space cost as with just foldr.

                            If you want a strict right fold in constant space, you need a structure that supports faster than O(n) access to the right-most element, such as Seq from the containers package.

                            Use of this function is a hint that the [] structure may be a poor fit for the task at hand. If the order in which the elements are combined is not important, use foldl’ instead.

                            so the document says you still have O(n) space in this function.

                            1. 2

                              I can’t pretend I really understand it. I just figured my manual recursion was causing problems and then decided on foldr because of https://wiki.haskell.org/Foldr_Foldl_Foldl'#Rules_of_Thumb_for_Folds. It did seem to solve the memory problems in my program. Maybe it was just a fluke or I’ve deferred them somehow.

                              1. 5

                                That is exactly the problem with Haskell, and the exact reason OP is even a thing. I guess in simple cases, GHC’s strictness analysis is good enough to avoid space leaks. But once there are a few lazy data structures, the monads you lego together become perfect landfills for thunks, so much so that GC kicks in 90% of the CPU time.

                                1. 2

                                  I actually didn’t know about GHC’s strictness analysis. I’ll look into that, thanks.

                                  I’ve dabbled with Elm and Purescript as well, which are eagerly evaluated, but somehow even with these problems and all the other warts I’m still gravitating towards Haskell for recreational programming.

                          1. 1

                            When I was learning Haskell (I never finished learning), the biggest problem I had was space leaks, and I literally littered bangs everywhere. I don’t have the courage to revisit my old programs, but if I remember correctly, I used all those State monad, Writer monad, IORef, STRef, Maybe, …

                            1. 2

                              I really wonder if those types were your problem or it was more about how you did recursion (see my other comment about how I failed to do it properly). Recommending not to use Maybe seems a bit overkill to me. It’s one of the really nice things about Haskell. Maybe a more experienced Haskeller could comment?

                            1. 1

                              That is super cool! I really want to learn to design a simple PCBs (not really sure if a keyboard qualify) and do not know how/where to really develop that knowledge being complete out of any hardware related stuff at work.

                              1. 2

                                I think a small PCB with 4 keys is not a bad beginner project at all especially if the keyboard side really motivates you. Check out Ruiqi Mao’s keyboard PCB guide for an excellent tutorial on doing just that. Also see our Awesome-Electronics list for more links and tidbits.

                              1. 2

                                @ozel pointed out to me that the banana has no effect on the sensor. They would get the same effect if they removed it.

                                1. 2

                                  I get it now. The given design uses an end-window type Geiger-Muller tube, and the window is not pointing at the banana. Probably it would work if a pancake tube was used instead.

                                  1. 1

                                    Why does the banana have no effect? Banana + geiger counter video: https://www.youtube.com/watch?v=X_XVRA5nD6M

                                  1. 9

                                    Interesting, a bit like what we came up with for our hardware build instructions. Though we embed ours in markdown.

                                    https://gitbuilding.io/usage/getting-started/

                                    1. 2

                                      This looks really useful too - have you considered submitting this separately so it gets a few more eyes?

                                      1. 2

                                        Thanks! I did a little while ago but it dropped off the front page pretty quickly with no votes. May try again at some point.

                                    1. 7

                                      I used to use this since I delete cookies for most sites on close. I have switched to Consent-o-Matic instead though since it’s able to select the most privacy preserving settings on a lot of sites.

                                      1. 15

                                        Conspiracy theory: This is advertisement for Kubernetes made by either people that get paid to do things with Kubernetes or are apologists for Kubernetes.

                                        1. 7

                                          I wouldn’t call that a conspiracy theory but merely talking about the author biases.

                                          1. 4

                                            …Kubernetes was an inside job?

                                          1. 4

                                            Host here, thanks for sharing. Conor is an interesting person: His competitive coding experience and his C++ work and algo focus gives him a lot of understanding of software performance. But he also is very interested in beautiful solutions and programming languages. He is like a PL person and a systems person combined.

                                            1. 2

                                              I like the moment in the podcast where Conor realised the common ground between array language compiler developers and competitive programmers, evidenced by creating macros that shorten everything. I think there was a lot of insight in that moment.

                                              I’m fascinated by the idea of languages as tools of thought as well. I’ve dabbled in APL (the famous Conway’s Game of Life in APL video pushed me to try it out). I’ve never gotten to any sort of point of fluency in it though.

                                              All that to say, I also enjoyed the video at the end where Connor walks you through the ice cream cone problem. Do you think you will keep learning APL @adamgordonbell?

                                              1. 2

                                                Thanks for listening @kaspar! Yeah, the notation argument really appeals to me and I think I keep learning more. I really like how using vim keybindings are just in my fingers and how regexs are such a succinct expression of string matching so I’m excited to see what is possible with Iverson notation.

                                                Julia has been mentioned to me several times now as a practical language with array programming first class, so I’m excited to learn more about Julia as well.

                                                1. 1

                                                  If you need help or just want to turboboost your learning, checkout the APL Orchard at StackExchange.

                                                  There are a lot of really talented APLers there, including Adám who works at Dyalog, who are happy to answer questions. Also the APLCart is an incredibly useful learning tool.

                                                  1. 2

                                                    Thanks! I’ll check those out.

                                            1. 29

                                              For a month, we looked closely at the parts of the browser that were “sparking joy” for people, and the parts that weren’t

                                              “sparking joy” is not very high on my list of things I want a web browser to do.

                                              1. 17

                                                It’s a reference to Marie Kondo who found popularity with her methods of tidying up. She wrote a book and had (one? more?) popular reality TV show(s). She advocates for going through each of your possessions, asking if it “sparks joy” and to get rid of it if it doesn’t.

                                                While I got the reference, I’m a bit apprehensive of a new Firefox re-design. I feel like I just got used to the last one. Admittedly that one was sorely needed. This time around I feel like it’s coming too soon and will waste my time unnecessarily. Hopefully it will still be as customizable as before though, so I can put it all back the way I like it.

                                              1. 14

                                                Just as something that probably should not be written in Go (like Docker) got written in Go due to hype, something that probably should not be written in Rust will be written in Rust.

                                                1. 4

                                                  Was it really because of hype? I don’t recall the timeline but Rust was still very unstable when dotcould was building whats now called Docker.

                                                  Its definitely fair to say it would be better in rust, but back in the days, rust would have been a difficult pick.

                                                  Go 1 still hasn’t broken its compatibility promise, which was a huge enabler for many projects.

                                                  1. 2

                                                    Hype was a big factor. At that time, Go was even seen as a risky bet (though you’re right that Rust would’ve been entirely untenable.) The “safest” choice would’ve been to continue what the industry as a whole was doing and write something like docker in C/C++. I was at dotCloud pre-docker, and it seemed clear that Solomon in particular was itching to find a way to use Go.

                                                  2. 4

                                                    It is inevitable.

                                                    1. 3

                                                      What’s the issue with writing something like Docker in Go?

                                                      1. 4

                                                        I think Go is fine for higher level codes of Docker. For lower level, Docker uses Linux namespace, Linux namespace is per thread, but Go runtime creates threads behind your back. This is bad and requires workarounds.

                                                        1. 3

                                                          The value on RPC was probably too much. Later, Redhat did a compatible rewrite as Podman without RPC and now it’s an advantage (security and otherwise). RPC was really hot for whatever reason when Go started. It’s probably something to do with the author’s worldviews or background at the time. Or another way, why does the Docker daemon exist? Why do you need to start docker and then connect to it with docker run. Why does docker run ever need to say “docker isn’t running”. I just ran it. You are docker, why are you saying you aren’t running? It’s that whole arch decision.

                                                        1. 4

                                                          If this catches on then I am sure Firefox will also re-integrate RSS.

                                                          1. 4

                                                            That would be both sad and hilarious.

                                                        1. 2

                                                          Interested to hear more about the garbage collector story when compiling Go to WASM. How does that work?

                                                          1. 7

                                                            If you are having problems with pipenv, try poetry. It’s modeled after things outside the python ecosystem (to me) and it’s worth a look. On one project, I had pipenv not able to solve the dep tree and poetry did solve it. And remember, these packages come from the same pypi source.

                                                            This is just an aside, not arguing the OP’s point of Nix as a universal cache or locking mechanism. I just think the smaller step would be to try poetry. I has almost nearly zero cost. I made a requirements.txt file out of pipenv and then just did poetry add for each line.

                                                            I think poetry would also address the original problem of not bumping all downstream dependencies and just the ones you need.

                                                            1. 4

                                                              That definitely sounds like a smaller step. The main reason that I have no desire to do it is that it would be a Python-specific step. I’ve used enough languages that I don’t really have patience for learning their idiosyncratic dependency management systems. Of course, for people who primarily identify as Python programmers, sticking with the traditional Python tools makes sense.

                                                              1. 3

                                                                We recently decided to go the other way, from Poetry to Pipenv. Our problem is that we mainly target Raspberry Pi and can’t get the particular dependencies pulled as binaries on ARM, instead we waste a lot of time compiling. We tried all sorts of settings in our pyproject.toml that didn’t work. Switching to Pipenv looks like it will solve it.

                                                                1. 3

                                                                  +1 for poetry. It’s made python development much less unpleasant for me. And, poetry2nix is pretty awesome, making packaging python projects with nix even easier 😁

                                                                1. 1

                                                                  Would managed Kubernetes from Digital Ocean or AWS be another option? I know it doesn’t solve the YAML problems but would probably save time and cost?

                                                                  1. 2

                                                                    I am using managed kubernetes from Digital Ocean at the moment. It’s a money pit for what I need to do.

                                                                    1. 1

                                                                      Ah, good to know. I am currently implementing a service using docker-compose and had thought about learning k8s and deploying it to a managed service, though it won’t see a huge amount of traffic to begin with (or maybe ever). That’s one more point to the “worry about it later” side. I will probably just deploy it with docker-compose on an EC2 instance.

                                                                  1. 3

                                                                    How does the ACME cert integration work here? I can see it in the config there but am not familiar enough with NixOS to understand it. Does it include a Nginx plugin that I am not aware of, is something built into Nginx directly or does it run a script (e.g. acme.sh or certbot) separately?

                                                                    I’ve been using a custom docker container that runs certbot --nginx to simplify my own deployment.

                                                                    1. 4

                                                                      It creates systemd units for getting and renewing the certificates (IIRC a systemd timer for renewal). It’s really nice, I have some NixOS machines running for years and all the ACME stuff is fully automatic.

                                                                      1. 3

                                                                        The config seen sets up a nginx with a virtual host, using certbot (not sure which ACME-client is used by default but probably certbot) to fetch the certificates.

                                                                        NixOS is very nice, especially in cases like this.

                                                                        1. 3

                                                                          How does the ACME cert integration work here?

                                                                          https://nixos.org/manual/nixos/stable/#module-security-acme-nginx