Archive for the ‘Computers & Internet’ category

Copyright infringement and The Pirate Bay

April 17th, 2009

PiratesLet’s get a few things straight, downloading copyrighted music, software, games and music is NOT theft and it is not a criminal act.  It is a civil act of copyright infringement.  Now that’s out of the way I will also start by saying I do not agree or believe in piracy or copyright infringment in any way, shape or form.

Firstly, today the founders of The Pirate Bay (and I won’t link) have been found guilty of breaking copyright law and sentenced to jail. Now whilst there are lot of torrents on The Pirate Bay that contain copyrighted files that are being shared illegally, none of these files are actually stored by the pirate bay whatsoever.  They are effectually a search engine for .torrent files.

So what does the rulings in the Swedish courts today mean?  Does it mean the fact you can find illegally shared files by Google mean that Google should be shut down?  Of course it would be ludicrous to suggest such a thing, but actually is it?  Google can be used for exactly the same thing as The Pirate Bay can.  Just Google ‘casino royale avi filetype:torrent’ and I can guarantee you’ll be able to find a page with a link to a .torrent download for that movie.

Does this mean that copyright holders shouldn’t protect their property and their rights, no of course they should, I just feel they are going about it the wrong way.

DRM (Digital Rights Management)

I have no problem with DRM until it gets in my way of doing something I want to do with it.  Now this does not mean sharing the files amongst my friends.  It means if I buy something from iTunes (pre music going DRM-free) and I change from an iPod to a Zune then I shouldn’t have to re-buy all my music.  Secondly if I want to archive all my DVD’s for playback on Apple TV and then put my DVD’s in the loft I shouldn’t have to find ways around the insane corruption that Sony puts on it’s DVD’s courtesy of the Arccos software.

For the most part DRM only seeks to annoy legitimate customers, as anyone who truely wants to pirate something, will find a way to do so regardless of how ‘protected’ the studios believe DRM to be… just take a look at how quickly BD+ got cracked.

Pricing

If I want to legitimately purchase a movie from iTunes for example, and let’s take an example of  ‘Max Payne‘, this costs £10.99 from the store. I can buy that same movie from play.com for £12.99.  Heck, when Quantum of Solace came out you could buy it from Tesco for £7, yet it was still £10.99 on iTunes and they won’t even let you buy an HD version!

Can the studios please explain to me how a movie that only has to be digitised once, costs nothing in physical storage in a warehouse, has no manufacturing costs and no distribution/delivery costs can cost only slightly less or indeed even more than it does in a shop?

If they studios want to stop people downloading for free they need to radically reduce the price of legitimately buying a film online.

Software

I can also see the arguement from the angle of the copyright holder, I am a software developer.  I have written and sold software online, only a minority of which are GPL’d.

There is a small subset of people out there that think it is their god-given right to give my software away and use it without me even getting a small amount of money for my efforts in developing it (I’ve never charge mega-bucks for applications, unlike some companies out there).

I do believe that copyright holders have the right to protect their rights, and make a living from it.

If I GPL’d my code and even though I sold it, there is nothing preventing someone else taking my same code and competing with me.  I’m not a Red Hat or a Novell of this world, I can offer the value added benefits of support and protection that they offer.  I wouldn’t be able to make any money from this type of arrangement.

This is why I believe the shared source licenses.  Basically buy the software, get the source, change what you want to in the source, but have no rights to redistribute it without permission.

Some more iPhone SDK tips and tricks

April 8th, 2009

In working on an update to one of my applications on the Apple iPhone I thought I’d share another quick tip.

I found on a blog and it works brilliantly,  to make rounded corners on any UIImage.

ImageManipulator.h

@interface ImageManipulator : NSObject {
}
+(UIImage *)makeRoundCornerImage:(UIImage*)img :( int) cornerWidth :( int) cornerHeight;
@end

ImageManipulator.m

#import "ImageManipulator.h"

