<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>daipratt.co.uk</title>
	<atom:link href="http://daipratt.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://daipratt.co.uk</link>
	<description>Concerned about Website Construction &#38; SEO</description>
	<lastBuildDate>Tue, 10 Aug 2010 08:59:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Best way to store IP addresses in MySQL</title>
		<link>http://daipratt.co.uk/mysql-store-ip-address/</link>
		<comments>http://daipratt.co.uk/mysql-store-ip-address/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 08:53:35 +0000</pubDate>
		<dc:creator>David Pratt</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<guid isPermaLink="false">http://daipratt.co.uk/?p=1258</guid>
		<description><![CDATA[It's tempting to store IP addresses in a database as a varchar of length 15 in the absence of a dedicated IPv4 field type in mysql, but that isn't the most efficient way of doing so...]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s tempting to store IP addresses in a database as a VARCHAR(15) in the absence of a dedicated IP address field type in mysql, but that isn&#8217;t the most efficient way of doing so. The best way that I&#8217;ve come across to store an IPv4 address is to store it as an unsigned integer.  In phpmyadmin you might set up an ip address field so that it looks something like:<br />
<div id="attachment_1264" class="wp-caption alignnone" style="width: 363px"><a href="http://daipratt.co.uk/wp-content/uploads/2010/08/phpmyadmin-ip-address-setup.png"><img src="http://daipratt.co.uk/wp-content/uploads/2010/08/phpmyadmin-ip-address-setup.png" alt="Screenshot of the PHPMyAdmin field setup for an IP address field" title="PHPMyAdmin field setup for IP address field" width="353" height="243" class="size-full wp-image-1264" /></a><p class="wp-caption-text">Screenshot of the PHPMyAdmin field setup for an IP address field</p></div></p>
<p>You&#8217;ll realise I&#8217;m sure that you can&#8217;t just add the dotted IP address straight into an INT field without first converting it into a valid format.  For that you&#8217;ll need a PHP function called <a href="http://php.net/manual/en/function.ip2long.php">ip2long</a> which will convert a string containing an IP dotted address into a integer that can be stored in the INT field.</p>
<p>Here is a quick example of how you might go about getting the real IP address of a client and then storing and retrieving its value from the mysql DB:</p>
<pre class="brush: php">
//Test if it is a shared client
if (!empty($_SERVER['HTTP_CLIENT_IP'])){
  $ip=$_SERVER['HTTP_CLIENT_IP'];
//Is it a proxy address
}elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
  $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
  $ip=$_SERVER['REMOTE_ADDR'];
}
//The value of $ip at this point would look something like: "192.0.34.166"
$ip = ip2long($ip);
//The $ip would now look something like: 1073732954
</pre>
<p>Now that you have the real IP address of the client converted to the INT format, you can write it into the DB as you normally would:</p>
<pre class="brush: php">
$sql = "INSERT INTO user(ip) VALUES('$ip')";
$dbQuery = mysql_query($sql,$dbLink);
</pre>
<p>To retrieve the original IP address from the database you can use the mysql function <a href="http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_inet-ntoa">INET_NTOA</a> like so:</p>
<pre class="brush: sql">
SELECT INET_NTOA(ip) FROM 'user' WHERE 1
</pre>
<p>Alternately you could use the PHP function <a href="http://www.php.net/manual/en/function.long2ip.php">longtoip</a> to convert the returned INT value into the dotted IPv4 address in the PHP code instead, and you could even add the dotted IP address to the INT field in the db using the mysql funtion INET_ATON.</p>
<p>Storing IP addresses in this manner is beneficial because it takes less space than storing it as a string.  The other benefit is that lookups are faster because integer comparisons are quicker than string comparisons.</p>
]]></content:encoded>
			<wfw:commentRss>http://daipratt.co.uk/mysql-store-ip-address/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Non-standard page size&#8217;s in TCPDF</title>
		<link>http://daipratt.co.uk/tcpdf-page-sizes/</link>
		<comments>http://daipratt.co.uk/tcpdf-page-sizes/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 18:11:12 +0000</pubDate>
		<dc:creator>David Pratt</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tcpdf]]></category>
		<guid isPermaLink="false">http://daipratt.co.uk/?p=1249</guid>
		<description><![CDATA[If you need to create a PDF using TCPDF that isn't a standard size (A4, A5, B1, LETTER etc.) then this snippet might help you out: $resolution= array(100, 100);  $pdf->AddPage('P', $resolution);]]></description>
			<content:encoded><![CDATA[<p>If you need to create a PDF using <a href="http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf">TCPDF</a> that isn&#8217;t a standard size (A4, A5, B1, LETTER etc.) then it is possible to specify a custom size even though it isn&#8217;t that well documented. To do this you need to pass an array containing the desired width and the height of the PDF instead a formatted parameter such as &#8216;A4&#8242;.  For example:</p>
<pre class="brush: php">
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// add a page
$resolution= array(100, 100);
$pdf->AddPage('P', $resolution);
</pre>
<p>Make sure you express the height and width in the unit of measurement (pt, px, mm, cm etc.) that you are using as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://daipratt.co.uk/tcpdf-page-sizes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using Crontab with Plesk to call PHP files</title>
		<link>http://daipratt.co.uk/crontab-plesk-php/</link>
		<comments>http://daipratt.co.uk/crontab-plesk-php/#comments</comments>
		<pubDate>Thu, 06 May 2010 18:39:01 +0000</pubDate>
		<dc:creator>David Pratt</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plesk]]></category>
		<guid isPermaLink="false">http://daipratt.co.uk/?p=1214</guid>
		<description><![CDATA[How to set up a scheduled job on Plesk that calls a PHP file at an interval of your choosing.]]></description>
			<content:encoded><![CDATA[<p>Having battled with getting a php file to be called from a scheduled task (a.k.a. a crontab task) using the Plesk interface panel on a Linux box, I thought I&#8217;d share a bit of a how-to on it because I struggled to find anything helpful out there on the topic.</p>
<p>Here is screen shot of a completed &#8220;Schedule New Task&#8221; form so that you can see what a working configuration looks like:<br />
<div id="attachment_1219" class="wp-caption alignnone" style="width: 483px"><a href="http://daipratt.co.uk/wp-content/uploads/2010/05/crontab.png"><img src="http://daipratt.co.uk/wp-content/uploads/2010/05/crontab.png" alt="Setting up Crontab from within Plesk to load a php file." title="Crontab" width="473" height="389" class="size-full wp-image-1219" /></a><p class="wp-caption-text">Setting up Crontab from within Plesk to load a php file.</p></div></p>
<p>The fields on the form look fairly self explanatory to fill out, but the first gotcha for me was how to get it so that the job runs every hour instead of on just one named hour. To get the cron to run every hour you just need to use an asterisk (*), the same technique can be applied for all other time frequencies as well.</p>
<p>Once you&#8217;ve set the cron to run at the required interval, you will need to tell it what command to call. This isn&#8217;t obvious either.  Firstly what you need to do is call php or state the path to the php folder, then pass it the parameter &#8220;-q&#8221; (to suppress the HTTP header output), and then state the full path of the php file that you want to run e.g.</p>
<pre class="brush: plain">
php -q httpdocs/cron.php
</pre>
<p>If you just put the path to the name of the php file that you want to run, then the cron will throw an error.</p>
<p><em>For reference, I&#8217;m using Plesk 9.5.1 &amp; PHP 5.3</em></p>
]]></content:encoded>
			<wfw:commentRss>http://daipratt.co.uk/crontab-plesk-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Calculate text width and height with JavaScript</title>
		<link>http://daipratt.co.uk/calculate-text-width-and-height-with-javascript/</link>
		<comments>http://daipratt.co.uk/calculate-text-width-and-height-with-javascript/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 08:43:06 +0000</pubDate>
		<dc:creator>David Pratt</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ui]]></category>
		<guid isPermaLink="false">http://daipratt.co.uk/?p=1123</guid>
		<description><![CDATA[A tutorial that shows you how to measure the height and width of a text element using JavaScript.]]></description>
			<content:encoded><![CDATA[<p>Occasionally when putting together an advanced layout it&#8217;s necessary to have a level of control over the UI that can&#8217;t be achieved with CSS alone.</p>
<p>One situation might be in displaying a place name. Say for instance that place name had to be rendered in block that has a width of 200px, with a height that can flex as necessary to accomodate the content. This won&#8217;t be a problem in 99.9% of situations, but what happens if the place name is Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch?! Yes this place <a href="http://maps.google.co.uk/maps?f=q&#038;source=s_q&#038;hl=en&#038;geocode=&#038;q=Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch&#038;sll=53.800651,-4.064941&#038;sspn=22.383401,67.631836&#038;ie=UTF8&#038;hq=&#038;hnear=Llanfair+Pwllgwyngyll,+Gwynedd,+United+Kingdom&#038;ll=53.223096,-4.206047&#038;spn=0.17636,0.528374&#038;z=12" target="_blank">does exist</a>! In cases like this you might want to apply a special class name, or maybe dynamically adjust the font-size so that it fits within the allowed container. The consequences of not defending against this situation might be that the layout behaves unpredicatably, breaks, or perhaps some of the word could be hidden by the overflow property in the CSS being set to hidden or something.</p>
<p>So, should you find yourself in a situation where you need to measure the height and width of a text element, this code might help you:</p>
<h5>HTML</h5>
<pre class="brush:php">
&lt;p id="place-name"&gt; Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch&lt;/p&gt;
</pre>
<h5>CSS</h5>
<pre class="brush:css">
#place-name{
    position: absolute;
    height: auto;
    width: auto;
}
</pre>
<h5>JavaScript</h5>
<pre class="brush:javascript">
var oPlaceName = document.getElementById("place-name");
if (oPlaceName){
	var iHeight = oPlaceName.clientHeight + 1;
	var iWidth = oPlaceName.clientWidth + 1;
	if (iWidth &gt; 200){
		//Deal with the long text.
	}
}
</pre>
<p>I have prepared a <a href="/examples/text-width.html" target="_blank">quick standalone example</a> should you want to see this in action.</p>
<p>A place name might have been a bad example, but it could have quite easily have been any other type of field who&#8217;s length or height you might want explicit control over. Other applications of this that I can think of quickly could be adjusting the font-size of headings so that they never wrap, perhaps adjusting letter spacings so that they have aligned edges, or whatever else the designers .psd file shocks you with! With a clever implementation, this sort of thing could be achieved without the user even noticing, but that&#8217;s a job for someone else!</p>
]]></content:encoded>
			<wfw:commentRss>http://daipratt.co.uk/calculate-text-width-and-height-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A few things to consider when developing on a public domain</title>
		<link>http://daipratt.co.uk/a-few-things-to-consider-when-developing-on-a-public-domain/</link>
		<comments>http://daipratt.co.uk/a-few-things-to-consider-when-developing-on-a-public-domain/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 17:07:21 +0000</pubDate>
		<dc:creator>David Pratt</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[seo]]></category>
		<guid isPermaLink="false">http://daipratt.co.uk/?p=1098</guid>
		<description><![CDATA[To prevent a site being indexed by Google before it is ready for public consumption, there are a couple things that you can do.]]></description>
			<content:encoded><![CDATA[<p>If you ever find yourself developing a site on a public facing domain, it is always a good idea to have measures in place to prevent search engines indexing it in the event that a stray link enables a search engine spider to find it. A few of the things that you can do are&#8230;</p>
<p>Ensure the document head of each page has the &#8220;noindex&#8221; meta tag. This statement tells search engine spiders to not index any of the content on the current page.</p>
<pre class="brush: php">
&lt;meta name="robots" content="noindex" /&gt;
</pre>
<p>Ensure the document head of each page has the &#8220;nofollow&#8221; meta tag. This statement tells search engine spiders to not follow any links on the page.</p>
<pre class="brush: php">
&lt;meta name="robots" content="nofollow" /&gt;
</pre>
<p>Add a rule to the robots.txt file that prevents search engine spiders from accessing the site.</p>
<pre class="brush:plain">
User-agent: *
Disallow: /
</pre>
<p>Just remember to remove these measures when you launch the site!</p>
]]></content:encoded>
			<wfw:commentRss>http://daipratt.co.uk/a-few-things-to-consider-when-developing-on-a-public-domain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Always cache the length property in for loops when using JavaScript</title>
		<link>http://daipratt.co.uk/always-cache-the-length-property-in-for-loops-when-using-javascript/</link>
		<comments>http://daipratt.co.uk/always-cache-the-length-property-in-for-loops-when-using-javascript/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 10:13:22 +0000</pubDate>
		<dc:creator>David Pratt</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[recursion]]></category>
		<guid isPermaLink="false">http://daipratt.co.uk/?p=1081</guid>
		<description><![CDATA[Well, you don't have to, but it helps a smidgen when it comes to performance...]]></description>
			<content:encoded><![CDATA[<p>To speed up <i>for loops</i> in JavaScript you should always look to cache the <i>length property</i> so that the value of this doesn&#8217;t have to be recalculated on every iteration of the loop.  There are a couple of ways to do this, the first and most obvious way is to calculate the array length outside of the loop e.g.</p>
<pre class="brush: javascript">
var l = bigArray.length;
for(var i = 0; i &lt; l; i++){
	//Do stuff
}
</pre>
<p>Another less well known way is to cache the length property in the for loop decleration e.g.</p>
<pre class="brush: javascript">
for(var i = 0, l = bigArray.length; i &lt; l; i++){
	//Do stuff
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://daipratt.co.uk/always-cache-the-length-property-in-for-loops-when-using-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal &#8211; Getting the image path of a CCK field</title>
		<link>http://daipratt.co.uk/drupal-getting-the-image-path-of-a-cck-field/</link>
		<comments>http://daipratt.co.uk/drupal-getting-the-image-path-of-a-cck-field/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 08:37:54 +0000</pubDate>
		<dc:creator>David Pratt</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[drupal]]></category>
		<guid isPermaLink="false">http://daipratt.co.uk/?p=1027</guid>
		<description><![CDATA[An explanation about how to use the internal Drupal function field_file_load() to get the path of an image that is stored in a CCK field.]]></description>
			<content:encoded><![CDATA[<p>I often find myself using the Views module in Drupal to generate SQL that I can then use elsewhere directly, such as from <a href="http://drupal.org/node/146172">page handler include files</a>.  Occasionally however, the SQL that the View module generates doesn&#8217;t quite work as you would expect, or as though it would from within a standard View.  This happens in my experience more often than not when you&#8217;re dealing with CCK image fields. The problem being that the contents of the 3 fields that are associated to a particular image within the content type table, don&#8217;t contain anything that resembles a path to the physical location of the image in the file system.  The 3 fields that I am referring to can be identified by their endings; one will end in <i>_fid</i>, another with <i>_list</i> and the last with <i>_data</i>.  To explain this better it might be easier if I give an example, the following SQL will get the contents of the 3 fields that are associated with an image, in this case it is the website logo field:</p>
<pre class="brush: sql">
SELECT
field_website_logo_fid,
field_website_logo_list,
field_website_logo_data
FROM content_type_website
LIMIT 1
</pre>
<p>When I perform this query I get:</p>
<pre class="brush: plain">
fid: 1723
list: 1
data: a:10:{s:8:"duration"; i:0; s:6:"height"; i:0;s:5:"width"; i:0;s:18:"audio_bitrate_mode"; s:0:""; s:18:"audio_channel_mode";s:0:""; s:12:"audio_format"; s:0:""; s:13:"audio_bitrate"; i:0; s:17:"audio_sample_rate"; i:0; s:3:"alt"; s:0:""; s:5:"title"; s:0:"";}
</pre>
<p>You&#8217;ll notice that none of these values give anything obviously meaningful to work with, and this can be confusing because as you can see, there isn&#8217;t anything obvious here (to me anyway) that looks like an image path, or that can be used to construct an image path. You might be able to guess that the <i>fid</i> value can be used as a look up on another table to get more information about the image (which it can by the way), but you&#8217;d need to find that table and either do a join or an additional look up to find that out.  Rather that doing that, the easiest method that I&#8217;ve come across to find the path of the image (if you know the <i>fid</i> value) is to use the <a href="http://api.lullabot.com/field_file_load">field_file_load</a> function like so:</p>
<pre class="brush: php">
$file = field_file_load($node->website_logo_fid);
$filepath = $file['filepath'];
</pre>
<p>You could then put the $filepath directly into an image:</p>
<pre class="brush: php">
print '&lt;img src="/'.$filepath.'" alt="" /&gt;';
</pre>
<p>Bear in mind that you might need to consider the base path before the <i>$filepath</i>.</p>
<p>The other instance that you might want to retrieve an image path from a CCK image field, is from within a template file.  If you know the name of the CCK image field, then you can retrieve the path by doing something like:</p>
<pre class="brush: php">
$field_website_logo[0]['filepath'];
</pre>
]]></content:encoded>
			<wfw:commentRss>http://daipratt.co.uk/drupal-getting-the-image-path-of-a-cck-field/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Importing large files into mysql with phpmyadmin</title>
		<link>http://daipratt.co.uk/importing-large-files-into-mysql-with-phpmyadmin/</link>
		<comments>http://daipratt.co.uk/importing-large-files-into-mysql-with-phpmyadmin/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 12:55:15 +0000</pubDate>
		<dc:creator>David Pratt</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<guid isPermaLink="false">http://daipratt.co.uk/?p=1015</guid>
		<description><![CDATA[A tutorial that explains the steps you need to take in order to import large (2Mb+) SQL files into phpmyadmin]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing this here because it&#8217;s the third time I&#8217;ve had this problem, and the third time I&#8217;ve forgotten how to fix it! If you ever get hit with the error message:</p>
<div id="attachment_1018" class="wp-caption alignnone" style="width: 509px"><a href="http://daipratt.co.uk/wp-content/uploads/2010/01/phpmyadmin.png"><img src="http://daipratt.co.uk/wp-content/uploads/2010/01/phpmyadmin.png" alt="Phpmyadmin error message" title="phpmyadmin" width="499" height="70" class="size-full wp-image-1018" /></a><p class="wp-caption-text">“You probably tried to upload too large file. Please refer to documentation for ways to workaround this limit.”</p></div>
<p>When trying to import large SQL files into mysql using phpmyadmin, the <a href="http://localhost/phpmyadmin/Documentation.html#faq1_16">phpmyadmin documentation</a> offers a few solutions, but I find the easiest method to overcome this is&#8230;</p>
<p>Find the <i>config.inc.php</i> file located in the phpmyadmin directory. In my case it is located here:</p>
<pre class="brush: plain">
C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php
</pre>
<p>Find the line with <i>$cfg['UploadDir']</i> on it and update it to:</p>
<pre class="brush: php">
$cfg['UploadDir'] = 'upload';
</pre>
<p>Create a directory called &#8216;upload&#8217; within the phpmyadmin directory.</p>
<pre class="brush: plain">
C:\wamp\apps\phpmyadmin3.2.0.1\upload\
</pre>
<p>Then place the large sql file that you are trying to import into the new upload directory. Now when you go onto the db import page within phpmyadmin console you will notice a drop down present that wasn&#8217;t there before &#8211; it contains all of the sql files in the upload directory that you have just created.  You can now select this and begin the import.</p>
<p>If you&#8217;re not using WAMP on Windows, then I&#8217;m sure you&#8217;ll be able to adapt this to your environment without too much trouble.</p>
]]></content:encoded>
			<wfw:commentRss>http://daipratt.co.uk/importing-large-files-into-mysql-with-phpmyadmin/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Using the logical OR operator in setting variables</title>
		<link>http://daipratt.co.uk/using-the-logical-or-operator-in-setting-variables/</link>
		<comments>http://daipratt.co.uk/using-the-logical-or-operator-in-setting-variables/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 09:58:01 +0000</pubDate>
		<dc:creator>David Pratt</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[javascript]]></category>
		<guid isPermaLink="false">http://daipratt.co.uk/?p=994</guid>
		<description><![CDATA[A technique that sets a variable by testing the result of the logical OR operator based on the existence of the two conditions.]]></description>
			<content:encoded><![CDATA[<p>If you ever find yourself setting a variable based on the existence of an object property or variable, and write tests similar to [Edit: assuming that the Object <i>object</i> is known to exist.]:</p>
<pre class="brush: javascript">
if (object.property){
	var foo = object.property;
}else{
	var foo = "foo";
}
</pre>
<p>Or:</p>
<pre class="brush: javascript">
var foo = "foo";
if (object.property){
	foo = object.property;
}
</pre>
<p>Then there is more elegant way to achieve this by using the logical OR (||) operator in setting the variable.  The same result as above can be achieved by this line of code:</p>
<pre class="brush: javascript">
var foo = object.property || "foo";
</pre>
<p>What this is in effect doing is testing the result of the logical OR operator based on the existence of the two conditions i.e. object.property and &#8220;foo&#8221;. As &#8220;foo&#8221; will always resolve to true because it exists, it is just down to the ambiguity of object.property to determine the output i.e. if object.property exists, then foo will take the value of object.property, otherwise it will adopt the value &#8220;foo&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://daipratt.co.uk/using-the-logical-or-operator-in-setting-variables/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Software to put on a clean install of Windows 7</title>
		<link>http://daipratt.co.uk/software-to-put-on-a-clean-install-of-windows-7/</link>
		<comments>http://daipratt.co.uk/software-to-put-on-a-clean-install-of-windows-7/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 14:55:03 +0000</pubDate>
		<dc:creator>David Pratt</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[software]]></category>
		<guid isPermaLink="false">http://daipratt.co.uk/?p=855</guid>
		<description><![CDATA[A list of software that you might find useful if you're a developer.]]></description>
			<content:encoded><![CDATA[<p>Having laboured under the fickle, unreliable Windows Vista (that came bundled with my new laptop) for the last 4 months, I was delighted to give the free Windows 7 upgrade that I was entitled to a go after it eventually dropped through the letterbox.  My excitement soon became frustration as the &#8220;straightforward&#8221; upgrade process proved to be anything but &#8211; software that I had on my machine was preventing the upgrade from completing successfully.  A clean factory restore of the original Windows Vista followed by a clean upgrade to Windows 7 did the trick, but at the expense of losing all of the installed applications.  And so I was presented with the task that every developer secretly enjoys but whines about, that of installing fresh copies all the applications that I frequently use. </p>
<p>Below is the list of applications that I loaded on to my new Windows 7 machine. Please let me know if you think my life could be improved by using anything not listed here!</p>
<p><i>(Note: Most of the applications that I&#8217;ve listed here can be auto-magically downloaded and installed with a tool called <a href="http://ninite.com">Ninite </a>. Handy.)</i></p>
<h6>Browsers</h6>
<ul>
<li><a href="http://www.mozilla-europe.org/en/firefox/" rel="nofollow">Firefox</a> &#8211; A fantastic nimble browser until you burden it under the weight of about <a href="#title_extensions">20 &#8220;must have&#8221; extensions&#8230;</a></li>
<li><a href="http://www.google.co.uk/chrome/" rel="nofollow">Google Chrome</a> &#8211; My new favourite web browser now that it supports <a href="https://chrome.google.com/extensions" title="Google Chrome extensions">extensions</a>.</li>
<li><a href="http://www.opera.com/" rel="nofollow">Opera</a> &#8211; Good and fast, but hardly ever use it for some reason.</li>
<li><a href="http://www.apple.com/safari/" rel="nofollow">Safari</a> &#8211; For testing.</li>
<li><a href="http://www.my-debugbar.com/wiki/IETester/HomePage">IETester</a> &#8211; A tool that allows you to see what your web pages look like in Internet Explorer versions 5.5 up to 8.</li>
</ul>
<h6>Coding</h6>
<ul>
<li><a href="http://www.eclipse.org" rel="nofollow">Eclipse</a> with <a href="http://www.eclipse.org/pdt/">PDT</a> &#8211; My IDE of choice, but still feels a bit clunky.</li>
<li><a href="http://www.editplus.com/">Editplus 3</a> with <a href="http://www.editplus.com/files.html">extras</a>. &#8211; I have been using this text editor for nearly as long as I have been coding websites.  I&#8217;ve tried many times to shift all my development work to a full <a href="#title_ide">IDE</a> such as Aptana or Eclipse, but I end up coming back to Editplus time and time again because of its speed and ease of use.</li>
<li><a href="http://api.jquery.com/browser/" rel="nofollow">jQuery API browser</a> &#8211; Much easier and quicker than navigating around the online API reference.</li>
<li><a href="http://winmerge.org/" rel="nofollow">Win Merge</a> &#8211; A great file compare tool. Integrates with Editplus nicely.</li>
</ul>
<h6 id="title_extensions">Firefox extensions</h6>
<ul>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/271" rel="nofollow">ColorZilla</a> &#8211; A colour picker for websites.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/10704" rel="nofollow">CSS Usage</a> &#8211; Allows you to scan multiple pages of a site to see which CSS rules are used.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/201" rel="nofollow">DownThemAll!</a> &#8211; A download manager.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/5392" rel="nofollow">Dust-Me Selectors</a> &#8211; Compare the DOM to the CSS and finds all unused CSS rules.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/1843" rel="nofollow">Firebug</a> &#8211;  Edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.</li>
<li><a href="http://www.firephp.org/" rel="nofollow">FirePHP</a> &#8211; FirePHP enables you to log to your Firebug Console using a simple PHP method call.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/748" rel="nofollow">Greasemonkey</a> &#8211; Allows you to customize the way a webpage displays using small bits of JavaScript.</li>
<li><a href="http://users.skynet.be/mgueury/mozilla/" rel="nofollow">HTML Validator</a> &#8211; Adds HTML validation inside Firefox and Mozilla. Aim for the green tick!</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/139" rel="nofollow">Image Zoom</a> &#8211; Allows you to zoom in on images on a web page.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/4788" rel="nofollow">KGen (for SEO)</a> &#8211; KGen is an extension that allows you to see what keywords are strong on visited web pages.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/3829" rel="nofollow">Live HTTP Headers</a> &#8211; If you haven&#8217;t got Fiddler 2 installed, then this is a basic alternative.</li>
<li><a href="http://tools.seobook.com/firefox/rank-checker/" rel="nofollow">Rank Checker (for SEO)</a> &#8211; Allows you to easily check your website rankings in Google, Yahoo, and Bing.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/1146" rel="nofollow">Screen Grab</a> &#8211; Allows you to take full web page screenshots, beyond the visible area.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/3036" rel="nofollow">SeoQuake (for SEO)</a> &#8211; A suite of SEO tools.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/5457" rel="nofollow">Shareaholic</a> &#8211; So useful it should be bundled with the browser as standard!</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/60" rel="nofollow">Web Developer</a> &#8211; Lost its crown as the most useful Firefox extension to Firebug, but still has some unique and useful features.</li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/5369" rel="nofollow">YSlow</a> &#8211; Analyzes web pages and why they&#8217;re slow based on rules for high performance web sites.</li>
</ul>
<h6>Image editing</h6>
<ul>
<li><a href="http://www.getpaint.net/" rel="nofollow">Paint.NET</a> &#8211; One up from MS Paint.  Handy for cropping images.</li>
<li><a href="http://toki-woki.net/p/Shrink-O-Matic/" rel="nofollow">Shrink-O-Matic</a> &#8211; For optimising images. It takes a bunch of images and squeezes every surples byte out of them.</li>
</ul>
<h6>Office applications</h6>
<ul>
<li><a href="http://freemind.sourceforge.net/" rel="nofollow">Free Mind</a> &#8211; A light-weight, free, mind-mapping tool.</li>
<li><a href="http://www.openoffice.org/" rel="nofollow">Open Office</a> &#8211; Not quite as slick as the latest version of MS Office, but still very impressive.</li>
<li><a href="http://office.microsoft.com/visio" rel="nofollow">Visio</a> &#8211; Still the best flow charting tool. Although there is an open-source one called <a href="http://projects.gnome.org/dia/">Dia</a> which is pretty good.</li>
</ul>
<h6>SEO tools</h6>
<ul>
<li><a href="http://home.snafu.de/tilman/xenulink.html">Xenu Link Sleuth</a> &#8211; An essential tool for understanding exactly how big sites hang together.  Great for finding obsolete and deadlinks.</li>
</ul>
<h6>Utilities and tools</h6>
<ul>
<li><a href="http://www.7-zip.org/" rel="nofollow">7zip</a> &#8211; The best free, multi-format file compression utility.</li>
<li><a href="http://technet.microsoft.com/en-us/sysinternals/bb963902.aspx" rel="nofollow">AutoRuns</a> &#8211; Offers a load more options over the Windows msconfig tool.</li>
<li><a href="http://www.ccleaner.com/" rel="nofollow">CCleaner</a> &#8211; Crap cleaner</li>
<li><a href="http://www.piriform.com/defraggler/download" rel="nofollow">Defraggler</a> &#8211; Allegedly better than the disk defragmenter bundled with Windows.</li>
<li><a href="http://www.stardock.com/products/fences/">Fences</a> &#8211; Desktop organiser. Wicked.</li>
<li><a href="http://www.fiddler2.com/" rel="nofollow">Fiddler 2</a> &#8211; This tool is amazing. What it does is watch all of the HTTP calls that are made when loading a webpage and record every detail about it, but what makes it particularly powerful is that you can set up a range of filters to record only what your interested in.  Essential for debugging and testing.</li>
<li><a href="http://filezilla-project.org/" rel="nofollow">File Zilla</a> &#8211; FTP client</li>
<li><a href="http://greenshot.sourceforge.net/" rel="nofollow">Greenshot</a> &#8211; For taking all kinds of screenshots. Way better than the classic combo of hitting the PrtScn button and pasting into MS Paint!</li>
<li><a href="http://www.httpwatch.com/" rel="nofollow">HTTP Watch</a> &#8211; Similar to Fiddler 2, but a bit more clunky!</li>
<li><a href="http://java.com/en/download/index.jsp" rel="nofollow">Java Runtime Environment</a> &#8211; Download it before you&#8217;re prompted to!</li>
<li><a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="nofollow">Process Explorer</a> &#8211; Shows you information about which handles and DLLs processes have opened or loaded.</li>
<li><a href="http://www.piriform.com/recuva/download" rel="nofollow">Recuva</a> &#8211; Enables you to recover files that you have mistakenly deleted.</li>
<li><a href="http://www.revouninstaller.com/" rel="nofollow">Revo Uninstaller</a> &#8211; Removes every trace of a program.</li>
<li><a href="http://www.roboform.com/download.html" rel="nofollow">Robo Form</a> &#8211; Enables online forms to be auto filled.</li>
<li><a href="http://www.skype.com/intl/en-gb/download/skype/windows/?c=204" rel="nofollow">Skype</a> &#8211; Messenger and voice communicator.</li>
<li><a href="http://www.safer-networking.org/en/download/index.html" rel="nofollow">Spybot &#8211; Search and Destroy</a> &#8211; Removes spyware and other sorts of undesirables from your PC.</li>
<li><a href="http://tortoisesvn.tigris.org/" rel="nofollow">Subversion with Tortoise</a> &#8211; I&#8217;m familiar with this, but many of the folk in the know seem to be making the switch to GIT these days. New years resolution, learn GIT.</li>
<li><a href="http://www.codesector.com/teracopy.php" rel="nofollow">TeraCopy</a> &#8211; The built in windows copy and move commands + 1.</li>
<li><a href="http://www.tweetdeck.com/" rel="nofollow">Tweet Deck</a> &#8211; Plugin in your Twitter, Facebook and LinkedIn account details, and you never have to visit the actual sites again.</li>
<li><a href="http://www.videolan.org/" rel="nofollow">VideoLAN</a> &#8211; Plays just about every video format that has ever existed, probably even some that don&#8217;t as well&#8230;</li>
<li><a href="http://windirstat.info/" rel="nofollow">WinDirStat</a> &#8211; Helps you understand visually exactly what is hogging all your hard disk space.</li>
<li><a href="http://www.httrack.com/" rel="nofollow">WinHTTrack</a> &#8211; For copying an entire website.</li>
<li><a href="http://www.wingrep.com/" rel="nofollow">Windows Grep</a> &#8211; The best find and replace tool that I&#8217;ve come across.</li>
</ul>
<h6>Music</h6>
<p>Where would a developer be without his tunes?</p>
<ul>
<li><a href="http://www.apple.com/uk/itunes/download/" rel="nofollow">iTunes</a> &#8211; I use it to get Podcasts from the iTunes store.</li>
<li><a href="http://getsongbird.com/" rel="nofollow">Songbird</a> &#8211; Similar to iTunes, but allows you to install add-ons in a similar fashion to Firefox.</li>
<li><a href="http://www.spotify.com/en/download/windows/" rel="nofollow">Spotify</a> &#8211; Amazing.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://daipratt.co.uk/software-to-put-on-a-clean-install-of-windows-7/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
