EvoNews: The Genetic News Aggregate

Posted by: William at April 19, 2011 1:59am  

What is EvoNews?

EvoNews is a genetic news aggregate.

I created EvoNews as a final project for my Evolutionary Computation and Artificial Life course at Carleton. It uses a genetic algorithm to determine the ultimate news homepage based on what you like and dislike.

Check it out at http://evonews.williamlang.net



Comments: (0) Post A Comment

Choosing Random MySQL Records

Posted by: William at April 12, 2011 9:00pm  

I recently came accross a need to choose a random record from a table in my database. I wasn't completely sure how I would do this in CakePHP as I was just getting started with the MVC framework.

CakePHP makes it easier to do this by turning a step into one line.

What you need to do:

  1. Determine how many records there are in the table
  2. Choose one of those records

So, how do we do it?

First off, a simple COUNT(*) on the table will return how many records there are. In CakePHP its as simple as calling find('count') on the model with no conditions. Choosing one of the records can be tricky and can be easy to overthink.

With the MySQL LIMIT clause we can specify an offset and a set size. (LIMIT [offset, ] set size)

The offset is our random number we will generate using PHP's rand() function. Remember, records are returned with a 0 based array so our maximum offset is the number of records minus 1.

Once you have your randum number offset its simply a matter of creating a SQL query with your offset and set size.

$count = $this->Model->find('count');

$offset = rand(0, $count - 1);

$record = $this->Model->find('all', array('offset' => $offset, 'limit' => 1));

All done!



Comments: (1) Post A Comment

Unveil Updates

Posted by: William at October 06, 2010 4:16pm  

I'd like to let everyone know Unveil now supports Unveiling and Veiling of pages. In the coming weeks Unveil will also Unveil and Veil articles as well.

Covet, the wishlist application is also nearing completion so look for that in the coming days!



Comments: (0) Post A Comment

Shop2Shop Shopify Application

Posted by: William at October 05, 2010 2:46pm  

Ryan Langlois (fellow Shopify coworker) and I have developed an application called Shop2Shop.

What is Shop2Shop?

Shop2Shop helps Shopify store owners or theme developers migrate data from one store to another.

How does it work?

Shop2Shop works by creating background jobs that will move data from one store to another. Every ten minutes all jobs that Shop2Shop can handle are executed. If Shop2Shop can't complete a migration it will simply save it for next time, ensuring everything you want done, gets done.


How much does Shop2Shop cost?

Currently? Not a dime.



Comments: (1) Post A Comment

Canada Post and ActiveShipping

Posted by: William at September 22, 2010 4:56pm  

I have been working on adding Canada Post as an available carrier to Active Shipping and the new version of the gem is finally available. You can download the new version of the gem or view the GitHub repo.



Comments: (2) Post A Comment

William Lang

LinkedIn Twitter Digg iScheduleTV Delicious RSS Feed PHPClasses Last.fm

Blogroll

Dean Pearce
Andrew Wylie

Twitter

Markup

Valid XHTML 1.0 Transitional Valid CSS! [Valid RSS] Nibbler report for www.williamlang.net