15 Jan 2010

Easy PHP Websites with the Zend Framework

By W. Jason Gilmore

I was after a good solid introduction to the Zend Framework (ZF from now on), but from the Amazon book reviews all the choices seemed poor. This one had the most promising reviews. It is self-published, the downside of which is that it is only on amazon.com, not .jp or .co.uk. I therefore bought the e-book version.

The first four chapters show the more traditional way of making web sites, without using ZF. They kind of feel redundant; they are aimed at beginners and not about ZF. They could be motivating for how easy ZF makes things, but (see below) that isn't the case. However as an introduction to PHP development they are okay.

Chapters 5, 6 and 7 cover the ZF way of writing applications (i.e. the split into model/view/controller), how ZF deals with databases and how ZF handles forms, respectively. In other words the core of a ZF-based website. At this point I have to admit my ignorance. Either this section of the book is doing a poor job of motivating the use of ZF, or ZF is not very good. I suspect it may be the latter, but I will have to do a project or two with it to tell you for sure. Anyway the example code comes across as verbose with no real advantage over the traditional PHP way of writing a complex web site.

I got a bit stuck at this point, and this book gathered electronic dust. But really needing to get up to speed on Zend I forced myself back to it, and I am glad I did as the last third of the book is where it shines. Chapter 8 is about managing users, with a brief coverage of how to make a SNS (social network site). Chapter 9 is on the Google Maps API. Chapter 10 is about integrating with Amazon. Chapter 11 introduces Javascript and Ajax. Chapter 12 has a (fairly brief) look at RSS, then (quite a long) look at Facebook APIs. Chapter 13 covers Google: Analytics (analyzing visitors), AdWords (advertisting your site) and AdSense (making money from ads on your site). Finally, Chapter 14 introduces PayPal, and introduces some third-party shopping cart applications.

Chapters 8 to 14 generally show the underling API, then show the Zend way of doing things if there is one. The exception is chapter 11 where Prototype and Script.aculo.us libraries are introduced (whereas ZF has adopted Dojo). The author tries to claim he deliberately introduces Prototype to show you how to use an alternative library. I suspect it is more like chapter 11 was already written before Zend announced the Dojo tie-up.

What else can I say? The book follows the theme of the GameNomad web site throughout the book, which is a web site to introduce and review people's computer game collections. This is good as it gives context for the features being introduced. The book was updated for Zend 1.9, and hopefully will stay up to date.

The code samples are frequently long-winded. E.g. the fopen/fwrite/fclose sequence is used to save just a single string, when file_put_contents() is both shorter and more descriptive. As another example, the listing on p.244, lines 13 to 19 could be replaced with a single, more descriptive line:
return str_repeat($star,$rating);

There is lots of good stuff in the "PHP framework" (i.e. the function libraries that come with PHP itself) that shouldn't be ignored in the rush to embrace 3rd party "frameworks".

Overall the first two-thirds of this book are nothing special, but the last third is good and makes this book worth buying if you have any interest in "Web 2.0".

$38 on Amazon (US), or $32 directly from the author
The e-book is $22, directly from author.

10 Apr 2009

Garfield Movie

In the cartoon strips Garfield is a fat, lazy cat, and Jon is a hopeless nerd who wears absolutely awful suits and entertains himself at weekends by trying to get both shoes on one foot. Both cat and owner are very funny. The cartoon strips are wonderful and I read every one.

Yet, in the first scene of this movie Garfield goes to a lot of trouble to wake Jon. This was the first warning signal that something is wrong. Later in the movie this supposed Garfield roams far and wide rescuing a dog. The so-called Jon is even worse - he is good-looking, dresses well, lives in a nice, large house and isn't clumsy, stupid or nerdy.

It is not that this is a bad movie. It is yet another generic American moralizing movie, about someone with a bad personality making a mistake, regretting it, then making up for it, and they all live happily ever after. Oh, with a love story tacked on.

I've nothing against that kind of movie, I even enjoy them. From that point of view this movie is average, a few laughs but nothing special. However, what I strongly object to is sticking the label "Garfield" on this movie. It is like biting into an egg-and-bacon buttie and discovering some idiot has actually filled it with ice-cream. What a waste of an opportunity.

You can find the comics here:
http://www.garfield.com/comics/vault.html

Or here are the links to buy the mediocre movie:

UK:


Japan:

30 Mar 2009

Skype, Logitech and the cost of ownership of Windows

