Coles fruit and vegetables: price tag unknown

December 8th, 2008

Coles logo

I’ve got a little beef with the local coles regarding the scales they provide to weigh. Because they’re selling by weight the laws require that the measurement is true. But I suspect there is nothing to say where exactly the scales must be located.

Where can I weigh these goods being sold by weight?

Zend Framework Quickstart Tutorial: Deploy to a subdirectory instead of web root

November 18th, 2008

When you’re just evaluating something new you do not want to rearrange your whole world just to try something out.

I wanted to try out the Zend Framework and the “QuickStart” tutorial looked very official and the ideal place to start.

However they assume installation is in the webroot. Sorry, but I have other, more important, stuff running on this server and I’m not shoving it aside just for a quick tutorial.

Try as I might, I had great difficulty getting this tutorial to run in a subdirectory. As I’m learning the thing I’ve no idea how to tweak it yet!

Anyway my web root is “/var/www” and I want to put the quickstart tutorial at “/var/www/QuickStart”, which in turn means the public directory is at “/var/www/QuickStart/public”. To make the whole thing work required three changes:

1. Redirect everything to the index in the subdirectory

When I use the cited .htaccess from the tutorial page titled “Create a Rewrite Rule” and call the index it works! Great, except that’s not the test for ‘working’.

Zend needs to feed all requests through the index page so it can farm them out to controllers. The controllers are identified by the ‘filename’ of the request: so the redirection is supposed to catch all the 404′s and feed them into the index. It’s not working until you can call non-existent URL’s without the webserver giving you a 404. eg: “http://servername/QuickStart/public/asdf” should show the “Hello, Zend Framework!” message.

Stay on this step until you get the “Hello” message for made up url under your public directory. E.g. “http://servername/QuickStart/public/asdf”.

My /QuickStart/public/.htaccess became (NB: this is Case Sensitive)


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /QuickStart/public/index.php [NC,L]

This might be done more cleanly with a “RewriteBase” but this worked so I moved on.

2. Set the “BaseURL” of the front controller

Now there is something not right in the Tutorial because the next checkpoint screenshots a message which doesn’t appear in the code so far displayed. That in itself is very frustrating and entire problem of its own so lets not get distracted. I tried to run through the tutorial again from scratch so I could make this post straight from a fresh run through. But not to be.

If you manage to overcome and reach the next checkpoint you’ll need this:

Add a line to “Step 3″ of the the /application/bootstrap.php to set the base url:


// Step 3: CONTROLLER DIRECTORY SETUP - Point the front controller to your action
// controller directory.
$frontController->setControllerDirectory(APPLICATION_PATH . '/controllers');
$frontController->setBaseUrl('/QuickStart/public');

This tells the front controller to prepend Url’s with the subdirectory, and this got me most of the way through the QuickStart tutorial with one exception.

3. Fix the “Action” in guestbook form

When you post to the guestbook you’ll get an error looking for a file “/guestbook/sign” which doesn’t exist. The form is created with that action and you need to fix it in the GuestbookController.php:

Change the setAction in function _getGuestbookForm() to


$form->setAction($this->_request->getBaseUrl() . $this->_helper->url('sign'));

And with that it should generate a form action “/QuickStart/public/guestbook/sign”.

I’m told this last issue has been lodged has a defect and not necessary from releases “1.7″ and beyond. The helper->url will henceforth prepend the baseUrl to its result.

Zend Framework QuickStart Tutorial: What are the filenames?

November 13th, 2008

I’ve just worked my way through the Tutorial for the PHP Zend Framework. I overlooked downloading the code at the start and launched straight into it creating each piece myself from the tutorial.

After the first couple of pages they (currently) neglect to mention where each piece of code is supposed to go. Maybe I learnt a lot more, but it did not make for a very ‘quick’ start trying to work out where things go from the error messages.

Here’s the final structure of the QuickStart Tutorial…


