Pro Tip Of The Day – Apache Startup Error

I run Apache on my local machine so I can develop web applications in a self-contained environment.  I encountered a strange problem the other day when tried to start the Apache service:

 

First of all, what an incredibly un-helpful message.  The details also proved less-than-enlightening:

 

Mmmkay.  Thanks for that.  I know exactly what the problem is now and I can easily go about fixing it…NOT.  msvcr71.dll is the C++ runtime library so it’s not like that narrows down my problem at all.  I do know however…that it has something to do with the C++ code.  Gee thanks.

Well if anyone is experiencing the same problem, let me save you the hours of fruitless Googling that I had to endure and just tell you what the problem was.  I had a VirtualHost whose DocumentRoot pointed to a networked drive that was not currently connected.  All I had to do was re-connect the network drive and bingo! Apache started up without a complaint.

A plea to application developers everywhere: Please, for the love of Blaise Pascal, write more informative error messages!  How hard would it have been to say: “Hey idiot, you’re trying to use a network drive that isn’t currently connected!”.  Instead I get all sorts of useless (but awesome) information about ModVer’s, AppVer’s and Offsets!  I love geeky error dumps as much as the next guy…but for crying out loud…toss me at least one piece of useful debugging information along the way.

Back To Geekness

lol1.jpgMy recent blog posts have not been nearly geeky enough…I mean my Blog’s tagline is “Family Man + Geek at Heart”. You’ve certainly gotten a glimpse of the “Family Man” part of the equation…but now I’m gonna hit you with some pure geekitude!

There’s a new programming language that has the coding community all abuzz (thanks Pete for bringing this important technology to my attention!). I don’t generally give too much credence to new programming languages…but this one has the potential to redefine software engineering as we know it. May I humbly present…LOLCODE.

Let the code samples speak for themselves:

Example 1: Filezorz


HAI
CAN HAS STDIO?
PLZ OPEN FILE "LOLCATS.TXT"?
AWSUM THX
VISIBLE FILE
O NOES
INVISIBLE "ERROR!"

 KTHXBYE

Example 2: IF/THEN/ELSE


HAI
CAN HAS STDIO?
I HAS A VAR
GIMMEH VAR
IZ VAR BIGGER THAN 10?
YARLY
BTW this is true
VISIBLE "BIG NUMBER!"
NOWAI
BTW this is false
VISIBLE "LITTLE NUMBER!"
KTHX
KTHXBYE

Simply the best implementation of natural language programming ever.  I encourage you to familiarize yourself with this emergent technology.  It won’t be long before employers will be requiring a working knowledge of LOLCODE for any serious software engineering position.  The following links should start you on the path to LOL zen

For additional inspiration you may also want to check out

My Web Developer Toolbox

I realized today that I am very dependent on a few really nifty tools to get my work done. As a developer I am inherently lazy so I need tools that let me get things done quickly and efficiently. I assume many of you are also developers and lazy so today I’m going to open up my web developer’s toolbox and show you what’s inside in hopes that I can inspire you to reach your full laze potential.

Firefox

If you’re not developing your web sites in Firefox, you should be.

Firefox AddOns That Rock My SocksAddons

Everyone has their list of “best Firefox addons ever”. I’m no different from them except I’m way cooler. So here is my list:

  • Web Developer Toolbar – The swiss-army knife of toolbars. It does everything including page validation, real-time CSS editing, form pre-population, DOM inspection etc etc etc. Trust me, you need this.
  • Firebug – Ever tried to debug JavaScript without it? Are you a sadist? Seriously go download this right now if you don’t have it already. When you’re back go read this and this.
  • QuickProxy – There are a few sites that I work on routinely that are only accessible through an SSH SOCKS proxy. I use QuickProxy to easily switch the Proxy on/off. Fewer clicks = more lazy (this is a good thing).
  • GreaseMonkey – Ever since I wrote my first only GM script I’ve been hooked on phonics GreaseMonkey. For those of you who have been living under a rock for the past several years, GreaseMonkey lets you inject your own JavaScript code into any webpage so you can customize your user experience. Check out all the cool scripts at Userscripts.org.
  • Adblock Plus + Filterset.G Updater – I seriously cannot remember the last time I saw an Advertisement on a webpage. I know there are a lot of people who don’t like ADP because they make their livelyhoods from web advertising. I am not one of those people.
  • FavIconize Tab – Real estate on my tab bar is a precious commodity so I use FavIconize Tab to only display the favicon of sites I visit frequently. Cool.

screenie_10-2007-05-11.gif

XAMPP

