Friday, February 25, 2005

WONTFIX woes

WONTFIX this, biatch!

It's kind of a major annoyance for developing XUL based data entry applications when you can't control what a user can edit :(

PHPretty Images



function tn($url) {
$step = 2;
list($width, $height, $type, $attr) = getimagesize($url);

if ($width <= $height) { $ratio["width"] = $height/$width; $ratio["height"] = 1; } else { $ratio["width"] = 1; $ratio["height"] = $width/$height; } while ($height > 90) {
$height = $height - $step * $ratio["width"];
$width = $width - $step * $ratio["height"];

}

return array("width" => $width, "height" => $height);
}



That's it. Badly remembered primary school math and PHP. Result? Reasonably sized thumbnails. I thought it would have been harder.

Refactoring & Optimisation Thoughts



  • $step is derived from the current height of the image vs. the intended size, thus really big images are quickly reduced initially. The closer you get to ideal, the smaller the step. Probably a good idea to set a bottom for the step, unless you want to waste a lot of cycles.

  • More generalisation during refactoring. $step, ideal $height & ideal $width should all be parameters.

  • Is there a way to ditch the iterations? That would improve performance a gadzillion-fold.



This code is part of GetFridged.com - see, I'm not being that lazy!

Wednesday, February 23, 2005

XUL & Images

XUL isn't friendly for images, as I discovered when prototyping up a quick and dirty product viewer. An image is worth a thousand words, so I hate it when they manage to skew what I'm trying to say.

XUL seems to suffer from stretchy image syndrome. I can put in a CSS max-width and max-height, but the image won't scale nicely - it will just bloat out until it reaches these values. I don't know if its a bug or a feature.

Suffice to say, I'm in a bind. It's either find a way to make it work as expected (like any image in a HTML document), or go with perfectly sized images for every single product in the point of sale system. The latter leaves a sour taste in my mouth, as I have every intention of making this an RDF-friendly application - Any URL for any image resource on any part of the net.

On the brighter side of things, after wallowing like a bloated otter (well, I imagine otters can bloat as well as wallow), I've finally cracked JPSpan. It's not as functional as I'd have wished, the documentation seems to have been set on fire then urinated upon from great height, but it's a better solution than any I could be bothered coming up with!
Also... it works!

I should do a tutorial post... JPSpan, PEAR::XML_XUL & 5 other reasons to nap before work in the near future.

Tuesday, February 22, 2005

One Small Step For CloCkWeRX...

...One Giant Leap Backwards for productivity.

After fooling about I've decided Ruby isn't for me. Yet. It's fine for rapid application development, but the documentation doesn't coddle me enough. Also, what am I thinking to pump out a web application in a language I don't grok!

I've also discovered a game. No, not a game, the game. Morrowind is the third in the Eldar Scrolls something or rather. I'm hooked. My roommate shifted the TV & XBox right next to where I usually code.
I'm stuck.
Quite literally.
I nearly lost my job because of the irregularities introduced into my sleeping patterns! :S

Of late, my coding efforts have been on

  • PointOfSale - XUL/JS/PHP 5/RDF

  • Fresh FM's new site - Customising Drupal

  • Fresh FM's intranet - Documentation galore

  • Refactorying Fresh Framework - migrating the code for the work website to new machines introduced a lot of bugs I ignored before.

  • Cursing Gallery 2 - Running direct from the CVS is no fun :(



Hopefully in the next few weeks I'll have more time to devote to PointOfSale, and indirectly PEAR::RDF as I track down bugs by the dozen. Stay tuned for some actual code related blogging!

Monday, February 14, 2005

Alphagrip

I certainly know what I want for my birthday. It's a game-controller keyboard. My wrists constantly hurt from RSI like symptoms (which is definately beginning to scare me), and being able to use a game-controller like keyboard... *whistles*. So, readers, feel free to start the buying.

Cool

Tuesday, February 08, 2005

What's in your fridge?


What's in your fridge?
Originally uploaded by CloCkWeRX.
Rubylicious. Sample interface... now to turn it into a working, clickable application with Rails.

I spent a while on this... I love the idea: it makes me hungry. Stay tuned, I've got to earn a bit more from the adwords before hosting costs can be covered :)

Rolling With Ruby On Rails

Rolling with Ruby On Rails was the first thing I ever did in Ruby.

Wow.

Wow.

Just... really, really... wow.

Ruby doesn't impress me too much. Rails... where I can tell what's not Ruby... is simply amazing. PHP has a lot to learn from this.

The gist of it? I was able to whip up something that made forms straight from the database. Hell, it made the entire application from the database. I define my fields in the database and it makes the forms.

ZOOSH! (Zoom, and Whoosh... but it's Ruby on Rails, so they only need to do it once).

Everything is facetted... it's PHP's Smarty built into the application framework. Database abstraction... built in. Forms manger... built in. Want a new facet? Override the old, and whammo!

I'm going to have a go at getfridged with Ruby.

Monday, February 07, 2005

Patently Insane, Continued

No less than 30 minutes after I had a bit of a go at patents, I found something that really annoys me.

The gist of it? Microsoft claims to have 'invented' a system of inserting imprecise numbers into URLs to represent longitude and latitude by concatinating them.

For the non geekish: Every point on the world has a longitude and latitude. These things are pretty precise... For instance, I live near longitude: 138.5831, latitude: -34.9502. Microsoft says that if I put those numbers in a URI in a certain way, and that URI is about whatever is there, they can sue me.

Summary of Patent: IfYouWriteLikeThisItsPatented... except with long/lat numbers. Joined together words are out of bounds.

To challenge them, it would cost me an arm and a leg. Not this very week was I renewing my interest in a geospatial annotation and mapping thing inspired by OpenGuides...

And now... NOTHING.

Wednesday, February 02, 2005

Robots, Robots, Robots

Ever wondered what it would be like to do that robot soccer thing? Get an AIBO and make it kick stuff?
I love this kind of nifty stuff, but I couldn't find a decent toolkit that was free enough for me to start developing in. Or it was written in something I didn't know.

Then, I found Robocode. It's aimed at people who don't know how to code, with the aim of teaching them the fundamentals of Java. You have tanks that basically have to destroy each other. It's fiendishly easy to get a start in, but not so easy to do well in. Right now, after having little success with individuals (weave, damn you, weave!) I'm having a crack at teams.
Though I'm making no progress, I'm thinking about the problems better.
I'm thinking about what was taught to me in the Army cadets, about flocking boids, about animal hunting patterns, about learning from your mistakes and about everything.
Stay tuned for some productive code!