Saturday, June 26, 2010

Are Microsoft Shooting themselves in the foot over Linux Lawsuits

Are Microsoft shooting themselves in the foot with the patent lawsuits they are filing regarding Linux. Now, whilst I'm not privy to all the facts of the case, I can still form an opinion on the subject.

Microsoft, I feel are going through a transistonary period. They are currently facing many challenges on many fronts. For many years they had it all their own way, near enough complete domination of the home computer software market with no real competitors in sight. Then things started to change, slowly at first, but significantly. The Internet allowed people to use their computers in different ways, people were starting to communicate via their machines rather just using them to create reports and pie charts!

People talked, people listened and eventually Microsoft started to lose ground. New companies started to emerge, Google became the search engine of choice, Apple started to make comeback - the Internet became a place of opportunity. User communities were springing up all over the place, as were developers who now had a platform to showcase their software to like minded individuals, which brings me to my next point - Linux.

Linux is a distribution based piece of software that runs on personal computers. It is an operating system created by Linus Torvalds and when it was first released the source code was freely available to anyone who wanted it, as long as they were prepared to release their changes back into the community. Distributions sprang up, some more popular than others, some have now gone onto become commercial successes (Red Hat being one of them), which is what is causing Microsoft to ruffle it's feathers.

It seems that Microsoft is claiming that a number of Linux distributions are infringing their patents and are threatening the companies that use them with legal action. One major sticking point is that Microsoft is failing to mention which ones they are! It seems MS are hoping the threat alone will stop companies using Linux OS software in their products or face the possibility of huge fines, the Dutch company Tom-Tom being one of the more high profile cases.

Take a look at these points,

1. The guys who work on the Linux software are extremely clever and seasoned developers and they have huge amounts of people working on the code, far more than Microsoft could ever employ. If MS were to ever actually state the actual infringements and if there was a genuine case of patent infringement, the code would be rewritten by the developers in a matter of moments and released for download.
2. Microsoft has had the lion's share of the home computer market for a long, long time and a little competition never hurt anyone. They now have multiple competitors: Linux, Apple and what was the result, ms release their best ever operating system with Windows 7. It seems the competition did them some good, compared to the normally buggy releases that take years to become what they should have been at release date.
3. The vast majority of people like to fair play and Microsoft's actions are anything but. They are purposefully trying to stifle the competition they are facing from Linux. I know they are trying to protect their future, but this should be done through innovation and product development(see my points below). If Microsoft continue down this route the only they will stifle is the growth of their reputation. Take a look at Apple, their reputation has gone through the roof these last 10 years or so and it is mainly through them delivering products that satisfy upon release. When a new product is released, the die hard fans buy them in their droves and this is because the people that buy them know that the product will deliver and they never question if the product lives up to expectations. I'm not a massive Apple fan, I own a couple of products, namely an iPod and MacMini but only for application development. I have to say, they are both very good products and I have no doubt if I bought another Apple product it would be very good and I would be happy with it.

Microsoft have started to branch in to other markets and I consider them to be a company I trust (now) when it comes to delivering software and hardware. ASP.net is a great framework and runs on thousands of machines and servers. The Xbox, another great piece of Hardware that has been bought and used by millions of people. Microsoft are also building and developing 'Surface' a great looking product and if it lives up to its promise will help instill Microsoft in to the psyche of the millions of future users that are out there. It is these things that Microsoft should concentrate on, not slapping companies with lawsuits.

Labels: , , , ,

Tuesday, June 22, 2010

jQuery is what JavaScript should have been - introduction and examples

jQuery is what Javascript should have been - introduction and examples
Please note this is not an extensive jQuery tutorial, it is more about how jQuery is the better option for client side browser scripting compared to javaScript and is aimed at people looking to change over from one to the other. jQuery is a framework that uses javascript to 'write less and do more'.

jQuery is what Javascript should have been. This is most definitely true, but is somewhat harsh I think. Javascript was created by Netscape as a language that allowed the programmer/developer of the website to manipulate the various elements of a web page. It was called JavaScript after Sun licenced their Java brand name to give the language a little more credibility. JavaScript allowed the creators of the website to display and showcase the content with a little more flair.

Like a lot of things on the Internet, the use of JavaScript was exploited and made web surfing painful at times. JavaScript can be used to open multiple windows at once and these 'popups', especially when a user was connected to the 'net using a dial up connection and tens of windows would open up simultaneously offering you products ranging from hair extensions to god knows what. Popups thankfully became less of a problem as browsers and firewall software improved including pop up blockers.