Need a complete WAMP solution without all the hassle of multiple packages, configuration woes and perhaps even *horror* compiling stuff? Look no further than XAMPP from Apache Friends. Their package contains the latest and greatest Apache, MySQL and PHP (both v4 and v5 support) all in an easy-to-use installable package. They also throw in some other goodies like an FTP server and PHPMyAdmin. Ever since I discovered XAMPP I do all of my testing and development locally before deploying to a staging server.

A Desktop Shortcut to Edit Your HOSTS File

What do you mean you don’t have one of these yet? Any good web developer needs to edit his/her HOSTS file frequently. Why are you still doing it the hard way: Explorer > C:/ > C:/WINDOWS > C:/WINDOWS/SYSTEM32 > C:/WINDOWS/SYSTEM32/drivers > C:/WINDOWS/SYSTEM32/drivers/etc > Right-click hosts > Open With > Notepad. Whew! Instead try something like this:

screenie_08-2007-05-11.gif

Double click that baby and your off and editing! BTW I use gvim instead of notepad because it makes me feel good. If you’re confused about what you’re seeing above, do this: Go to your Desktop. Right click > New > Shortcut. Enter “notepad c:/windows/system32/drivers/etc/hosts” as the location then click Next. Give it a name and you’re done! Double-click when you need to edit your HOSTS file.

A Good IDE

I use Zend Studio but I wouldn’t hold it against anyone for using Eclipse. The point is you need a good IDE to develop quickly! There are probably some purists out there that will extol the virtues of “Notepad coding” — or typing everything by hand. This is complete crap. Get an editor that does auto-completion, tag insight, tag highlighting and sports a full debugger.

ColorpicColorpic

Simple but awesome. How often do you need to find out what color that was on that site you just visited. Enter Colorpic. (Not on my list but also cool is Screen Calipers from the maker of Colorpic)

ScreenHunter

You need screenshots! You need them in your documentation, you need them to attach to emails, you need them to post on your blog, you need them to corroborate your stories. ScreenHunter is an unobtrusive screen capture utility that sports full-screen capture, area capture, timed capture, JPG, GIF and BMP support amidst a whole slew of other features. Did I mention it’s free?

Launchy

Nevermind…I’ve decided I don’t like Launchy all that well.

So there you have it. My toolbox opened for the world to see. I hope this post spawns an army of eager web developers ready to code the next killer web two-point-oh site.

Jon Gale is currently employed by nextSTAT and spends his days looking for tools and tricks that will let him express his inner slackitude. He enjoys rousing games of badmitton and has had a goatee for over 10 years.


Monitoring Entries In A MySQL Table With MRTG

At work last week I set up some MRTG reports to monitor our MySQL servers. I used the handy mrtg-mysql-load utility to get queries/slow queries information but I also needed to monitor the number of records in a particular table and graph it using MRTG. For those unfamiliar with MRTG, graphing “custom” data is very simple. All you need to do is write a script that outputs 4 lines:

Line 1 -current state of the first variable, normally ‘incoming bytes count’
Line 2 -current state of the second variable, normally ‘outgoing bytes count’
Line 3 -string (in any human readable format), telling the uptime of the target.
Line 4 -string, telling the name of the target.

So I created a simple script to get the record count from a particular table:

#!/bin/sh
echo 0
mysql -h $1 -uwww -e "SELECT COUNT(*) from injector" nextstat_injector | tail -1
echo 0
echo "Queued Records"

Which I would call passing the MySQL database host as the first argument. Once I had the script I added a new MRTG target like this:

Target[injector]: `/etc/mrtg/injector-stat 192.168.1.121` + `/etc/mrtg/injector-stat 192.168.1.122` + `/etc/mrtg/injector-stat 192.168.1.123`
MaxBytes[injector]: 500000
Options[injector]: nopercent,growright,nobanner,nolegend,noinfo,gauge,integer,transparent,noi
Title[injector]: Injector Records Queued
PageTop[injector]:<h3>Injector Records</h3>
YLegend[injector]: records
ShortLegend[injector]:
LegendI[injector]:
LegendO[injector]: records

You’ll notice that I’m adding the totals from 3 different servers to graph a single sum value in MRTG. Any mathematical expression can be used to generate your graph values. From the manual:

You can also combine several target definitions in a mathematical expression. Any syntactically correct expression that the Perl interpreter can evaluate to will work. An expression could be used, for example, to aggregate both B channels in an ISDN connection or to calculate the percentage hard disk utilization of a server from the absolute used space and total capacity.

