Magudia.com Blog

Archive for the ‘web’ Category

Just another javascript flickr mashup…

Sunday, May 25th, 2008

Why? 

Over the last few weeks i’ve moved over all my pictures from my php gallery to flickr, so now I really need to replace my hosted gallery with something better than a link to my flickr account. My solution to this was to create (what I think is) a nice little mashup of flickr hosted based pictures and a javascript visulisation of them. Rather than use one of the many flickr mashup’s out there I decided it was more fun to wrote my own…Simply i’ve taken 36 square thumbnails arranged in a 9×4 grid from flickr and used a combination of prototype, cube (with some modifications), lightbox2 with some javascript glue of my own to bind them together.

What does it do…

Well it’s easier to see it, but every second or two a randomly selected thumbnail in the 9×4 grid will rotate to a new picture from flickr and then this repeats forever. You can also click on any of the thumbnails in the grid to hightlight a picture and eventually i’ll provide a link to where that photo is hosted on flickr, once a figure out a better way to do it than to put the link into the title.

How’s it work…

Well i’m using a php script on my server to get a selection of photo details using phpFlickr; I decided to get 72 photo objects ever time I accessed to script, but on the initial load I display the first 36 onto the page. I used prototype to handle the Ajax request and json parsing, I guess I could I done this without prototype, but I couldn’t be bothered and it would have taken longer and lightbox2 requires it anyway! Then using a javascript image cube animation library I found this will animate a image rotation to a new picture from the remaining 36 pictures. Although I did have to modify the cube library a bit to use absolute positioning and setting some divs to be inline apart from the first thumbnail of the row. Once the page has runout of pictures from the initial server script load a new call is made to that script for another page of 72 picture objects from flickr … and so on … and so on … I also used lightbox2 to load up a larger version of the square thumbnail when you click on the thumbnail.

You didn’t take those pictures…

At the moment I’m just using the interesting pictures from flickr (they look better than mine), but once I fix the odd bug or few I’ll replace my hosted gallery to a nicer version of this mashup using my own pictures. Phew! PS Thanks firebug!

What next?

Tuesday, April 15th, 2008

So I thinking of writing a new website project in Ruby (probably Rails), but I’m stuck on an actual idea. I know what I want to play with:

  • Languages: Ruby on Rails, JavaScript
  • DB: MySQL (as Dreamhost doesn’t have PostGres) 
  • Test frameworks: rSpec, Selenium
  • CI: CruiseControl.rb

At the moment I’m thinking of porting the lovely RoundCube mail project from PHP to Rails, it’s something that uses concepts that i’m fairly familiar with i.e. email protocols and I guess i’ve never been all that happy with any self-hosted web mail client, so I guess it’s time to put up or shut up and build my own. Obviously I want to refresh/update my Ruby and JavaScript skills and it’s associated agile components as well. Also as i’m using rSpec i’ll try and develop the project using BDD, but how i’m going to map business value priorities to a web email client could pose some interesting questions, although mapping behavior in tests might work better with the way I think … I think ;-) It’s not all that exciting, but if anyone has any other suggestions then just add a comment and i’ll consider it?

Simple Storage Service (You’ve Come a Long Way, Baby)

Wednesday, March 26th, 2008

It’s taking a few weeks of cooking, but my Simple Storage Service is ready to come out of the oven to be eaten (and possibly spat out) by the world at large. Now there are still a couple of things on my TODO list, but nothing massive. Basically URL authentication of requests (needs some thought), postObject (I need to read the docs), virtual hosting of buckets (a lot of thought) and some tiny changes and bugs that i’ll fix over the next few days. So what has changed since my last post:

  • Anonymous requests can now be made where permission to do so has been set.
  • Authenticated/Alluser groups and ACL get and sets have been implemented.
  • All REST calls have been implemented (except postObject)*
  • Exception handling matches the S3 documentation (with some guess work)
  • The REST layer was completely rewritten using test driven development
  • phpDocumentator comments are being added to the code, so docs can be generated
  • I’ve created a web form to help you create new users to the service

So what’s next …. ? I guess I’ll polish what’s been completed so far and add some documentation to make it simpler to deploy. And as i’m off Snow boarding from Saturday i’ll wait to see what sort of feedback I get before getting started on the SOAP section which should be easier now that I’ve got a good testing setup + looking for a new job as i’ll be leaving mine soon! I’ve also found that the most popular php client for S3 (from a google search) is missing some useful functionality, so i’m pondering re-writing it and making several optimizations so it can stream downloads from S3 etc etc…

The best use for this software, apart from academic curiosity and mocking is probably a failover/backup service incase S3 goes down (which it has done). This would work best if you are CNAME record to map to s3.amazonaws.com as I believe that as this is under your DNS control it is fairly trivial to map it to another host.

Other than that I’ll write a blog on how to set it up using xampp on windows and macports on a mac (when I MacBook Pro arrives)…

You can checkout the latest code from here: http://svn.magudia.com/s3server

