Skip to content

Archive

Category: Technical Musings

I was recently looking at different opportunities and saw a quite a few great companies doing wonderful things. Among them is Cooliris, previously known as PicLens. Their flagship product is a browser plugin which allows a very enticing scrolling view of media files. Images, videos, and music scroll by on the screen in an endless wall. Clicking on an image will zoom in to a higher resolution photo and a video file will zoom in and start playing. Needless to say this is a pretty cool little tool, but it’s a plugin which means the download stops a lot of potential users. But wait, they have a flash embed file which allows any website to embed the same experience on any web page! Let’s see how we can use this to show off our photos. continue reading…

I’m not sure how everyone else is using Zend_Layout, but I’m doing the following to render my navigation and footer links. It’s not the most DRY code, but works until I learn more about the framework.

In my Action file, I add actions to the stack for nav, footer, continue reading…

Someone asked how I get a db connection in my models using ZF1.5.1

Basically I have a ConfigDB singleton pattern that gets one db connection, then sets the default adapter so when I extend the Zend_DB_Table_Abstract class, the default connection gets carried around.

class ConfigDB {
static private $instance;
private function __construct() {
}
public static function getInstance() {
if (!ConfigDB::$instance) {
$params = array(
/* redacted */
);
ConfigDB::$instance = Zend_Db::factory('Mysqli', $params);
Zend_Db_Table_Abstract::setDefaultAdapter(ConfigDB::$instance);
}
return ConfigDB::$instance;
}
public static function selectDb($db) {
return ConfigDB::$instance->getConnection()->select_db($db);
}
}
ConfigDB::getInstance();

That grabs the connection and sets the default adapter. So in my model class I can do:
class Country extends Zend_Db_Table_Abstract {
protected $_name = 'countries';
protected $_primary = 'country_id';
function __construct($country = 1, $abbr = '')
{
parent::__construct();
}
}

That’s it

Monkey See. I was poking around Flickr recently and was amazed at the amount of ‘Interesting Photos’ that users have tagged. Some of the sunsets and scenery photos are absolutely stunning. Naturally, I wanted to fetch and use it as my desktop background. However, (understandably) Flickr doesn’t like people downloading (or referring directly to the images) so they have gone to some lengths to obfuscate and hide the actual image url. If you try to right-click and copy image source, you get an annoying little image called spaceball.gif. How does Monkey get around this?

Monkey Do. Having recently downloaded and installed the GreaseMonkey plugin for FireFox, I searched and couldn’t find a suitable userscript to handle the situation. Being the obsessive type, I went ahead and wrote two quick scripts to help me get at the actual image urls. One, ‘Flickr Img Src Exposer‘, exposes the image url on an individual photo. It adds a link ‘IMG LINK’ underneath the image allowing for easy copying. The second script, ‘Flickr Download Links‘, works when you are exploring the last 7 days’ interesting photos. I got tired of clicking on each photo and then saving the image, so I put a ‘LINK’ under each photo in the page. Clicking on the link takes you to a gallery of all the available image sizes. You can click on the download link to get the image downloaded or copy the images source from the image displayed. The largest size may not be available and you’ll find out if so after clicking on it. I chose not to display the largest image size to save Flickr some bandwidth.

Monkey no get spaceball.gif. This has proved somewhat useful for me and I thought I’d share it with others. You can find the scripts on ‘http://userscripts.org‘.

A preliminary demo for my hack is already installed on this site. My hack was to take any text selections a user makes and allow them to search Y! Shopping for related products. You can see it at work by selecting any word or words on this page and then by clicking the little blue box that comes up next to it. Although you might find an obvious shopping term such as nikon digital cameras much more relavant.

This can be improved very easily. For example, instead of only searching Y! Shopping, the initial box can be a drop down menu populated with results from a text analysis tool. Then the user can perform a web/news/product search by following the corresponding links.

A key benefit to this implementation, any web publisher only needs to include a single (two at the moment) javascript reference in their header to receive this functionality. They don’t have to link terms by hand, or do any backend work to support this. They get better user experience and a richer webpage essentially for free.

Here’s a plugin for people wishing to link to products within their blog. It’s simple to install and use and will allow you to add product titles and more by simply including <asin>1580420818</asin> in your posts or pages. I had written an earlier post but it was deleted accidentally. Here’s the shortened version.
continue reading…

Okay, so it doesn’t completely solve the puzzle yet. Using javascript to remove possible values from each block, the user can plug in hard values from the puzzle they are working on. The solver will try and arrive at a solution but you will be require to guess at some points. Improvements like a save point creation will be very helpful. Another improvement is to have the solver auto create a save point and branch until it gets to the final answer(s).

If you don’t know what sudoku puzzles are, check out sudoku

Here is my javascript solution to sudoku puzzles

Update: I’ve modified my sudoku solver to be a generic sudoku puzzle. You can play it for free at www.numbercrazy.com.