Below you will find pages that utilize the taxonomy term “Programming”
The Political Reading of If You Give a Mouse a Cookie
This morning I was listening to one of my favorite podcasts, Decoder Ring. The most recent episode had a very interesting title: If You Give a Mouse a Cookie…Will he want a Welfare check? I don’t remember this book from my childhood, but I do remember reading this one (and others in the series) to my kids. The podcast explores the fact that, starting around 2015, this book started to become known by conservatives as an allegory against the welfare state. While this podcast episode eventually interviews the author and confirms this was not her intention, I can certainly understand how the book could be read that way. It’s a great example of how art (literature, movies, images, music) becomes “property” of the culture once the creator releases it into the world. In many ways it doesn’t matter what the creator wanted (although I always find that fascinating), but what the culture does with it.
Review: If Hemingway Wrote Javascript
If Hemingway Wrote JavaScript by Angus Croll
My rating: 3 of 5 stars
The intro mentions the natural language nature of Javascript. I wonder if the book had been concieved a few years later if it would rather have been Python or Ruby - both of which are way more like human language than Javascript.
The book is fun and I mostly get it, but to truly get what the author is doing here, I think you would need to be a Javascript dev. The whole point is that the author is nerding out not only on the writing style of the authors they have chosen, but also converting that into Javascript coding styles. As someone who programmed in many languages, but hasn’t touched Javasscript in the the mid-90s, a lot of the elegance of this book is lost on me.
How Go Helped Save Healthcare.gov!
I recently used Mastodon to ask for recommendations for Go podcasts and one of the suggestions was Go Time. One of the recent episodes in the feed was a rerun of an older episode about " How Go helped saved HealthCare.Gov". This was extra interesting to me since I wrote my Master’s Special Project on Healthcare.gov. (I haven’t read it in nearly a decade, so I don’t know if it’s cringe-worthy at this point). The episode had on one of the programmers who helped get things back on track for the site. It was incredibly informative about the problems that led to the site not being responsive enough and how they were able to help fix it without scrapping the entire site. No matter what side of the political spectrum you’re on or if you’re even an American, the episode is fascinating for understanding how things can go wrong even when everyone has the best intentions and how to fix a large, complex code base.
Programming Update: Sept 2022
This month I wanted to practice Go outside of Advent of Code puzzles. So I decided I would port over my Dreamhost DNS updating script from Python to Go. This would have the advantage of being a compiled program. Every time I update Python on my system, the virtual environment points to the wrong Python version and my program breaks. But, boy is parsing JSON in Go (at least with the built-in JSON tools) a real pain in the butt. I have to make a struct to hold and parse the data, but it comes back from Dreamhost as a 1-key dictionary holding an array of dictionaries. After a few hours of trying to figure out how to get Go to parse the JSON I was still unable to get the struct right. I may do a little debugging to see if I can figure it out before searching for any simpler JSON libraries.
Software I used for Programming in 2020
I last wrote about the software I’m using while programming back in March. I think at the time I was thinking of writing quarterly updates, but my preferences didn’t change with that much regularity. I decided to make it one of my annual posts instead. So here is the software I used in 2020 to program.
Python Projects
PyCharm
For my Python projects I transitioned fully to PyCharm Community Edition. I documented my reasons for moving towards Pycharm in this post with a followup here. As I was writing this, I learned of a Real Python guide to Pycharm that taught me a few things I didn’t know about how to make better use of PyCharm. PyCharm has made Python programming a real joy. For any libraries I have imported (or standard libraries), it provides excellent code completion as well as context for function or method arguments that saves me time vs looking it up in documentation. The git integration is also great and I’ve recently started exploring usage of the lower git window which may make GitQlient obsolete for my Python projects. I haven’t made the best use of the debugger yet, but I’m slowly learning how to take advantage of it in my larger projects. If you’re a Python programmer I can’t imagine a better IDE. I did have access to Pycharm Professional for a while in 2020, but I wasn’t doing any Flask or Django work, so I didn’t really notice anything useful over the community edition.
The Right Programming Language can make a big difference
Recently I came across this video where a programmer solves the same problem in 6 different programming languages:
What’s incredibly beautiful are the Haskell and APL solutions. Whereas every other language requires multiple lines, Haskell solves the problem in just one line. And APL is just a few symbols.
Here’s the same guy solving a problem from the Leetcode challenge in a few languages. Once again, it’s pretty neat how the elegance of the solution varies across languages:
Today in Programming: Microsoft MakeCode
With the twins, I messed around with a Neopixel strip. Not sure what I’d do with one in a future project, but at least I know how to program it in MakeCode now. Our project:
Messing around with the Neopixels Strip
Today in Programming: Microsoft MakeCode
Since I’ve been making a lot of great progress programming with the kids in Scratch, I bought some Circuit Playground Expresses to program with the kids. The Circuit Playground Express can program in Arduino’s C dialect, CircuitPython, or Microsoft MakeCode, which uses blocks like Scratch. Today Scarlett and I made our first useful bit of code, a digital spinner we called The Sibling Chooser. Here’s the code, and you can see that it is indeed like Scratch:
Programming Tools Q12020
I decided to document the tools I’m using for development since the various programming subreddits I frequent always have someone asking what tools they should be using.
IDEs/Editors
Linux
As I wrote in September, I’ve moved to using KDevelop for my larger projects.
KDevelop
Its built-in Python parser (working with flake8) has helped me find a lot of issues before getting to the stage of running flake8. The GUI for pushing commits to git has been very helpful in helping remind me what has changed and even (sometimes) noticing something I forgot to add to git. Its project-wide search has been invaluable when refactoring or renaming functions/classes. When it comes to large, complex programs, it’s hard to beat KDevelop when using KDE. That said, it’s only recently that the developers have started focusing away from being only a C++ editor and as you’ll see at the end of this blog post, for my Python workflow, I might be switching away.
Getting rid of some old Java textbooks
I had been hanging on to these books in case I ever found myself wanting to do some Java programming. But as I’ve come to learn (mostly because of Python, but also through following the Perl 6 saga), languages change and evolve and so a couple books from nearly 20 years ago probably won’t be more useful than a newer book or a good Google search.
Cornell’s CS101 class textbook back when I was a freshmanI don’t remember what class this was for, but Cornell sure loved Java back then.
Git gets interesting
This used to look pretty regular. Just two parallel lines with the devel branch connecting into the master branch here and there. But then I merged master into devel because I added issue templates on the github website directly into master. Things got….interesting….
Here’s the before (but a few weeks ago):
git before merging master to devel
Here’s what it looks like now:
git after merging master into devel
Discovering new git GUIs
When I wrote about checking out KDevelop, I mentioned that it was due to a blog post by the Kate developers about how to evolve Kate going forward. Last night I came across a new article in the same vein in which they looked at potential git GUIs to use from within Kate. In my KDevelop post, I mentioned that I use QGit, but it can look a bit small in the screenshot of my 3 monitor desktop. So this is my typical QGit setup:
My First Pull Request to a project I don't own!
When MakeMKV added a new requirement for ccextractor, allowing it to grab subtitles that are encoded on the DVD or Blueray as Closed Captioning instead of subtitles, there wasn’t a package available for Fedora. (There is now, but at the time where wasn’t) So I wanted to make an RPM that I could host on Fedora’s COPR for others who needed the package. There was a problem with their shell script for building RPMs. At the time I just kept hacking away at it until I was able to build RPMs. But I didn’t think about how the manual process wouldn’t be sustainable as changes were made to CC Extractor. They weren’t having releases too often, so I didn’t worry about it. But then they made a new release and I knew that this time, having leveled up on my git-fu, I would try and figure out how to fix that problem and submit a pull request.
Addendum to my KDevelop Post
A couple days ago, I wrote about giving KDevelop another look and posted it to reddit’s r/kde. In my post, I’d said it was annoying to have to configure the color schemas per file. Someone commented on the subreddit that if you use the View->Schema menus it’s per file while if you go into Settings->KDevelop settings you can change it for all files.
As a side effect I explored the same options in Kate and set it up like this:
Why there are over 2 dozen music players
People often groan when they hear of someone making another game of Tetris, Window Manager, or audio program. After all, people ask, “Do we really need another? Why can’t you just contribute to fixing annoying bug X in gTetris/KDE/xmms?” I’ve always been on the side of the argument that said - “So what! They’re doing it for free. Not only that, but they’re not getting paid for this. It’s their hobby. So you can’t tell them what to make. If they don’t WANT to help Amarok, then leave them alone. Don’t download their program and they will eventually lose interest.” I’ve never been one for telling people what they should do in their spare time. (Not in any serious sense, anyway)
Procedural Art
edited to add the tags I used
That collage was created by a program. I certainly don’t have the patience to arrange all of those photos one-by-one!I told the program to download all of my pictures tagged with Eric Danny David and Danielle and create this collage.
But does that make this any less of a work of art? I think the answer is no. The artwork was just created procedurally instead of visually. To argue that this is less artful is to say that the The Lion King isn’t art because the wildebeast scene was created procedurally. Of course, in this situation I don’t see myself as the artist, but the guy who wrote the program is the collage artist. It’s his procedures which created the art. His name is Jim Bumgardner and he’s a really nice guy who helped me fix up the script. I copied it from his book, Flickr Hacks, but unfortunately, as the code he relied on has changed, it didn’t work as posted. In fact, here is the fix you need in his program, makeCollage.pl :
Use Minix....create a free OS?
As we all know, Linus Torvalds created Linux out of his frustration with the lack of features in Minix, a teaching OS meant to duplicate a POSIX-compliant Unix system. Well, as a great followup to Saturday’s Post, why not check out Minux yourself? A new group has begun developing Minix3, in the hopes of getting into a niche somehwere between FreeBSD and Linux: tiny, old computers. All you will need is the VMWare Player and Minux source. Typing root at login gets you in without any passwords. Tinker with Minux3 and tinker with a bit of history. It’s not EXACTLY the version Linux used, but it’s still pretty darned cool!
My first project on Freshmeat!
Frustrated with the lack of an easy way to create a video DVD on Linux, I decided to write a program to do just that! I wrote a program that will generate the dvdauthor.xml file needed to create the video DVD. Then I realized that if I had been so frustrated, perhaps others were too, so I created a project on Freshmeat.net.
Check out my project! Pydvdauthor
My Monty Hall PHP Script
Well, actually, it’s not mine. It was a script in Linux Format Magazine a few issues ago. As hobbyists have done since the beginning, I copied the code down to see it actually work.
First the background on Monty Hall. Here it is from Wikipedia.com:
The Monty Hall problem is a puzzle in game theory involving probability that is loosely based on the American game show Let’s Make a Deal. The name comes from the show’s host, Monty Hall. In this puzzle a player is shown three closed doors; behind one is a car, and behind each of the other two is a goat. The player is allowed to open one door, and will win whatever is behind the door. However, after the player selects a door but before opening it, the game host (who knows what’s behind the doors) must open another door, revealing a goat. The host then must offer the player an option to switch to the other closed door. Does switching improve the player’s chance of winning the car? The answer is yes — switching results in the chances of winning the car improving from 1/3 to 2/3.
Bash Shell Scripting
One of the best things about Linux is the ability to write shell scripts. These are most often used as utility programs to do repetitive tasks for you. I just wrote my first one on Sunday and here it is followed by commentary.
#!/bin/bash echo "starting xchat..." xchat& echo "starting Gaim..." gaim& echo "starting Thunderbird..." thunderbird& echo "starting Gkrellm (docked)..." gkrellm -w& echo "starting 2 instances of Eterm (transparent, no buttonbar, no scrollbar)" Eterm -x --scrollbar=0 --buttonbar=0 --trans& Eterm -x --scrollbar=0 --buttonbar=0 --trans&
More Atmel Code available!
I have posted the latest code from the work Rich and I have done for our microcontroller class at Cornell. We are releasing all of our code under the GPL license so feel free to use it, modify it, and have fun with it. The code is modified C code and assembly language for the Atmel Mega32 chip running on an STK500 board. It should be easily available from Atmel or perhaps your local electronic hobbyist shop.
A few updates and notes
If you go to my main page, you can see where I have added a new section, C code from a class I’m taking this semester. We’re making a lot of really cool designs based upon the Atmel CPU, which is readily available for those who like to tinker. I’ve put up my first project, a reaction time tester. It has the user push a button, waits approximately two seconds plus a random amount to keep the user from guessing, and then displays the user’s reaction time. It also keeps the user from cheating by detecting if they are holding the button down.