« Back to home

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 »

PHP: The Right Way

There are a lot of pitfalls to using PHP, and they bite new users quickly. “Spot the vulnerability” is a cool site which highlights examples of these pitfalls: http://spotthevuln.com/ (BROKEN NOW) Of course, PHP is a pretty speedy way to develop any type of server-side web code. Josh Lockhart has put together a list of best practices for PHP development and tailored it to new PHP developers: http://www.phptherightway.com/ If developers would follow the recommendations in the databases section it would take care of so many vulnerabilities out there today.…

Read more »

LCD Modules

I’ve never built anything with an LCD on it before, but it seems like it’d be useful. Here’s some good info on creating an project with an LCD and an Arduino: http://arduino.cc/en/Reference/LiquidCrystal It’s a library of functions that make it very easy to work with the LCD controller. The controller has to be compatible with the HD44780 controller’s instruction set, but that’s basically an industry standard. Mouser has a selection of 20x4 character displays:…

Read more »