Categories
Uncategorized

The Code Struggle

I struggled with some code this week. I knew what I needed to code to do, based on the behavior of the device I was building, but getting to the point where the code did exactly what I wanted took some time. I made mistakes, I had to test things repeatedly, I had to add code to show me exactly what was happening… and in the end, it worked.

I’d say that 95% of the code I write nowadays is pretty simple (for me) and I get it right on the first try. The other 5% is maybe a bit of a challenge and some is just challenging to me.

But… I like the challenge.

I would rather struggle with the code and find a solution, and celebrate the outcome than just have some fucking AI robot write the code for me.

I know, some people would rather just get the answer, have it handed to them, skip the work, and move on. Life should be easy, not a struggle!

But it’s through the struggle that we become who we are, how we learn about ourselves, and others, and the world around us.

What great achievement has been taken place without some form or struggle? Without working towards something better?

The Billionaire Ruling Class know nothing of struggle, because everything has been handed to them. Perhaps that’s why they try to shove AI down our throats. They assume everyone wants the easy answers.

I’m thinking of lyrics from two different hardcore bands right now that are a perfect fit for this post… and maybe that’s part of why I am the way I am, because some guys in a punk band 30 years ago recognized the same thing and wrote words and music and piled in a van and drove around playing to small crowds and screaming and connecting with people who felt the same.

Life should be about always seeking answers, always gathering knowledge, it’s an exploration, it’s a journey, and there is no shortcut or magic answer key that will solve the mysteries of life for you.

Categories
Uncategorized

milesBiked – A Bar Graph Generator

In a previous post titled Miles Biked (so far)… I talked about generating bar graphs to show how many miles I biked. And in the post before that I suggested you Share Your Code. So this post is the logical conclusion.

You can find milesBiked on Codeberg, a community-led platform that offers Git hosting and other services for free and open source projects. Codeberg is a non-profit organization based in Berlin, Germany, that respects privacy, supports the commons and celebrates creativity.

When I posted about blogNag – A Blog Post Reminder I decided I should try to do more to share the code I write. It’s not amazing, it’s not worthy of praise, but it’s code that works for me, solves a problem, and others might be able to use it to learn from. In the age of AI, LLMs, and “vibe coding” I think this is important.

In a world where so many applications are subscription-based, or the free version has limitation that can only be unlocked by paying, releasing free software and open source software to the world can be seen as an act of resistance… or rebellion, even.

Code given freely is a gift to the world. I expect no remuneration for the code I share. Save it for larger projects with more impact. I donate to a number of larger software projects that I use all the time. Inkscape, OpenSCAD, CryptPad, and others… Tools I use almost daily that have allowed me to escape restrictive commercial software. Send your money where it will help the most.

Right, so I learned a bit about Matplotlib and used my basic Python skills to write about 25 lines of code… but I stand on the shoulders of giants. Those who created Python, who documented it, the Matplotlib authors, and the people who wrote articles, blog posts, forum posts, and tutorials with example code that made it all very easy for me.

Good software isn’t created in a void… and it’s not created by telling a machine what you want your code to do. It’s created by people like you. Let’s all work together to make a better world.

Categories
Uncategorized

Share Your Code

code-share

It’s important to share your code, and for you to see the code other people have written. I almost never start with an empty text document when I write code. I either use my own previous code or find examples of how to do something. (And my “previous code” probably came from someone else anyway!)

I should note that I am not a “software developer” but just some guy who has been writing code since the 1980s and managed to cobble things together so they work and I can use them to get things done.

I am not some amazing coder, but I get the basics of how things go together. I have absolutely zero interest in “vibe coding” or explaining to an AI what I want and having it spew code at me.

I am, and always have been, deeply interested in learning things, understanding things, figuring things out, and solving problems. I will take the long way round to meet my goals because I don’t mind doing the work. I discover new things, and what could be more exciting than that? Saving time to do more work to try to make more money? No… no thank you.

The maniacs I know who “save so much time with AI” are still working 50+ hours a week and for what? How is life improved? I don’t know. I enjoy learning new things and don’t want to outsource that enjoyment to machines.

Now, that said, there is a quote from “The Fly” that I’ve always liked:

There’s a lot of stuff in there I don’t even understand. I’m really a systems management man. I farm bits and pieces out to guys who are much more brilliant than I am. I say, “build me a laser” this, “design me a molecular analyzer”, that. They do, and I just stick ’em together. But, none of them know what the project really is. So…

Mostly the “bits and pieces” and “those who are much more brilliant than I am” and some of the “a lot of stuff in there I don’t even understand” to a certain degree. Though I actually do want to understand it.

I just did a small coding project and I was able to find example code that got me 90% of the way there… after a bit of searching I found other example code that got me the rest of the way there. I may want to take my code further, in which case more example code will surely get me there.

But the thing is, that example code needs to exist. I need people to share their code. I hope that doesn’t sound selfish, as I also share my own code. I want to learn from other humans, and I want to share what I’ve learned with other humans.

