« Back to home

Scope: Not Just Mouthwash

I’m teaching a Python class which acts as an introduction to programming, for most of the students there. This is an awesome experience - for me personally because I enjoy this, and for my resume. I hope to do this full-time someday, but today I’ve just got 3 sections of the same class. We’re doing a lot of cool things that I should write about some other time - one of them is using a free, open source textbook called, Runestone - How to Think Like a Computer Scientist.…

Read more »

Deploying Github to Dreamhost

One feature I lost moving from Wordpress to Hugo for this blog was the ability to write a blog post from anywhere. I really liked being able to do that… I could be riding in the car, or smoking brisket at 2 AM, or on vacation without a computer, and just login and write something. I wanted that back - a posting solution from my cellphone. The reason I lost that ability is because the simplest update process for Hugo is:…

Read more »

Archive Pages

I recently converted this blog over from a WordPress installation to use static pages generated by Hugo. I’ve used Hugo for my other recent web creations and I’ve been very impressed. The templating system is very nice, the page generation is lightning fast, and I’m always able to find something near what I need in the themes. One WordPress feature I liked was the listing of articles by year and month… My blog had a little timeline on the side with each year and month listed, annotated with the number of postings I made during each.…

Read more »

Syntax Errors

Syntax Errors in Python are great. Here’s one: File "asdf.py", line 2 print("Result is: {}".format(result)) ^ SyntaxError: invalid syntax result = ((5 * 10) + 15 print("Result is: {}".format(result)) Two lines of code… Syntax error on the print line, evidently. But where? That line looks so simple and correct! And pointing directly at the t? Well - it’s not really on the print line. Folks who have done any amount of programming will look at the preceeding line fairly quickly and notice the missing parenthesis.…

Read more »

Writing About Writing Secure Shell Scripts

I recently read this cautionary tale about shell scripts. https://www.linuxjournal.com/content/writing-secure-shell-scripts It’s cautionary in two ways: it is intended to cause shell programmers caution, and I caution against you taking the article too seriously. One of the biggest threats to the shell in memory was the Shellshock vulnerability. This wasn’t typically a direct threat to shell scripts, but one caused by a bug in a shell, and by other programs exposing parts of the shell to external input, often in unexpected and unlikely places.…

Read more »

RasPi Flow Meter In A Pinch - Part 2

META: Part 1 describes the problem I’m trying to solve here. I need a way to monitor water flow through my water filter over several days, and I don’t want to sit and watch it. So - I took a Raspberry Pi I’ve got and a little Python and hacked a solution together. The basic idea was that I’d position a plastic cup below the output stream of the waste water, I’d put two wires into the cup, I’d put a voltage on one wire and attempt to see the voltage on the other.…

Read more »

RasPi Flow Meter In A Pinch - Part 1

META: This first part is about the problem that caused me to build the solution. Part 2 is about the solution. My new place has an awesome feature that was disabled when I moved in - a reverse osmosis water filter! It’s not a whole-house hookup, it’s just for the refrigerator and a dedicated tap on the sink. We definitely wanted to use this thing! At first, I just turned it on and it seemed to work fine.…

Read more »

Unix Text Editing Awesomeness

Oh, LaTeX acronym package, you won’t automatically alphabetize my list of acronyms? Strange… Let’s see if Unix will… $ echo "\acro{SCADA}{Supervisory Control And Data Acquisition} \acro{PLC}{Programmable Logic Controller} \acro{RTU}{Remote Terminal Unit} …" > toSort $ for i in cat toSort |sed "s/.*\\acro{\(.*\)}.*{.*}/\1/" | sort; do grep "{$i}" toSort; done \acro{ADC}{analog to digital converter} \acro{API}{application programming interface} \acro{APT}{Advanced Persistent Threat} \acro{ASCII}{American Standard Code for Information Interchange} … Unix, you rock my world.…

Read more »

Bash Dictionary - Terrible Hack of the Day

So, I just had a reason to implement something like a dictionary in Bash. Of course, I could try to determine if such a feature exists already (it does in Bash 4, alas the default on OS X seems to be 3.2), but why not just try to hack something together? Here’s what I got initially: OFFSETDICTkeyUno=5 OFFSETDICTkeyDos=4 OFFSETDICTkeyTres=17 OFFSETDICTkeyQuatro=21 keyToLookup="keyQuatro" value="$(eval echo ‘$OFFSETDICT'${keyToLookup})" echo $value > 21 So, that’s ridiculous.…

Read more »

Python's super()

I’ve been writing a lot of Python lately, and there are some things I love about it, some things I’m uncomfortable with, but nothing I hate. The super() builtin function makes life a lot easier when you’re using Python for object oriented code and have some inheritance going on. This blog post describes the best way I’ve seen it used so far. First of all, in Python3 you no longer need to write “super(CurrentClass, self).…

Read more »