1. 13

    I’m sorry, I’m calling bullshit on the snippet being authentic. I’m sure there’s a lot of bad code out there, but this is too overwhelmingly wrong in neatly orthogonal ways. Sounds to me like a contrived example that tries to be wrong in as many ways as possible, on nearly every line of code.

    1. 6

      Apparently it’s not, according to the linked Reddit post.

      1. 2

        Maybe it came out of some code farm somewhere? I am skeptical too though

        1. 1

          I’ve been chipping in on a stackexchange site recently. This is par for the course, ‘overwhelmingly wrong’ is not an unfamiliar feeling if you browse new questions on SO these days. In fact I’m skeptical that this code didn’t get improved as it having been structured into sensible functions like this is inconsistent.

          1. 1

            I’ve worked on projects where the initial version was outsourced, and let me tell you: I’ve seen far worse than this. Imagine hundreds of lines of code, no whitespace, non-descriptive variable names, logic that is plain wrong, etc. There is a surprising number of people who do programming that really should not be allowed near a computer.

            1. 1

              Ten-thousand line payment processing function, here. Indexed through hundred-column listview-thing from DotNet framework, most of which were hidden. File had 4 functions, 40k lines, just about. Nightmare.

              [Edit: written by a CS student, who happened to be my boss. Not company owner, but the owner didn’t know better]

          1. 6

            Can’t quite agree that it would be fine for a junior developer to write code like that. There has to be some level of education before working in a professional setting surely (unless you want your senior developers to be full time tutors)?

            1. 12

              This is one of the main gripes I have with code camps. While I’ve encountered very good people coming out of those, I’ve encountered a good deal more who are woefully unprepared but mysteriously pass through the interview steps. Usually it takes about <probation period duration length +1 minute> before you figure out exactly how bad it is. By then, the good peeps have found their way and are at least decently junior and very open to feedback, but in other cases it’s just you, paying after the fact for their career change.

              Just to be very very clear: I have nothing against whoever tries this per say. A career change is perfectly normal, and I very much enjoy doing what I do, so I get why they’d want it too. I can’t stand whoever promises them that after barely a few weeks of very basic training in the tech du jour.

              I apologize in advance for my rant because I feel it would put down the people who end up tricked by those specific schemes.

            1. 8

              https://en.m.wikipedia.org/wiki/Calm_technology

              I think that these two things are connected to each other.

              1. 10

                I’m gonna play board & video games, eat sushi, see family and eat cake, as my birthday is imminent. Probably touch up my lsp proxy, of which I have a working prototype that I now use in my day to day work.

                1. 3

                  Week two of being back after 4 months leave. I think we’re having a planning session with my team, so we can decide what we want to do in the next week or two. I’m still catching up a lot on what happened and what code got written. I’ve been doing a lot of backlog management and email digging, i expect to do much of the same this week (although the backlog is starting to look pretty sharp)

                  1. 1

                    Week two of being back after 4 months leave.

                    Were you on parental leave?

                    1. 4

                      I was! Now I’m a Pentadad!

                      1. 2

                        Pentadad

                        Is that…5 kids?

                        Talk about life on hard mode. :)

                        1. 4

                          From a logistics standpoint it’s not that bad. Eldest is 10, and on average the elder 3 can help with their younger siblings. 😄

                          1. 1

                            I’ve heard it said that after 4, each additional child is no further strain on the parents, mostly as a result of older kids being more useful and parenting needing to be lower effort (not helicoptering) to have that many kids already.

                          2. 2

                            At least it’s not octodad.

                            Nobody suspects a thing

                    1. 2

                      I may work a bit on an LSP proxy I started yesterday. Its only goal is to do path translation between a client and a remote server such that it becomes feasible to work through a mounted directory. My personal use case is using that through 9front in a vm talking to its host, however i can imagine that you could have a smaller dev machine and very powerful spot instances in “the cloud” (or a big server in your basement)

                      1. 2

                        This is my last weekend on paternity leave after four months of being away. I’ll soak up on video games (Elder Scrolls Online for now) and take it easy. And take care of the family, and the usual chores of course. Monday is gonna be a while other ball game.

                        1. 2

                          I have many intents, most of which will never manifest into action. I need to reinstall Windows on a laptop of mine with a faulty uefi implementation, in order to hopefully use the Windows Boot Manager to convince it to boot Linux reliably. Meanwhile there’s another laptop that will be simpler to reimage that I happen to have lying about, where I’ll migrate my services from a third laptop where I have borked the package manager beyond my ability to fix it, and it’ll be much faster to just move the data and config over. Then, I might try to install a plan9 directly on the third laptop, see where the hardware gets me. I’d love to be able to grow my plan9 home cluster with my consumer-grade old-ass hardware.

                          1. 2

                            I got on paternity leave for four months on the day stuff got locked down here in Quebec. When he grows older, my son will be told how he was born during a plague (and l will make sure to dramatize a good bit for entertainment purposes).

                            I’m going back to work in mid-July. I’ve been keeping in touch with the team, because I suck at extended vacations; our offices are shut down until September, last I heard, and everybody is remote until then. Right now, they’re evaluating what stuff is gonna look like when people come back, and I’m trying to use that opportunity to turn 4 days a week remote into 5 days a week remote.

                            Which brings me to: for me, it’s been essentially business as usual, except the rest of my little tribe doesn’t get out much, which is doing weird stuff to our brains. Thankfully, we live some ways out of the big city and are not confined to an appartment. The kids can go out and enjoy the yard, which they do. Some stuff has reopened too, like some hiking paths. We haven’t gone on those much, yet. It’s slowly slowly starting to look like we can have a social life again, which to me means “bring the wife and kids over to the grandparents”, but it feels a bit risky still. On my wife’s side, it’s fine, but I got 2 brothers and 3 sisters and most of them are mega-careless, despite both my parents being in the medical field and us having brought up in a medically knowledgeable environment. Anyway.

                            TLDR, I’m good, we holding up, I wish you all the same, long days and pleasant nights to you

                            1. 3

                              I’m curious, has the indieweb landed on microformats for a reason? Even if it’s a tad more verbose my preference would tend to RDFa; is there some form of adoption for that or is it a big no-no for reasons unspoken?

                              1. 3

                                I might be way off base here, but RDF was a big part of the push for “Web 2.0” - which I see as the spiritual precursor to today’s IndieWeb. The problem was that the entire process bogged down into standards wankery. It doesn’t help that RDF is pretty damn weird, and the proponents didn’t do a great job explaining why the overheard was required.

                                I think microformats (which are basically HTML+CSS classes) is a reaction to that overcomplication.

                                1. 4

                                  I’m not actually sure what the rationale was for landing on Microformats.

                                  As far as I know, it’s only Microformats that have been adopted within the Indieweb. I don’t recall reading anything about other platforms within their documentation.

                                1. 11

                                  My hard-earned response to this is: just don’t do it. There is a minefield of gotchas under Mnesia, and they will maim you and your production system. Mnesia was built for configuration management, not for OLTP. You wouldn’t suggest using Apache Zookeeper as a production database, why suggest mnesia?

                                  1. 4

                                    I’d be interested in some examples of gotchas, documentation references, and the like, if you have specific references handy. I know of a few basic ones like the disc copies vs ram only vs disc only, but I haven’t used it enough to encounter other gotchas. I hold most of that knowledge from reading books or documentation.

                                    1. 4
                                      1. Two-phase commit.

                                      2. Since Mnesia detects deadlocks, a transaction can be restarted any number of times. This function will attempt a restart as specified in Retries. Retries must be an integer greater than 0 or the atom infinity. Default is infinity.

                                      This is from: http://www1.erlang.org/documentation/doc-5.1/lib/mnesia-4.0/doc/html/mnesia.html
                                      In practice this means that a big transaction can be preempted in perpetuity by an onslaught of smaller transactions on (a subset of) the same data.

                                      1. When you get “Mnesia is overloaded” warnings in production. At 4 am.

                                      2. Bad performance on sync transactions -> you move to async -> then move to async_dirty. Now you could have simply be optimistically !-ing to other nodes’ ets-owning processes without the headaches of mnesia cluster setup.

                                      Most oldtime erlangers have good mnesia stories, talk to them and be amazed :)

                                    2. 2

                                      This is a fascinating assertion. Thanks for chiming in, I’ll read up a bit more.

                                      1. 2

                                        This discussion is timely for the thing I’m currently building. I had already come to the conclusion that Mnesia had too many gotchas for me to handle but I’m still hesitating between using lbm_kv and going the riak_core+partisan route. Both options seem built on top of Mnesia, iirc riak uses a patched version of Mnesia.

                                        I got thousands of long-running processes updating their state every few seconds. This will soon take too much memory (because of process heap size) and later on it will have to be distributed anyway. My idea was to store state as native Erlang terms (to preserve read/write perfs and be responsive enough), and have drastically less processes than one per “state” with a pool of workers that would update the store instead and be released to the pool to move to the next thing to do. I also think that it will make it easier to move to distributed later on.

                                        Do you have thoughts on this?

                                        1. 2

                                          riak did not use Mnesia. neither does partisan’s version of riak_core, iirc.

                                          1. 1

                                            I think the Whatsapp scaling video has some details on this. Not sure if it is 100% relevant to you but it is worth a try.

                                            https://www.youtube.com/watch?v=FJQyv26tFZ8

                                            1. 2

                                              I rewatched last week and it’s not that relevant IMO but thanks anyway :)

                                              The thing is, my current challenge is going from a single node to distributed, their challenge was to overcome the practical limits of the maximum number of nodes in a cluster (fully connected mesh), so basically going from a ~1000 nodes cluster to >10k nodes cluster. What I’m working on is too specific to ever reach close to 1000 nodes but unfortunately still a bit too big to stay on a single node (or to be more precise: we could probably scale up but one machine with loads of ram is more expensive than a few smaller machines).

                                              Still a great talk for people interested in pushing things to the extreme!

                                              1. 2

                                                Yes, sorry I could not be more useful. I think the riak_pg might be still useful to you when going from 1 node to N. Or maybe you are not trying to go this route either. Anyways, if you write a blog post about your experience solving this problem I would be happy to read about it. I need to jump this hoop soon with my pet project so it is relevant to me.

                                                https://github.com/cmeiklejohn/riak_pg

                                        1. 2

                                          tmux is the one for me. It really changed the game for me. Multiplexing terminals has been so crucial in delineating my work. I wear a few different hats at work so its nice to just switch between terminals with ease.

                                          1. 2

                                            I find mosh coupled with tmux is invaluable.

                                            1. 1

                                              I’ve never given mosh a proper look but reading about it now, this seems extremely valuable.

                                            2. 1

                                              How do deal with scrolling and copy+paste?

                                              1. 1

                                                You can create bindings for tmux that allow you to do vim-style copy and paste.

                                                Scrolling is built into tmux, ctrl + [ and then just page up / page down.

                                                1. 1

                                                  Tmux has bindings for that. Iirc the default backscroll thingie is ctrl+[

                                                  1. 1

                                                    I set my terminal emu’s scroll back to 0 and have bindings for the scroll wheel events. Setting console scrollback to 0 is important cause otherwise the terminal will try to scroll too.

                                                1. 3

                                                  Curiosity

                                                  1. 2

                                                    Stubbornness for me. I’ve learned so much from being 100% sure that my code or software should work the way I expect it to, and fighting with it and learning what’s actually going on behind the scenes and why its behaviour is actually expected.

                                                  1. 8

                                                    I teach my kids how to code. A bit. Slowly. They have interest, and I feed their interest with bits that might keep their curiosity alive. Also might not. I don’t especially care if nothing comes of it. They’re building small silly games with Scratch, or play drag-and-drop coding games a bit. Conditionals, loops, that kind of stuff? It’s just an interest, in their myriads of interests, and it’s a bit fun too. Problem solving, maneuvering a computer, why not?

                                                    1. 2

                                                      I recently started looking at a Raspberry Pi 4 hoping to run 9front on top; I wonder if this could run it? Then again, i can get the raspberry pi for much cheaper. 🤔

                                                      1. 3

                                                        i can get the raspberry pi for much cheaper.

                                                        It’s not that much cheaper; $80 plus SSD, display, power, keyboard, chassis, etc. vs $200. Wouldn’t be the slightest bit surprised if once you added up all that the Pi ended up costing more.

                                                        1. 1

                                                          While I somewhat agree, I’m looking at the 4GB desktop kit (sold on buyapi.ca for 169 CAD). It includes keyboard, mouse, SD card and a bunch of cables. I kinda have “the rest”, in one form or another. One of the reasons for my “9front” comment is that I intend to run it as my main driver, if at all possible. One of the things that I’d like to do is to have my main disk space “elsewhere”. I have external drives lying around, and probably could rip out an SSD from a computer around here if I wanted more storage. Moreover, confinement means I don’t move as much with a computer as I used to do, so technically, a desktop is fine.

                                                          I wanted to toy around with the fact that in a minimalist case the raspberry pi is extremely portable. Potentially, I could move from one place to another with only the Pi in tow. If I wanted to do stuff “on the run”, it would help to have an external screen, of course, and the “I can do things from everywhere” with my laptop is an affordance I might end up missing, but I also have a few laptops lying around. Old ones. I wonder if I can boot 9front on an old EEEPC I have here. Might try that first.

                                                          1. 4

                                                            Potentially, I could move from one place to another with only the Pi in tow.

                                                            Theoretically this is possible, but the Pi is impractical to run off battery power in the way you describe. The Pine64-based systems all have onboard LiPoly support, (so the OS can be aware of the charge levels) and not only does the Pi have no such thing, all the external charging circuits I have been able to find either max out at 1A (the Pi3 takes 1.5A; the Pi4 even more) or do not support pass-thru charging. That means you can run the Pi off battery power, but you have to shut down the whole system to either charge the battery or move it over to another power source. This makes the Pi very impractical for portable computing.

                                                            1. 1

                                                              Ah, yeah, that’s a bit crappy, although I don’t think 9front supports suspending, so I’d have to shut down to move around anyway, or not move far distances, and make sure to have pass-thru. I think the pinebook might be more expensive than it seems too; it sells for 200 USD, and I’m pretty sure I’d have to pay a nice fee at the border, I’d probably end up paying 300-some CAD. 😑

                                                              1. 3

                                                                If you want to go the DIY route for something battery-powered, you can just swap out the Pi with a Pine64 SOC; I had a lot of success doing that here: https://atreus.technomancy.us/markv

                                                      1. 1

                                                        The article renders weirdly on my android device, especially the code samples (which is particularly sad because that’s what I wanna read)

                                                        1. 2

                                                          Sorry about that! I need to look into the theme I use on the blog. I’ve recently changed it and it does indeed seem broken :-/ Thanks for pointing that out!

                                                        1. 3

                                                          Learning a bit of C, continuing to explore plan9/9front as a plausible main driver, possibly getting Upspin up and running on my local servers maybe. Some ec2 config work, some api integration work. Probably and hopefully not more than one foray into the outside world to gather supplies from the absolute minimum amount of shops, which I’ll time for minimal human foot traffic. Also we had to take down the pool and there’s a fair bit of cleanup left. Also most of these tasks are done with a 2-month-old baby strapped to my chest, except the buying stuff.

                                                          1. 1

                                                            Learning a bit of C

                                                            C is a marathon, not a sprint. I’ve been learning it the last year or so, and I finally understand, to a degree, memory management through pointers, free(), malloc(), etc.

                                                            1. 3

                                                              Aye. I’m reading through K&R, even though it must be a bit dated by now. I did a lot of Go, which weirdly helps with some bits, less so with mem management; I haven’t really had to deal with that in the past, i have a vague understanding of stack vs heap and that’s about where my memory allocation knowledge ends: gotta allocate if you want stuff to exist when you return, is my gross oversimplification of my already overly simplistic mental model.

                                                              I wanna be able to read Plan9/9front code. Their C is a bit different, but the differences are well documented. So, ANSI C it is.

                                                              1. 2

                                                                For me, I think what might have helped to understand the distinction was when I learnt enough of assembly to understand how function calls work. Because function calls basically make you need/want stack, and also as a side effect they introduce a possibility of “local” (per function call) variables. While the “heap” is basically “all the rest of the memory that is not stack”. Where also part of this memory is then commonly taken by the OS for managing this memory itself, such as tracking of which areas of this “heap” are “reserved” (allocated) by which process. (Though stacks are also “reserved” per process by the OS.) Not sure if I managed to make anything more clear to you… ;)

                                                                1. 1

                                                                  Yes! Thanks!

                                                                  1. 1

                                                                    Awesome! :) happy to help :) if you have more questions feel free to ask, I will try to help if I can :)

                                                                2. 1

                                                                  I’ve heard K&R has alot of gotchas, but the writing style is just so fantastic that I can’t not recommend it. I still consider the c string copy function to be a work of art.

                                                                  while(*dst++=*src++)
                                                                  

                                                                  Of course it doesn’t work for utf-8. Or do bounds checking. I’m sure there are other problems.

                                                              2. 1

                                                                Have you been documenting your learnings from K&R? I had a brief interlude a few months back reading through the first few chapters. Would love to hear or read about your experience!

                                                              1. 1

                                                                woah crazy. I know nothing about selfhosting like that. What’s that it talks about with a reverse proxy? How’s that go from a public IP on vultr to a closet in your home?

                                                                1. 4

                                                                  I think his main motivation was to not expose his residential IP address. If he’s on a dynamic IP address, a cron job could access a secret URL on his VPS over at Vultr. The receiving end over at the VPS could then look at the client’s IP address (ie. his current residential IP address) and reconfigure nginx (or HAProxy, etc.) to route traffic to that specific IP adress instead of the old one.

                                                                  1. 1

                                                                    If you wanna be fancy you can have a gpg key pair and send an encrypted payload to a doesn’t-need-to-be-secret url. Swap out for other asymmetric encryption schemes to your liking. I just picked what I know.

                                                                    1. 1

                                                                      You can also simply run a client for any dynamic DNS at home, then you have an A record to lookup. It’s probably more reliable to not rely on DNS propagation times and just push your IP periodically, like @enpo wrote.

                                                                      I use duckdns.org, but I don’t host anything public at home, but I do access my MP3s with subsonic, so I don’t need the static IP.

                                                                    2. 2

                                                                      In addition to @enpo’s suggestion, you could easily do this with a VPN or SSH.

                                                                      1. 1

                                                                        Ah! Why didn’t I think of that :)

                                                                        The clever thing about a VPN is that you can leave the residential firewall as-is with no open ports to the outside world.

                                                                        You’ll also benefit from basically no delay if your ISP changes your IP address as the VPN would just reconnect.

                                                                        On top of this, your layer 7 reverse proxy (nginx, HAProxy, etc.) wouldn’t need to be reconfigured in the event of an IP address change, as the IP address over the VPN would be private (RFC 1918), and most importantly: static.

                                                                        Just benefits and no downsides :)

                                                                    1. 13

                                                                      I don’t believe the logic behind the EARN IT act adds up. If we ban things because unsavory people use them then why does the US allow guns, for example?

                                                                      This excerpt summarizes a majority of the article, and I think it exemplifies a particularly weak line of argument. People will be more likely to be convinced a law is right or not by you elaborating on what it does and how that effects them than they would be because you’ve moralized the pretenses under which it was passed. Case in point since you mention them just after that, the NRA has been pushing the “most gun owners are good guys!” angle for a very long time and it’s done little but intensify the ire of people they might be trying to sway. Saying “we shouldn’t ban encryption because not everyone that uses encryption is a pedophile” doesn’t exactly make the strongest case.

                                                                      1. 8

                                                                        the NRA has been pushing the “most gun owners are good guys!” angle for a very long time and it’s done little but intensify the ire of people they might be trying to sway.

                                                                        I think part of the issue is that the NRA isn’t always trying to sway the other side with this line. They’re often trying to rally support on their side. As such, I see using the same line of argument as useful in helping people on the right who may not normally identify with a tech issue to see it in the same way they view their gun rights.

                                                                        1. 3

                                                                          While I agree with most of what you’re saying, there just has to be a better way to combat illegal sexual exploitation than this. As much as I don’t like that it is still a big thing on the internet, removing encryption is not the solution.

                                                                          1. 5

                                                                            Sexual exploitation of kids was a thing before the internet was a consumer thing. Those who partake in such despicable acts will just find another way to do what they do if online transit is no longer practical or safe. And then we’ll have no legitimate encryption, and still have sexual exploitation of kids.

                                                                            1. 2

                                                                              I’m not against encryption either. Maybe if you really want to confront that part of the issue I think instead of talking about how it’s “not all encryption” I would personally take on the route of not only further exploring how futile it is to try to curb these crimes by pursuing them once they’re already being shared, but also showing how much more effective things like community programs might be at trying to fight the issue at its source.

                                                                            2. 3

                                                                              Saying “we shouldn’t ban encryption because not everyone that uses encryption is a pedophile” doesn’t exactly make the strongest case.

                                                                              Maybe it does, if one poses it as “encryption is the tool that allows you safely exchange, say, intimate pics with your partner, and financial information with your family members; if we ban it, your next-door neighbor could creep into your personal stuff”.

                                                                              1. 3

                                                                                That’s my point.

                                                                            1. 3

                                                                              Parenting, mostly. My kids who can read have received an introduction to Scratch through some game. Now I’ll install Scratch on their computer and they can start coding stuff i guess.

                                                                              I looked at Crystal a bit this week, i got disappointed when i couldn’t run it on my machine without Docker, so I’m thinking of heading in a different direction. The learning made me realize i missed Ruby, so i might head to Elixir because it has a similar “vibe” and the tech behind it is solid. Might also give a try to installing Jitsi Meet on my local boxes, but at this point it feels like a heavy heavy gun for my occasional needs. I might just resort to a Prosody image instead. Maybe i should just formulate clearly what i would want to replace from the Big Corporations Of Doom first. I’m not sure i like Signal.