More TPP and Perl

Finished reading the main sections of The Pragmatic Programmer.  The fifteen year old book shows its age in some spots, but mostly is great advice.  I was pleased to see that a lot of the practices the book encourages, are already being implemented at the place I work at, and other places I’ve interned.   Specifically, using source control, commenting your code in a sensible manner (document why, not how, the code tells you how), and automated builds and test suites.

It’s a great reference book to have with you whenever you’re starting a new project.  The thing I’m mostly going to take away from it is to think about what I’m trying to solve.  I see a lot of instances in my job where more automation would help.  Developer environment set up, data conversion, and some other areas could all use a bit of automation.  I do recognize that somethings would be harder to automate, than to just do it manually.  Some deployment procedures would be difficult to automate as required permissions are missing.  Sometimes you have to work with what you’ve got, but that doesn’t mean you shouldn’t look for improvements.

I’ve been slowly going through this Perl book: Learning Perl 6th Edition.  I’m about 4 chapters in, and it’s been a good resource so far.  Each chapter has exercises at the end to work through, which I’ve enjoyed.  Some of them require user input from the console, and I’ve found that Notepad++ is not the best environment to be running the programs from, as there doesn’t seem to be a way to end the program without killing it completely.  Specifically, the <STDIN> command for inputting an array of values.  Normally, you would send it the EOF command (ctrl-D, or ctrl-Z, depending on your OS of choice), but I was unable to find a way to do that within Notepad++.  I’ve switched to Sublime Text as my IDE.  I haven’t found out if it supports <STDIN> for arrays, but I like the look of it.  I think I’m going to have to learn to run the programs from the command prompt.

Beginning with Perl – Perl for XML transformation

I’ve been reading through TPP, and the second chapter deals with the tools that a good programmer should have access to.  I never really thought about it, but text manipulation is a big part of the job.  In the past I have written small projects in Java to create test data, or transform one data set to another, but the development time and overhead is quite high.  The book mentions Perl, Python and Ruby as better text manipulators, and I’ve decided to try using Perl.  I’ve done a bit in Python before, but nothing more really, than a Hello World program.

Reading the book has exposed me to some glaring holes in my knowledge, but also inspired me to look for better solutions to problems.  There are some manual processes I’ve been doing at work, that I don’t think I would have considered automating until I started reading tech books.  It’s ignited my passion for writing code.

So, I downloaded Strawberry Perl for Windows, and set up Notepad++ for executing Perl scripts and wrote my first Hello World program.  I’m going to try some XML transformation as my first real program.  I don’t know if it’s the best tool for the job (XSLT, Python, etc., could all be better choices), but I guess I’ll find out.

Adaptability and Calmness

I haven’t had much time lately to read more of TPP, but I did  have some thoughts about it, and what a developer needs to be successful.  Or more accurately, how a developer should react to changes to keep themselves sane.

A developer has to contain their frustrations, when changes occur.  Changes occur for many reasons, due to additional or revamped requirements, team member additions or subtractions, alterations in company policy, or a variety of other reasons.  Eliminating all possibility of change is not feasible, and you have to take them in stride.  It’s easy to hold a static view of how a project should be progressing, but when something happens that goes against that view, it can make you angry, looking for people to blame.  A better approach would be to try and determine the true value of the change in terms of time and effort, and figure out how to get it done, rather than fester because you believe that the change is unnecessary, or is coming in too late in the project’s timeline.

Sometimes, changes are unnecessary, but if you’re not the one making those decisions its better to go with the flow and reduce your stress levels.


The Pragmatic Programmer

I finally found some time to start reading “The Pragmatic Programmer”.  I got through the first chapter, and I’m already hooked.  A lot of good information, and recommendations, presented in a clear and concise way.  Some great summaries of some things I’ve tried to do at work, including:

  • Fix Broken Windows – Don’t let small, broken things stay broken.  It degrades the overall impression of the project, and leads to more and more ignored problems
  • It’s Both What You Say and the Way You Say It – Make sure that when you’re communicating with people, either written or in conversation, that your tone is respectful and the message is clear.

The section I found the most valuable was the Knowledge Portfolio section.  I made the mistake of not putting enough effort into continuing my education after I landed my job.  I let the work be my sole teacher, where as I should have kept reading and trying other things outside if my job’s responsibilities.  Other books I’ve read have advocated that as well, but TPP provided great concrete examples, with links!  Some of the recommendations I get nervous about finding the time to do, but something is better than nothing, and I will try to accomplish as many of these as I can this year:

  • Learn at least one new language every year – This one seems daunting, but is probably the best suggestion.  I’ve done enough C# / Java, I need to branch into something different.
  • Read a technical book each quarter – I’m on my way to doing this one.  One a quarter is definitely doable.
  • Participate in local user groups – This one makes me nervous as well.  I understand the importance of networking, but I need practice.  I’ll try to attend at least one this year, a very low bar to set
  • Stay current – I read all day on the internet, and all night on my phone.  Might as well add some tech sources to my reading list.  Gladly, the book adds some recommendations.
  • Get wired – Join a newsgroup.  I think once I decide what language to try and learn, I will look for a newsgroup to join to keep me interested.

There were many more great suggestions and Tips, and I’m looking forward to the next chapter.

Bit operations and Book learning