* As this service hasn’t been developed to work to meet Amazon’s data consistency model I implemented getBucketLocation, but essentially it does nothing. Although in theory I could use MySQL clustering to implement this I’m not going to unless someone wants to pay me and I also don’t have a global server network to play with ;-)

One reason not to use a email address as an username

Thursday, February 21st, 2008

I’m helping out a friend at the moment to include a forum into a charity site. The site is used by teachers and students as a educational resource and some of the resources are protected by your typical authentication system which uses the users email address as a username and a password of their choosing. Now none of this would normally set of any alarm bells, but adding a forum to this site brought a question.

 A typical forum uses a unique friendly name to identify users without exposing any contact information. If the only unique user identifier you have is a email address and you for very obvious reasons you don’t want teacher and students email addresses exposed then how do you resolve this?

In this case a solution was achievable although with caveats which I’m not going to go into right now, but in future when I (or you) design an authentication system it might do you good to at least consider how your user identifier is going to be used.

Before anyone says use OpenID I just don’t think it really would work in forums (yet); Although I know that you can have a nickname in OpenID it’s just too clunky a system at the moment to create a new persona for a new site for the average user (if your default nickname is already in use) i.e. it doesn’t pass my ‘Can my mum understand this?’ test!

Do I have a better solution - hell no, but i’m sure smarty people than me are thinking about it!

UPDATE: I found a excellent blog which articulates some of my concerns about OpenID

Simple Storage Service - Very Alpha Release

Monday, February 18th, 2008

So after reading about the unscheduled downtime of Amazon S3 yesterday I thought that I should probably release what I’ve done so far. Although most of the work I’ve done has been focused on the storage layer and writing many many tests for it. So last night I spent a few hours hacking in functionality into what will be the REST layer of the service mostly from a PHP S3 Client to provide a very basic service to show what I’ve been doing - mostly handcrafted responses; although I’m probably going to the the pecl http extension to handle most of this in the future

This isn’t really up-to what I’d call alpha ‘quality’ in any respect, but it’s just a sneak peak with many many cavets i.e.

Anonymous authentication doesn’t work at all (you need an authenticated user for all method calls)

Only putBucket, deleteBucket, putObject, getObject, deleteObject have been partially implemented, although most methods are implemented at the storage layer.

Many many things need to be re-factored

Exception handling isn’t fully implemented yet

The REST layer has no tests and the SOAP layer hasn’t been started yet

You need the (PECL) PDO MySQL extension added to PHP (and probably some other PEAR libraries like Crypt/HMAC)

No documentation yet, but I’m willing to help with any questions

You need to be able to edit the httpd.conf for apache to enable PUT and DELETE http verbs*

If your running PHP as CGI then you may need to modify my .htaccess (well maybe?)

You need to create your own user using createUser in the storage class (but I’ll add a script into the subversion to help with this)

Security hasn’t been tested and the code is not optimized in any way

Plus some other stuff that I may have forgotten because I’m tired

You may have got the impression that I’m not entirely satisfied with this code yet and you’d be right. I’m only releasing this as *some* people *may* find it interesting. And one final thing, I don’t have a Amazon S3 account, I’ve basically cobbled this together from the documentation (which can be inconsistent), because I read the T&C’s and I wasn’t sure if Amazon would sue me if I agreed to them, so I didn’t!

Also you’ll need to create a mysql database, but the database details are hardcoded into the src/s3/lib/storage.php file and test/AbstractTest.php for unit tests.

So … blah, blah … it might not work … blah, blah … give me a break and i’ll help you ….. blah, blah …. I won’t be able to do any more work on this for one week before I start again … so here is the SVN URL ….

http://svn.magudia.com/s3server/

On the positive side of things, when I do get time next week to continue working on this project the hardest parts of the project have been thought about or have already completed, so implemented the REST and SOAP layers shouldn’t take along as I did implementing the storage layer.

* You need to modify your httpd.conf to allow PUT and DELETE http verbs by including these commands in your htdocs <DIRECTORY> tag (Apache doesn’t allow PUT or DELETE http verbs by default for sensible security reasons)

Script PUT /workspace/s3server/src/index.php

Script DELETE /workspace/s3server/src/index.php

Where the index.php matches where you (relative to your htdocs path) checked out the code.

I joined Facebook

Saturday, May 26th, 2007

In my last post I asked what the point of Facebook was, so I decided to sign up and I found it surprising easy to use. Firstly it can connect to your Hotmail (or other) address books and check to see if any of your mates are already on, which I thought was pretty neat (although I did accidently invite one person that I shouldn’t of!).

Once you’ve done that I set up a simple profile, I quite like the design they’ve used, much better than some myspace pages i’ve seen as most people create some stunning ugly profiles (i’m never ever going to join myspace).

The whole thing is a bit like linkedin, bits of google calendar, yahoo groups, twitter (you can add your twitter noise to your profile page) and it has some flickr like aspects as well.

On the whole I like it, if you’re a social nutter like me then I reckon you might even find it useful, which is strange for the more recent buzz sites that have been popping up lately.

Facebook

Monday, May 14th, 2007

What’s so great about it?