1. 11

    Not that interesting to fix, but certainly interesting to find. We had an operation on one of our Ruby process worker servers that would get some data from one service, write it to a file, perform a few brief operations on it, and then send the data to another service. It always worked fine locally and in all development and testing environments, but would occasionally fail on being unable to find the file in Production. Seemed really strange - how in the world would a file get deleted with no explicit delete steps only a few lines of code after it was created?

    It turned out that we were using the Ruby Tempfile class, creating an instance, and then returning the path of that tempfile to be used by the next step. Turns out that the Tempfile Ruby class silently deletes its file on finalization, and instead of returning the whole object, we were just returning the path from it, and letting the actual object go out-of-scope when the method returned. Most of the time, that object would happen to stick around for a while, and no problem would be seen, but in the tighter memory conditions on Production, the GC would sometimes run between the steps, collect that object, and delete that file before we were done with it. D’oh. Lesson learned - pay close attention to the scope of your Tempfile objects, and don’t pass their paths around separately from the object itself.

    1. 5

      Had a similar issue! We learned that Tempfile.create[1] is what we wanted — it doesn’t automatically delete the file.

      [1] https://ruby-doc.org/stdlib-2.6.5/libdoc/tempfile/rdoc/Tempfile.html#method-c-create

      1. 2

        I tend to prefer:

        Tempfile.create do |file|
             #do stuff with file
        end
        

        That assures you the file will exist as long as you’re in the block, and that it’ll be disposed as soon as you leave it. Leaking tempfiles in case of errors has caused us problems too.

    1. 1

      Interesting this only appears to show results for which there is an “Instant Answer” available. Searching for my own name does nothing (yep, I’m vain), while on the real DDG, I get some results.

      1. 6

        Really nice post, regarding:

        Writing C code and trying to keep it indented was a bit of a pain and I wish I would have done something else. I believe some compilers write ugly code and then “pretty it up” with a library before writing it out. This is something to explore!

        you can use clang-format.

        1. 3

          Cool, I’ll check it out! It’d be nice to find some library code or something I can depend on cross-platform though. Maybe I’ll consider writing my own bit of C tidying code.

          1. 3

            There’s also indent, multiple forks of it actually. Most advanced are (in no particular order) GNU indent, FreeBSD indent(1), and cindent.

            1. 2

              Oh cool! This looks like something I can use!

          2. 2

            The nice thing about writing your compiler in elisp is you have all the indenting functionality you could ask for all built-in.

            (please don’t do this)

            1. 2

              Steve Yegge famously(?) wrote a JavaScript Parser / analysis engine in Elisp to make js2-mode.el. Can’t be that bad. :)

          1. 8

            If you haven’t come across it, I also highly recommend Bob Nystrom’s book Crafting Interpreters, available for free. It has two parts: first he goes over building a tree-walking interpreter in Java then he goes over building a bytecode compiler & VM in C.

            This second part is still a work-in-progress but he’s kept a strong pace, last chapter was released about a week ago.

            Thank you for the great write up. I’m on a similar learning path and I really enjoyed it and got me excited to write my own compiler as well!

            1. 6

              I’m hoping to get the chapters done by the end of 2019. If you’re impatient, all of the code for the entire book is already done. (In fact, I wrote all of the code and carefully split it into chapters before I wrote the first sentence of prose.)

              You can see it all here: https://github.com/munificent/craftinginterpreters/tree/master/c

              1. 2

                Thanks! I had briefly noticed Crafting Interpreters before, but I’m glad to hear it’s worth a second look.

                Thanks for the kind words, and I hope you will continue on your journey!

              1. 3

                Good stuff. Outputting machine code for amd64 isn’t too bad, you only need a small subset and the Intel manual is pretty good. Writing a JIT might be a nice next step, sort of combining an interpreter and a compiler. Unfortunately there isni’t much information out there about JITs.

                1. 2

                  Working with incremental compilation really got me thinking about JITs. Definitely something I’m interested in learning more about!

                1. 2

                  Love this concept, but not for the multiple orgs. It may make sense to you personally to have an “old projects” org, but it changes URLs for people that may have bookmarked your old junk. I did create an org for forks, though. That’s brilliant. Most of those were done to make a single PR.

                  1. 1

                    Assuming the PR was merged, why not delete the fork?

                    1. 2

                      As trousers said, sometimes the PRs aren’t merged in quick order. In other cases I will continue to make contributions to the project over time and want to keep my fork around. I’ll rebase in upstream as time goes on and make new feature branches for PRs. But, even in the case where I just made a single PR, I like to have that record around where I can find it or point to it in case the need arises. If a future employer was curious what my relationship is like with the open source community this new “org” is a great place to send them.

                      1. 2

                        I’ve had PRs hanging out for /months/. Sometimes I just forget to go clean up the repo later.

                    1. 8

                      Thanks for sharing this! I think it’s so crazy it may loop around to being cool somehow. I’m already thinking of how I can write an LDPL compiler in LDPL. ;-)

                      What does L.D. stand for?

                      1. 8

                        Thanks to you! Hahaha bootstrapping LDPL in LDPL is something I would like to do someday, if you do it please show it to me!

                        LDPL stands for Lartu’s Definitive Programming Language. I’m Lartu and, apparently, this is my definitive language (?

                        1. 6

                          Little Dinsaur Programming Language

                          Obviously. ;)

                        1. 2

                          I’m going to work on my Mal (Make a Lisp) compiler. There is a bug where it cannot compile the Mal interpreter which is written in Mal itself and somewhere here my mind turns into one of those conspiracy theory boards with perp photos and strings and newspaper clippings. Anyway, it’s a fun challenge!

                          1. 9

                            I showed this to my kids, who use Facetime a lot with their cousins, and they were floored. Now they’re using it to spy on each other. What a fun way to inspire a 10-year-old to become a security researcher!

                            1. 18

                              Additional info on the reddit post:

                              Final Update

                              It really was the ex employee who said he put it there almost a year ago to “help us identifying wifi problems and tracking users in the area around the Managers office”. He didn’t answer as to why he never told us, as his main argument was to help us with his data and he has still not sent us the data he collected. We handed the case over to the authorities.

                              1. 8

                                That’s an incredibly weak lie lol

                              1. 6

                                You’re an inspiration. Can’t wait to see what else you do with sr.ht!

                                1. 1

                                  Thank you!

                                1. 2

                                  This is really great!. I have a related question. What is a sane clipboard manager that one can use that

                                  • Is as simple as this window manager – i.e no big dependencies, a plain C file if possible so I can recompile it if needed easily.
                                  • Simple enough in practice: i.e Let me bind a key combo to copy and a key combo to paste. I ask for nothing more.
                                  • Does not get overwritten when I select a line in some application (i.e play nice with selection buffers)
                                  • Works with all standard applications (at least firefox, terminals, office and the like).
                                  • Works with WMs like aphelia and i3.
                                  1. 4

                                    I blogged about this back in 2012[1] and still use it today. Though the code is simple, I’m not sure if you’d call it “lightweight” since it has to poll the clipboard once every second. I wish I knew an evented way to do that…

                                    [1] https://mpov.timmorgan.org/super-simple-clipboard-history-for-linux/

                                    1. 1

                                      There’s a dmenu script. Haven’t used it myself, but usually suckless stuff is easy to modify if it doesn’t exactly do what you want.

                                    1. 10

                                      I’m surprised this is voted as highly as it is. Aside from being a 2012 article, it is scant on any interesting details - it reads to me like I pat-myself-on-the-back, I’m smarter than the people around me personal fiction. Even the lesson learned is “I’m smarter than the advice that was actually given to me”

                                      1. 3

                                        I upvoated because I found it interesting, and the politics of my-code/your-code are familiar from past jobs I’ve had.

                                      1. 17

                                        I used Mastodon for about six months … Then stopped, because that sort of social networking didn’t make me a happier or better person, regardless of platform or community.

                                        1. 7

                                          You know I hear this a lot.

                                          My Twitter feed isn’t full of trolls, and neither is my Mastodon feed. I find and interact with people who want to have meaningful, interesting and civil discourse on a variety of topics.

                                          Sorry your experience was so different.

                                          1. 6

                                            This is so true. Took me way too long to figure this out. Also, I never follow coworkers — it ruins the relationship for me to get inside their head that much.

                                            1. 2

                                              That’s generally good advice. For me it depends. I can usually draw a bead on the maturity level of the people in question, and I follow the ones I trust.

                                              That may bite me in the posterior someday. Hasn’t yet.

                                              1. 2

                                                I’m really glad I run my own mastodon instance. The major instances have massive block lists and I’ve found a lot of people on blocked instances to be really cool. There are other people who have mobbed me and they couldn’t even see counter arguments because they came from blocked instances; they were in an echo chamber.

                                                If you want to use Mastodon, I suggest you start your own instance (or you can PM me if you want an invite to mine).

                                                I’m at @djsumdog@hitchhiker.social

                                              2. 4

                                                I think that Twitter, Mastodon, etc. can have ill effects even if you’re only following people you like and no one is harassing you. (And of course, it’s surprisingly difficult sometimes to realize that following a certain person is not bringing you joy and that you should stop following them.) Some people—myself included—get a little twinge of pleasure any time someone likes/favourites/boosts/retweets their stuff, and over time that can make posting feel a little bit like a slot machine. Some people are less prone to that, but for the rest of us it’s not a very healthy dynamic for a social network.

                                                1. 2

                                                  Except that, if you want to reduce it to the neuro-psych effects of interacting online, what’s so different about this venue? We crave upvotes and standing in the community.

                                                  Admittedly unlike failbook there’s no giant MegaCorp using our data in immoral ways, but that’s the same for Mastodon as well.

                                                  So, basically, I don’t see your point at all. Humans crave social approval. it’s how we’re wired. Companies like Failbook and Twitter leverage this in ways that end up being morally questionable (and in FB’s case just straight up evil) but when you take them out of the equation, your point falters IMO.

                                                  1. 1

                                                    That’s a good point. Perhaps another part of it is that Twitter and Mastodon also encourage (both socially and through their UX design) short, tossed-off posts. Especially back when Twitter only gave you 140 characters, there wasn’t much room for any kind of nuance or subtlety; it was way easier to say something snappy that would garner you a bunch of likes than to engage in a conversation with any level of depth. Lobsters does show your karma up there in the corner, but it also encourages you to write long posts (that are displayed in threads!) and I think that’s an important part of building a discussion-oriented community.

                                                    1. 3

                                                      Ah, there’s the crux of it!

                                                      You cite “building a discussion oriented community”.

                                                      To my mind, things like Mastodon and Twitter for that matter aren’t that at all. They’re more like a crowded cocktail party where people get into a crowded room and chatter. Clumps form and topics are discussed, then disband as another hot topic of interest pulls people in a different direction.

                                                      I like gatherings like that. I feel like they have a lot of value and are a particular type of social inercourse I quite enjoy. If you don’t, that’s totally cool! Nobody says you have to :) But that doesn’t make them bad.

                                                      1. 2

                                                        Makes sense! And to each their own :) It’s unfortunate, of course, that so much of our public discourse has found itself shoehorned into a space designed for a more intimate cocktail party…

                                                    2. 1

                                                      I need to periodically take breaks from lobste.rs because the upvote game is getting me too worked up – don’t you?

                                                      That very rarely happens to me on mastodon, because I hide all notifications except mentions in order to actively prevent getting sucked into a popularity-contest mentality (and disable desktop/push notifications and notification sounds altogether). That’s not the default, but it’s explicitly supported by the settings (while doing the same on twitter as a non-bluecheck requires a browser extension).

                                                      1. 1

                                                        I don’t really get ‘worked up’ around the voting, but I do find myself investing more ego in it than I like.

                                                        Mostly this manifests when I feel like someone has flagged a comment unfairly :)

                                                        1. 3

                                                          I find that over here, I get fixated on checking whether or not posts I think are good are ‘doing well’ – primarily because that information is easily accessible / even visible when I’m not looking for it in some cases. It produces stress I don’t need in my life. If I had an extension that removed upvote counts & karma from lobste.rs posts entirely, I would use it.

                                                  2. 2

                                                    Same here. I think of my twitter/mastodon feed as a kind of soup. I craft it into something enjoyable by being selective about the ingredients that go into it. https://mastodon.xyz/users/donpdonp/

                                                  3. 3

                                                    To expand a little now that I’ve thought about it more… It wasn’t that I didn’t follow good people, as I certainly tried to. It was more that I couldn’t filter by topic, at least not well. This seems like the big difference between “social media”, where you follow people and have to bear whatever they feel like saying, and more “old-school” group communication like Usenet, fora, or their successor Reddit (or Lobste.rs). There’s people out there I really like and enjoy talking to, but I really don’t feel like wading through, say, their stories of Counterstrike triumph to get to the useful and wise things they have to say about software consulting.

                                                    The number of people out there where I honestly want to listen to everything they say is quite small.

                                                  1. 2

                                                    I just lurk here but I post regularly at https://mastodon.sdf.org/@seven1m. See you on the fediverse!

                                                    1. 3

                                                      I’m at SDF! cfenollosa@sdf.org.

                                                      I toot about BSD mostly. My Mastodon timeline is like 90% of BSD users.

                                                      1. 2

                                                        cfenollosa@sdf.org

                                                        Hey can you post a profile link? Doing a search on that nick doesn’t yield anything for me.

                                                          1. 1

                                                            Whoops, I missed a part of the domain

                                                            https://mastodon.sdf.org/@cfenollosa

                                                          1. 1

                                                            OK, thanks!

                                                            1. 1

                                                              Question is why it’s taking this long to just generate a new cert with the extra SAN…

                                                              1. 4

                                                                No one is paid to work on lobsters. If you know ansible and letsencrypt you should be able to help out.

                                                                1. 1

                                                                  Well I don’t really know how the current Lets Encrypt cert was generated, but it’s literally just another argument. Did ask about it when it came up on IRC 3 weeks ago, but didn’t get a reply then, and figured it would probably be fixed pretty quickly then so completely forgot about it.

                                                                  1. 1

                                                                    It was manually created with certbot but, as noted in the bug, should probably be replaced with use of acmeclient to have much fewer moving parts, if nothing else.

                                                                    It’d be great to have someone who knows the topic well to help the issue along in any capacity, if you have the spare attention.

                                                                    1. 1

                                                                      I’ve done entirely too much work with acmeclient to automate certs for http://conj.io and some other properties I run. Will try and find time this weekend to take a run at this.

                                                                      1. 1

                                                                        That or to use dehydrated: in a text file, one certificate per line, each domain separated by a space.

                                                              1. 5

                                                                I’m learning how to build a Debian package so I can make installation of my open source church software easier for the non-nerdy. So far I’ve been pleasantly surprised – the process isn’t too bad actually. I’m hoping this will make it easier for people to install and keep upgraded without having to git pull and bundle install and rake db:migrate and all that. Wish me luck!

                                                                1. 3

                                                                  Are you trying to get it accepted into Debian? Making a Debian package isn’t so hard, but making one that passes Debian policy is a lot harder.

                                                                  1. 1

                                                                    No I figured I’d host my own apt repo. Good to know!

                                                                    1. 3

                                                                      Yeah, Debian is really anal about what it accepts as a package. Every file has to be in the right location, there must be documentation, license must be clearly stated, permissions must be right, install and uninstall scripts must work harmoniously with every other package in Debian…

                                                                      It puts a lot of burden on the maintainers, but as an end user, I usually love the final packaged product. I would recommend trying to make it pass Lintian, or at least do run Lintian to see what it complains about and see if you don’t mind living with its complaints.

                                                                      1. 1

                                                                        Thanks for the tips!