• 0 Posts
  • 74 Comments
Joined 1 year ago
cake
Cake day: June 11th, 2023

help-circle
  • I started in C and switch to C++. It’s easy to think that the latter sort of picked up where the former left off, and that since the advent of C++11, it’s unfathomably further ahead. But C continues to develop and occasionally gets some new feature of its own. One example I can think of is the restrict key word that allows for certain optimizations. Afaik it’s not included in the C++ standard to date, though most compilers support it some non-standard way because of its usefulness. (With Rust, the language design itself obviates the need for such a key word, which is pretty cool.)

    Another feature added to C was the ability to initialize a struct with something like FooBar fb = {.foo=1, .bar=2};. I’ve seen modern C code that gives you something close to key word args like in Python using structs. As of C++20, they sort of added this but with the restriction that the named fields have to come in the same order as they were originally defined in the struct, which is a bit annoying.

    Over all though, C++ is way ahead of C in almost every respect.

    If you want to see something really trippy, though, have a look at all the crazy stuff that’s happened to FORTRAN. Yes, it’s still around and had a major revision in 2018.




  • Falsehoods About Time

    Having a background in astronomy, I knew going into programming that time would be an absolute bitch.

    Most recently, I thought I could code a script that could project when Easter would land every year to mark it on office timesheets. After spending an embarrassing amount of…er…time on it, I gave up and downloaded a table of pre-calculated dates. I suppose at some point, assuming the code survives that long, it will have a Y2K-style moment, but I didn’t trust my own algorithm over the table. I do think it is healthy, if not essential, to not trust your own code.

    Falsehoods About Text

    I’d like to add “Splitting at code-point boundary is safe” to your list. Man, was I ever naive!



  • Ah so it’s not only Tkinter then. Interesting. Maybe this is one of the reasons why Python-specific GUIs like Kivy came about? When I first started learning Python though, I came under the impression that Tkinter was the “official” Python GUI with privileged status in the standard library, so I started there and was surprised at how it actually doesn’t play all that nice with the language.

    Oh well. I’m glad OP brought it up because I’m sure everyone who’s tried to write a GUI in Python for the first time hits this before long and has that same wtf moment. :)




  • I’ve used Tkinter in a number of projects, though not the PIL specifically. At least not recently?

    What I have found with Tkinter in general is that it can be rather quirky in terms of dealing with object ownership. I don’t know why this is? You shouldn’t have to worry about tracking object lifetimes in a garbage-collected language like Python, but Tkinter is just…weird about it.

    My wager would be that for whatever reason, once your change_image() function returns, the garbage collector is coming around and releasing new_tk_image (or maybe even new_image?), even though test_image_label should hold a reference to it by that point? And the breakpoint() stops the function from returning, so you are “safe” (at least temporarily).

    What I would try then, as a workaround, would be to store your own references to some of these and see if it works? You can begin by just making them globals to see if this is indeed the problem, though it’s probably more elegant to group them together in a class with anything else to do with the window.



  • Based on my personal observations, there are sort of like 3 rings to a religion. The outermost contains the vast majority of adherents who are pretty casual in their faith. If they are of some Christian denomination say, they’ll show up for Christmas or Easter services and go their separate ways otherwise. The 2nd ring contains people who attend services regularly but are non-evangelical. They are devout in their faith but not pushy about it.

    Then finally, there is this innermost ring of evangelicals who make it their mission to tell you how great it is to find God and can be pushy enough to make a priest cringe. People from the outer rings generally try to avoid this group, but they tend to be the most active online. I guess maybe lemmy has yet to be overrun by them?


  • So you’re saying the comments themselves get cached on the local instance where the user is registered before being synced with the remote community-hosting instance?

    I honestly don’t know how these things work internally, but had assumed the comments needed to go straight to the remote instance given the way you can’t comment once said instance goes down? You can still read the cached content though.


  • When I first heard the term “fediverse”, it immediately made me think of some sort of vast interplanetary network. And let’s face it: a fediverse-like model is really what you would need if you had settlements scattered throughout the solar system. A monolithic, centralized service would be awful, given the reality of communication lag and likely limited bandwidth.

    So let’s say lemmy (or more generally activitypub) were to go interplanetary. How would that work out? You set up your first instance on Mars. Any content that’s posted there will be immediately available to your fellow Martians. Earthlings who subscribe may also be able to view it as their instances cache the content, albeit after some delay.

    But the trouble starts when Earthlings want to start contributing to the discussion. If they have to wait the better part of an hour to get a single comment lodged, it’s going to get old fast.

    So you would need to allow the Earth side to branch off to some extent from what’s happening on Mars. Then eventually, something like a git merge would try to bring it all back together? I wonder if that would work?





  • Well, Shortcuts comes from the iOS world and is a relatively recent addition to macOS. Automator originated in macOS and I don’t think it has made it over to iOS at this point?

    That’s not even the full extent of it though. Before Automator, there was Script Editor, which could also create script applications, but that doesn’t seem to work so well anymore. Automator has become the preferred approach for that. But Script Editor is still around and is useful for looking up AppleScript dictionaries. These tell you if a given application offers special scripting support, and there are also a few general dictionaries like StandardAdditions that are worth a gander. I wish AppleScript existed for iOS.

    And then there’s the command line approach of using crontab to open your files with the open command. And osascript lets you run any AppleScript from the command line.



  • I have some vague recollection of a hacker convention from the 90s where people were challenged to come up with wireless networking in a one night coding marathon. (This was long before wifi.) So some dude used speech synthesis to get a machine to say “one zero one one zero…” and another to assemble the binary data into packets using speech recognition. It was hilarious, and the dev had to keep telling people to shut up and stop laughing so he could complete the demo.

    But anyways… what I’m trying to suggest here is you might have the best luck if your notification sounds contain spoken commands and you use speech recognition to trigger scripts? That tech is pretty mature at this point.