I'm not much of a phone person, preferring email for most business and personal purposes, so had never got around to looking at internet telephony. But I have been wanting to try video chat with family back in the U.K., and the reason that gave me the push to actually do something about it was wanting to encourage my daughters to speak more English (for instance a weekly video call with Grannie). Oh, and a niece I have only seen in photos.

I'm on Linux, my brother is on Mac, and my Mum would be on Windows, and I assumed Linux would be the hardest of those to satisfy. Skype was the first name I recognized in my search, so I went for that! Installation went smoothly, and it auto-detected my web cam. The first time I started it it prompted me to create a user. Easy, simple. Impressed.

I emailed my brother and he also got setup quickly. It took us a few days to find a time when we were both around to try it, but when we did it worked first time. Impressed. And my family got to meet my new niece. I say "meet", because it really felt like it. Okay, I didn't get a cuddle, didn't get to smell the dirty nappy, and didn't get the dribble down the front of my t-shirt. But there was interaction, and there is nothing like seeing a baby's smile happen live!

So, then I set it up on the Windows XP notebook in our lounge. Not easy. Not impressed. The hard part was getting the Logitech webcam installed. I plugged it in. It popped up a box saying unknown USB device, and offered to search for a driver for me. A few long minutes later it gives up. Having thrown out the packaging a long time ago, I tried the Logitech web site. It wants to know what device I have. On the device it says "Logitech" and no other information at all! On the cable is a label with "M/N" (model number??), "P/N" (part number??) and "PID" (???). No luck with any of those.

So, here is what I did. I plugged the webcam back in Linux! The log then told me it is a "Logicool" camera. Still no model number, but it turned out that was enough information to find the correct driver. I then got a 50Mb "driver" to download. I ran it and without asking any questions it chugged away for a couple of minutes, then said it needed to reboot. Ok. After a reboot it opens up and asks if I want to install just the driver or the Logitech software too. Sadly those were the only two choices. The button labelled "Please explain to me what you've been doing for the past 10 minutes and why I had to reboot the machine when you haven't even installed a driver yet you moronic piece of time-wasting software" was missing.

For contrast, as long as you have a 2.6 kernel (i.e. any linux distro from the last 2-3 years ago), the webcam was genuine plug-n-play, a 1 minute install, rather than the above 45-minute marathon.

Anyway, finally the webcam installs. Skype install and setup was reasonably straightforward - not quite as easy as on linux as there are a lot more options compared to the clean linux version. Also when adding a new contact you are forced to send them a text message. Or I misunderstood the over-complex user interface. But, anyway, it works.

For both ease of use and power Linux caught up with Windows about two years ago (as a desktop machine; it has been superior as a server machine, in my opinion, since about 1998.) But it seems the trend has continued and Linux is now far superior. I remember Microsoft ads trying to claim that even though Linux was free its Total Cost Of Ownership was much higher than Windows. As it turns out Windows Total Cost Of Ownership is about 12 times higher: 60 minutes to install a web cam and Skype, compared to 5 minutes on Linux.

In particular if you've bought a simple Logitech webcam and discovered you are running Windows, and you only use Windows for email, browsing the web, office applications, Skype, photos, etc., etc. then I suggest you wipe your disk and install Ubuntu Linux, rather than try to install the Logitech drivers. It is going to be easier, and you also get a better and more secure operating system to boot.

By the way, the video on Windows is much jerkier, and the camera takes five seconds longer to start, compared to Linux, but my desktop machine is more powerful than the notebook. So that may just be a hardware difference rather than the combined incompetence of Microsoft and Logitech.

Anyway back to the main point: video conferencing actually works! And I can recommend Skype as the platform to choose.

11 Oct 2008

japanesepod101.com

JapanesePod101 is a web site for learning Japanese. I have previously used ChinesePod.com for learning Chinese, and found it the most effective way to learn a language, so I was already familiar with, and enthusiastic about the format. However my Chinese level is beginner while my Japanese level is more advanced. My review is based on the 7-day free trial, and is from the point of view of someone with already strong Japanese skills.

Lessons are organized by levels, from Newbie to Upper Intermediate. These are shown as buttons along the top of the Lessons page. But the links on the right include some extras, so better to use them. Lessons are also organized by series, within the same level. So there is Lower Intermediate Series 1, 2 and 3. This distinction is confusing and unneccessary.

