home | contact us
» » December


Often you will come across a situation where you have to do a mass of redirects, often when moving platform e.g. from osCommerce to Magento.

So you might create a whole load of .htaccess rules which you want to verify, either before or after implementing them.

Rules like :
RewriteRule ^top-level-category/old-category/product-name-p-3944.html$ new-product-name.html

I wrote this bash snippet to do just that – here’s the validate the pages you are redirecting to are valid (200) :-


for f in `cut -f3 -d' ' .proposed-htaccess`; do
curl -I -v http://www.mydomain.co.uk/$f 2&1 /dev/null | grep 'HTTP/1.1 ' | sed s/'.*1\.1 '// | grep 200 /dev/null || echo $f failed to fetch
done

Then, once you have got the .htaccess uploaded you can verify that they are indeed rewriting should you wish :-


for f in `cut -f3 -d' ' .proposed-htaccess`; do
curl -I -v http://www.mydomain.co.uk/$f 2&1 /dev/null | grep 'HTTP/1.1 ' | sed s/'.*1\.1 '// | grep 301 /dev/null || echo $f was not a 301.
done


 

If you would like your users to be able to spell check their text before they send it and need something more than the browser based spell checking then this could be of interest.

Recently came across this and it looks very impressive:

http://www.phpspellcheck.com/

There is a commercial licence for $89 which is a reasonable price I think.

You can download the package and integrate it for free though so you don’t need to buy the licence until you decide to deploy it to a commercial site.


 

If you are writing any javascript in magento and try to debug using console.log, you may find that nothing happens in Chrome, but everything works as expected in Firefox.

The reason for this is that varien have included a blank console object to prevent any calls to the console throwing an error if a console isn’t defined. However they explicitly check for firebug, which means if your running chrome the built in console is replaced.

To fix this you need to edit the js/varien/js.js file and find the following line

if (!("console" in window) || !("firebug" in console))

Replace the line with the following

if (!("console" in window) || typeof console !== 'object')

and you can start console logging in chrome


 

So there is often a requirement for sharing files but what happens if those files are files that absolutely must be secure, like private ssh keys?

Well Dropbox whilst a good product is third-party and not encrypted so if there’s an exploit, the contents of the files could well be exposed to people you don’t want.

Enter Wuala, a service by Lacie. Similar to Dropbox in many ways, but differing in that the files are encrypted locally, so if you loose your password, the files will be inaccessible, permanently. Believe it or not, that’s a really good thing!

Oh, and there’s a client for Linux, Mac, Windows and Mobile (Android and iPhone).


 

Answer to this quite clear and simple question is:

unetbootin

Not the easiest to find but definitely one of the easiest solutions.

If you search for USB bootable drive generators mostly you will find windows apps.

Not too useful if you are already on Linux and simply want to try the latest version or perhaps an alternative distro on something that is going to give more useful performance than the traditional live CD.

uNetbootin is a nice solid cross platform USB bootable Linux generator that will even handle the download of ISOs for you if required.


 

So, you’ve just moved a magento setup from one host to another, and you want to check if the email setup is correct, how do you do it?

The simple easy way to do this is to have a test front-end user (which you probably already have) and send a password change email to the user.

A simple trick but a good timesaver.


 

The php simpleXML object is my preferred way of working with XML, but it has some unusual quirks that can drive you up the wall. One of these is that, by default, it will not read CDATA within an XML file, and will just leave the node blank.

If you need to access this data then create your xml object like this


$xmlFile = "/path/to/xml/file.xml";
if (file_exists($xmlFile)) {
$xml = simplexml_load_file($xmlFile,'SimpleXMLElement', LIBXML_NOCDATA);
echo $xml-cDataNode;
}


 

Line-us and Lin-us are both valid pronunciations of Linus, but there is only one way to pronounce Linux (Lin-ux not Line-ux).


 

We told you about HipHop a while back and we were pretty excited about it.

Now Facebook have decided to develop a virtual machine to allow dynamic translation and faster results than their previous interpreter based approach. This is paving the way for further performance improvements and ease of development.

You can read the full story here.

We suspect it is still some way before this kind of thing will be more widely adopted but its certainly a good thing for PHP.


 

If you need to track down exactly how and when a particular change happened and you are not even sure exactly where it is (perhaps because its no longer present but you are not totally sure where it was supposed to be) then this little trick can be a life saver.

You can search git log for a specific string with the -S flag

eg, searching for a constant definition

git -log -SCONSTANT_NAME

very handy indeed :)


 
rss icon