Web Programming

Oooh, “extended interview”

Oliver Brown
— This upcoming video may not be available to view yet.

Well the interview went well. Although it didn’t feel like it at first since the first thing I had to do is optimise a SQL query which I kind of fumbled my way through. The result - they want me in for an afternoon to perform some programming task to see how I actually work.

Although I keep thinking of ways for it to go badly, I did that before the first interview and everything worked out fine…

I have an interview

Oliver Brown
— This upcoming video may not be available to view yet.

Woohoo, I have an interview.

Before they offered me a face-to-face interview they wanted to do a telephone interview first. This consisted of a series of technical questions I really wasn’t prepared for (“What’s the difference between an inner join and an outer join in SQL?”, “What are the restrictions on cookies?”, “What do the HTTP status codes 302 and 303 mean?”).

But since they offered me the interview I guess I did quite well :)

(On an unrelated note, “Woohoo” is not in the Google spellchecker database but “Whoop” is….)

jobs, interviews, web developer, PHP developer

Nice searching in Wordpress

Oliver Brown
— This upcoming video may not be available to view yet.

You may have noticed that all the tags on my posts point to URLs of the form /ob-search/_search+term_. That’s a reasonably simple bit of mod rewriting. This article is aimed at people who can do that.

I wanted a way for the search box to point to the same pages. I figured I could point the search form at a fake page and redirect (it with a HTTP status code of 302 so it is sent to the browser and the user sees it in his/her address bar) to the nice URL (which would secretly redirect to the real one).

So I came up with the following:

RewriteRule ^fake-search.php?s=(*.)$ /ob-search/$1

It didn’t work. Unfortunately Apache strips of query strings before the get to Rewriting and the reattaches them. So to sort it out I had to hack off the query string with one rule (which is accessed using an environment variable) and then extract the bit I wanted with another rule:

RewriteRule fake-search.php /-%{QUERY_STRING}? RewriteRule ^/-s=(.*)$ /ob-search/$1 [R=302] RewriteRule ^/ob-search/(.*)$ /index.php?s=$1

The third rule just does the “simple” redirecting as a said in the beginning.

The ? appending the query string on to the end afterwards. The hyphen in the first two lines could be anything you want - it’s just something for the second rule to recognise.

To finish it off I altered the search form’s action attribute to point to fake-search.php and all was well :) Try it :D

More features for Extending SimpleXML

Oliver Brown
— This upcoming video may not be available to view yet.

I’ve added two new public static function to [ExtendXML](/exml.txt). The first one is registerTagClass. This takes two arguments, the first is a tag name and the second is a class (that extends ExtendXML. This will make all children of that tag name become that class instead. The second is registerTagCallback. This takes one argument, a callback. That callback must take one argument, a tag name and must return the class (as a string) that those tags should become.

If for example you were parsing HTML and you wanted all paragraph p tags to be handled by ParagraphXML, you could use: ExtendXML::registerTagClass('p', 'ParagraphXML');

A word of warning, it’s case sensitive. If a callback is registered this will be used regardless of any calls to registerTagClass.

If you’ve never used callbacks before, they take one of three forms. Either a string that is the name of a function, an array with the first element a class name (as a string) and the second element a static method of that class (as a string) or finally, as an array with the first element an object and the second element a method of that object.

EXML, ExtendXML, SimpleXML, XML, parsing XML, PHP5, callbacks, programming, coding, parsing HTML, OOP

Competing with Pimsleur

Oliver Brown
— This upcoming video may not be available to view yet.

As I mentioned earlier, I’ve written the framework for a language learning system similar to Pimsleur. Well the approach is similar but the mechanics are different.

Basically each phrase (in English, the target language, what the instructor says) is a separate audio file. The system then chooses what you listen to automatically handling things like the right amount of repetition or you. How often something is repeated is time based meaning if people do things slowly they will find themselves repeating more often (which makes more sense since slower equates to using the system less often). I almost have a demo ready. The big thing I need however is voice talent. I’ve just about accepted that I will have to suffer by hearing myself but it’s not very clear what’s going on if the instructor, the English voice and the foreign voice are all the same person.

It is also extremely modular. Each module (a module could be a conversation, a sentence, a whole topic - whatever makes sense in the circumstances) has a list of requirements that has to be completed first. This means no explicit ordering of modules is necessary, the system picks whichever one the learner can do. This also allows some cross-language capabilities. If someone learns more than one language and something is similar or the same in the two, it could tell and possibly speed things up depending on how similar they are.

So if there is anyone who might possibly be interested, let me know. If you’re learning a language this could be ideal (during my Maths degree I discovered if I could explain something to someone else, it was a good sign I understood it myself) I’m not quite sure if, and how (or should) this make money but anyone who helps significantly would have a say in what happens with it.

iMode and cHTML

Oliver Brown
— This upcoming video may not be available to view yet.

I’ve seen adverts around for iMode recently, with no idea what it was. Well I found out last night by coincidence after looking around Google Sitemaps. Well sort of. Although I didn’t look at the details it seems like some sort of alternative to WAP. What interested me more was cHTML, iMode’s equivalent of WML.

cHTML, or Compact HTML, is basically what WML should have been. Instead of completely new tags and new way of looking at things it’s just a subset of HTML that makes sense for mobile devices. There are a few extensions to normal HTML but these aren’t required and are very simple anyway (like using tel: in a link the same way you’d use mailto:).

Of course I don’t really have any sites that would make sense in a mobile world…

Just search for imode chtml for loads of bits of info.

Galactic Horde

Oliver Brown
— This upcoming video may not be available to view yet.

You may have seen the link for Galactic Horde, an online game, in the links bar but never thought to visit. Well the link is not there randomly, it’s something I helped in. Specifically I wrote the PHP back-end for it.

Well I never really had time to play it myself and never knew exactly how the client interacted with what I wrote. The result is that I can read the forums for the game and have no idea what people are talking about. It’s really scary.

Have a look in their forums for an idea.

Wordpress and phpOpenTracker problems…

Oliver Brown
— This upcoming video may not be available to view yet.

Has anyone else tried to use phpOpenTracker with Wordpress? Whenever I do I get strange DB error messages. If you have used the two together, either unsuccessfully or not, please let me know.

Playlists in Windows Media Player

Oliver Brown
— This upcoming video may not be available to view yet.

Windows Media Player will only play .m3u playlists two levels deep…

You can include a playlist inside another playlist and it copes fine. If you include a playlists inside a playlist inside a playlist, the innermost one doesn’t get played.

Why do I tell you this? I decided to try and create a Pimsleur-style CD for Finnish. But to save on effort and increase modularity everything is done in bits and joined together with .m3u files. Since Windows Media Player can’t cope with the nesting though, I had to write a PHP to dump them all in one file (I’m expecting to hit a limit on the amount of songs in a playlist soon).

By the way a .m3u (playlist) is really complicated… it’s a list of URLs separated by newlines…

Code generator update

Oliver Brown
— This upcoming video may not be available to view yet.

The PHP Code Generator now handles docblock style comments properly as well as method keywords. For static, abstract and final keywords, if one is present in any definition of a method it will in the output. For visibility keywords the method will have the “most public” specified. See my previous code generator post for more info.