Saturday, May 8, 2010

My thoughts on my Mac Mini and OSX

Despite the excellent releases in my previous post both working, there were a number of issues with the installations. Despite the community, there is a certain amount of luck when it comes to osx86 and it is down the architecture of how a PC is put together. There are numerous configs and countless peripherals - both the PC's biggest strength and weakness. The PC is slated by many a (mac) user because it crashes often, but compared to the Mac it is so much more versatile. Windows can run thousands of different components and in nearly every case it runs them well. There are some conflicts, but Windows 7 is so close to getting this right I have to say that the OS is almost perfect. The second part of this is that most Mac users make the incorrect assumption when they make their face of disgust when it talking about PCs that all PCs = Windows. I am also a very heavy Linux user. I have to be, I'm a PHP developer and the language runs best when it runs on a Linux Machine (but it can run on Windows ;-))

The reason I mention all this is because I tried everything that I could before purchasing my Mac-Mini. I also want to show that I have a reasonable background to give an honest and frank review of my new piece of equipment.

Anyway, down to my first thoughts of the Mac. Well it cost £592 for a machine with a Intel core 2 duo CPU, 320gb hard drive and 1gb of RAM. Quite expensive for that range of kit, but the little box that encompasses it is very, very well built and is very, very quiet. Not to mention that it uses very little power at all. Perfect for the greenies out there that want to save the planet and still be able to use a computer. My one [tiny] problem with the hardware is that Apple supplies a Mini DVI to DVI adapter but it is only DVI-D. Most adapters that PC monitor owners have are DVI-I and the two will not fit together, I had to buy one from Amazon. Other than that Iwas very happy with it.

Down to Mac OSX - it's a good system and owes much of its existence to Unix/BSD and this can be seen in many areas of the OS. If you are a seasoned Linux/Unix user then you should have no problem using Mac OSX and you can probably do more with the system than most Mac OSX users. I have to say it works pretty well and it does everything it should do, you can customise most of the OS and you can do it with very little fuss. The one major advantage that MAC OS has over Windows is when it comes to system settings. Apple pretty much knows what components are going to be found in the box and therefore its drivers should be perfect, this shows. I think this is where most Mac users get the notion 'my Mac just works'. Can you imagine buying a PC, unpacking it and it 'not working', no me neither. I like the OS, the dock and a number of other things, but it is no better than Windows. It does 'work', but so do my Windows and Linux Machines, funny that!

Whenever you talk to any Mac owner they say they would never go to back to using Windows. When it comes to the Apple brand it has some of the most loyal customers of any company I know of and I think I have found out why this is so. Apple spoil their customers. They make them feel special, they make them feel like they are a cut above the rest and that paying a premium for a service is perfectly fine. I have to admit that when I first opened the system I felt that little bit of Apple magic, the box and packaging was flawless, you even get a little message saying telling you that you and your product are one. The way they spoil the customer doesn't just stop with the packaging, it runs through the system, brushed aluminium is everywhere from the keyboard to the way that it is part of your desktop programs.

This is not a rant against Apple, they make some great products and they are perfect for certain functions, but it is more a discussions urging users to remain pragmatic and to use the right tool for the job and that there are (nearly always) alternatives.

Building iphone Apps Cheaply - my initial thoughts on my Mac Mini purchase

Hell must have frozen over. I'm also pretty sure that someone out there is going to make me eat my hat as It is probably something I would have said should anyone have asked me whether or not I would ever buy a mac product.

I have been a PC user since I was the tender age of 15 and I love PCs and I love using them. I feel very much at home when I have a computer in front of me.

Unfortunately, the times they are changing (thanks bob ;-)) and with the advent of the iPhone from Apple and customers enquiring more and more about iPhone Apps I decided a Mac was needed. The first thing I tried was one of the number of hackintosh products, both iAtkOS and Kalyway relases of osx86 and I managed (albeit after a lot of hard work and tinkering) to get them working. I managed to get one working on a AMD based system and one on a Intel Core 2 Duo System, they are both made and very well supported by a dedicated community. There are answers out there for almost any product for both releases, so it is a great way to get to know OSX and you can do it with the equipment you probably already own. If you want to find a copy, check out the bay of pirates.

Saturday, May 1, 2010

Using PHP's XMLWriter to create a basic Google SiteMap

The PHP manual is one of the greatest programming references I have ever used, however when I came across the need to use XML Writer class that is packaged with the later versions of PHP I needed a quick guide to using this amazing class and couldn't find one. So in the spirit of the open source movement I decided to write this little tutorial, it's not exhaustive, but it should get you started and it's handy when I work in different places and I need a quick reference to the class.

I had to create an XML feed for Google Maps and I needed to do it using PHP. As the site was dynamic and the URLs were often changing, it would have become a little tedious to create and update an XML feed by hand. Here I will explain the core methods to create your sitemap in PHP and where to post it on Google Webmaster Tools.

To get you started you need to create an instance of the class. Once that is done we will be using these methods. There are others available, but in this case, these are the only ones we need:

