Tag: development

  • CSS: Useful CSS Selectors

    There is a range of fancy stuff you can do with HTML and CSS but a lot of developers are not aware of the little tricks you can do with CSS which results in developers using alternatives such as JavaScript or PHP when CSS can achieve the same results, sometimes even better as its less code to be written and downloaded by the client.

    Time after time I notice websites which have used JavaScript to achieve something like a menu when most of the time simple CSS selectors such as :hover could have been used resulting in a 100% CSS menu which works the same.

    Here is a must read article which outlines some of those hidden CSS selectors which make development a lot easier and faster. Did you know you could use regular expressions in CSS as I didn’t.

    http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/

  • Making Internet Explorer development easier

    Internet Explorer (IE) also known to some as Internet Exploder or the worst browser on the internet causes headaches for a lot of us developers. IE has what I would call a lack of tools or features, IE7  lacks the abilities to show images with a alpha channel which is something we take for granted these days, this is just one of many features used on modern websites which us developers have to combat against due to IE limitations.

    The main issue is that people are still using IE7 and IE8 which are very out dated, both of these versions of IE don’t support many of the new technologies meaning us developers have to be careful which normally results in hours of extra time writing code specific for each browser version so that the pages render correctly.

    Thank fully people have realized these issues and have written some JavaScript libraries we can use to try and fix / add features to IE to make development a lot easier.

    HTML5Shiv

    A great library I use often which adds HTML5 support to IE8 and below.

    http://code.google.com/p/html5shiv/

    IE7-JS

    Tries to fix various issues with IE7 so you can spend a considerable amount less making sure your website renders correctly in IE7.

    http://code.google.com/p/ie7-js/

  • PHP: Compare floats & why its different to a normal comparison

    Comparing two bits of data in PHP is quite simple but there are special occasions when a simple comparison of data needs to be slightly different. One of the common issues is comparing float numbers, a common mistake is comparing two float numbers the same way in which you would compare two integers or two strings.

    What does float, double or real number look like?
    1.234
    1.2e4
    7E-10

    This is due to how PHP stores float numbers (also known as doubles or real numbers) which gives this type of data a very limited precision resulting in numbers being slightly off, for a more in-depth explanation please read the following article http://php.net/manual/en/language.types.float.php.

    This issue only occurs once a calculation is performed on a float number.

    The best way of comparing two floats to get an accurate comparison is to convert the value to an alternative data type such as a integer, string or use “bccomp” which allows you to compare 2 float data types together up to the precision you specify (bccomp can also be used to determine which of the two floats is higher or lower).

    Read up on bccomp: http://php.net/manual/en/function.bccomp.php

    Is Match Comparison

    Greater or Lower Comparison

  • Pinning Eclipse to the taskbar with Windows 7

    Eclipse is a brilliant programming interface for many languages but when using a Windows 7 based PC you may have issues when pinning the shortcut to the task bar. As you can see below when I launch eclipse via the shortcut instead of using the pinned icon it creates a new one.

    If you right click the active icon you do not get a “Pin this program to taskbar” option like you would with other programs. Eclipse on the left and Microsoft Word on the right.

    All we need to do is add 2 simple lines to our Eclipse configuration file so that Java is detected correctly which then enables us to pin the application to the task bar. First we need to go to the directory where we have placed the Eclipse files, in my case this is “C:/Program Files/eclipse” but this will differ between everyone.

    If you can’t find the files try right clicking any shortcuts you have and select properties that will tell you where the actual files are.

    There is a file called “eclipse.ini” open it in Notepad it should look something like this.

    Add the following to the top of the file and save it. The second line needs to point to your Java installation bin directory; this may differ on your computer.

    You can normally find all the Java installations in the following location “C:\Program Files\Java\”, if you have a older or new version of java than me or using the JDK version then the name may differ from”jre7”.

    You can now start Eclipse and right click the icon on the task bar where you will now see the “Pin this program to taskbar” and when you open Eclipse it will no longer create a new icon.

    If you receive the following error when trying to start Eclipse then you have provided a invalid file location for Java. Try the other locations or in my case it was due to me pointing it to the 32bit version instead of the 64bit version (Program Files (x86) instead of Program Files).