Tag Archives: rant

Logical Meltdown

I have been totally unable to accomplish any coding this week.  I’ve been rewriting this application at work and while I’ve made some decent progress, I haven’t gotten a damn thing done this week and it’s frustrating as hell!

Of course now that it’s Friday and I’m feeling the urge to start writing more code having to do with dongs.  What the fuck is wrong with me?  Don’t answer that.

I figured that by explaining some of what I’m struggling with, some magic will happen.  I need to blog more and work on my “explaining complex shit in a meaningful way” skills, so if this in any way interests you please read on.

WARNING: TECHNICAL SHIT BELOW!

The application I am rewriting is a MySQL database-driven app that has two interfaces:

  1. A command-line interface (CLI) utility written in Perl for direct manipulation (addition/removal of records) and querying (searching) of the database. Only engineers have access to this tool.
  2. A web application written in PHP for searching the database for non-engineers.  Mostly support and operations staff use this. This also provides a hacked up “API” that returns a list of comma-separated values (CSV) of matching records.
It’s something I wrote years ago using PHP & MySQL that is way more complex than I remember it and double-dog dare you more complex than it needed to be. It’s strange going back in time with my code, especially PHP (shame), and realizing how competent I was even then, but how unnecessarily convoluted I made some things.

There are a shit-ton of logical pitfalls in that code that have really thrown me off.  Being that we have a Perl CLI tool and a PHP web app, the much of the code is duplicated for each language. The tool was originally written in Perl with the web app piece tacked on as an afterthought.  At the time I was really into PHP’s native support for MySQL but was pretty much a novice so ended up making some downright lazy and bad choices.

With PHP and it’s bloated cousin Perl, there are so many ways to do the same thing that there really isn’t one right way to do things.  Typically that means there are that many more wrong ways to do them.  For example, horrible crap like this where we have PHP making a system() call to execute a Perl script from within index.php:

<table>
  <tbody>
    <tr valign="top">
      <td>
        <?
          system('perl body.pl column="' . $POST['column'] . '" value="' . $POST['value'] . '" netmask="' . $_POST['method'] . '"');
        ?>
      </td>
    </tr>
  </tbody>
</table>
Couple that with my prior lack of regimented programming style because I originally learned to code from the back of a Cracker Jack box (aka the internet), and what I am working with is pretty much a nightmare.

“Why is that?”, you ask?  Well let me tell you!

First things first, the primary users of the app (aka the stakeholders) have been requesting some new features for a long time and with everything else going on it hasn’t really been a high priority for me.  Especially because it was written in Perl, which I have grown to hate passionately since I started using Python.

Next, the systems from which the CLI tool runs are being replaced, which means the app has to be moved to the new systems. We run a Red Hat offshoot distribution of Linux, so we use RPMs to manage what gets installed on machines.  What this means is that any Perl module dependencies need to be installed via RPM. With RPM and Perl there are always dependencies of your dependencies, and you can bet that some of those won’t be available in the repository. This opens a massive can of worms of having to download the module source and convert it to RPM.  For those of you who are familiar with Perl’s CPAN and RPM, you’re probably thinking “Just use cpan2prm!”. Right, if only it were that simple…

You see, the new hosts are running a 64-bit kernel, which means that the subset of available packages is even smaller because packages have to be specifically built (or rebuilt) for 64-bit installation. Even if it’s the same files inside of the package, it still has to be re-packaged for 64-bit.

So, I was left with the choice of either uprooting the tool from its current location, wrangling package dependencies, rebuilding packages, modifying the Perl code to shoehorn it into the new systems all the while overlooking the implementation of the requested features; or rewriting it using Python & Django.

Naturally, I chose to rewrite it because the thought of having to trudge through antiquated Perl hackery gave me diarrhea and I really don’t want to ever touch Perl or PHP again if I can help it. By rewriting the app in Python, I can implement the new features and bring the code into the present at the same time without having to go through bouts contemplating suicide. Annnddd… That leads us back to the nightmare that is Perl and PHP.

As I mentioned above, with Perl & PHP there are so many ways to do things that most of them are convoluted, confusing, hard-to-read, and just plain fucking wrong. With Python–and Django for that matter–there is usually only one right way to do things, and that way is pretty much always elegant.  Plus, one of the most beautiful things about Django is that it wholly and completely abstracts the database interaction from the source code.  That means not having to write complex SQL statements manually, and the less SQL I have to write, the better.

In meeting with the stakeholders on rewriting the application, we decided that all of the energy should be invested in replacing the web app with a real API with a RESTful interface. If you don’t know the basic premise of REST (which is a methodology, not a protocol), it’s that URLs should be easy-to-read, self-describing and beautiful. Beautiful URLs? WTF? How can a URL be beautiful?  I’m glad you asked!