For a graph like this you’ll want to use similar options to the ones I used above. nopercent disables percentage display, growright tells the graph to read from left to right instead of the default right to left, gauge tell MRTG that the data points are “current status” measurements rather than ever-increasing counters, noi tells MRTG there is no “input” data to compare against “output” data and a few cosmetic display options. The resulting graph looks something like this:

injector-day.png

So there you go…a quick and easy way to monitor entries in a MySQL table using MRTG.

Living on the Edge

There’s quite a little uproar going on about the release of a certain hex key that can be used to decrypt HD DVD movies. Apparently the AACS doesn’t like it when you publish that particular key on your blog. Desperate for anything to drive some attention and traffic to my blog, I have decided to post that key here; however, I’m going to disguise it as a poem so no one will recognize it for what it really is!

Oh Nine, Eff Nine
One one zero two!
Nine Dee Seven Four,
Ee Three Five Bee.
Dee Eight
Four one
Five Six, See Five?
Sicks Three Five Six,
Eight eight See ZERO.

fin

So welcome AACS, MPAA and other industry watchdogs! Hope you enjoyed my poem.

Bang Shebang Bop

Or in other words: ! #! ->

Code monkeys have all these cute little names for various character combinations used in their code. Because programmers’ time is so much more valuable than anyone else’s they can’t call “!” an exclamation point…it’s a BANG! (what happens when you use the word “bang” followed by a “!”…is that a Bang-Bang?). Likewise, the !# is called a shebang because it would take far too long to say “Exclamation point hash”.

Wanting to be super cool, some co-workers and I added our own little code-ism to the mix. The “->” (PHP Object Dereference symbol) has been officially dubbed the “bop”. How much cooler are you going to sound in your next code review when you say:

“So I totally had this object I needed to dereference so I fired up Notepad and typed dollar sign variable name bop methodName open paren close paren (BTW – parentheses are called “parens” in code-speak). It was so sweet!”

OK, so you’ll never sound cool during a code review meeting…but you get the point.

So there you go…another contribution to mankind from yours truly. The “bop”. Have fun with it…name your next object instance $mmm and I guarantee you’ll chuckle every time you call a method of that object (admit it…you just laughed at that).

Spread the word…spread the love. -> = BOP ! (err…bang!)

Search Operators – not just for Google anymore

Google is nifty. One thing I particularly like is their use of advanced search operators (I call them search expressions…but who am I to change Google’s nomenclature). If you don’t know what I’m talking about, it’s the ability to do cool stuff like this:

I liked this idea so well that I stole incorporated it into a project I’m working on. I wanted to be able to search for invoices using Google-esque search operators so I came up with this little nugget (more after the jump)
Continue reading

Binary Fulfillment

10101101101110.  Pretty awesome eh?

Once upon a time the 1’s and 0’s used to do it for me…not anymore.  As a programmer I’m spent, burnt, depleted, drained…done.  I still program for a living but the honeymoon is over.  I find very little satisfaction and enjoyment in programming like I once did.  I tried to pinpoint the moment it happened…was it at HomeStar Communications where I went the last 3 months without getting paid?  Maybe it was at Caldera before they became SCO.  Or perhaps it was SCO.  Regardless of when it happened, the fact is, it happened, and now I’m stuck here in a profession I no longer enjoy.

When I first chose programming as a career (or did it choose me?) I thought I wanted to work with computers instead of people.  People intimidated me.  Now all these years later the words of Albert Einstein speak to my soul:

“A human being is a part of a whole, called by us universe, a part limited in time and space. He experiences himself, his thoughts and feelings as something separated from the rest… a kind of optical delusion of his consciousness. This delusion is a kind of prison for us, restricting us to our personal desires and to affection for a few persons nearest to us. Our task must be to free ourselves from this prison by widening our circle of compassion to embrace all living creatures and the whole of nature in its beauty.” (emphasis added)

I’m deluding myself into thinking I can spend a lifetime surrounded by computers, code, bits and bytes.  This is my prison from which I need to be freed and it can only be done by “widening [my] circle of compassion to embrace all living creatures”.

It’s all about the people.

Getting Jiggy with JavaScript

I’ve recently accepted a position at NextStat and many of the projects I’m working on are ideal candidates for JavaScript flashiness. I played around with Scriptaculous and Prototype but for me the holy grail of JS frameworks is Moooooooootools.

I’ve used a lot of sliders in my code recently and it’s brain-dead simple:

var lislider; window.onload = function() {  lislider = new Fx.Slide('newlineitem'); lislider.hide(); }

And then whenever I want to toggle the slider I use:

lislider.toggle();

What could be easier?  If you want to get started with a VERY powerful, yet lightweight JavaScript framework, give MooTools a try.