Multiton base class
While I like the Singleton pattern every now and then, I prefer the flexibility that the Multiton potentially offers, and well it's just an extended version of the Singleton, so it's "compatible" with the Singleton model.
Anyway, to the point, PHP5.3 is coming, and with Late Static Binding you can do a base Multiton (or Singleton if you insist), which wasn't possible before. Now I like this very much because you can simply extend it rather than rewriting those (few, I know, but still) lines each time.
December 23, 2008 // PHP // Post a comment
The joys of user stylesheets
User stylesheets are a way to inject some CSS in all the sites you visit, each browser has his own way of setting it up (if you use opera step 2 there should be replaced with: "Tools > Preferences > Advanced > Content > Style Options > Select your css file in My stylesheet"), but the idea is always the same.
I've recently found a couple of use for these styles so I thought I might as well share :
Changing gmail's font
I like gmail, but losing my dear monospaced font was annoying me - especially when reading code-related mails with snippets in them. So this little hack allows you to choose the font used in the mail body area of the page. It's made for the "old" gmail interface since I don't have the new one yet, but it can probably be adapted if it doesn't work with the new one.
.XoqCub .ArwC7c {
font:16px proggytinytt, "courier new", courier !important;
font-size:16px !important;
}
This uses the proggytinytt font by the way, which is my font of choice for all monospace purposes, however if you don't have it it falls back on courier new/courier.
Saving flickr's images peacefully
Some images on flickr seem to be protected with a file called spaceball.gif that's overlayed onto the actual image, so that when you right-click it to save, you hit the transparent gif and can't save the image. With the help of that great CSS3 selector :nth-child(N), you can make sure you hide the gif if it's there.
.photoImgDiv img:nth-child(2) {
display:none !important;
}
If you've anything useful, feel free to post it in the comments.
November 28, 2008 // Web // Post a comment
Dwoo v1.0 is out
Now that Dwoo's user base has grown a bit and that I've received enough feedback and fixed quite a bunch of bugs and design flaws, I feel confident it's time to go stable, so here comes Dwoo 1.0.0
For those that missed it, Dwoo is a template engine compatible with Smarty templates, with a lot of new features and syntax sugar and a new PHP5 codebase, if you want to read more I suggest you have a look at my earlier post, and its website.
October 23, 2008 // PHP // Post a comment
Installing Habari on Lighttpd
Just a small post about Habari installation over Lighttpd, since it is not really documented anywhere that I could find.
I will assume that you know how to run php scripts on your server, and start from there. So once you have unpacked Habari files in say /home/seld/domain.com/, all you need to do is add the following to your lighttpd.conf file :
$HTTP["host"] =~ "^(www\.)?domain\.com$" {
server.document-root = "/home/seld/domain.com"
url.rewrite-once = (
"^/(?!scripts/|3rdparty/|system/|doc/)(.*)$" => "/index.php"
)
}
With this setup, your blog must lie in the top level directory ( http://domain.com/ ), should you want to install it in a subdirectory, you need to add it to the url rewrite, for example to install in http://domain.com/blog/ you would need to replace line 4 with :
"^/blog/(?!scripts/|3rdparty/|system/|doc/)(.*)$" => "/blog/index.php"
August 02, 2008 // Web // Post a comment
Who let the Dwoo out ?
Four months have passed since I started on this project and I finally feel that it is stable enough to make an announcement and have more people trying it.
So what is it ? Dwoo is a PHP5 template engine. Another one you might think, indeed but with every new project comes a new vision, and hopefully you will like mine.
May 13, 2008 // PHP // Post a comment
Random Seeds - Ordering Disorder
Randomness is great, that's a fact, it's very useful in many areas of programming, and is especially good to build non-repetitive games. However in some cases, it's useful to be able to reproduce randomness.
Let's say you have a Tetris game or a puzzle that randomizes it's different elements before the game start. It might be a nice feature to offer a "Try again" button, which would allow the player to replay the exact same game, to see if he performs better. Or you may want to have two players play the same game to compete against each other, while still playing a random game.
There are two approach to this, the first and maybe the most straightforward is to log the random somewhere to be able to replay it. This works of course, but it forces you to implement the entire logging process, and it uses memory. That's not efficient.
March 13, 2008 // ActionScript // Post a comment