@implementation ImageManipulator

static void addRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWidth, float ovalHeight)
{
    float fw, fh;
    if (ovalWidth == 0 || ovalHeight == 0) {
        CGContextAddRect(context, rect);
        return;
    }
    CGContextSaveGState(context);
    CGContextTranslateCTM (context, CGRectGetMinX(rect), CGRectGetMinY(rect));
    CGContextScaleCTM (context, ovalWidth, ovalHeight);
    fw = CGRectGetWidth (rect) / ovalWidth;
    fh = CGRectGetHeight (rect) / ovalHeight;
    CGContextMoveToPoint(context, fw, fh/2);
    CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1);
    CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1);
    CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1);
    CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1);
    CGContextClosePath(context);
    CGContextRestoreGState(context);
}

+(UIImage *)makeRoundCornerImage : (UIImage*) img : (int) cornerWidth : (int) cornerHeight
{
	UIImage * newImage = nil;

	if( nil != img)
	{
		NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
		int w = img.size.width;
		int h = img.size.height;

		CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
		CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst);

		CGContextBeginPath(context);
		CGRect rect = CGRectMake(0, 0, img.size.width, img.size.height);
		addRoundedRectToPath(context, rect, cornerWidth, cornerHeight);
		CGContextClosePath(context);
		CGContextClip(context);

		CGContextDrawImage(context, CGRectMake(0, 0, w, h), img.CGImage);

		CGImageRef imageMasked = CGBitmapContextCreateImage(context);
		CGContextRelease(context);
		CGColorSpaceRelease(colorSpace);
		[img release];

		newImage = [[UIImage imageWithCGImage:imageMasked] retain];
		CGImageRelease(imageMasked);

		[pool release];
	}

    return newImage;
}

@end

Just call the static method makeRoundCornerImage and pass your image to have the image rounded off the way you want.

For example

UIImage *imageFromFile = [UIImage imageNamed:@"myimage.png"];
imageFromFile = [ImageManipulator makeRoundCornerImage:imageFromFile : 20 : 20];

Note that you do need the CoreGraphics framework for this to compile.

More information can be found at the blog post link above.

The second tip is to load a remote image over the web and display it in a UIImageView object.

Create the following method in your interface

-(UIImage*) newUIImageWithURLString:(NSString*)urlString
{
	return [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]]];
}

Then call the following

UIImage *myImage = [self newUIImageWithURLString:@"http://url.to/image.jpg"];

.tel goes live

March 25th, 2009

media_right_3Well I’ve just got my .tel domain http://richardhyland.tel

Time will tell if it’s any good or going to work, however I’ve actually got a .tel iPhone management tool awaiting approval from Apple.

Changing browser loyalties

March 11th, 2009

internet_explorer_7_logoI’m a web developer and unlike a lot of developers I have been a big fan and user of Internet Explorer 7 and now version 8.

However the standards compliance of Internet Explorer has always left something to be desired.  With the introduction of 7 a few years back the job of making sites work in Internet Explorer became a whole lot easier, but there is still a lot missing that really ought to be included, and thank goodness transparent PNG support was added.

Recently I switched to using Internet Explorer 8 RC as my main browser and whilst I like it there were a number of failings I found.  The first is the so-called standards compliance.  Well seeing as it doesn’t support lots of CSS 3 properties doesn’t really make it standards compliant, but I digress. Mainly my issues were with it’s rendering of pages that looked great in Firefox, Chrome, Opera and Safari but just didn’t work properly in Internet Explorer 8.  The sites weren’t even using browser sniffing to load different stylesheets.  Quite simply IE’s implementation of the standards was different to all the other major browsers.  Sorry Microsoft, must try harder!

Over the past month or so I’ve suddenly discovered that I now use Firefox 3 as my primary browser at work (I still use Safari 4 at home as I’m a mac person) and combine it with Firebug and it’s simply stunning.

Spreadfirefox Affiliate Button

