Log <-

Archive for February, 2006

Rabobank internet banking

This is for Dutch people only I'm afraid. If you're curious…

RaboBank internet bankieren heeft een kicken 'Download' feature waar je je volledige rekeningen overzicht kan downloaden. Dat scheeuwt natuurlijk om het genereren van zinloze statistieken. (Lies, damned lies and statistics!).

Zie hier, RaboGRAP. (Ik weet het; zinloze titel. Het betekend 'Rabo Gegenereerde Rapportages'. Hip, ey?).

'k Zal er binnenkort eens een mooi projectje van maken.

Screenshots:
Titel pagina
Jaar overzicht
Maand overzicht

What'll PHP6 bring us?

CorePHP took the PHP 6 Developer Meeting notes minutes, which covers the discussion on the upcoming changes in PHP6, and made it into an nice summary article. Interesting stuff.

Looks like they'll be breaking a lot of stuff such as removing the dreaded 'Register Globals' option, Safe mode and Magic Quotes. Good.

This piece of the minutes intrigued me:

Issue: PHP only supports type hinted arguments and not for return values or properties.
I recently saw that PHP supports type hinted arguments, but it only supports objects and arrays, not strings, integers, etc. I understand that this may seem useless to support anyway since PHP is a loosly typed language and integers will just get converted to strings and the other way around. But from my experience it's still nice to do checking on parameter types; it catches a lot of programmer errors. Too bad strings and integers aren't going to be supported as type hinted arguments.

The other thing I'm disappointed about is that there doesn't seem to be any steering towards objectifying the primitive types such as string, integer and float. I like $foo = "bar:bas"; $foo->explode(':'); better than $foo = "bar:bas"; explode($foo, ':');. And if you'll look closely at the previous example, you'll know exactelly why. (hint: it has to do with argument order).

Oh well, I'll just wait for PHP7 I guess ;-)

On naming your projects…

I used to name my projects based on really cool acronyms like "PROMS" (Project Management System) and "Nimf" (Non-irritating Manager of Files). When I got a bit more serious about my little programmings, I decided not to give them nonsensical names anymore but instead tried to come up with original, but more importantly, meaningful names. It's a lot easier to guess what a program called "ListPatron" or "DataQ" does.

Check out these absolutely brilliant project names:

  • Pessulus
  • Sabayon
  • Yelp
  • Ekiga
  • Metacity

Can you guess what function these programs fulfill? Neither can I. If you're curious, they're names of programs and utilities in the upcoming Gnome 2.14 release. I got the names from the 'A look at GNOME 2.14' article.

Their functions are as follows:

  • Pessulus: Functionality lockdowm administrator tool
  • Sabayon: Group profile creator administrator tool
  • Yelp: Gnome help browser
  • Ekiga: The formerly known 'GNOME Meeting'
  • Metacity: The GNOME window manager

Who would've guessed?! Where did they get these names from? Who comes up with this stuff? I guess you can get away with shitty names like these if you're a small-time developer nobody has ever heard of or if you're only making low-level tools (such as GIT). But for an end-user desktop environment like GNOME, stuff should be called 'Group profile administrator' and 'GNOME Help browser'.

Let's hope they don't actually but these names in the menu's like this.

RssMerger v0.5

Version 0.5 of RSSMerger is available. Changes in this release include:

  • (My)SQL insert queries can now be generated for inserting into a database.

Unicode for programmers

Programmers should understand Unicode because
* It is one of the cornerstones of software internationalization.
* The Web is full of Unicode data.
* XML and HTML are based on Unicode.
* WinNT-based operating systems use Unicode for all string values internally.

This article is a short course on Unicode programming.

Every programmer, but especially Web developers, should read it.

PHP: Directly Assign Exploded Parts To Variables

Many languages (amongst them Python and Perl) provide a way to directly assign the parts of a split string to variables. The syntax usually used is something like:

firstname, lastname = "John,Doe".split(",");

or something similar. PHP does not support such a syntax. The programmer instead has to perform all spliting, checking and assigning himself.

This little snippet of code allows you to directly assign parts of an exploded string to variables or -if the exploding does not match the number of variables- assign defaults.

function explodeAssign($string, $seperator, $vars) {
    $temp = explode($seperator, $string);
    if (count($temp) != count($vars)) {
        return(false);
    } else {
        for ($i = 0; $i != count($temp); $i++) {
            $vars[$i] = $temp[$i];
        }
        return(true);
    }
}