Another problem and some may argue a bigger problem was the way the software ran in browsers. Javascript was created by Netscape and was thus adopted by other browsers, unfortunately the language was not adopted as a standard and the browsers (namely Internet Explorer) did not all act the same when they came across JavaScript - this gave developers a huge problem. Scripts had to be tested in mutliple browsers and debugging time obviously shot through the roof.

This is where the wonder of jQuery comes rushing through. JavaScript had started to be used more and more as many online applications needed the little bit of extra functionality to deliver. jQuery took away the need for writing scripts for multiple browsers. You could in a reduced manner add in code in one line that would without jQuery library taken 10 or so line of code. It really did make it that easy.

Below are a number of examples of some of the more common tasks that you can use JavaScript for. Starting with the basic task of obtaining an element's value right through to the more advanced method of making an AJAX call. Each example will have the jQuery code followed by the JavaScript that would have been necessary without the jQuery library. jQuery also allows for developers to easily add events to elements, i.e. a mouse click. This is where we will begin as it one of the cornerstones of using jQuery and using for the coding on the web.

For the sake of this tutorial, I will be an using an element named 'myElement' - which could be anything like a paragraph, div, input. If any other elements are used or are a special, I will explain further where necessary.

You will see the $ sign a lot throughout this exercise, it basically means let jQuery handle the code.

Adding an event in jQuery:

This is how you add an event in jQuery:
$('#myElement').click(function(){
alert('Hello World');
});


Like with all jquery it works in all browsers, now lets take a look at the above in plain JavaScript, unfortunately there are a number of issues when it comes to adding event handlers - Internet Explorer. Microsoft, in their infinite wisdom decided to add their own event handling system.

Here is the the code according to w3c specification - i.e. for Firefox, Opera, Chrome using an anonymous function as the second parameter - you could as easily add a reference to another function, i.e. myFunction() instead like I have shown on the Internet Explorer example below

myElement.addEventListener('click',function(){
alert('Hello World')
},false);


The 3rd parameter given here as boolean = false refers to refers to event bubbling and that goes beyond the scope of this introduction, rest assured though, jQuery makes that easier too!

Here is the code for Internet Explorer

myElement = document.getElementById('myElement');
myElement.attachEvent('onclick',myFunction);


The problems here not only lead to writing more code to get the reference for the variable, address both w3c spec and non w3c spec browsers but you may also have to write code that detects the browser type so that your script doesn't cause errors.

Getting the value of a input form field

This includes select inputs and and select, most form values- I know, how easy...

var myVar = $('#myElement').val();

Now let's look at this in plain JavaScript to obtain a text input value:

var myVar = document.getElementById('myElement').value;

For a select dropdown menu it's even more cumbersome, not only do you have to select the element from a form, but you have to go through the array of options to find the value:

var mySelectDropDown = document.forms['myForm'].mySelect;
var selectChoice = mySelectDropDown[mySelectDropDown.selectedIndex].value;


Modifying an Element's CSS property

Let us look at this in jQuery:

$('#myElement').css('background-color','#000000');

Now let us look at this in JavaScript:

In this case we are going to change the background color of an element and set it to black(#000000). First we have to find the element using the document.getElementById() function. We then have to name the CSS property

myElement = document.getElementById(myElement')
myElement.style.backgroundColor = "#000000";


Again, how much easier is this? The added bonus is that it uses the same referencing system that you may be used to using in CSS, rather than a different reference, again saving you time and effort.
On to Ajax...

Performing jQuery Ajax calls couldn't be easier. This example uses a the .open() method, but there are a number others you may be interested in, namely $.get() and $.post(), so you may want to read up on them later. The following example takes the contents of another page and then adds the content to the element:

$('#myElement).open('myOtherPage.html);

Now let's look at that in plain JavaScript:

//first we have to create the XmlHttpRequestObject
var myAjaxObject = createXmlHttpRequestObject();
//then we create the function that triggers the event
function getContents() {
//reference the source to open
myAjaxObject.open('get', 'myOtherPage.html);
//assign the function that will handle the response
myAjaxObject.onreadystatechange = handleInformation;
//declare extra parameters, not needed when using the get method
myAjaxObject.send(null);
}
//now we have to create the function to handle the above:
function handleInformation() { //check the state of the request
if(myAjaxObject.readyState == 4 && myAjaxObject.status == 200) {
//Add the information to the myElement ID
myElement = document.getElementById('myElement');
myElement.innerHTML = myAjaxObject.responseText;
}
}

Hope this helps.

Labels: , , ,

Monday, June 21, 2010

Facebook and Microsoft to take on Google?

I'm a pretty regular Facebook user, but I am a heavy, heavy Google user. I was browsing on Facebook the other day and I have seen that Facebook is offering up web search results as part of its search scheme. Have I clicked on the links yet? No, I still use Google.

Google became popular because it offered great results and its home page was quick to load for dial up users, these were its advantages and like in nature, the strongest survived. Could Facebook's main advantage be that allows people to do everything in one place. Search And Socialise could be next big thing - Remember that users are only one click away from leaving any site.

At the moment though it seems that Facebook is beginning to offer these results as a supplementary set of links after the results that are shown for pages/profiles on their own system. How is it doing this? Well the key thing is that they are using Bing as the provider. Bing as we all know, is part Microsoft/part Yahoo and it should come as no surprise that Microsoft is becoming more and more visible in Facebook. For those who didn't know, MS bought a large stake in the site in 2007. In my opinion, I'm surprised that it took them this long to do it.

It seems that is this is yet another step by Microsoft/Bing, after their merger with Yahoo to take on Google and to make sure they are at the forefront of the web. They know that were caught with their pants down when it came to the Internet and how it was going change the way that people were going to go about their day to day business. Google on the other hand, were one of the companies that really benefited from this and it was them have constantly pushed the boundaries, whether it be offering an Web Email alternative to Hotmail or buying companies that they know can improve their business model.

So what could this mean for the future, well a few things are starting to emerge in the online world which shows that Microsoft and its partners are slowly to try to catch Google in the Search Engine and online application stakes. When Google launched it's version of office online that allowed users to create and edit from decentralised locations, it was seen as ground breaking. Microsoft has not taken this lying down and has in the last couple of weeks incorporated software into Hotmail that allows users who have sent and received MS Office documents to edit them from within their browser in the cloud.

In terms of Facebook, what next there. Well I bet that we'll once again get an update to the Facebook front end that will add the Bing results in to the pages in a more in-your-face-way rather than at the bottom of the pages, like they are now.

For Google, their next big mission is obviously going to be the encroachment on the operating system market with their introduction of Chrome OS. This may allow them to take back other market share that they may lose in the future as a result of the above. They are though, going to have to think long term with this project. There are a number of large players in this market already, most notably Windows, Linux, Mac OSX and loosening their grip on the operating system is going to be tough - I'm sure most of you know how loyal Apple fans are.

James

Labels: , , , , , , ,

Monday, June 14, 2010

How to make Scheduled MySQL database backups using Windows

Had a bit of a hair raising issue the other morning with database problems. So I decided to write this post: There are a number of other options some paid, some free. But this is a free solution and works using free software that anyone can download. The more commercial software allows you to manage multiple databases easily, but if you need to backup your database on a budget or you only have a small number of databases on the same server then this will suit you fine. When I get round to it, I will write this tutorial for Linux.

Also this article assumes you will have your machine switched on when you set the scheduled backup to run.

The software:

1. Download and install MySQL Administrator Tools from mysql.com: http://dev.mysql.com/downloads/gui-tools/5.0.html

2. When you have installed the program, look in your start menu for the MySQL System Tray Icon - run that (if not already).

3. Right Click on the system tray icon -> Monitor Options -> Launch Monitor After Login

Setting up the MySQL Backup

1. Connect to your database using the supplied information
2. Set up the environment

Tools -> Options -> General Options

Check The Store Passwords Option
Set Password Storage Method = Obscured

Click Apply

This is so that your backup Choices can remember the details

Click Close

3. Add a stored connection. This can be done via the stored save Current connection option, but this normally doesn't work for me as the connection disappears from the folder on restart of the program. So for the sake of this tutorial we will be saving a brand new connection

Tools -> Manage Connections

Click New Connection
Under Connection - Add a name, i.e. the website name
Username: Enter the username for the database connection
Password: Enter the password for the database connection
Hostname: The hostname or IP address of your database

Click Apply and Close the dialog and then close the program. This has to be done as to schedule the backup properly you need to be logged in under a stored connection.

4. Now back at your main screen, click the backup button

5. Click New Project and the screen will become active with your database(s) on the left. - Enter a name in to the Project Name field

6. Click the database(s) you want to add to your backup by clicking on the 'greater than' arrow that points to the right - '>'and this will add the database to the backcup operation as well as all the tables within (default)

7. Once you have done this - click the Schedule Tab at the top

8. Click Schedule This Backup Project and then choose a location where your backups should be stored

9. The filename should be filled in automatically, so choose your own backup Execution options: Time, Frequency - i.e. daily, weekly...

10. Click Save Project

11. Click Execute Backup to test settings

12. Enter your windows password (if required)

Labels: ,

Thursday, June 10, 2010

Performing mathematical analysis on two dates using PHP

Hi there,

I recently had to work out how much time had passed since an event had occurred in PHP and needed to do in a way that worked it out in minutes. I of course decided to use PHP's time functions to do so.

The key to making this work was of course to find out how time had passed between two references, namely now and a stored reference of time, i.e. a date time piece of information stored in a database, i.e. '2010-06-03 09:56:00'.

The first thing we have to do is find out the UNIX timestamp of the date that we are going to compare now to and this is done like so:

$reference1 = strtotime('2010-06-03 09:56:00');
/*
This function takes a typed out date time value (its first parameter) and and then returns the number of seconds that have passed since 1970-01-01 00:00:00 - aka The Unix Epoch.
*/

$reference2 = time();
/*
This again returns the number of seconds passed since the Unix Epoch.
*/

Now that we have our our two values standardised in to seconds we can perform analysis on them by using a little mathematics, like so:

//calculate difference in seconds
echo 'Seconds: '. $secondsPassed = $reference2-$reference1;

//calculate seconds to minutes
echo ' Minutes: '. $minutes = $secondsPassed/60;

//convert minutes to hours
echo 'Hours: '. $hours = $minutes/60;

//convert to days
echo 'Days: '. $days = $hours/24;

//convert to weeks
echo ' Weeks: '. $weeks = $days/7;

Of course this is only a small set of examples and you can mix and match the arithmetic to get to a more precise value in less steps. This example also doesn't round any figures, but you may wish to do so, functions like round(), ceil() and floor() would be of help, depending on the value you want to extract.

I hope that helps.

Wednesday, June 2, 2010

What is it be a web developer?

This piece is not about the history of the web, more about how the web grows and how new technologies constantly change the nature of what it means to be a web developer.

The Internet is growing (nothing new there with that statement). When a new idea or piece of technology springs up, developers are needed to be able to write software for it so that the new innovation gains ground and popularity.

The term 'web developer' came about because the web became the most sought after use for the Internet. When this happened people wanted to access information quickly and reliably. As a result web developers started programming on systems and servers that could dish out this information in a better way. With the integration of databases and server side coding, it allowed websites to move on from the stateless nature of HTML that is when Tim Berners-Lee developed it.

As time has moved on the web has gone from strength to strength. The other huge leap forward was advent of Javascript, a programming language that allowed coders to manipulate the pages that users saw in their browsers. This allowed websites to start behaving more the more traditional applications that ran on PCs and other computers. Of course it was only matter of time when the two started to inter mingle to give us even better applications and lo and behold Ajax sprang up when Microsoft created the XMLHttpRequest Object which allowed developers to send asynchronous requests to servers without the page reloading, thus enhancing even further the web experience. Ajax was designed to work with both XHTML and XML so that information could be injected and updated quickly and using less resources. Why reload the whole page when you only need to change the information in a single element? XML and the many web services created to use it allowed people to integrate information from website to another in a standardised way and crossed the divides that sprung up from the use of different systems.

The web didn't stop there over time, newer ideas and innovations continued to spring up all over the shop and applications became more and more complex. Social Media started to come in to the main stream and integration between web sites and applications became more and more common. MySpace and Facebook started to come to fruition and the web continued to make new ground with many people that had considered the web to be a fad with those 'young people'.

With the advent of Ajax it allowed applications to be made and resemble desktop programs, but there was a problem that became apparent as time went on. As with most javaScript functionality it had its problems with the numerous browsers that were available in the market. It was also quite code intensive and lots of testing was usually needed to make sure code with all browsers. That is where my topic pops up and that topic is jQuery. jQuery is a javaScript framework and has ironed out many of the problems that made javaScript such a pain to work with in the first place. DOM traversal, Ajax calls and element selection was made easier and standardised, no more cross compatibility testing to make sure things worked in firefox and IE. Debugging and development time has become vastly decreased, something of which, if you are a business can be passed on when you quote your customers for work.

So what is the future for the web. Well in my opinion, the future is becoming smaller. Well it is terms of the web. Mobile technology is becoming more and more common and I think that is where a lot of the future innovations will lie. Apple and Google have both moved into the mobile phone market and making a lot of people think about using their mobile device as the primary device for accessing the Internet. I myself have bought a mac mini to develop applications for iPhone as I want to keep with up with how the market is changing. I haven't actually created an app yet as I have too many commitments in other areas but the area between desktop applications and web applications are coming together quicker than ever, something of which I think will change the web and the Internet forever.

Labels: , , , , , ,

How long does it take to become a web developer

This is almost like the question 'how long is a piece of string', because in my experience you can never stop learning.
The real question is how long does it take to become proficient as a web developer and my answer, in my opinion is about 2 years. This is obviously not a definitive answer and is subject to change, especially if you know a programming language for another discipline. The 2 year time frame should not put you off, but it will take you this amount of time to really truly understand all the ins and outs of web programming.
First let's take a look at what you technologies have to learn to become a web developer. When you start down this road, you need to understand how the web works and why it does what it does. What happens when a request is made by the user, how a server responds and how the output is generated by the browser.
The basic model for this piece of user interaction is like so:
The User Requests data via their browser -> The web server responds and sends HTML (Hypertext Markup Language - the language your browser understands) to your computer/device which then in turns displays it to you. That is it, the basic web request. A few other bits and pieces are sent but we'll look at those a little later.
So let's look at the above and break it down. The HTML this is the basic building block of the web and you cannot create a web page without knowing how write HTML. So this is obvious place to start, learning HTML is not that hard and you should be able to start knocking pages together within a week or so. The other part of learning how to write HTML is the ability to learn something called Cascading Style Sheets (CSS). CSS is a technology that allows a page's content (the HTML) and the page's design to be separated in to different elements. This allows for a more structured site, easier design updates and less cluttered mark up. Learning CSS can take a little longer to learn HTML as it has many different aspects to it. There are great many tutorials and books out there and any decent book that teaches you HTML should teach you CSS, if it doesn't, pick a different book. I have already written different post regarding books for beginners, so please take a look there for my recommendations. You should be able to grasp a good amount of CSS in a few weeks/months for you to be able to start knocking web pages together, it can take a couple of years to master CSS as there are so many ways of doing things. i.e. using different methods to solve different issues, different properties for different elements and coupled with the fact that it is constantly being updated by the W3c, it gives CSS and long a drawn out learning curve.
The previous paragraphs, really dealt with the browser/client side of what websites and how they work. The next sections really deal with how a server sends a page to the user. At a basic level a server responds with HTML based on a request from the user. These pages can be static - where a page's content is hard coded in to the request page or dynamic - where a page is constructed and delivered according to a set of parameters. Dynamic pages are still served in HTML, this is the only language a browser can intepret, the difference with a dynamic page is that the page's content can be manipulated by the server when it sends the information.
This is where you really start to become a 'web developer', when you start to learn a language that runs on a web server and is executed at run time. There are a great many choices when it comes to choosing the language, my personal preference is PHP, many others like ASP.net or Java - all work in a similar way and all perform similar tasks though PHP allows you to code using both procedural and object oriented approaches (see other posts of mine regarding this). This part of the learning curve is going to be the longest. You should be able, once you have grabbed the principles of programming, to start programming in PHP and even start creating some dynamic pages within a couple of months, even less if you are doing it full time. Believe me, if you stick with it and you like coding, when you start creating programs, see people using them, then you really feel an excellent sense of worth. However to truly understand the language of PHP is going to take a while, you may be able to create some decent scripts quickly, but like I said before it will probably take you a couple of years, before you get to the point where you are truly comfortable with language. An example of this is where you get to the point that you know that no matter what a customer/colleague asks you to do, you know that you will be deliver what ever they need.
Once last thing, before I sign off. People often ask 'Am I am scripter or a programmer ?' This is a large can of worms and I do not wish to reopen it as it has been argued to and fro by many people. In my opinion, a script is something that runs on a single page, an application is something that runs across many pages and does multiple tasks geared towards a set of goals or objectives.


Labels: , , , , , , ,