What actually prompted me to write about this was a story I picked up upon this morning entitled ‘IE8 May Be End of the Line For Internet Explorer‘.  It discusses the fact that Microsoft might be considering using Webkit (the engine behind Chrome and Safari) for Internet Explorer. In an article on AppleInsider Steve Ballmer is quoted as saying

Addressing a developer conference in Sydney Australia, Microsoft CEO Steve Ballmer said the idea of using WebKit as the rendering engine within its web browser was “interesting” and added “we may look at that.”

The fact that Ballmer would even mention using WebKit is very interesting indeed as you’d expect such a thing to be dismissed out of hand.  WebKit quite simply has the fastest and best rendering engine of any modern browser.  Just try Safari 4 on Windows or a Mac to try it out for yourself

Living without Windows

March 10th, 2009

Quite possibly the best article I’ve read about living without Windows and using Linux instead, and just why Linux still has a long way to go when it comes to desktop usage for non-techies.

http://www.computerworld.com/action/article.do?command=viewArticleBasic&taxonomyName=Operating+Systems&articleId=9126042&taxonomyId=89&pageNumber=1

Fixing other people’s code

March 10th, 2009

Well I’ve spent a very productive afternoon fixing CSS bugs in jQuery UI http://jqueryui.com, to make a very specific set of conditions work under Internet Explorer.

If you’re interested, basicaly putting an overflow inside the dialog overlow causes the first overflow to render incorrectly if the positions are relative.

The great thing, though about the open source community is I can now help my fellow programmers by submitting my findings (and fixes) back to the UI dev team.

This is where I have mixed feelings about open source, as in GPL style open source. If I write software as a sole developer what can I realistically offer than a small amount of support in addition to effectively giving my code away for free to anyone who buys a licence. Then for them to be able to resell it and I don’t make money anymore.

The GPL is great for big projects or simply hobbies but it isn’t all that great for sole developers. I much prefercthr method of giving source with the application but don’t give distribution rights away.

Two days with PDO and my lack of faith in the PHP extension developers

February 25th, 2009

OK let me first start by saying, I absolutely love PHP, I tend to compile my PHP from source and for the most part have absolutely no issues with it whatsoever.

Now for work I needed to install PDO extensions to PHP with Microsoft SQL Server support (PDO_DBLIB). I shall also start off by saying that I currently use the standard sqlite extensions to PHP.

Now PDO is actually available on Linux as pdo.so in the modules directory usually by default so let’s actually just try to run

pecl install pdo_dblib

Can’t do that we get the error

“pear/PDO_DBLIB requires PHP extension “pdo” (version >= 1.0)”

OK well we had PDO installed but clearly the wrong version.  First up I recompiled PHP adding in the following configuration lines

–with-zlib –enable-pdo=shared –with-pdo-sqlite=shared –with-sqlite=shared

I actually already had zlib compiled, I just reference it here as it’s required. That all worked great, without errors.  So now let’s run

pecl install pdo

we should get the right version, correct?  No we still get the same error.  This led me to the following bug report.  Note that this bug was opened in May 2006 and is still unsolved at the time of writing.  What we have to do is manually download the package, edit package.xml and remove the PDO dependency line.  Install as usual and restart apache!

These are the steps that work

pecl download pdo_dblib

This will download a tar ball of the extension. Extract the tar ball.

tar -xzvf PDO_DBLIB-*.tgz

That will uncompress the package in to a standalone file, package.xml
and a folder containing the extension, in my case it was, PDO_DBLIB-X.X.
Where X was the version number. Open package.xml using your favourite
command line editor. Find and remove the line,

<dep type=”ext” rel=”ge” version=”1.0″>pdo</dep>

Save the package.xml file, and move it in to the PDO_DBLIB directory.

mv package.xml ./PDO_DBLIB-X.X

Navigate to the PDO_DBLIB directory, then install the package from the
directory. You may need root access for this step.

cd ./PDO_DBLIB-XX

pecl install package.xml

After editing php.ini to load

extension=pdo.so
extension=pdo_dblib.so

phpinfo() reported that the DBLib driver was available as was PDO, all was great. Now I tried to run sqlite_open and it refused to work.

I thought maybe it was the pdo sqlite extension that was conflicting, as I don’t actually use the pdo version of sqlite, just the main function library I decided to reconfigure php without the sqlite options.

Then I get an error saying that I had configured PDO as a shared object but sqlite was static.  Hmm the PHP manual tells me something different though and I quote

In PHP 5, the SQLite extension and the engine itself are bundled and compiled by default. However, since PHP 5.1.0 you need to manually activate the extension in php.ini (because it is now bundled as shared). Moreover, since PHP 5.1.0 SQLite depends on PDO it must be enabled too, by adding the following lines to php.ini (in order):

So this is telling me that SQLite is enabled by default and is installed as shared.  Well the PHP installer just told me different, that it’s installed by default but as static!

OK so back to configure PHP again but this time with the sqlite shared options.  Then we’ll reference sqlite.so in the php.ini extensions and restart apache!

Oh no we can’t load apache because the version of sqlite.so is incompatible with the version we need for pdo_dblib.so.

Let us run

pecl install sqlite

Running that gives us the following error

tmp/tmp8laqB1/SQLite-1.0.3/sqlite.c:125: warning: initialization from
incompatible pointer type
/tmp/tmp8laqB1/SQLite-1.0.3/sqlite.c:126: warning: initialization from
incompatible pointer type
*** Error code 1
make: Fatal error: Command failed for target `sqlite.lo’
ERROR: `make’ failed

The PHP bug report at http://pecl.php.net/bugs/bug.php?id=8181 that was opened in July 2006 tells us this has all been fixed, but with numerous responses telling the developers that it’s still broken.  At the time of writing, this is still broken!

This then leads me to the following fix

$ pear download sqlite
then unpacked and began to compile it
$ tar zxvf SQLite-1.0.3.tgz
$ cd SQLite-1.0.3
$ phpize
$ ./configure
$ make

edit sqlite.c, comment out the following line:
/* static unsigned char arg3_force_ref[] = {3, BYREF_NONE, BYREF_NONE, BYREF_FORCE }; */