application/
|-- app.ini
|-- bootstrap.php
|-- controllers
|   |-- ErrorController.php
|   |-- GuestbookController.php
|   `-- IndexController.php
|-- forms
|   `-- GuestBook.php
|-- layouts
|   `-- scripts
|       `-- layout.phtml
|-- models
|   |-- DbTable
|   |   `-- GuestBook.php
|   `-- GuestBook.php
`-- views
    `-- scripts
        |-- error
        |   `-- error.phtml
        |-- guestbook
        |   |-- index.phtml
        |   `-- sign.phtml
        `-- index
            `-- index.phtml

A 30-second Geek chair review: Aeron, Mirra, or Leap?

October 30th, 2008

A chair is an underrated essential item for a programmer; consider how much time is spent in it. Things came to a head when I moved recently. Whilst lugging around all those boxes and furniture my back insisted on telling me it is in poor health. Most probably I arrived at this situation by sitting a large, very impressive, leather executive chair which my cousin lent me whilst he is overseas. It really looks and feels great to other people who saw me in it; but was terrible for me to actually sit in over time – being quite a short fella perhaps didn’t help. I was adopting such a curved slouch that I was even putting a cushion in behind me to fill some of the gap.

Anyway I decided it was time to get a proper “task” chair to alleviate the situation.

Now everybody (in the internet world) is well aware of the famous Herman-Miller “Aeron”. Needs no introduction really. The price tag does need some recovery time… say AU$1300 as a guide. But in researching reviews from the USA I saw quite a few favourable mentions of the Steelcase “Leap”. They’re an unknown in Australia.

Steelcase Leap

The Steelcase Leap task chair
It seems Steelcase aren’t using the usual retail channel to flog individual chairs. None of the retail stores stock them. I’m not spending a thousand dollars on a chair without sitting in it, but rather fortunately they have a showroom/office in Sydney so I went to check them out. “How many would you like?”, “Well just one.”, “oh”. The sales rep took me to her own desk and invited me to sit in her own chair – which was a little unexpected.

It felt really good. She ran through the controls and I was rather impressed with the variety and particularly the ease adjustments could be made. I wasn’t sitting particularly long, maybe 20 minutes, but my back was saying ‘yes’ and was already envisaging my spine lining up again and long abused muscles getting their wake up call. They don’t stock these things and suggested an order and 12 week wait. I can’t wait that long!

The Aeron and Mirra

The Herman-Miller Aeron task chair
I found an Herman-Miller retailer around the corner, so ran to check out the Aeron and Mirra. Yeah, nice chair, but didn’t immediately impress me as being all that worthy of the price tag. Generally the age of the design was quite evident. To raise/lower the arms I had to get off the chair, walk around the back and wrestle them in to place. To adjust the tension of spring in the backrest required a lot of turning the knob with very little feedback – am I turning it the right way? Is anything happening? To stop the backrest I don’t recall being difficult, but to release the backrest once on the backstop required taking all your weight off the back of the chair – enough to release the pin – before being able to lean back further. This last inconvenience paled the Aeron in comparison to the Leap.

The Mirra came across as a crippled version of the Aeron.

Leap wins

There was no real comparison in my mind. They both might be comfortable chairs but the Leap was equal or more comfortable, vastly easier to use, and 30% cheaper.

The armrests float a surprising distance: 2 inches forward/back and an inch in/out without having to touch any knobs – something the Aeron was entirely void of. The up/down action (2-3 inches) is a simple push button on the armrest. You might rationalize that once you’ve set these things up the ease which they move is no longer relevant. But you’d be wrong. I’m finding myself moving the armrests around all day as various positions become tired and I resettle into a new one. The ease of movement is fantastic.

The backrest is excellent. For one, the tension can be adjusted in quarter turn measures, as opposed to 10 turn measures for the Aeron. But truthfully I don’t change the tension routinely; once I’ve set the tension such that once I settle on an angle it will stay there without having to apply force to keep it there I leave it alone. The major difference here is that if I push further it will go and stay there as I stop pushing. Hard to convey in words but basically it is easy to get both the right amount of back support and a comfortable back angle without touching any knobs. My concern with the Aeron was the requirement to lean forward and release every time I wanted to change the angle of the backrest. The Leap also has four backstop positions which I’m surprised to be using increasingly; when I’m “thinking”, reading, browsing, talking then I let it lean right back. But when concentrating I get upright and set it to the first or second position – right hand click-click-done.

