Jaffa Cake Advert Found

October 13th, 2011 by Richy B. 1 comment »

After my May 2005 blog post about a Jaffa Cake song, I’m overjoyed to say that “Jo” has found a YouTube copy:

1992 Jaffa Cake Calypso Song.

Uploaded by CultOfJaffa

Many thanks Jo!

PHP: PHP Programming on Windows using JetBrains PhpStorm and local PHP

October 12th, 2011 by Richy B. No comments »

Here’s some steps which may help somebody else install PHP on their Windows machine to run alongside JetBrain’s PhpStorm for PHPUnit testing

  • Download Windows PHP from http://windows.php.net/download/ . I selected PHP 5.3.8 ‘s VC9 x86 Thread Safe (2011-Aug-23 12:01:10) Installer.
  • Install, with no web server configurations, to C:\Program Files (x86)\PHP
  • Download the appropriate APC module from http://downloads.php.net/pierre/ to match your PHP version. I picked: http://downloads.php.net/pierre/php_apc-3.1.5-5.3-vc9-x86.zip
  • Copy the enclosed php_apc.dll from that .zip file to C:\program files\x86\PHP\ext
  • Download the appropriate XDebug module from http://xdebug.org/download.php to match your PHP version. I picked: http://xdebug.org/files/php_xdebug-2.1.2-5.3-vc9.dll
  • Save the file to c:\program files\x96\PHP\ext (I had to save it as c:\users\richyc and then, from my administrator command prompt (see below) do “cp c:\users\richyc\php_xdebug-2.1.2-5.3-vc9.dll.dll “c:\program files (x86)\php\ext”)
  • Start a command prompt, cmd.exe, with administration rights (Windows->Search->cmd.exe right click and then “Run as administrator”)
  • In the command prompt, enter the following:
    cd “c:\program files (x86)\php\pear”
    php go-pear.phar
    Are you install a system-wide PEAR or a local copy? system
    Accept all defaults
    pear upgrade pear
    pear config-set auto_discover 1
    pecl channel-update pecl.php.net
    pecl config-set php_suffix .exe
    pecl install channel://pecl.php.net/dbus-0.1.1
    pear install channel://pear.php.net/HTTP_REQUEST2-2.0.0RC2 channel://pear.php.net/Net_URL2-0.3.1 pear/XML_RPC2
    pear install pear.phpunit.de/PHPUnit phpunit/DbUnit phpunit/PHPUnit_Selenium phpunit/PHPUnit_Story phpunit/PHP_Invoker
    echo extension = php_apc.dll >> ../php.ini
    echo zend_extension = “C:\program files (x86)\php\ext\php_xdebug-2.1.2-5.3-vc9.dll” >> ../php.ini
    echo xdebug.remote_enable=1 >> ../php.ini
    echo xdebug.remote_host=localhost >> ../php.ini
    echo xdebug.remote_port=9000 >> ../php.ini
    echo date.timezone = “Etc/UTC” >> ../php.ini
  • To test from the command prompt, just try php -m. You should see apc and xdebug (twice) listed.

Now PHP is configured, we need to configure JetBrain’s PHPStorm to use it:

  • Load PHPStorm
  • Open or create your project
  • Go to File->Settings->PHP
  • In the PHP home section, enter: C:\Program Files (x86)\PHP and select “Xdebug” as your debugger
  • Select “Update include paths”
  • Select PHP->Debug->Xdebug proxy
  • Enter Host: localhost and port: 9000. Leave “IDE Key” empty

Books: Holiday reading

September 29th, 2011 by Richy B. 1 comment »

I’m going on a little holiday soon and so want to take a number of books to read. I’m tempted to buy:

And thanks to various recommendations (particularly Kirstie Haxby and Martyn Drake), I’m also going to be ordering:

Any other recommendations? (Thanks Tim – but I’ve already got all the Ben Elton books, along with all the Robert Llewellyn ones)

Varnish: Unable to start: SHMFILE owned by running…

September 15th, 2011 by Richy B. 2 comments »

If, when trying to start the Varnish reverse proxy server, you receive an error message such as:
[root@internet634.fbi.gov ]#/usr/sbin/varnishd -d -f /etc/varnish/default.vcl
GeoIP plugin loaded successfully.
storage_file: filename: ./varnish.8QhQpI size 4208 MB.
SHMFILE owned by running varnishd master (pid=2451)
(Use unique -n arguments if you want multiple instances.)

but “ps auxwww | grep 2451” doesn’t show Varnish (in my case, it was dkim-milter on that pid) and “ps auxwww | grep varnish” shows nothing, then you need to manually reset Varnish’s SHMFILE settings.

This is easier done than said! Just go into /var/lib/varnish/[hostname] and delete all the files in there (such as varnish.8QhQPI and _.vsl). Restarting varnish should then be successful.

PHP: Magento – current stock value

August 13th, 2011 by Richy B. No comments »

If you run the Magento ecommerce shopping cart software and you want to find out how much your stock is worth, how many product lines you have stocked and how many individual items you have, you may find the following MySQL query handy.

I’m assuming that you’ve created an attribute with the attribute code “supplier_price” as a decimal, that you’ve kept this field up to date and your stock levels are accurate đŸ˜€ If it isn’t called “supplier_price” change the appropriate part in the query.

COUNT(sku) AS 'products_stocked',
SUM(qty) AS 'items_in_stock',
SUM(stockvalue) AS 'stock_value'

(cataloginventory_stock_item.qty * catalog_product_entity_decimal.value) AS stockvalue
catalog_product_entity.type_id='simple' AND
cataloginventory_stock_item.product_id=catalog_product_entity.entity_id AND
catalog_product_entity_decimal.entity_id=catalog_product_entity.entity_id AND
eav_attribute.attribute_id=catalog_product_entity_decimal.attribute_id AND
eav_attribute.attribute_code='supplier_price' AND
cataloginventory_stock_item.qty > 0

%d bloggers like this: