Smarty prefilters need to have the compiled templates wiped to work.

I just thought I would drop this little tidbit to help save someone some time (hopefully). In the smarty template engine there is a pretty useful call “register_prefilter” which basically lets you pass a function to smarty that gets run on the whole template file before the template file itself has any of the substitutions made to it. This can be a god-send, however the first time you use it it probably won’t seem like it’s working. The secret is that you need to go into your templates_c directory, and dump all of the compiled templates every time you change the pre-filter.

Keeping your inbox empty in gMail

So a friend of mine recently convinced me to try using gmail in a different way. His suggestion was that I try archiving all of the mail that I have that no longer requires direct attention, or has some action I must take hanging on it. I have to admit its a pretty appealing idea, since the mail will still show up in searches and whatnot. Shortly following this suggestion I got put on a very high volume mailing list that I also wanted to read many of the emails on. So I decided to give it a try.

I started by setting a group “instant unarchive” on the first two-hundred emails that I have. Then I did the select all action, and clicked the link that appears at the top of your email list when you select all to “select all 70 billion emails” and archived the bunch. I then clicked on the left the “instant unarchive” group, and moved them to my inbox. Ta-Da now I’m down to my latest 200 emails in my inbox. As some of these are still relevent & outstanding I’m going to have to archive them by hand.

The concept of having an empty inbox is pretty darned appealing to me. I’ll give you updates as I go. (oh by the way, the command key to archive an email is “e”)

Why Doesn’t TinyMCE load in IE?

looks like it is all due to the insertAdjacentHTML call being used in another library. In my case, wz_tooltip. Oh wow did this hurt me. So that horror of a project that keeps on poking its head up sent in another small request… put tinyMCE or FCKeditor into one page on the website. Offered 5 hours. Well TinyMCE is already installed, so I figured this was a chance to recoup a little of my loss on this project. Sure enough, I activated TinyMCE with about 5 lines of code, checked that it worked in Firefox, and billed my money.

Next morning I get a call. The thing doesn’t work in IE. So I try a few quick and obvious things, move around where it gets loaded, try a few different load orders. No luck. Grr. I was going to type out my whole damn process, but I realized that’s not what people want to read…

Short version is: the wz_tooltip.js library conflicts with the TinyMCE library ONLY in Internet Explorer. This is because of a call to insertAdjacentHTML which is an IE-only javascript call (thanks again for embrace and extend M$). As a workaround, you can modify the wz_tooltip file by commenting out from line 397 (inclusive) (thats: if(wztt_body.insertAdjacentHTML) ) down to line 400 inclusive (thats : else if(typeof wztt_body.innerHTML != wztt_u && document.createElement && wztt_body.appendChild) ) And now I’m off to submit bug reports.

What a waste of a morning.

Weird Issue between Smarty and Google Maps

I’m doing some work on a site that uses the google maps API (which is clean, simple and absolutely fabulous, by the way) and I have bumped into a strange problem. When I draw the page that uses the google maps api with smarty everything works fine, generally. However if I put the {debug} tag into the template (which causes smarty to give you a nice little pop-up window of all of the variables it’s working with, and some other great info) google maps stops working.

This isn’t really that shocking, since there is a bunch of javascript that gets pushed into the page by debug, what is weird, and a pretty large problem is that once I do this, google maps continues not to load, even after the {debug} tag has been removed. I haven’t really dug into what is going on to carefully yet, but its an interesting issue.

Really lame solution found after the jump

Continue reading Weird Issue between Smarty and Google Maps

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

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

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.