Acquisition

Getting my Leap chair was not all that conventional. As I mentioned Steelcase appear to be neglecting retail sales, no doubt chasing the big deals. I chatted to the sales rep (gosh that was easy, an unsurpassed beauty) at their showroom/office and expressed the urgency of my need and my disinterest in specific options (eg color and quality of the fabric etc). Surely there was one just lying around ready for sale. She said she’d see if she could find a spare one. A few days later I was directed to go to an area near the airport (Mascot) and collect my chair.

It was quite difficult to find the dirt road as it lay through the gates of an unrelated warehouse. I arrived in a brown dusty dirt paddock town made up of shipping containers. The office was, of course, a shipping container. Out in the dust, standing in front of a big red two story shipping container was a large cardboard box in which I found my chair (fully assembled inside the box). I chatted to the lady in the ‘office’ and discovered that the gorgeous sales rep had indeed had to dig around to find me a chair. Seems this particular chair was originally shipped in for a very large Westpac order. I guess they didn’t want it yet/anymore. Lucky me.

Four weeks later and I’m still very pleased with both the decision to spend some real money on a chair, and to get the Leap.

Million dollar idea #964

October 19th, 2008

You’re in the nightclub but you can’t hear anyone. Product is a nearly invisible hearing piece which you have in your ear (secret service style). It has a small, very directional, wireless microphone you wear it on your collar, earring, on your finger, whatever (accessories). You could just move it into someone’s voice projection to hear them, but that’s going seems a geriatric piece, kinda the stealth/lurker model. No money in that.

So to market this we have a version which is more visible, more social. Your microphone/broach has a red/green light on it. If you like the look of the boy/girl approaching you press it to set the light to green; they press theirs and the two systems connect. You can hear each other talk. Range is 50 centimeters so you have to stay close to stay in radio contact or it drops out. The game is to keep ‘pressing each others buttons’.

Getting started with Drupal

October 17th, 2008

Is Drupal

Set a Static IP Address with Ubuntu Linux

October 9th, 2008

Problem
I want to ensure my linux server always has the same IP address. If it still wants to use dhclient to find a dynamic ip address, and the nameservers, then that’s ok too.

Solution

By setting an “alias” for the fixed address in dhclient it will answer to both the static ip address you want and any dhcp address leased from a dhcp server.

Method

Edit /etc/dhcp3/dhclient.conf to include something like:

alias {
      interface "eth0";
      fixed-address 192.168.1.101;
      option subnet-mask 255.255.255.255;
}


Which tells dhclient that whatever ip address it gets for eth0, 192.168.1.101 is also its ip address. So it will answer to two ip addresses simultaneously.

Restart the network and you’re done…


john@lappy:/etc$ sudo /etc/init.d/networking restart
[sudo] password for john:
 * Reconfiguring network interfaces...
...
DHCPACK of 192.168.1.4 from 192.168.1.254
bound to 192.168.1.4 -- renewal in 120670 seconds.
                                                                                                                      [ OK ]
john@lappy:/etc$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0d:60:8a:35:92
          inet addr:192.168.1.4  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20d:60ff:fe8a:3592/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10012 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5789 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:13138975 (13.1 MB)  TX bytes:565365 (565.3 KB)

eth0:0    Link encap:Ethernet  HWaddr 00:0d:60:8a:35:92
          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.255
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:56 errors:0 dropped:0 overruns:0 frame:0
          TX packets:56 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3850 (3.8 KB)  TX bytes:3850 (3.8 KB)

john@lappy:/etc$

Story

Once upon a time every computer had a static IP address and setting it was a trivial text edit or command line task. But today I had trouble getting Ubuntu Linux (Intrepid) to do it. A simple edit of /etc/network/interfaces no longer seems to work as expected. With a whiff of Microsoft “helpfulness” a irrepressible effort now goes into ensuring Ubuntu is dummy proofed to find an IP address for itself. Me trying to tell it not to find an IP address I found was working against the flow of traffic.

