« Back to home

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 »