The old PHP version of the API is very heavy on the query string, requiring GET variables to be passed in the URL itself which is not only cumbersome, but can get confusing and hard to read very quickly:

http://server.whatever.com/api.php?show=all&user=jathan

Compare that to a RESTful version of the same:

http://server.whatever.com/api/show/all/jathan/

This is where Django excels because it encourages pretty URLs by making it easier to use pretty URLs than not to.

So, cutting this post off at the knees, I’ve been pounding on this for the past few weeks, learning a lot about how NOT to do things from my old code and how TO do things using Django as my guide.  I made a lot of progress, got the API working, and a basic search interface that returns stuff all using the same code.

But this week, I’ve been stuck.  I haven’t made any progress, have been getting really confused, and just generally bashing my skull into the keyboard.  I think I’m just fried from trudging through all of Perl’s curly braces, semicolons, ampersands, dollar signs… OMG THE SYNTAX!  KILL ME NOW!!

Besides, it’s Fried-day anyways, so I hope that just by spelling this all out here that I’ll be able to dig back into the code after the weekend with a renewed perspective.

p.s. Fuck Perl.

p.p.s. Fuck PHP too, but wrap that rascal. She gets around!

Quaker’s Original Oatmeal Tastes Like Original Crap

I would so kill for some of this right now.

I would so kill for some of this right now.

Strolled into work today at zero-dog-thirty, which I think translates roughly to “seven-thirty-four” in human terms.

Waltzed into the kitchen to make myself a bowl of Maple & Brown Sugar flavored oatmeal only to discover in horror and shock and also awe that there was nothing but Original flavor left! The place where there is normally an even distribution of each flavor was clandestinely filled with Original flavor by someone who I’m sure is of ill repute.  As if I wouldn’t notice!

That’s when panic set in.

“Is there a plot against me?”

“Are they trying to get me to quit?!”

I checked all the cabinets, rifled thru the packets of Original and after doing that four or five times, concluded that if I was going to eat breakfast this was my only chance. So made myself the usual double helping thinking, “Ah, fuck it, how bad can it be?” How bad can it be indeed!

Please God, make it stop.

Please God, make it stop.

I proceeded to my desk, ate a big bite, and found that it’s like spooning mouthfuls of mushy, wet toilet paper into my face. Sustenance must prevail!!

No way can I do this. This shit sucks! Who eats this crap?! Because that’s what it is. Crap. I needs my maple & brown sugar!! But I’m so hungry… UGHHH…

This isn’t breakfast.  This is punishment!

CheckPoint Firewalls Can Suck My Whole Ass

Fuck CheckPoint, and fuck the people who both make them and buy them.  Yes, you!  Assholes!  Seriously?  It’s fucking 2009 and you’re still making a firewall product that requires motherfucking WINDOWS to configure?  No command-line interface at all?  The first time I used a CheckPoint firewall in NINETEEN NINETY SEVEN (12 years ago), it had the same limitations.  Back then it was passable, but now?  Now it’s just insulting.

The CheckPoints we have at work are to support 3rd parties and acquisitions.  We would never fucking actively use this bullshit.  NO fucking way.  Everything is color-coded and iconic, so I guess for enterprise donkeys who don’t know jack shit about security, maybe this is a plus.  But let’s be totally honest here:  It’s definitely not helping humanity progress.

MY PACKETS ARE GREEN, THAT MUST MEAN THEY ARE OK!

I am a Mac user, so to configure the CheckPoint firewalls we have at work I have to use Remote Desktop Connection into a Windows terminal server we have SPECIFICALLY for managing these firewalls.  So I TS into this machine, fire up the GUI-only Dashboard client, and then have to struggle thru managing firewall policies thru an archaic interface that literally has not changed in the twelve years since I first used it.

You’d think that would make me a pro, but no.  It just fucking pisses me off.  I can’t automate the shit, I can’t even dump the configuration files in a plain-text format.  No, that would be too motherfucking convenient.  No, no, no.  They’re stored in a proprietary binary format.  The absolute worst part is that everything has to be hand-entered line-by-line.  Click OK.  Are you sure?  Are you sure you’re sure?  YES DAMMIT JUST ADD THE FUCKING POLICY!

OH MY GOD I THINK I JUST MURDERED SOMEONE.

So if you’ve ever bought a CheckPoint firewall.  FUCK YOU.

If you make the CheckPoint firewalls.  FUCK YOU TOO.

FUCK FUCK FUCK FUCK FUCK

Gonna go smash my skull against the wall until the pain stops…