Each lesson has an audio lesson, generally about 7-12 minutes long, which has a dialogue by Japanese voice actors, and introduced by at least one native Japanese speaker and one native English speaker. Then there is a lesson notes PDF, which I found to be well-done, especially with the grammar discussions. In fact, unlike ChinesePod, there is probably good value in going for the Basic ($8/month) subscription. There is also a kanji PDF, but that was less useful: it is designed for tracing, but doesn't indicate stroke order. Better to buy a kanji learner's dictionary and use a piece of scrap paper.

Each lesson also a video showing the movie. I thought this was useful. My only criticism here is that it could be done as a flash movie, which would reduce the 10Mb file down to about 200Kb.

A few odds and ends. They have JLPT tests, but only for levels 3 and 4 (the easier two levels). There is a lesson called audio blog, which is all Japanese. The blog itself is only a few minutes long and is then followed with discussion (also in Japanese). They have special offers, both during the trial (wait for day 5 at least before signing up!), and every month or two after that.

The 7-day trial allows a maximum download of 10 PDFs (with lesson pdf and kanji pdf counting as one each), which caught me by surprise and effectively cut short my evaluation. I didn't notice any other restrictions however.

Summary: even for the more advanced student I think the lessons are useful, and I intend to sign up for a month's hard study in the Autumn. If and when they add tests for JLPT level 1 and 2, it will be even more useful.

P.S. I see ChinesePod.com are in the process of setting up JapanesePod.com. Given the headstart it has, I expect JapanesePod101.com to be superior for at least the next year.

7 Aug 2008

Breadmaker, Wholewheat flour

I live in Japan and they have a different approach to bread. They like it so white it has slightly less nutrition than a piece of damp cardboard, they like it so soft and bouncy it is impossible to spread margarine on, and they like their slices so thick that each is really a mini-loaf. Oh, and they don't like the crusts: they are cut off and thrown away at the bread shop.

It seemed that whenever I found a nearby supermarket stocking (relatively) healthy bread they would discontinue that line within two weeks. The local co-op had a multi-grain bread that had 10 slices to the packet, and so could be used for sandwiches. That lasted a number of months, though was frequently sold out, but then, while they kept that bread type, they switched to 6 slices to a packet. This was never sold out, but was much less useful.

Obviously the supermarkets are run by morons.

A minor rant but it explains why I finally decided enough is enough and got a breadmaker. I wanted one that can handle wholemeal flour; my wife wanted one that can use tennen-koubo (natural yeast?). These two conditions eliminate some models, but it turns out you still have plenty of choice. We went for a 1.5 loaf model in the end, as it was only slightly more expensive and some reviews mentioned the 1.5 loaf model was quiet, while some reviews mentioned the 1 loaf model was noisy.


The one we went for was the National SD-BM151. But as far as models go, this is my first and only breadmaker, so I cannot compare them.

We have had this almost six months now and it has been wonderful. We have simply stopped buying bread! I've been baking about two of the 1.5 loaves each week, freezing some of the bread each time. It takes about 10 minutes effort to grab the ingredients from the cupboard, measure them and put them in the bread maker, and start it. Let's call it 15 minutes if we include the time spent on the washing up afterwards, and the slicing.

Some downsides.
  • There is a little indentation in the bottom, which depending on where the rotor finally ends up can affect from 1 to 4 slices.
  • You have to slice the bread yourself. It can be quite soft and so it is tricky to get all the slices beautiful. So we often end up with at least one slice that is wedge-shaped.

