« Back to home

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 »

MinGW and Cygwin to build a Windows DLL

I was writing C++ in Linux - gvim + aterm is my development environment of choice. I needed to turn my code into a Windows DLL, though, and the following webpage was really helpful. http://www.mingw.org/wiki/sampleDLL I installed Cygwin in a Windows XP virtual machine, used Cygwin to install MinGW, modded my code and Makefile a bit based on the samples on that page, then ran “make windows” in that virtual machine.…

Read more »