//create the instance
$xml = new XMLWriter();
//assign memory for output
$xml->openMemory();
//start the document
$xml->startDocument();
//create our first element. We use this element when we do not want to close the element after the value has been written
$xml->startElement('urlset');
//this adds the correct namespace for the sitemap specification
$xml->writeAttribute('xmlns','http://www.sitemaps.org/schemas/sitemap/0.9');

//your set of urls, could be generated in a number of ways including a database
$urls = array('http://www.domain.com/index.htm', 'http://www.domain.com/page2.htm', 'http://www.domain.com/page3.htm');

//loop through your urls
foreach ($urls as $url) {
$xml->startElement('url');
$xml->writeElement('loc', $url);
$xml->endElement();
}

//this ends the urlset element
$xml->endElement();
//end the document
$xml->endDocument();

//declare the type of page that you will be creating
header('Content-Type: text/xml');

//flush the content into the page
echo $xml->flush();

There are 3 other optional piecse of information you can add to the url element, these are:

lastmod
changefreq
priority

In terms of adding them in to the above code, you could make the array multi dimensional and change your foreach loop to look something like this:

$urls = array(
$urls[] = array('location' => 'http://www.domain.com/index.htm', 'lastmod' => '2009-12-10', 'changefreq' => 'daily', 'priorty' => '0.8'),
$urls[] = array('location' => 'http://www.domain.com/page2.htm', 'lastmod' => '2009-12-11', 'changefreq' => 'daily', 'priorty' => '0.7'),
$urls[] = array('location' => 'http://www.domain.com/page3.htm', 'lastmod' => '2009-12-12', 'changefreq' => 'daily', 'priorty' => '0.5'),
);

//loop through your urls
//we use write element when are opening and closing a tag at the same time
foreach ($urls as $url) {
$xml->startElement('url');
$xml->writeElement('loc', $url['location']);
$xml->writeElement('lastmod', $url['lastmod']);
$xml->writeElement('changefreq',$url['changefreq']);
$xml->writeElement('priority', $url['priority']);
$xml->endElement();
}



Becoming Mobile

It's been a while since I last added a post on to this blog, mainly because I have been very busy. I took on a full time PHP development role in September and left behind the world of search (for the time being) so that I can really push on with my career.

Anyway, down to business. I once thought that if I could master a web language then I could stick to that, work away day after day and life would be good. This was of course a feeling I had before I had actually learnt a language, before I had actually applied the skills in a real life situation. This is now such a silly notion to me now that I cannot believe that I actually thought that, but I guess that is the benefit of hindsight. This is even more astonishing when you consider what the Internet is and how the very nature of the beast requires you to be fluid, adaptive and progressive. This now brings on to my next point. Mobile Apps.

I really do not want to talk about what I am going to do with them (in this post) yet, but as I have actually bought a Mac Mini to develop iPhone Apps I am sure I am going to have some great fun in doing so (but more on this later). The main point of this post is to discuss why I made the decision to start building apps and continue on my learning spree that I have been on these last couple of years. The purchase of Mac while important, only served as a catalyst to get me thinking about this idea of linked learning (a phrase I have coined for this post) and what the effect of learning one skill helps/drives to you to learning another. If this makes no sense to you, then please let me explain:

Years ago I taught myself VBscript to run within the ASP environment. These scripts required the use of databases (new skill) which in turn required me to learn MS Access which in turn allowed me to create dynamic website. The need to learn how databases worked is the link I am referring to. The acquiring of knowledge for one subject turned into another. This is quite a short chain of events, mainly because I came to the whole ASP game quite late, .Net was coming in and I considered learning that for a while but ended up choosing PHP instead.

This is very much a stripped down version, but you will get the idea. The arrows are not literally a point from one skill to another, just merely a way of demonstrating movement. If this was to be made a graphical representation then it would be more like a flow chart and many of the skill sets would be interlinked.

PHP/MySQL Led to Programming Skills -> OOP Theory -> XML -> javaScript
MySQL -> Advanced Database SQL-> Stored Procedures
Apache (running on windows) -> Regular Expressions
javaScript -> DOM knowledge -> jQuery and other frameworks
Apache (Windows) -> Apache running on Linux
Apache (Linux) -> Linux web server setups -> Linux OS
Linux OS -> Application Languages (c++, python)

This is not an exhaustive list, I could be here forever doing that. I would also have to decide at which point does each skill set become its own subset. Also, just because one skill has fired another it doesn't mean that its parent subject has been exhausted. This is especially true with something like Linux, which is a huge topic and will take years to master. The problem with this linked learning is that fact you may spread yourself a little thin. While I can apply all the skills mentioned above I am always new things about each one. In addition, as the skills are inter-related, it generally (though not always) makes each new skill all that bit easier. For example, once I had learnt PHP, I found C++ much easier as many of the constructs are similar in nature.

Does this post apply to other areas, of course. You could apply it to just about anything, if you have a similar experience then please think back. It may help you to [re]discover skills and improve your career prospects or just help you find some direction.

So what's next on the learning radar? Well, like I mentioned at the beginning of the post it is now Apple Apps for iPod and iPhone, so please watch this space as I be reporting on this once my shiny new Mac mini arrives and I learn how to use OSX (oops another new skill), it's a good job I know how to use Linux as I hear they have many things in common ;-)

Labels: , , , , , ,