14
votes
What programming/technical projects have you been working on?
This is a recurring post to discuss programming or other technical projects that we've been working on. Tell us about one of your recent projects, either at work or personal projects. What's interesting about it? Are you having trouble with anything?
Learning Minecraft, surprisingly.
My work has scheduled me without asking my availability to teach a pair of students the their next level of Python classes in a newer format that uses Minecraft Education Edition. I'm not really sure if I really like it or not. There are parts of it that have extremely rough edges, some of which I think are because of the company I'm working at, and others because of Minecraft Education Edition seems to be a not-so-great way to teach. I'm worried about having to wrestle the kids away from the game that I am literally putting them right in front of. There are a lot of really mixed incentives with the program, I think. I've played around with the lessons that Microsoft has made, and they are ... not rudimentary, exactly, but they show off the constraints. Every task they have you do is in a world and it seems like it's good because it makes logical sense, but then again you are programming a little robot to do things that if you weren't constrained would be so much easier for you to go out and do it yourself.
But the curriculum I'm teaching is the more advanced stuff, for kids who have already learned these concepts that Microsoft's lessons have been teaching. And so what exactly is the point?
I say this, but really, I think this might be helpful to these particular students because the thing that I find most of my students have a hard time with is being flexable in their thinking. Even if all they did were drawing with blocks, it's still going to need them to learn to think a little differently.
The thing that's really bugging me, though, is that this uses the relatively new Python Notebook editor. The Notebook editor is just stupid.
For one, the editor is just a web browser integrated into minecraft. It's not well integrated, either. You need to click on it before it will register any inputs, so if you want to, for instance, click on a piece of your code. you will have to open the editor with the "c" key, and then click somewhere in the editor before it will actually allow you to click on your code. To run any given piece of code, you will need to open the editor, click on it, then click a second time to actually run it. If you want to see the code in action, you can theoretically press escape to close the editor, but in reality your input is being captured by the browser so you will have to click on the "X" close window button - twice. So basically, everything feels like it's barely working because it doesn't actually do what you want to do the first time.
Beyond that, there is almost zero advantage to using notebooks over a basic editor. For one thing, you cannot save your own projects. Officially, at least; the program tells you when you start a new project it will not save, but it's persisted every time in the world I've created. But even then, the actual usefulness is gimped. For one, you cannot write plain text anywhere. The only option you have is to write code. It seems like they are using the format to integrate lessons - that's how they do it in their example teaching worlds - but for the life of me I cannot find a way to write my own and include it in a world. It seems like you are supposed to be able to write rich text and insert gifs and images and even have multiple pages, but none of that functionality is exposed to the user. The only things I have found - by accident - were that you can press "a" when not in an editor and a new editor will appear somewhere, press "x" and some editor will be deleted, and sometimes pressing "z" will bring back an editor that was deleted. So basically, my only real option to teach my students is to be sitting next to them and walking through everything bit by bit.
The flaws in using it to teach coding reminded me of https://youtu.be/K1DoZCJcxFE, a video by a geologist that breaks down some of Education Edition being factually incorrect. It seems that they invested just enough to trick the decision makers into believing it is a competent education tool, but while leaving it in a very problematic state.
I have been learning how to read code in larger projects. Since my programming experience has only been in school, I have not had to take on a larger codebase that I need to modify and debug. The project I am working on is a fork of someone's personal project, so code comments are minimal. So I have been slowly piecing together all the project libraries it is using and for which. I have a rough understanding of the overarching concepts, so now I am creating a flow chart of the different app pages and trying to figure out which methods are called and when.
Didn't realize that my previous comment was at the near end of the previous thread, and since
I wasted far too time during workit takes more effort than you'd think to change lyrics: enjoy. It's based on '2 days into college'. Gotta vent frustrations having to deal with a frontend you barely control.I built a NAS
Background
I picked up an HP Elitedesk 800 G4 Mini to use as a home server almost a year ago, and set up Home Assistant OS through Proxmox (RIP tteck). I had wanted a NAS for a long time, and bought that model because you can install 4 drives into it (2 m.2, 1 SATA 2.5" SSD, 1 m.2 drive in the network card slot with an adapter). But the entire project went on hold for a couple reasons:
Fast forward to this past January, and I stumble on a post of someone stuffing 4 SSDs into the same computer I have while managing to find an adapter that fits an SSD into the wifi card slot without chassis modification. This was a kick of motivation that made me realize the very obvious fact I don't need a NAS for bulk storage and OS drives for bulk storage, so I can move my largest capacity SSDs into the NAS and replace my OS drives with much smaller capacities. I still did need to buy one SSD, but that was better than three. And while I didn't want to mangle the chassis of the computer, I was fine with mangling the SSD caddy to make everything fit.
The Build
This should've been simple. Just:
It wasn't that simple.
Moving my data off my existing 2TB drives was a journey in realizing my only spare storage capacity was scattered across multiple smaller SSDs, trying to delete as much data I didn't need, attempting to compress 100s GB of data, noticing after 2 hours that the compressed archive was bigger than the data I was trying to compress, realising that compressing compressed data (i.e.
.mp4
,.mp3
,.jpeg
, etc...) yields little to no space savings, and finally settling for spreading out those files anywhere they would fit.Modifying the caddy was initially pretty straightforward, and I was pretty quickly able to get everything installed onto the motherboard so I could boot the device. And... the SSD in the network card slot wasn't detected by the server. I figured this might be a case where plugging in one SSD disables PCIE lanes elsewhere on the motherboard. So I emptied out all the drives I just installed, and repeated the cycle of installing one drive and booting to check that it showed up. All the drives were functional. Assuming that maybe I had a faulty connection at the start, I reinstalled all the components into the chassis, closed it, and booted it up again. And the network card SSD is gone again! It turned out that installing the 2.5" SSD caddy seemed to cause the network card SSD to malfunction. I'm pretty sure the caddy was shorting out the SSD, because it eventually died. I ended up cutting the caddy in half to guarantee that no part of it could get even get close to my storage devices, which seemed to solve the issue.
The rest was pretty smooth sailing. OpenMediaVault was very easy to set up on Proxmox, and seems to work fine after using PCIE passthrough to give it access to the SSD controllers.
What did I learn
I built a standing deskI bought a surge protectorI built a standing desk to help me be less sedentary when I work from home. Thinking about cable management threw me down a rabbit hole about surge protectors, and learned some basic facts that I probably should've known years ago:
I am also running Proxmox and OMV and it is a very simple process to get everything running. Having a NAS is really convenient, especially if there are multiple users or devices on your network. This post is a good reminder that I should start planning out a rebuild of my server since it is underpowered and the storage situation could use some improvements.
I'm working on an infinite canvas [drawing / note taking] app that I call Mitten. I'm trying to design an elegant algorithm to support a truly boundless canvas (infinite zoom and pan). I thought I could solve this quickly but it's proving quite hard. There are so many pitfalls (floating point issues, how to uniquely identify a point within the world, data structure, camera system, etc).
I've built a few things like this. Most recently a program whose online help is on an infinite canvas that you can pan and zoom around on on your phone's touch screen, or just pan around on a computer. (I only need the zoom for online help on small screens.) Here's the current build with more improvements over the screenshots there. The programming environment I use to live-edit these programs is also on an infinite surface.
If you want to try it out, it's easy to try out on Windows, Mac, Linux, Android. iOS is a little more involved but also doable. I'd be happy to answer questions.
You're probably trying to do something I'm not, but I'm curious to hear more details.
I don't know how much help they might be, but I know of two other programs that seem similar:
Mitten looks very cool. It has been years since I last used a program like this, and I don't know why. They're super useful for taking notes and brainstorming/sketching all kinds of ideas. I will watch Mitten's repository with great interest.
Mine is inspired by Milton. I used it for years before coding Mitten from scratch. It doesn't have as much range as mine.
There's Endless Paper on the iPad that does. But it's not as good as I'd want it to be. They cheat by hiding lines when zooming in too big. (Quite noticeable when using a stroke as the background and zooming in on it to draw smaller and smaller.)
For note taking, I had written this article in the past: https://jeandavidmoisan.com/posts/using-a-graphics-tablet-as-a-programming-tool/.
I believe I checked out Lorien in the before. Thanks for reminding me, I'll have to test the edge cases that I have.
This is using Endless Paper: https://youtu.be/GeEISHh37lY.
Ahh, I replied before I read this. Infinite zoom! Yeah I have nothing to offer there besides gawking at fractal rotation videos. Also rotation, which I don't do (but I use a game engine and that would help with it). And freehand strokes which I know nothing about.
Surprisingly, the infinite zoom is the easy part, I have a solution that works by using the exponential scale and the numbers stay within an acceptable range. It's the panning on the X, Y axes that's throwing me for a loop. You just run out of numbers, thinking outside the box feels required.
If I didn't allow panning, I could have something that only zooms on the origin.
For freehand strokes, my solution is quite simple. A stroke is a collection of lines at full opacity (no transparency). I wrote a library to render shapes and it felt like a could just chain lines one after the other to draw any strokes and the result seemed acceptable. A single stroke can be hundreds of lines with slightly different thickness, angles and lengths.
Would it help to have some sort of library for infinite-precision numbers? I don't know how performant they are, but you probably also only need a few operations per pan/zoom..
This is quite likely what I'll have to do. I need to figure out a good way to represent any coordinate. I can represent a position with 3 values: X, Y and exponent. Those can all be integers. You can think of the exponent as scaling the grid size towards or away from the origin. Works well for zooming in or out on the origin until I run out of values for the exponent (-2,147,483,648 to 2,147,483,647 which would be unimaginably large).
I'm not yet sure how to represent X and Y values outside their range. If you pan away from the origin and zoom in, you quickly end up in a position way outside the range of any fixed size data type I could chose.
Are the strokes in a line forming its outline or more like a bush? How do you compute the lines in response to touch events?
I get a list of position and pressure from the tablet driver and I just create a line between the points. The line drawing is done with a signed distance field where I only draw a fill color and no outline. snip More info here.
The mouse code shows it pretty well: https://github.com/Apostolique/Mitten/blob/9a5bf951d12face22420e49d3ceb36b302e61f04/Game/GameRoot.cs#L418-L443.
The
_draw.Pressed()
starts the action. The_draw.Held()
happens as long as the mouse is still pressed._draw.Released()
then ends the stroke.CreateLine(a, b, size)
is the API to create a line. It doesn't commit the line to the history yet until the stroke is over.CreateGroup();
is what commits all the lines so far to history. That allows undo and redo to remove all the lines that constitutes the stroke in one go.The code is executed in a game loop over multiple frames.
The
StrokeWithTablet
code is pretty much the same but there are a few edge cases to handle.About a week ago came across Dick, an esoteric language, and got sniped into making an interpreter for it in (zsh) shell script.
Well, at that point it was just rubber-duck with ChatGPT to think about how to do that.
Only today did I build out the interpreter script and a few sample programs.
https://github.com/master5o1/dick-sh