Schedule specific files with Transmission-remote

October 7th, 2008

Problem

You’re using transmission remotely and you don’t want to download every file in a particular torrent, just some of the files in it. (V1.34 web interface doesn’t implement this functionality).

Solution

Use transmission-remote to view and (de)select specific files.

Method

Show me the running torrents (and your id numbers for them)
transmission-remote -l
Show me the files in torrent 2 (and your id numbers for them)
transmission-remote -t 2 -f
Don’t download any of the files in torrent 2
transmission-remote -t 2 -G all
Download files 1 and 3 in torrent 2
transmission-remote -t 2 -g 1,3

See the transmission-remote man page for more detail.

Example

john@laptop:~$ transmission-remote -l
ID Done ETA Up Down Ratio Status Name
2 0% 17 hrs 0.0 15.6 0.0 Downloading Neighbours
john@laptop:~$ transmission-remote -t 2 -f
Neighbours (318 files):
# Done Priority Get Size Name
1: 0% Normal Yes 174.8 MB Neighbours/Pilot - [DVD]/001 - The Neighbours Chronicles - [DVD].avi
2: 0% Normal Yes 174.9 MB Neighbours/Season 1 - [DVD]/002 - The Stakeout - [DVD].avi
3: 0% Normal Yes 174.9 MB Neighbours/Season 1 - [DVD]/003 - The Robbery - [DVD].avi
john@laptop:~$ transmission-remote -t 2 -G all
localhost:9091 responded: "success"
john@laptop:~$ transmission-remote -t 2 -g 1,3
localhost:9091 responded: "success"
john@laptop:~$ transmission-remote -t 2 -f | head -7
Neighbours (318 files):
# Done Priority Get Size Name
1: 0% Normal Yes 174.8 MB Neighbours/Pilot - [DVD]/001 - The Neighbours Chronicles - [DVD].avi
2: 0% Normal No 174.9 MB Neighbours/Season 1 - [DVD]/002 - The Stakeout - [DVD].avi
3: 0% Normal Yes 174.9 MB Neighbours/Season 1 - [DVD]/003 - The Robbery - [DVD].avi
4: 0% Normal No 174.9 MB Neighbours/Season 1 - [DVD]/004 - Male Unbonding - [DVD].avi
5: 0% Normal No 174.8 MB Neighbours/Season 1 - [DVD]/005 - The Stock Tip - [DVD].avi

Schedule transmission bittorrent

October 7th, 2008

Problem

Transmission doesn’t include any scheduling functionality to start/stop/trottle torrents during the day/week.

Solution

Don’t run the gui client. Instead (or as well) invoke transmission-daemon from the command line and use crontab to apply the schedule via transmission-remote

Method

  1. Install the transmission-cli package corresponding to your Operating System
  2. Start transmission-daemon eg:
    transmission-daemon -f -g /home/torrentuser/transmission-config -w /home/torrentuser/incoming
  3. Test it is running by opening a browser and visiting http://localhost:9091
  4. Play with transmission-remote to get a feel for what you can do. eg: start and stop all torrents…
    transmission-remote -t all -s
    transmission-remote -t all -S
  5. Setup your schedule in Cron with crontab
    eg: to start all torrents at 2:02AM every day and stop them at 11:58AM…
    crontab -e
    02 02 * * * /usr/bin/transmission-remote -t all -s
    58 11 * * * /usr/bin/transmission-remote -t all -S
  6. optional: You might also play with at for scheduling once off tasks

    Start Headless vbox on windows

    October 2nd, 2008

    I keep forgetting this simple little line to start a virtualbox so that it behaves like a remote server (ie without any windows and crap cluttering my display)

    start /b vboxheadless -s myjeos

    “start” is the windows command to start a process
    “/b” tells start not to create a window for the process
    “vboxheadless” is the process to start
    “-s” tells vboxheadless to start a machine
    “myjeos” is the name of the machine to start