Some upsides
  • No preservatives or chemicals.
  • I am typically using 50% organic wholewheat flour, 25% organic white flour and 25% cheap white (bread) flour. So almost organic (I'm not using 100% organic simply as it costs more). I also use whole milk, and brown sugar. This makes a loaf that is not just tasty but also so much healthier than anything we can possibly buy.
  • A gorgeous smell for the last hour of the baking.
  • Something satisfying about baking your own bread.
  • Our most common recipe is to add raisons and walnuts. A delicious and healthy combination (the raisons also give a bit of moisture for people who find 50% wholewheat too heavy). And, again, you simply cannot buy this in the shops.
  • It makes pizza dough! Pizza with 30% or so wholewheat flour is a real delight; white-bread pizza just seems so bland now.

Where to get wholewheat flour in Japan? First there is FBC: http://www.fbcusa.com/
They are resellers for Alishan, but if you are buying over 10,000 yen's worth anyway then delivery is free. Or you can go direct to Alishan here: http://www.alishan-organic-center.com/en/index.html
Here is a direct link to their flours.
They have a great-value 5kg wholewheat flour there, but be careful: it is not organic (I didn't realize until it arrived, so I am working through that at the moment, and will then go back to ordering the organic 2kg bags).

14 Dec 2007

Ubuntu 7.10

To put this review in context, my previous workstation was running Fedora Core 5, with Gnome, and I've been using Fedora since it was called RedHat 6. I prefer to get work done instead of reading man pages and configuration files; I know how to edit httpd.conf or /etc/hosts in vi, but I just don't enjoy it.

My new machine had modern hardware (Intel ICH5 chipset) that Fedora Core 7 choked on, and basically the just-released Ubuntu ended up being chosen as it was the first user-friendly distro I tried that would install. (CentOS also failed, as did the Fedora 8 pre-release; I didn't get to Suse as some web searching hinted it would fail.)

The quick summary: No regrets. Ubuntu is good. Better than Fedora. Better overall than Microsoft Windows. (Far better than OS/X, but Macs and I have never really got on - we just don't seem to understand each other.)

Install starts with a live CD boot, where you can play with the system. Then install. The install went smoothly. There were very few questions, which is a criticism - I had to spend a lot of time after the install completed realizing things were not installed and having to install them. On the other hand Synaptic Package Manager is easy to use, and I can generally have the software I need installed and running within 60 seconds. I had been very reluctant to switch from a familiar RPM distro like Fedora to a deb distro, but in fact I have not had to be aware of the differences so far.

Support, via Google, is excellent. "Ubuntu xxx" has almost always given me a helpful page telling me how to setup or troubleshoot xxx.

Lots of things Just Work. Printer just worked when I plugged it in. The samba network drive was found first time. Setting up an encrypted partition was easy, as was setting up special encrypted directories, again following Ubuntu-specific tutorials. Burning DVDs just worked. My USB thumb drive just worked. My scanner too. Sound too. Gigabit ethernet too.

Getting scim-anthy working required a bit of effort. See http://tlug.jp/ML/0710/msg00295.html and http://tlug.jp/ML/0710/msg00305.html. But it was roughly the same steps I had to go through on Fedora: I need to simultaneously use Japanese, Chinese, Arabic, etc. in an English environment, which is not a common need, so I can accept a little work. I am not even sure it can be done at all on Windows?

Webcam just worked. Google on "ubuntu webcam" took me to a page suggesting I use Camorama. I went to the package manager and that was installed within a minute. And it just worked first time. It took longer to find my scissors to get it out of the packaging that it did to plug it in, install the software I needed and get as far as taking a snapshot and emailing it to my Mum.

Two problems stand out. First multimedia (Fedora was terrible here too). I had to follow a tutorial to get most audio and movie formats to play. I then had to hunt and follow another one (the one that talks about mediaubuntu.org) before DVDs would play. There are two formats I still cannot get to work: VCD (and Google tells me no-one else is having much luck there) and Real Media. The latter is irritating as, despite there being video formats that are superior in all respects, some web sites still insist on only publishing in that format (e.g. the BBC, and MIT open lectures). I ended up having to install RealPlayer on Windows to be able to watch some things. (Real Media's own Real Player For Linux installed without complaint but crashes with a segmentation fault every time I run it.)

Second problem was the 19" 1440x900 wide-screen monitor. I installed using a spare 15" monitor, no problems, then when I was ready to switch to it to be my main system I plugged in this monitor. Seven hours later I finally cracked it: in the x11 conf file it has to be referred to as Monitor-VGA-1, the "-1" on the end being critical. Without that the configuration I thought I was adding was being ignored and then it was falling back on its clever auto-detecting, and (as it had no knowledge of this particular monitor model) it was choosing 800x600 or something.

One more thing. After installing I suggest you go to this obscure place: Systems|Preferences|Sessions, where you can disable a number of services you don't need. I disabled Evolution alarm notifier (I'd stripped out the default-installed Evolution, as I prefer to use Thunderbird), bluetooth manager, tracker and visual (a mysterious one but nothing has broken since I did that). Tracker is the key one you must disable - it will continuously index your entire home partition for some search program that as far as I can tell I have never used or needed. And according to some web searching it is unreliable and will sometimes use 100% CPU.

Other other minor comments. bash has intelligent tab completion, just like zsh, but while still being bash apparently. Nice. Firefox 2.0, and especially Thunderbird 2.0, run more slowly than the 1.5 versions I was using under Fedora Core 5, without a single useful feature to compensate that I've been able to notice so far. Gnome file manager was also a bit sluggish, but killing "Tracker" (see above) seems to have helped there. Having changed three things at the same time (hardware, distro, version) I am unable to say if the slower performance is due to the way ubuntu builds them compared to Fedora, or due to bloat caused by bigger version numbers, or due to my new, faster hardware.

Overall, Ubuntu 7.10 is good, and is now my first choice of OS to install on a new machine.

1 Nov 2007

Casio Ex-word XD-SW6500

I am a patient man, but one thing that always drives me crazy is using a Japanese kanji dictionary: the radical index. There are two things I don't like about radicals. First that they are frequently illogical, irrational and inconsistent, and second that they are stupid. For some kanji the radical is actually a straight horizontal line hidden in the middle of the symbol. For others the radical is obviously the three strokes on the left but in fact you need to know those three strokes are shorthand for water which is under the five stroke radical index. Okay water is easy to recognize, but others are not. (See http://www.saiga-jp.com/kanji_dictionary.html for a search function that solves this latter problem, but it is still not enough to make me like radicals.)

Rant over, on to the review. I wanted an electronic pocket dictionary; I had seen friends using them and they no longer seemed to be gimmicks. There were three items on my wishlist: 1. Under 20,000 yen; 2. Able to write the kanji, instead of using radicals (see above); 3. including the Green Goddess dictionary (otherwise known as Kenkyusha's New Japanese-English Dictionary: 新和英大辞典 第5版 ― 並装), which I have been told my numerous professional translators is the best.

I went for the Casio Ex-word XD-SW6500, which at 31,500 yen only satisfied one of my three criteria (NOTE: it is 29,800 yen at Amazon JP: カシオ計算機 電子辞書 Ex-word XD-SW6500 XD-SW6500 I should've checked first!!). But it was worth 15% points at Bic Camera, so really I was only 7000 yen over budget. The Green Goddess dictionary is only built-in on top-end models costing over 45,000 yen.

But what decided me on this model was that it can be easily expanded, either with SD card, or with a dictionary on CD and feed the data in over USB cable. So even though it did not come with the dictionary I wanted, I can add it later for 10,000 yen; I have not done so yet. (The downside there is that I can either buy an Ex-word CD version (EX-WORDデータプラス 研究社新和英大辞典), or a Windows CD version (13,500 yen: 研究社 新和英大辞典 第5版): if I want to use it on both Ex-word and PC I have to buy it twice! Also note that the Epwing CD is different from the logavista CD! The Epwing format seems to be more open and can be used on linux too, apparently; it is however a few thousand yen more expensive.)

The kanji handwriting recognition is good (though not available in all dictionaries which is a little annoying). Even if I'm confident I'll guess the pronunciation in my first 3 attempts, drawing it is still quicker than typing it in, and it has proven very accurate so far. It is also not fussy about stroke order, or how long you pause between strokes. And when it gets it wrong you tap the teisei button and get shown its other guesses.

I have some minor criticisms of the handwriting recognition. If I'm inputting say a three character word, and it was only the first character I wanted to draw and I know how to pronounce the last two characters I still have to draw the last two characters. Well I can type the last two characters in as hiragana but mixed kanji/hiragana words are not found. Another problem is when inputting say a two character word and it guesses the second character wrongly. When I tap teisei it shows the two character word with no way to choose an alternative for just the second character. So I have to delete the second character and draw it again, taking more care.

What else can I say? The user interface is easy to learn, but you will need to be able to read at least basic Japanese, and there is no English manual. The dictionaries seem reasonable so far. They boast 100 content items, most of which I have no interest in (this product is aimed at a Japanese person). The speech is another feature of no value to me (it speaks the English, not the Japanese); however there are phrase books for Spanish, German, French, Italian, Chinese and Korean and these also have speech, which I did find useful. It takes two AAA batteries, and they have not run out yet so I cannot comment on battery life except to say it seems fine so far. There is a backlight.

In summary, I think this product is expensive, but very useful.

P.S. If anyone has bought the Ex-word Green Goddess CD please let me know how you are getting on. How well does it integrate? Does it become the default wa-ei dictionary, or is it harder to access?