A Rough Path Finder in CoffeeScript

I’ve recently been playing with CoffeeScript, a neat little language that compiles to JavaScript. It’s a lot more concise than plain old javascript and can be organised much more tightly, so I’m really having a blast with it. That said, its conventions are a bit different to what I’m used to working with, so more bit of practice is in order.

One of the practice scripts I wrote is a very basic 2d pathfinder, hooked up to an html5 canvas element. The original idea was to get a good feel for the CoffeeScript syntax and then write a bit about it, but a screenshot of the finder on Facebook generated a bit of curiosity among some friends, so this post will be about the pathfinding algorithm instead; the CoffeeScript post will just have to wait a bit longer.

finder

Continue reading

Easy CSS Management and Spriting With Sass and Compass

Every so often I like to revisit old projects of mine and refactor them a little, either using some new ideas I learnt in the meantime, or trying out some new technique or framework on familiar ground. This time, I’m going over a wordpress theme I made a couple of years ago and using Compass to organize the style sheets. Converting the existing style sheet (circa 8k uncompressed) to SCSS didn’t take long – only a few minutes by hand – and there are tools which you can use to automate the conversion, so it left me plenty of time to explore more Sass features which make style sheet management much easier. Today we’re going to look at command directives and a few basic spriting helpers. Continue reading

Magento Search: Getting Better Results In Product Searches

Magento is a whopping big platform – even the community edition is something of a beast. That gives it a nasty learning curve, and while, in most cases, it simply works, there are some places where it tries to be clever, with mixed results.

The product search is a case in point. A friend was recently trying to get it to cooperate, but the way the results were being returned made it quite unusable. By default, the search uses an OR comparison to find what you’re after, so if you look for “web development books”, it will give you any product whose description contains “web”, “development”, or “books”. Since the order or relation of the words is not considered, you might end up with Twilight as a top result, which I’m sure you’ll agree, is not conductive to your users not gutting you with a rusty fork.

The easiest way I found to fix this, is to change the search query, defined by the fulltext.php file (/app/code/core/Mage/CatalogSearch/Model/Mysql4/fulltext.php). Continue reading