The __ function in PHP

Recently I bumped into a function I wasn’t familiar with in PHP, It looked like the app I was working in was wrapping just about every constant that they used in the __ function. (Yes, that is two underscores.)

It turns out that this is actually an abbreviation for the gettext function, which is for allowing your application to support multiple languages. I think that this is a very clean way to support multiple languages (though admittedly, I haven’t read it very carefully yet), but I really do think that a better function abriviation could have been chosen. Oh, well, I suppose you learn something new every day.

Meditations on Craftsmanship

Recently I have been somewhat frustrated with some aspects of my work. (See previous post.) I have decided that in many ways I have wandered off track in my work, and I need to start writing code that I like again. By chasing after efficiency, I have allowed quality to become a second priority, and in doing so have begun to lose morale as well. I feel as if this is a very common problem in modern practical programming, and as if it’s a good thing to explore solutions to. For the last several weeks I have been searching for a book on programming that covered tools, tips and tricks for making yourself feel enthusiastic about what you’re working on, and dedicated to doing it well. So far I have not had much luck.

What I have found is a lot of books that tell me about tools for generating quality work, but ignore the emotional end of the process. One of the few bits of emotional advice that they do turn up repeatedly is that once you let some of a project start to slide into a lower level of quality, all motivation to keep the quality level up drains away in what is typically called “Broken Window Syndrome“. What they don’t talk about is how to recover from it (my own personal holy grail, since I am so often brought in to save messed up projects) or how to feel a sense of quality to start with.

Since I am feeling around in the dark, I thought I would take two blind stabs at raising my quality level. The first idea I am putting into practice is literally sitting down and meditating on quality & craftsmanship before I start to work on a project. This means 15 minutes of cross-legged, closed eye meditation, thinking about the nature of quality, (very much in the style of “Zen and the art of motorcycle maintenance“), and on my own personal visions of a true craftsman at work. This does seem to help.

The second part of this approach that I am taking, is to start a personal project and try to hold it to a very, very high standard of work. The idea behind this is to help develop the habits of quality, and help it become a familiar thing. This will probably be a cakePhp project, which I will most likely write about more here. I’m already looking into getting started with unit testing for it, but more on that later.

If anyone has any tips on emotional self management for programming, or can refer me to a book on it, that would be great as well.

Writing A Spec Way Too Late

So what was a wonderful project to start with became a nightmare, but I finally see the light at the end of the tunnel with it. Because this project started off so innocently, and became such a disaster, I feel like I should share some of the mistakes I made along the way, and some of the insights that I have gained in both 1) extracting myself from the problem and 2) not allowing myself to get sucked into issues like this again. So lets start with a little bit of history of the project and the situation and go from there.

The development company, which I will refer to as “E” in this post is one that I have worked with for a while. They are good, skillful and friendly, they also do have a history of not generating sufficient (or any) spec’s for projects before they sign deals. This is a known problem, and something that both developers and designers have been complaining about for a while.

Continue reading Writing A Spec Way Too Late

Time Tracking Software

The development team where I work is going to start tracking the time spent working on each project. Although in some ways this feels like a bureaucratic hassle, it will be useful as far as justifying our existence and provide some ammo for why we shouldn’t tackle every suggestion that crosses our desks (e.g. the “trivial tweak” that actually take 12 hours to implement).
Clock
Continue reading Time Tracking Software

Adobe AIR and digital certificate password length

I’ve received several e-mail messages over the past couple months letting me know that the desktop magic eight ball application I created for a beta version of Adobe AIR no longer worked.

Naturally, it wasn’t the highest priority on my to-do list, but I finally decided to get around to it. But I kept getting an error message: “no such file C:\air\eightball\in”
Continue reading Adobe AIR and digital certificate password length

Emacs and osX

I am a huge emacs fan, to the point of having written my own major mode for working in coldfusion when I couldn’t find one that satisfied (rather than moving to another editor) Its something that I see as part of my personality, almost like a political affiliation. I also happen to be using a mac at the moment, and my first few tries at using emacs under osX went pretty poorly, but I did work everything out, and I thought that I would write about it some to save everyone else the trouble.

First off, I initially tried just installing a standard version of emacs and using it through the terminal. As it turns out that has a lot of problems, particularly with keys being in odd spots (the meta key behaves a little oddly) and with the interaction of cutting / pasting / killing and Yanking. The next try was xEmacs under the mac X11 server. That was an instant disaster.

My third try was with aquamacs which worked decently, but I still found to have several frustrating bits of unpolished interaction. I could have lived with this indefinitely, but another emacs fan I know suggested I look at carbon emacs and wow am I glad I did. This is what emacs for mac should be.

The only major change I needed to deal with is adding (setq mac-option-modifier ‘meta) which made the damn meta key work in a way that doesn’t drive me nuts.

So for those of you on a mac, consider having a look.

Very Frustrated with mysql on the mac

So I just discovered a little bug with mysql in general, and which I am finding extra frustrating on the install I have set up on my mac. The short version of the problem is that if you have a whole lot of tables in a database the application “mysqldump” no longer works, producing

Got error: 1016: Can’t open file: ‘./<database>/<table>.frm’ (errno: 24) when using LOCK TABLES

So I followed up on this, and it seems like this is a somewhat known bug. In particular the problem is noted here: http://forums.mysql.com/read.php?28,162893,162893 along with a solution. However for some reason the mac version of mysql is not obeying the open-files-limit param, either when I pass it through the command line of mysqldump (which doesn’t recognize it as a viable option, or when it is set in the config file my.cfg and rebooted. I happen to be runing mysql version 5.0.51a

SEO and title tag density

How does keyword density in the title tag affect search engine placement? On Facts about Title Keyword Density, it says that Live.com rewards high keyword density in a title tag, whereas Google.com punishes high keyword density in a title tag.

I don’t really care about search engines other than Google. I’ve heard SEO experts claim that Yahoo! and MSN/Live still contribute a fair number of clicks, but that’s not true according to my server stats. I’d like to find out if Google really does punish keyword density in a title tag.

I created 3 similar pages for a fictional person, whose name currently return zero results in Google. Using the name as the search term, there are 3 different keyword weights.

  1. Test A (100%)
  2. Test B (50%)
  3. Test C (9%)

This may not be the best test methodology, but at least it’s a start. In a few days, I’ll see how Google ranks them. Any opinions on how the pages will rank?

Cake CleanUpFields

Yesterday night I managed to get stuck on my cake project it two separate places, which is sort of amazing since I have only been stuck with cake once other than that on this project. (To Be fair, One of the problems is with Plesk, may it’s name be damn for a thousand years, not cake)

Anyway, I just solved the other problem thanks to the comments on this post, and I thought I would share.

When you cuse cake’s helper to pick a date/time it builds a whole lot of sub-fields. Then when cleanUpFields is called it stitches them all back together into one date time. However, it’s a little too smart for its own good, it only stitches them back together if it knows about the date-time, and it only knows about the date-time if that field is in the primary model for the controller your working with. This means that if you are using a second model , it wont fix the date-times.

The good news is that their is a work-around for that, you can simply call cleanUpFields again, with the second, or third model name as a param. (I.E. $this->cleanUpFields(‘payments’); )

What I haven’t found a work around for however, is if you want to get a date that doesn’t belong to a model at all. hopefully I will stumble on an answer as I continue with this, If I do I’ll post it in the comments.