And then change these lines
function_entry sqlite_functions[] = {
PHP_FE(sqlite_open, arg3_force_ref)
PHP_FE(sqlite_popen, arg3_force_ref)
to:
function_entry sqlite_functions[] = {
PHP_FE(sqlite_open, third_arg_force_ref)
PHP_FE(sqlite_popen, third_arg_force_ref)

$ make
$ make install
$ cp modules/sqlite.so /usr/lib/php/modules
$ /sbin/service/httpd restart

Why oh why do I have to edit the c source code to get this working?   Which by the way DOES actually fix the problem and now I have PDO, SQLite and PDO_DBLIB working on the same system.

This is why I’m starting to loose faith in the open source PHP community, not because they do a great job in the first place, but because bugs like this exist for well over 2 years!

The response from the Open Source community will be, fix it yourself.  That simply isn’t the point, I’m not a C developer, nor do I have the inclination to be.  I also do not know the inner C workings of PHP to easily fix these issues.

I’ve just wasted two days of my life researching, testing, debugging PHP extensions, I hope it helps anyone else with these issues!

Choosing a hosting provider

January 30th, 2009

Always a bit daunting and a question I’m often asked. ‘I want a website but where do I host it’?

A quick Google search will reveal thousands of companies (and the 12 Google Adwords results) and 10’s of different options.

A web developer looking to publish a website will most likely be even more confused when doing a search, instead of finding a good web hosting provider highlighted by the search engine.

The reason is very simple many individuals and companies, small and big, have seen the opportunities in web hosting.  Indeed even I partnered with a friend a number of years back to sell space on one of my dedicated servers… it was space going to spare why not make some money from it?  Of course responsibility and support needs come with that and that is the reason I stopped offering it as I had too much real work to do!

The result of this saw new web hosting providers created overnight, to go with this there is now a plethora of forums, ‘reviews’ sites, publications and middle parties, mixed with an entire array of web hosting products, from free hosting to powerful dedicated or co-located servers.

Now I’m not going to recommend any specific providers, even the ones that currently host my site but to try to explain the options available.

Free Web Hosting

Unless you have a personal website, you should never look for free web hosting.  Sorry you just shouldn’t, unless that is your experimenting and testing code or are willing to be at the whim of a company that can delete, loose your website without any guarantees from the provider themselves.

Companies that offer free hosting tend to do it for the following reasons:

  • they will recoup their costs back by inserting ads on your website or
  • they are providing Internet for you, and offer you a ‘free web space’ and free email, as part of their Internet package, so it’s not truely free anyway

Putting ads outside your control on your own website can be irrelevant and obtrusive  and won’t make your website appear credible. Those webpages are as credible a myspace page, and are just useful to host a couple of images and html pages.

As for Internet Hosting Providers, their free web hosting service is often tied to your subscription. This means that as soon as you stop doing business with them, the free web space is most likely to be deleted or at the very least you will no longer have access to it for updating your site.

Shared Web Hosting or ‘Cheap’ Web Hosting

Cheap web hosting is almost always shared web hosting.  A shared web host is where you get a little bit of space on a larger powerful server.  Shared hosting is very common amongst websites online.  Pricing ranges from just over $1 to over $30 (it is common for many web hosts to change in US $ even if they aren’t based in the US!).

They offer a huge array of options from PHP to .NET to OSCommerce to PHPBB.

Here is what you should look for in shared hosting:

  • Web Technologies supported. If you are looking to open up a wordpress blog, you need obviously to make sure that the shared plan has PHP and MySQL. Same for Ruby On Rails applications, or .NET shared hosting. This criteria is probably the most important since there’s no use finding a cheap web hosting provider if it won’t run your website. Here’s a possible list of what to look for: programming languages, database, web server software installed, cron jobs, domain name tools, etc.
  • Number of users hosted on a single machine. The total number of users directly affects the speed of your website, and there are lots of providers who overload their servers. To gauge this number, ask for a list of active and fairly big websites under their shared web hosting plan, and see if the websites are running well.   They may not be able to divulge the exact domains running but they should be able to give you and idea of how many sites.
  • Price and possible discounts. Many companies offer deals and discounts at specific periods so shop around.
  • Support and Guarantees. Lastly, doing business with a web hosting company is mostly a long-term relationship, as it is a huge hassle moving hosting providers, especially when it comes to moving all your domains and IP addresses, etc. You might find a great deal, from a new unknown provider, but what you need to make sure is that this company is reliable, that they will still be there one year from now; and there will be someone listening to you if you are having a technical problem with your website.  Looking for well used support forums and live chat capabilities from your provider are good indicators.

Dedicated Servers or ‘Virtual Private Servers’

You can look for a VPS (virtual private server) or a dedicated server if you are a small or large company serious about your web presence, if you are a web developer who need performance and greater control of your web server, or if you plan to host an entire array of websites, either your own, or your clients’.

Here are the advantages for virtual private servers offerings:

  • it’s often cheaper (although not always) than dedicated servers
  • provisioning is usually automated, on-demand and quick, which is good for web developers looking for a hassle-free experience or quick deployment of their server infrastructure.  You can have your server ready for your to load your sites on in minutes.
  • billing can be done hourly, which can be a key business argument for startups and companies alike,
  • you get SSH access and a control panel (Plesk or cPanel), which is often enough for your needs.

Here are the advantages for dedicated servers offers:

  • you can get customized servers, fine-tuned to your needs, such as the exact quantity of RAM, the right CPU, network speed, required bandwidth etc. You can order a RAID hardware setup for instance, which is impossible for a VPS. Need more RAM than processing power? it’s possible. Do you prefer AMD chips instead of Intels? Just order it in the form.
  • you can setup advanced configurations for your technology infrastructure, by setting up firewalls, web clusters, load-balancers, anti-DDOS solutions, etc., which is again, impossible for a VPS
  • you don’t have to design advanced backup solutions, since your dedicated server is physical and your data won’t evaporate one day, which is the case for VPSs. Of course you still need to consider backups but it’s just the same as backing up your home computer, just make sure you do it!
  • a dedicated server can be cheaper than many purchased virtual servers, if you use virtualization software such as Virtuozzo or VMWare. For example, by virtualizing your dedicated server, you can have one instance as the web server, another instance as the database server, another instance for cache.
  • You have 100% control of your server. The web hosting provider cannot for instance offer CPU or RAM bursts to other users, so performance will be equal and guaranteed any time of the year.

In my opinion the biggest advanced of dedicated vs VPS is that there are known ways to secure your data, whereas data tampering is a real issue in cloud computing.

Here are the main points you should look for when choosing the best web hosting providers for your dedicated or virtual server:

  1. Assess if the company owns their data center, or if they are a reseller who are in fact hosting their server in another company. Look for a physical address, phone lines, network details. Of course, it’s better to do business with a company which runs its own data center. It’s not only about the price, but the guarantee that there will be personel who will physically fix servers when the need arises, know their own equipment and hardware inside out and have a quick turnaround
  2. Price of your desired configuration, and price of hardware parts and software, both the setup and monthly costs
  3. Path to scalability, such as availability of more powerful configurations
  4. Quality of network, which can be done with traceroutes, pings or by testing various websites hosted there
  5. Reliability and trustworthiness. See for instance how many years the company has been in business. For instance, a company which has been operating for more than 10 years means it is unlikely to disappear overnight. Also, a company which has a open blogs and forums is more trustworthy than another web hosting company which doesn’t offer a place for its users to collaborate and exchange.  A lack of a forum could also indicate the company doesn’t have many customers.
  6. Support. Assess if the company’s support is responsive, if there are customer complaints on the company’s forum.

As stated in the shared hosting section, don’t forget that doing business with a web hosting company is above all a long-term relationship. Please don’t judge purely on the price, choose most of all a company you can trust.

If anyone is interested my site is hosted on a dedicated server by iWeb in Canada after a disasterous experience with The Planet when their datacentre had their power transformer explode!  It’s running CentOS and sitting on a 100Mb/s port so network speed won’t be an issue.

A weekend of XBox 360

January 18th, 2009

XBox 360You can’t argue with spending a day of playing on the XBox 360, well you can but I enjoyed it!

So I’ve been playing with a few new games recently.  Now I often find it very hard to get into a game longer than a few plays, and indeed in the past the only two that have really gripped me are Call of Duty 4: Modern Warfare and Tom Clancy’s Rainbow Six Vegas.

So I’ve been playing recently Tom Clancy’s Rainbow Six Vegas 2, 007 Quantum of Solace, WWE Smackdown vs Raw 2009, Call of Duty: World at War and Need for Speed Pro-Street.

So I’ve already got bored with Need for Speed and Rainbow Six Vegas 2.  Call of Duty: WaW had me gripped for a few weeks, especially as I leveled up to the max during the beta, but now that’s bored me.

007 and WWE I’m enjoying in single player mode very much at the moment, but for XBox Live, I keep being drawn back to CoD4 for some reason.  Bring on Call of Duty: Modern Warefare 2 in the autumn (fall for any US readers).

So this weekend I’ve managed to up my gamer score by about 500 and up my CoD4 level to 49 Prestige 2, that was until either BT or XBox Live decided that the Internet was something that should run at 28.8kbs again.