There is some concern that forums where people ask coding questions will go away, and that would completely suck for people like me who love to see a question with multiple answers on how to do something. I found like six different solutions to what I was working on today, and it took a few tries but one of them worked quite well for my case. Another might be right for you.

If I skip the BASIC I wrote in the 1980s and jump to the 1990s when I was learning Perl (and eventually other languages) it was due to developers and other nerds publishing their code, and their tutorials and documentation and putting it out there. That is how I learned, and it’s still how I learn, and when the AI bullshit hype circus is done and gone it will still be how we can learn from each other. Human to Human… Nice.

Categories
Uncategorized

blogNag – A Blog Post Reminder

I recently released blogNag which is a Python script I run once per day via a cron job to notify me how long it has been (in days or hours) since I last wrote a post on this blog. This forces me to think “Hmm, I should write another post…”, thus promoting a cycle of continuous blogging.

I remember back around 2000 so some bloggers had this idea to “bug” each other if they didn’t post for a while. This is the modern day version of that, since most of the 2000 bloggers have stopped long ago. ;p

It uses feedparser and I remember having some issues getting that installed in the past so I set up a virtualenv for Python. I had these two links for notes: venv — Creation of virtual environments and How to Set Up a Virtual Environment in Python – And Why It’s Useful

My short version for setting up a venv since I will probably forget by the time I need to do it again…

mkdir blogNag
python3 -m venv ./blogNag
cd blogNag
./bin/pip3 install feedparser
# now we can run
./bin/python3 ./blogNag.py

Look, I’m not great at Python but It Works For Me.

Also, this is on Codeberg because I don’t plan on putting any of my personal work on GitHub in the future if I can avoid it. (Microsoft acquired GitHub and I prefer not to support them if possible. Others can make their own choices in the matter, and I won’t judge!)

You’ll probably want to change the code to look for your own feed and do your own notification thing… Again, it works for me, YMMV and all that. Enjoy!

Categories
Uncategorized

Circular Positioning in OpenSCAD

This post is about a problem… it’s about looking at a problem from the wrong angle, and eventually realizing it.

I wrote some code in OpenSCAD, and then I wanted to change something and I could not figure out how to get the positioning right. I should confess I am terrible at maths. In school I took geometry, but never did calculus or trigonometry, and know almost nothing about those areas of mathematics.

Since I tend to work in Cartesian coordinate systems I think about moving things in X and Y. Left, right, up, down… Sure, there are angles, but they can be difficult. But maybe they shouldn’t be…

Here’s what I wanted to do: Create a circle with three smaller circles evenly placed into a triangle. Now typically in OpenSCAD I move things around in the X and Y and for the mostly rectilinear things I design (mostly enclosures) that’s simple, but circles can get weird. So what I tried to do was move each of the holes along the X and Y axes, but I could not get them evenly spaced…

See, this is easy for me. Four things, evenly spaced. Everything moves from the center an equal amount in X and Y. My simple maths brain has no issue with this. I’m so used to doing it this way I can bang it out without any thought. But this way (while simple) is sometimes not ideal.

As is often the case, I took to Mastodon with my problem, because there are people there much smarter than I am… Luckily @GeekAndDad was on the case! While he was busy doing the hard math I was distracted with some other projects… but when I returned I realized I knew how to do it… because I did it ten years ago! Check out this post about Derby Wheels.

Okay, so I did it before, but didn’t have easy access to the code I had written, but remembered how it worked, so I banged this out:


// Position things in a circular pattern in OpenSCAD

$fn=100;

howMany    = 3;
distance   = 10;
holeSize   = 10;
startAngle = 30;

difference() {

    // create the object
    translate([0,0,0])
        cylinder(d=40, h=3, center=true);

    // loop around in a circle and difference some holes
    for(variable = [startAngle : 360/howMany : 360+startAngle]) {
        rotate([0,0,variable])
            translate([distance,0,0])
                cylinder(d=holeSize, h=3.1, center=true);   
    }
}

(You can also find this code in my gists repository.)

Here we go! Three holes, evenly spaced… We do this by rotating around the center and placing the hole X number of units from the center, every X number of degrees. You can set the number of holes howMany, the distance from the center, and of course the holeSize and also the startAngle which helps rotate the whole set into something that matches up properly.

Hey, you can even do four holes! They are all still evenly spaced from the center…

You can do seven holes… The bit with 360/howMany does the maths to determine how many degrees there are before adding another hole.

Heck, you can even do just two. Want them top and bottom instead of left and right? Just change the startAngle appropriately.

You can put the holes on a square instead… or a rectangle, or anything, really. And they don’t even need to be holes… I just needed holes for this specific example.

Another square with some holes…

And yet another square with some holes… This time with a different startAngle set.

Those holes look a little large… can we make them smaller?

We sure can! Look at that… Obviously you are not limited to just making circles, and this technique of using a for loop to put things around the center of an object can be expanded in many ways. I just wanted to share this recent remembrance so I can find it again when I need it!

By the way, these OpenSCAD renders were all done using my Cyber Night theme for OpenSCAD.