Press "Enter" to skip to content

Richy's Random Ramblings

xckd: Learning a new language

xkcd
xkcd

This comic on xkcd is quite relevant at the moment Yes, I’m splitting up with my other half – No, don’t panic K, I’m not really 😉 But she and I were watching Firefly over the weekend (10 out of 14 episodes done: big pity they cancelled it) and we did find it annoying that we didn’t understand the Chinese language in it: and we know at nearly the big “three oh”, we’re both going to find it difficult to learn a new language (especially since we would prefer to learn Japanese or Mandarin/Cantonese) as our brains have “solidified”.. Shame!

Anybody got any tips for learning totally new languages when you are a bit old in the tooth? Neither of us know any other languages (apart from several computer languages and very basic French: but those don’t count)…

PHP: Zend Session: don’t set it up in the Initalizer

I’ve just wasted a few hours trying to get Zend_Session (part of the PHP Zend Framework) working correctly – previously, on this codebase, I had “rolled my own” cookie and session management system, but I thought I’d do it properly and utilise the Zend_Session system and store it all in a database…

It didn’t work.

Short answer as to why my sessions weren’t saving into the database (even after I switched to using the “default” Zend_Session_SaveHandler_DbTable ) was that I was setting up the session within the “routeStartup” section of Initalizer.php (which is loaded, in MVC fashion, via the bootstrap.php file). Changing bootstrap.php to:

// Prepare the front controller.
$frontController = Zend_Controller_Front::getInstance();
// Change to 'production' parameter under production environemtn
$frontController->registerPlugin(new Initializer('development'));
$maxSessionTime=60*60*24*30*6; // six months
Zend_Session::setSaveHandler(new My_Session_DbTable($maxSessionTime));
Zend_Session::rememberMe($maxSessionTime);

(i.e. take move the session savehandler out of the Initializer, but keep all the $thingy=new Zend_Session_Namespace whereever they are needed) means it started to work.

Most annoying thing: that there was no reason it didn’t work (no warnings, no errors, no documentation hints and no ‘out of place feeling’). Meh.

Personal: You know you are getting old…

  • When Policeman start looking younger
  • You don’t remember being absentminded.
  • You have more patience; but actually, it’s just that you don’t care any more.
  • Your memory is shorter and your complaining is longer.
  • You look forward to a dull evening.
  • You quit trying to hold your stomach in, no matter who walks into the room.
  • Your idea of a night out is sitting on the patio.
  • You begin every other sentence with, “Nowadays…”
  • A ‘late night’ now ends at 11 pm.
  • When the actor playing Doctor Who is younger than you

*sigh*

ClickCartPro: Extracting Sales Figures

If you want to get an idea of the stock you’ve sold using the ClickCartPro UK e-commerce software, then you may find the following SQL query useful. Run in phpMySQL to be able to export the data into a spreadsheet.

SELECT SUM(itemquan) as itemssold, count(*) AS timesordered, itemname, itemnum, itemopts, SUM(itemquan)/COUNT(*) AS average FROM `gbu0_orderitems` WHERE FROM_UNIXTIME(epochorder) BETWEEN ‘2007-01-01’ and ‘2008-12-31’ GROUP BY itemnum,itemopts ORDER BY itemssold DESC

What does this mean?
Well, “SUM(itemquan) AS itemssold” grabs the number of items sold, “count(*) AS timesordered” grabs the number of times that item has actually been ordered (as an order could be for 2 or more items), “itemname, itemnum, itemopts” grabs the items name, item number and the options ordered (handy for sizes), “SUM(itemquan)/COUNT(*) AS average” works out the average number of items per order, “FROM `gbu0_orderitems`” says to look at the order table (ok, I’m not distinguishing between cancelled, pending and completed orders at the moment), “FROM_UNIXTIME(epochorder) BETWEEN ‘2007-01-01’ and ‘2008-12-31′” says to only include orders placed between the 1st of January 2007 and the 31st of December 2008 and “GROUP BY itemnum,itemopts ORDER BY itemssold DESC” means group the items for the counts by the item number and options and then order everything by the number of times sold in decending order.