$string is the string you want to explode.
$seperator is the seperator you want to use.
$vars is an array containing pass-by-reference variables. (this is important, otherwise it won't work)

Some examples:

if (!explodeAssign(
  "ferry,boender,25",
  ',',
  array(&amp;$firstname, &amp;$lastname, &amp;$age))) {
    $firstname = "John";
    $lastname = "Doe";
    $age = "20";
}
 
print("Hello $firstname $lastname. You are $age years old.n");
 
if (!explodeAssign(
  "ferry,boender",
  ',',
  array(&amp;$firstname, &amp;$lastname, &amp;$age))) {
    $firstname = "John";
    $lastname = "Doe";
    $age = "20";
}
 
print("Hello $firstname $lastname. You are $age years old.n");

The output of which will be:

Hello ferry boender. You are 25 years old.
Hello John Doe. You are 20 years old.

Hope it's useful.

Update: Not as useful as I thought, as PHP has a list() language construct:

list($firstname, $lastname, $age) = explode(",", "ferry,boender,25"));
print($firstname); // ferry

Ctags and Object Oriented PHP5

About CTags

Ctags is a great utility. It creates a file with a list of 'tags' that are found in various program sources that it finds in the directory where you run it. These tags can then be read by editors so that they know where in the source to find, for instance, the definitions of functions, methods, constants and variables. Or as the CTags homepage describes it:

Ctags generates an index (or tag) file of language objects found in source files that allows these items to be quickly and easily located by a text editor or other utility. A tag signifies a language object for which an index entry is available (or, alternatively, the index entry created for that object).
Editors like Vim use it to let you peek at or jump to the definition of a function; a feature commonly thought to only exist in bloated IDE's such as Eclipse.

PHP5 Object Oriented

Unfortunately, CTags doesn't support PHP's Object Oriented features very well. All you'll get is globally defined constants and functions. It also generates tags for classes, but that's it. No support for methods or anything! Hardly very useful in it's current form, I'd say. Thankfully there is a patch available that greatly extends CTags' Object Oriented PHP support.

Fixing CTags

To fix CTags so that it does support PHP in a not-completely-retarded fashion, you'll have to patch and compile CTags yourself. Here's how:

Download CTags v5.5.4.
Download the patch (alternatively and in case the patch disappears from the previous location, download it from electricmonk's mirror.

Next, patch, build and install CTags:

[todsah@jib]~/download$ tar -vxzf ctags-5.5.4.tar.gz
[todsah@jib]~/download$ patch ctags-5.5.4/php.c ctags-php5.patch
[todsah@jib]~/download$ cd ctags-5.5.4
[todsah@jib]~/download/ctags-5.5.4$ ./configure
[todsah@jib]~/download/ctags-5.5.4$ make
[todsah@jib]~/download/ctags-5.5.4$ sudo make install

The new ctags binary will be installed in /usr/local/bin by default.

Now you can use the self-built version of ctags to create tag files that contain enough information about your PHP's source code to actually do something meaningful:

[todsah@jib]~/plugwiki$ /usr/local/bin/ctags -R --extra=+q

Fire up your Vim editor (you are using Vim, aren't you?? Get off my site, you dirty Emacs user!) and start exploiting your newly created tags file.

Using ctags in Vim

In case you don't know how to use ctags from within Vim, don't worry. It's really easy. Move the cursor on top of some method call and press Ctrl-]. Vim will jump to the definition of the method/function/constant/whatever that the cursor was currently on. To jump back to where you came, press Ctrl-t. It's a simple as that.

An example. Suppose I have the following code:

if (!$page->hasAccess(

I'll position my cursor on hasAccess and press Ctrl-]. Vim will now jump to this text:

  public function hasAccess($user, $access)
  {
    $userId = $user->getUserId();

When I type Ctrl-t, Vim will jump back to:

if (!$page->hasAccess(

and I can complete my code.

Another cool tool for Vim that uses tags is TagList.

The "Tag List" plugin is a source code browser plugin for Vim and provides an overview of the structure of source code files and allows you to efficiently browse through source code files for different programming languages.
You can see TagList in action in this screenshot of Vim.

(Thanks to Michiel van Baak for corrections in this post.)

www.SorryNorwayDenmark.com

www.SorryNorwayDenmark.com. Finally some people with sense.