I found a link to a page on bit operations via Hacker News today.  I plan to go through it in some spare time, to refamiliarize myself on them, as I’ve never come across the need to use them in any work project, and could probably use the refresher.

I finished the main articles in Programming Pearls, and will probably order Pragmatic Programmer in the next week and start going through that.  There was a great side article in the 13th article about a lightweight dictionary.  There were a lot of tricks used to shrink the space of the stored words, including hashes, and suffix and prefix pruning.


2 years since the last post…

Since then I abandoned the Mnemosyne project. It was fun to work on for a while, learning some CSS and working with PHP. But I started using Evernote, which basically had every feature I wanted already implemented, with phone support.

I worked on a chess board coverage simulator that helped you visualize which of your pieces were in danger. Build in HTML, JS and CSS. I played with JQuery a bit on that one, and tried to build a good UI. Each square tells you in the top two corners, how many pieces are covering it at that moment. You can initialize the board, and move all the pieces around. It’s free form, so you can move any piece anywhere you want.

I also worked on a parser in PHP for an NFL pool I was in. The software the pool used was very old and unsupported, so it was missing a lot of basic functionality. I created a site that would scrape the page of player picks, and dynamically sort the standings based on the current game scores. I hooked into an XML feed from for the current scores. The site also allowed you to submit hypotheticals, eg., if you wanted to know where you’d place if certain teams won. I worked a bunch on it in 2012, and then polished it in 2013. I think I’ve convinced the pool admin to switch to better software next year, so unfortunately, it won’t be useful anymore.

Recently, I’ve been reading tech books that I should have read in University: Mythical Man-Month by Brooks, Programming Pearls by Jon Bentley, and hopefully next will be Pragmatic Programmer by Andrew Hunt and David Thomas.

I’m currently reading through Pearls, but I haven’t been doing the coding exercises. I wanted to read though it first, and absorb the knowledge first and maybe go back later and try some of the problems. I haven’t worked in C++ or C in quite a while, most recent would probably be in 2010 fooling around with Microsoft Kinect SDK.


I haven’t been putting much effort into my websites recently. I went through a couple of weeks of work on Mnemosyne. I tried converting it to CakePHP, but was distracted by my actual job in the process. My initial impressions of CakePHP weren’t great, but once I started working with it I really liked it.

I worked on an entry for the AI Challenge. I built an ant-bot to compete against other ant-bots. There were some really interesting strategies from some of the winners. I developed my bot in Java. I started out my career as a Java dev, but I’ve moved to .NET / C# in the past few years. It was nice to get my hands in a Java program again.

I also added a new photo to Apollo.

jQuery & mouse events

I’ve been really motivated on Mnemosyne since the start of the new year. A lot of features are working now, at least in functionality. Some code cleaning is going to be needed fairly soon or it will just become such a mess.

One interesting thing I was able to get working (in everything except IE, grumble) is a entry control menu to appear and disappear on mouse entry / exit.

Here are two screenshots with the menu on and off:

Basically, when the mouse enters the parent div of the entry, the absolute positioned div of the controls should appear, and when the mouse exits the div the controls should disappear.

I first tried doing this from scratch with my basic javascript understanding, but it wasn’t working properly. I couldn’t get a proper handle on the control div. I then tried the first jQuery on the site and it went a lot smoother. Here’s the code:

  $('div.entry').each( function(intElementIndex, objElement) {
      function(){ $(this).find('div.entry-controls').css("visibility", "visible"); }
      function(){ $(this).find('div.entry-controls').css("visibility", "hidden"); }

So, the selector gets all the entry divs, and registers functions to toggle the visibility of the child entry-controls div.

Other things I got working are user registration, and a recycle bin. Next on the plate is code refactoring, and improving the tag support.

Password Protection is Key

Worked on Mnemosyne the past couple of days. Added password protection so that spammers can’t enter anything. Add the same functionality to the delete page so that only I can delete the entries for now.

Also added an edit page (also password protected). The main functionality is starting to come together. Stuff on the horizon:

  • Tag support
  • Profile Support
  • styling
  • search

And then a bunch of code quality issues. I’m sure there’s got to be a better way to handle database stuff. Hopefully something like hibernate for php. I’ll have to look into that.

Got my local environment set up, so I don’t have to use the live site as my testing ground. That didn’t take as long as expected. A couple of trip ups. For one, if using Windows 7 64-bit, apache 2.2, and php5 make sure you get the VC6 thread safe versions, or else apache and PHP might not work well together. I tried all four distributions of php5 before I got it right.

New Year’s Motivation: Mnemosyne Fix, Homepage Cleanup

Hello 2011.

I sort of let this site slip. And by sort of, I mean completely. I had uploaded functionality to Mnemosyne without fully testing it, and it pretty much broke everything. I was able to sort out what the problem was and fix it, but I don’t think I’m doing database connections properly in PHP. I basically have a database connection opening at the beginning of each page, then closing it at the end. Maybe that’s how it should be done, but it seems intuitively wrong. I’ll have to look at that.

So Mnemosyne works again. Lots of spam on there that I’m going to have to clean up. I’ll need a password or CAPTCHA to filter that out. Maybe password for the beginning, then CAPTCHA when I have more time.

I removed some music flash players on the home page. They had worn their welcome. I need to change that front page completely. I don’t like it anymore.

Hopefully this isn’t the last entry for a while.