Archive for June, 2010

Couple of interesting news items today

Couple of bits I spotted in the news today that I though warranted posting;

I’m particularly interested in the IE9 release 3 to test it out with the html5/ javascript game I’m building for the 8 week game competition

No Comments

FileUpload.PostedFile.Filename includes all the client Path info, but only in IE

This is a known problem documented on the MSDN – I’m sure I’ve been caught by this before so thought i would blog it!

Firefox and IE7.05XX treat the PostedFile.Filename property differently.

In Firefox, calling FileUpload.PostedFile.Filename will return the name of the file, with no path information.

In IE7, calling FileUpload.PostedFile.Filename will return the full path of the file + the filename.

e.g. if the client file is located at c:\My Documents\Test.xls, Firefox will return ‘Test.xls’, and IE7 will return ‘c:\My Documents\Test.xls’


Google Font API

Just stumbled across the Google Font API- it’s a (at the moment) small directory of open source fonts hosted by google which can be used on your website via their font API. Looking at the quick start it just seems to be a matter of adding an include to your page, then referencing the fonts in your css, like you would any other font. Clever stuff!

No Comments

Example update with left outer join in SQL Server

I always seem to remember the access syntax for this rather than the sql server version–

    harrietId = u.Id
    hachette_digitalideas_import h
    left outer join user_group u
        ON ( = or h.[full name] = AND u.btype = 'u'

As opposed to the following in access;

    left outer join user_group u
        ON ( = or h.[full name] = AND u.btype = 'u'
    harrietId = u.Id

1 Comment

Mac Safari Web Developer Tools (inc javascript debugging!)

make sure you don’t have safari running, then go to the terminal window and type;

defaults write IncludeDebugMenu 1

You will have a new menu when you launch safari entitled “develop” in safari 5, and “debug” i believe in earlier versions.

No Comments

HTML5 Audio and Video (Media) Tags – How do you know when the data’s loaded? And how to play multiple instances of the same sample at the same time

Quick post with a snippet of code I’ve used for the 8 week game competition I’m in- I’m going to be using html5 audio element for all my game’s sounds and needed a way to make sure the samples were totally loaded so the resource manager knows when to hand control to the game- So after flicking through the html5 spec came up with this code (utilising jQuery to bind my event handler)

Note- This applies to any media object- so the video tag as well, but I’ve only tried this with audio.

var ao = new Audio();
$(ao).bind('canplaythrough', function() { // totally loaded
alert('ready to play');
ao.src = 'sounds/my_sound.wav';

The above example will wait until the media element has enough data to comfortably play through without stopping to buffer. if you wanted you could also bind to a whole host of other events in exactly the same way, which you can read about here. You can check the status at any time to see how loaded the audio/video file is like this;


This will return you back a number between 0 (HAVE_NOTHING) to 4 (HAVE_ENOUGH_DATA) – full info can be found here.

Because I’m building a game I have slightly different requirements to the average web project- The way I use this is have a central “ResourceLoader” which I load up with all the url’s to the asset’s I’ll be using, this then reports when all the assets are totally loaded and hands control to the game. So there is a single instance of every image and audio element I’m using- I then hand each loaded sound to the sound manager to play. This raises a problem when i want to play the same sample more than once, overlapping because you are essentially just passing around reference to the same audio object- so i execute the play method, then execute it again and nothing happens because it is already playing! The answer is to perform a deep copy of the audio element before playing- because this is a DOM object you can do this easily like so;

var instance1 = ao.cloneNode(true);
var instance2 = ao.cloneNode(true);;;

This way you can hit the play() method of instance1, and the instance2 and they will both play at the same time, totally independant of each other, even though they both originate from the pre-loaded instance ao.

Anyway- you can see live demos of this here;

Notice the need for 2 demos because chrome cant read wav and mozilla wont do MP3! Ogg vorbis is a common format for the two, but i couldn’t quickly find any example files to use! Read here for browser file format support.

These demo’s were made for us in the 8weekgame site – bare in mind the sound manager class I literally started about an hour ago so it’s got hardly any functionality but it does play sounds so take a look at the source code and hopefully it will all make sense!

No Comments

WordPress 500 Error when submitting a blank comment form under IIS7 and PHP5

I recently noticed an issue on this very blog and a couple i have hosted on this server when people just hit submit on the comment form without entering anything into the comment field- i would get a 500 server error back.

error_pagesI spent ages googling figuring it was some kind of config error on the server as it happened across all of the wordpress blogs on this server- I eventually found it wasn’t an error at all- The skins used across these blogs didn’t seem to validate the forms so it was falling back to wordpress which was returning an error like “Error: please type a comment.”- however IIS seemed to be intercepting this as a full error and rendering a 500 error- the solution was simple!  Turn on detailed error’s.  Obviously this isn’t good on a production box running dot net, but for PHP you can control the error reporting from within the php.ini file anyway, so this just makes sure IIS doesn’t add an additional layer of error filtering confusing matters.

Update: Thanks to Kanwaljeet Singla on the comments for pointing out a better fix for this as detailed on Kern Handa’s blog here.  This can basically be fixed easily by setting a web config entry to tell IIS to let errors pass through, like so;

<?xml version="1.0" encoding="UTF-8"?>
        <httpErrors existingResponse="PassThrough" />


Cross Apply in SQL

In Summary: I basically wanted to take the data in a table, then linked data from another table concatenated into a comma separated string, and attached as a varchar column on the end of the first table!

I have the mis-fortune of working on a terrible intranet system based on technology built by a company I won’t actually name- so for the purpose of this post, lets say they are called Source. It’s basically a big buggy CMS powered by some aging and creaky classic asp files and lashing of very frail javascript (this isn’t a legacy system- it was installed in the company around a year ago!). It allows you to build forms and data grids, but is quite restrictive with how you attach these to the database- you cannot for example use a stored procedure as a data source- it has to be a table or a view.

We have an internal app to allow staff to order with a table structure like so;

OrderHeader -> OrderDetail -> Publisher -> Warehouse

On the order header view page we need to know which warehouses are involved, which means a query going right down the chain from product on the order line, to the publisher, down to which warehouse that publisher is based at- because we can only tie to a single table or view I had a problem unless i wanted loads of repeated rows- after some googling I found CROSS to be what I was after;

Based on the above post I was able to build SQL like so;

	WareHouses = LEFT(o.list, LEN(o.list)-1)
	OrderHeader INNER JOIN
	User ON OrderHeader.UserId = User.UserId LEFT OUTER JOIN
	SELECT distinct
		CONVERT(VARCHAR(50), WareHouse.Name) + ',' AS [text()]
		INNER JOIN Publishers ON = Publishers.WarehouseId
		INNER JOIN OrderDetailLine ON Publishers.PublisherID = OrderDetailLine.PublisherID 
		OrderDetailLine.OrderHeaderId = OrderHeader.OrderHeaderId
		CONVERT(VARCHAR(50), WareHouse.Name) + ','
) o (list)

This bought me back each row, with a comma separated list of the warehouse names in the end column which i could then filter on!

No Comments

8 Week Game Competition

I’m currently participating in the 8weekgame competition.  This 8 week sprint is dedicated to (by picking out of a hat) a clone of the retro classic, “Manic Miner“- I’ve chosen to build mine using javascript and the canvas element in html5 (and probably the audio elements also).  The other 2 guys are using Microsoft XNA framework; with Martin targetting windows, and Gareth targetting XBox live arcade.  You can follow our progress here ;

No Comments

I absolutely love these. They came at the lace wigs are good quality, and very soft. Absolutely love these extensions. I just love this hair. Hair came on time, I waited until after hair extensions uk very full, no shedding and it is been installed for 3 weeks now and yes I jus ordered 3 more bundles. Lol. I definitely recommend this company for your bundles ladies. They are soft, hair bundles on the head for human hair wigs and I would continue to recommend them. I have thinner hair so they cover and blend nicely.