<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Magp.ie</title>
	<atom:link href="http://magp.ie/feed/" rel="self" type="application/rss+xml" />
	<link>http://magp.ie</link>
	<description>A nest for the random, shiny, online tidbits I stumble across...</description>
	<lastBuildDate>Tue, 31 Jan 2012 19:01:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='magp.ie' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/061e340c5da13b5a41ae8016bee03aa8?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Magp.ie</title>
		<link>http://magp.ie</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://magp.ie/osd.xml" title="Magp.ie" />
	<atom:link rel='hub' href='http://magp.ie/?pushpress=hub'/>
		<item>
		<title>Uninstall and Remove Xcode Completely</title>
		<link>http://magp.ie/2011/12/12/uninstall-and-remove-xcode-completely/</link>
		<comments>http://magp.ie/2011/12/12/uninstall-and-remove-xcode-completely/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 17:12:53 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Guides]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[max osx]]></category>
		<category><![CDATA[remove]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[uninstall]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=688</guid>
		<description><![CDATA[If you are in a position where you want to remove the colossus that is Xcode, here is the terminal command to use. sudo /Developer/Library/uninstall-devtools –mode=all In my case, I was using migration assistant to migrate my applications and user &#8230; <a href="http://magp.ie/2011/12/12/uninstall-and-remove-xcode-completely/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=688&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you are in a position where you want to remove the colossus that is Xcode, here is the terminal command to use.</p>
<p><code>sudo /Developer/Library/uninstall-devtools –mode=all</code></p>
<p>In my case, I was using <a href="http://support.apple.com/kb/HT4413" title="Super Time Saver!" target="_blank">migration assistant</a> to migrate my applications and user account to a new laptop. My older laptop had an older version of Xcode that I didn&#8217;t want included in the migration and as it is so big, I didn&#8217;t want to take the chance.</p>
<p><a href="http://pushkararora.com/how-to/how-to-uninstall-xcode-completely/" title="Thanks!" target="_blank">Kudos to Pushkararora.com</a></p>
<br />Filed under: <a href='http://magp.ie/category/guides/'>Guides</a> Tagged: <a href='http://magp.ie/tag/bash/'>bash</a>, <a href='http://magp.ie/tag/max-osx/'>max osx</a>, <a href='http://magp.ie/tag/remove/'>remove</a>, <a href='http://magp.ie/tag/terminal/'>terminal</a>, <a href='http://magp.ie/tag/uninstall/'>uninstall</a>, <a href='http://magp.ie/tag/xcode/'>xcode</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/688/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/688/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/688/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/688/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/688/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/688/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/688/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/688/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/688/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/688/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/688/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/688/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/688/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/688/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=688&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/12/12/uninstall-and-remove-xcode-completely/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>HTML5 Data attributes in HTML and jQuery</title>
		<link>http://magp.ie/2011/11/29/html5-data-attributes-in-html-and-jquery/</link>
		<comments>http://magp.ie/2011/11/29/html5-data-attributes-in-html-and-jquery/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 18:18:41 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Guides]]></category>
		<category><![CDATA[data attribute]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[json_encode]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=667</guid>
		<description><![CDATA[When writing javascript, it is often necessary to include metadata in the HTML markup, to help define some element or behaviour. There are common options available. You can use hidden inputs and/or standard attributes like class or title to store &#8230; <a href="http://magp.ie/2011/11/29/html5-data-attributes-in-html-and-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=667&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When writing javascript, it is often necessary to include metadata in the HTML markup, to help define some element or behaviour. There are common options available. You can use hidden inputs and/or standard attributes like <code>class</code> or <code>title</code> to store this metadata. However with HTML5&#8242;s data attribute, storing and parsing this data has become a whole lot easier and cleaner.</p>
<p>The syntax is straightforward. Any attribute prefixed with <code>data-</code> will be treated as data storage.</p>
<p><pre class="brush: xml;">&lt;div class=&quot;test&quot; data-foo=&quot;bar&quot;&gt;&lt;/div&gt;</pre></p>
<p>jQuery accesses this data like so&#8230;<br />
<pre class="brush: jscript;">var data = $( 'div.test' ).data( 'foo' ); // returns bar</pre></p>
<p>Support for the data attribute has been added since jQuery <a href="http://blog.jquery.com/2010/10/16/jquery-143-released/" title="version 1.4.3" target="_blank">version 1.4.3</a>. jQuery&#8217;s implementation is smart enough that it can parse the attribute easily and even determine the correct data type used.</p>
<p>What I have found really useful is the fact that the jQuery can parse JSON syntax and return a JSON object. This makes passing data in PHP trivial, using the <a href="http://php.net/manual/en/function.json-encode.php" title="json_encode" target="_blank">json_encode</a> method. We also need to use <a href="http://php.net/manual/en/function.htmlspecialchars.php" title="Escape quotes" target="_blank">htmlspecialchars</a> method to escape or convert any quotes in the JSON string.<br />
<pre class="brush: php;">
&lt;?php  
$test = array( 'row' =&gt; 1, 'col' =&gt; 6, 'color' =&gt; 'pink' ); //create array of data you want to pass to jquery
$test = json_encode( $test ); //convert array to a JSON string
$test = htmlspecialchars( $test, ENT_QUOTES ); //convert any quotes into HTML entities so JSON string behaves as a proper HTML attribute.
?&gt;
&lt;div class=&quot;test&quot; data-complex=&quot;&lt;?php echo $test ; ?&gt;&quot;&gt;&lt;/div&gt;</pre></p>
<p>The jQuery parses the JSON string like so&#8230;<br />
<pre class="brush: jscript;">var test = $( 'div.test' ).data( 'complex' ); // returns JSON Object

console.log( test.color ); // outputs pink!</pre></p>
<p>Important to note that this method is also backward compatible with older browsers, so there is no excuse not to give it a go!</p>
<br />Filed under: <a href='http://magp.ie/category/code/'>Code</a>, <a href='http://magp.ie/category/guides/'>Guides</a> Tagged: <a href='http://magp.ie/tag/data-attribute/'>data attribute</a>, <a href='http://magp.ie/tag/html5/'>html5</a>, <a href='http://magp.ie/tag/jquery/'>jQuery</a>, <a href='http://magp.ie/tag/json/'>json</a>, <a href='http://magp.ie/tag/json_encode/'>json_encode</a>, <a href='http://magp.ie/tag/php/'>php</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/667/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=667&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/11/29/html5-data-attributes-in-html-and-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>iWorks 09 DVD installation problems</title>
		<link>http://magp.ie/2011/10/18/iworks-09-dvd-installation-problems/</link>
		<comments>http://magp.ie/2011/10/18/iworks-09-dvd-installation-problems/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 18:14:20 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Guides]]></category>
		<category><![CDATA[Mac OSX]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[iWorks]]></category>
		<category><![CDATA[installation]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=658</guid>
		<description><![CDATA[I&#8217;m pretty sure this will help nobody and it&#8217;s unlikely I will have the same problem again but just in case&#8230; If you are having difficulty installing iWorks 09 from the DVD, then this is what I went through to &#8230; <a href="http://magp.ie/2011/10/18/iworks-09-dvd-installation-problems/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=658&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m pretty sure this will help nobody and it&#8217;s unlikely I will have the same problem again but just in case&#8230;</p>
<p>If you are having difficulty installing iWorks 09 from the DVD, then this is what I went through to finally get it to work.<br />
<span id="more-658"></span></p>
<ul>
<li>Bought iWorks 09 from the Apple store, and they sent the software on a DVD <em>(how retro!)</em>.</li>
<li>Tried to install the software, but each time I was asked for a serial number or to install from the DVD.</li>
<li>No serial number could be found on box, inside box, on disc etc. Confusion reigned.</li>
<li>Figured as a trial version of iWorks was installed that perhaps my Mac was also confused.</li>
<li>Removed the application from the <code>Applications</code> directory and removed any iWorks cache files from <code>Library/Caches</code> directory.</li>
<li>Reinstalled and this time it <strong>crashed</strong> when loading&#8230; sigh.</li>
<li>After a long search, I found a full list of what I need to delete to make sure no trace of iWorks exist <em>(below)</em>.</li>
<li>Restarted Mac, reinstalled and registered, I&#8217;m now good to go.</li>
</ul>
<p><code>/Macintosh HD/Applications/iWork '09 (folder)<br />
/Macintosh HD/Library/Receipts/iWork09* (any file in this folder that refers to iWork)<br />
/Macintosh HD/Library/Preferences/com.apple.iWork09.plist<br />
/Macintosh HD/Library/Preferences/com.apple.iWork09.Installer.plist<br />
/Macintosh HD/Library/Application Support/iWork '09 (folder)<br />
/Macintosh HD/Library/Application Support/iWork (folder--if present)<br />
/username/Library/Application Support/iWork (folder)<br />
/username/Library/Preferences/ByHost/com.apple.iWork.Pages.NUMBER.plist<br />
/username/Library/Preferences/ByHost/com.apple.iWork.Keynote.NUMBER.plist<br />
/username/Library/Preferences/ByHost/com.apple.iWork.Numbers.NUMBER.plist<br />
/username/Library/Preferences/ByHost/com.apple.iWork.NUMBER.plist<br />
/username/Library/Preferences/com.apple.iWork.Pages.plist<br />
/username/Library/Preferences/com.apple.iWork.Keynote.plist<br />
/username/Library/Preferences/com.apple.iWork.Numbers.plist<br />
/username/Library/Preferences/com.apple.iWork.plist</code></p>
<p>[<strong>NOTE</strong>:: Not sure if it's relevant, but I used <a href="http://www.mactricksandtips.com/2008/07/easily-delete-files-using-terminal.html" title="Delete files with terminal" target="_blank">terminal to delete these files</a> as I didn't trust Mac Finder at this stage!]</p>
<br />Filed under: <a href='http://magp.ie/category/guides/'>Guides</a> Tagged: <a href='http://magp.ie/tag/installation/'>installation</a>, <a href='http://magp.ie/tag/iworks/'>iWorks</a>, <a href='http://magp.ie/tag/mac-osx/'>Mac OSX</a>, <a href='http://magp.ie/tag/software/'>software</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/658/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/658/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/658/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/658/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/658/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/658/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/658/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/658/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/658/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/658/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/658/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/658/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/658/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/658/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=658&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/10/18/iworks-09-dvd-installation-problems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>Filter IP addresses with PHP</title>
		<link>http://magp.ie/2011/09/01/filter-ip-addresses-with-php/</link>
		<comments>http://magp.ie/2011/09/01/filter-ip-addresses-with-php/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 19:33:47 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[blacklist]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[IP address]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regular expression]]></category>
		<category><![CDATA[whitelist]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=642</guid>
		<description><![CDATA[You may at some stage want to filter an online service based on IP address. In other words, you may want to block or grant access to a request based on their IP address. This can be handled in PHP &#8230; <a href="http://magp.ie/2011/09/01/filter-ip-addresses-with-php/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=642&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You may at some stage want to filter an online service based on IP address. In other words, you may want to block or grant access to a request based on their IP address. This can be handled in PHP by doing the following.</p>
<p>If you have the IP addresses, then it is trivial.</p>
<p><pre class="brush: php;">

//First check IP address is valid
$request_ip = $_SERVER['REMOTE_ADDR'];

if ( !preg_match( &quot;/^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/&quot;, $request_ip ) )
    return false;

$blacklist = array(
'111.222.12.11',
'222.111.21.22',
'221.112.11.12'
);

//check that ip is not blacklisted
if ( in_array( $request_ip, $blacklist ) )
    return false;

</pre></p>
<p>If you want to include a range of IP addresses, best to use a regular expression.</p>
<p><pre class="brush: php;">

$blacklist_ip_range = array(
    '/^122\.244\.(\d+)\.(\d+)/', //for IP address in the range 122.244.0.0 - 122.244.255.255
    '/^123\.(\d+)\.(\d+)\.(\d+)/', //for IP address in the range 123.0.0.0 - 123.255.255.255
);

foreach( $blacklist_ip_range as $ip ) {
    if( preg_match( $ip, $request_ip ) )
       	return false;
    }

</pre></p>
<p>If you have a better solution, then please let me know.</p>
<br />Filed under: <a href='http://magp.ie/category/code/'>Code</a> Tagged: <a href='http://magp.ie/tag/blacklist/'>blacklist</a>, <a href='http://magp.ie/tag/filter/'>filter</a>, <a href='http://magp.ie/tag/ip-address/'>IP address</a>, <a href='http://magp.ie/tag/php/'>php</a>, <a href='http://magp.ie/tag/regular-expression/'>regular expression</a>, <a href='http://magp.ie/tag/whitelist/'>whitelist</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/642/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=642&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/09/01/filter-ip-addresses-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>Change Float style with Javascript</title>
		<link>http://magp.ie/2011/08/21/change-float-style-with-javascript/</link>
		<comments>http://magp.ie/2011/08/21/change-float-style-with-javascript/#comments</comments>
		<pubDate>Sun, 21 Aug 2011 19:58:54 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[style]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=639</guid>
		<description><![CDATA[If you would like to change the float style of some element using javascript, then use the following. Filed under: Code Tagged: dom, javascript, style<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=639&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you would like to change the float style of some element using javascript, then use the following.</p>
<p><pre class="brush: jscript;">

var element = document.getElementById( 'some_element_id' );

element.style.cssFloat = 'left';

</pre></p>
<br />Filed under: <a href='http://magp.ie/category/code/'>Code</a> Tagged: <a href='http://magp.ie/tag/dom/'>dom</a>, <a href='http://magp.ie/tag/javascript/'>javascript</a>, <a href='http://magp.ie/tag/style/'>style</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/639/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/639/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/639/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=639&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/08/21/change-float-style-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>Mac mail not sending Gmail email</title>
		<link>http://magp.ie/2011/08/10/mac-mail-not-sending-gmail-email/</link>
		<comments>http://magp.ie/2011/08/10/mac-mail-not-sending-gmail-email/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 09:49:24 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Guides]]></category>
		<category><![CDATA[connection doctor]]></category>
		<category><![CDATA[Gmail]]></category>
		<category><![CDATA[IMAP]]></category>
		<category><![CDATA[mac mail]]></category>
		<category><![CDATA[outgoing server]]></category>
		<category><![CDATA[SMTP]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=613</guid>
		<description><![CDATA[Infrequently my Mac mail would be rendered incapable of sending email. It appears the Mac mail client could not connect to the outgoing Gmail SMTP server, smtp.gmail.com, then after a few hours the connection would be restored automatically. I assumed &#8230; <a href="http://magp.ie/2011/08/10/mac-mail-not-sending-gmail-email/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=613&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Infrequently my Mac mail would be rendered incapable of sending email.</p>
<p>It appears the Mac mail client could not connect to the outgoing Gmail SMTP server, <code>smtp.gmail.com</code>, then after a few hours the connection would be restored automatically.</p>
<p>I <em>assumed</em> that my settings must be fine as they remained constant, it <em>must</em> be a problem on the Gmail servers end, but it was happening too often for that to be plausible.</p>
<p><span id="more-613"></span></p>
<p>So I used the <a title="Connection Doctor" href="http://docs.info.apple.com/article.html?path=Mail/2.0/en/ml1098.html" target="_blank">connection doctor</a> to see what was happening under the hood.</p>
<p>To access the connection doctor, go to the <code>Windows-&gt;Connection Doctor</code> option in your Mac mail menu.</p>
<p>First thing I noticed was that I was trying to connect to a bunch of different outgoing servers. This is because I had set up separate email accounts (another Gmail and Yahoo mail account). It couldn&#8217;t connect to any of them, which was suspicious in itself.</p>
<p>Slash and burn time. <a title="Remove SMTP servers" href="http://email.about.com/od/macosxmailtips/qt/How_to_Delete_an_Outgoing_Mail_Server_in_Mac_OS_X_Mail.htm" target="_blank">I edited my SMTP servers list and I removed the 2 other outgoing servers</a> that I never used, leaving me the one server that I always tried to use.</p>
<p>I ran the connection doctor again and watched the output window.</p>
<p>Failed to connect again, bummer. But I noticed it was using port 25 when trying to connect. That&#8217;s not right I thought, it should use port 465 if it&#8217;s using SSL. <a title="Gmail server settings" href="https://mail.google.com/support/bin/answer.py?hl=en&amp;answer=13287" target="_blank">Gmail expects you to use SSL, when connecting and to use port 465</a>.</p>
<p>So I edited the remaining outgoing server connection settings by doing the following.</p>
<ul>
<li>Went back to editing SMTP list (described above)</li>
<li>Clicked on remaining server</li>
<li>Clicked on Advanced Tab</li>
</ul>
<p>Instead of choosing &#8216;<strong>Use default posts</strong>&#8216;, I specified a custom port <strong>465</strong> and made sure the &#8216;<strong>Use Secure Sockets Layer (SSL)</strong>&#8216; checkbox was checked.</p>
<p>Saved settings.</p>
<p><img class="alignnone" title="edit advanced outgoing server settings" src="https://img.skitch.com/20110729-kgj2ex4j7j3hwinry4ppcbssq9.jpg" alt="edit advanced outgoing server settings" width="388" height="206" /></p>
<p>Returned to connection doctor. This time I again failed to connect (boo!) but I got a different error (yay!). Authentication failed. Huh? I didn&#8217;t change anything, how did that happen&#8230; <em>hmm</em>.</p>
<p>Now I returned to edit the remaining outgoing server. Made sure the Password option was set and I re-entered my account username &amp; password.</p>
<p>Saved settings again.</p>
<p>At this point, I was a little exasperated so I also tried unlocking my Gmail account. I was aware that Gmail lock accounts if they detect unusual behavior, so I made sure my Gmail account was unlocked by going to <a title="Unlock Gmail Account" href="https://www.google.com/accounts/UnlockCaptcha" target="_blank">https://www.google.com/accounts/UnlockCaptcha</a>.</p>
<p>Tried the connection doctor again and sweet baby zeus it connected.</p>
<p>Unfortunately, I cannot say for certain what was the issue. I had tried unlocking the account before I started this and it didn&#8217;t connect, so it wasn&#8217;t just that.</p>
<p>Anyway, thought I&#8217;d post what I tried, might help someone&#8230; might also waste 10 minutes of some punter&#8217;s life!</p>
<br />Filed under: <a href='http://magp.ie/category/guides/'>Guides</a> Tagged: <a href='http://magp.ie/tag/connection-doctor/'>connection doctor</a>, <a href='http://magp.ie/tag/gmail/'>Gmail</a>, <a href='http://magp.ie/tag/imap/'>IMAP</a>, <a href='http://magp.ie/tag/mac-mail/'>mac mail</a>, <a href='http://magp.ie/tag/outgoing-server/'>outgoing server</a>, <a href='http://magp.ie/tag/smtp/'>SMTP</a>, <a href='http://magp.ie/tag/ssl/'>SSL</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/613/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/613/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/613/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/613/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/613/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/613/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/613/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/613/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/613/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/613/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/613/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/613/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/613/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/613/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=613&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/08/10/mac-mail-not-sending-gmail-email/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>

		<media:content url="https://img.skitch.com/20110729-kgj2ex4j7j3hwinry4ppcbssq9.jpg" medium="image">
			<media:title type="html">edit advanced outgoing server settings</media:title>
		</media:content>
	</item>
		<item>
		<title>How to check if an element exists in jQuery</title>
		<link>http://magp.ie/2011/08/03/how-to-check-if-an-element-exists-in-jquery/</link>
		<comments>http://magp.ie/2011/08/03/how-to-check-if-an-element-exists-in-jquery/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 20:02:56 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[exists]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[selector]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=606</guid>
		<description><![CDATA[Briefer again&#8230; via http://aaronrussell.co.uk/legacy/check-if-an-element-exists-using-jquery/ Filed under: Code Tagged: exists, jQuery, selector<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=606&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><pre class="brush: jscript;">
if ( $(&quot;#mydiv&quot;).length ){
  // do something here
}
</pre></p>
<p>Briefer again&#8230;</p>
<p><pre class="brush: jscript;">
if ( $(&quot;#mydiv&quot;)[0] ){
  // do something here
}
</pre></p>
<p>via <a title="check-if-an-element-exists-using-jquery" href="http://aaronrussell.co.uk/legacy/check-if-an-element-exists-using-jquery/" target="_blank">http://aaronrussell.co.uk/legacy/check-if-an-element-exists-using-jquery/</a></p>
<br />Filed under: <a href='http://magp.ie/category/code/'>Code</a> Tagged: <a href='http://magp.ie/tag/exists/'>exists</a>, <a href='http://magp.ie/tag/jquery/'>jQuery</a>, <a href='http://magp.ie/tag/selector/'>selector</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/606/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=606&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/08/03/how-to-check-if-an-element-exists-in-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>Faster Javascript Trim</title>
		<link>http://magp.ie/2011/07/28/faster-javascript-trim/</link>
		<comments>http://magp.ie/2011/07/28/faster-javascript-trim/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 21:25:02 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[fast]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[trim]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=592</guid>
		<description><![CDATA[Want the best way to trim a sting in javascript? A while ago, I came across a post on such a subject. It was written a few years ago but it&#8217;s still as relevant and useful as ever. http://blog.stevenlevithan.com/archives/faster-trim-javascript  The &#8230; <a href="http://magp.ie/2011/07/28/faster-javascript-trim/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=592&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Want the best way to trim a sting in javascript?</p>
<p>A while ago, I came across a post on such a subject. It was written a few years ago but it&#8217;s still as relevant and useful as ever.</p>
<p><span id="more-592"></span></p>
<p><a title="faster-trim-javascript " href="http://blog.stevenlevithan.com/archives/faster-trim-javascript" target="_blank">http://blog.stevenlevithan.com/archives/faster-trim-javascript </a></p>
<p>The author basically compares a bunch of different methods to trim a string across the 2 big browsers at the time, Internet Explorer and Firefox, and figures out the fastest way of doing it.</p>
<p>For more detail, follow the link above, otherwise, here is the conclusion.</p>
<p><strong>Fastest trim method for normal length strings</strong></p>
<p><pre class="brush: jscript;">
return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
</pre></p>
<p><strong>Fastest trim method for super long strings</strong></p>
<p><pre class="brush: jscript;">
function trim11 (str) {
	str = str.replace(/^\s+/, '');
	for (var i = str.length - 1; i &gt;= 0; i--) {
		if (/\S/.test(str.charAt(i))) {
			str = str.substring(0, i + 1);
			break;
		}
	}
	return str;
}
</pre></p>
<p><strong>Note</strong>: For the super geeks out there, <a title="Trim testing" href="http://jsperf.com/mega-trim-test" target="_blank">this site will show you and allow you to test what is the fastest trim method on a particular browser&#8230; enjoy</a>!</p>
<br />Filed under: <a href='http://magp.ie/category/code/'>Code</a> Tagged: <a href='http://magp.ie/tag/fast/'>fast</a>, <a href='http://magp.ie/tag/javascript/'>javascript</a>, <a href='http://magp.ie/tag/optimize/'>optimize</a>, <a href='http://magp.ie/tag/regex/'>regex</a>, <a href='http://magp.ie/tag/trim/'>trim</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/592/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/592/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/592/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=592&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/07/28/faster-javascript-trim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>Find process using port number in Bash</title>
		<link>http://magp.ie/2011/04/19/find-process-using-port-number-in-bash/</link>
		<comments>http://magp.ie/2011/04/19/find-process-using-port-number-in-bash/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 08:37:03 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Guides]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[killall]]></category>
		<category><![CDATA[lsof command]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=575</guid>
		<description><![CDATA[Something that has bugged me recently is that when I go to proxy on a particular port, the port is already in use and I get the following error. bind: Address already in use channel_setup_fwd_listener: cannot listen to port: 8090 &#8230; <a href="http://magp.ie/2011/04/19/find-process-using-port-number-in-bash/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=575&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Something that has bugged me recently is that when I go to proxy on a particular port, the port is already in use and I get the following error.<br />
<code><br />
bind: Address already in use<br />
channel_setup_fwd_listener: cannot listen to port: 8090<br />
Could not request local forwarding.<br />
</code><br />
<span id="more-575"></span><br />
So I had a quick look to find out how to locate the process hogging the port. All I need to do is use the <a href="http://www.catonmat.net/blog/unix-utilities-lsof/" target="_blank">lsof command</a>.</p>
<p><code>lsof -i:8090</code></p>
<p>This command returns a list of open processes on this port.</p>
<p>Something like&#8230;<br />
<code><br />
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME<br />
ssh 75782 eoin 5u IPv6 0x01c1c234 0t0 TCP localhost:8090 (LISTEN)<br />
</code></p>
<p>To free the port, kill the process using it&#8230;<br />
<code>kill 75782</code></p>
<p>&nbsp;</p>
<p>[<strong>Update</strong>: Simpler solution found]</p>
<p>Easier to kill all ssh processes and restart them (if you use <a title="Terminal Aliases" href="http://magp.ie/2010/02/11/terminal-aliases/" target="_blank">terminal aliases</a>!), since in my case it is always an ssh process that is hogging the port.<br />
<code></code></p>
<p><code>killall ssh</code></p>
<br />Filed under: <a href='http://magp.ie/category/guides/'>Guides</a> Tagged: <a href='http://magp.ie/tag/bash/'>bash</a>, <a href='http://magp.ie/tag/killall/'>killall</a>, <a href='http://magp.ie/tag/lsof-command/'>lsof command</a>, <a href='http://magp.ie/tag/terminal/'>terminal</a>, <a href='http://magp.ie/tag/unix/'>Unix</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/575/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/575/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/575/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=575&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/04/19/find-process-using-port-number-in-bash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>Tidy assignments in Coda and TextWrangler</title>
		<link>http://magp.ie/2011/03/16/tidy-assignments-in-coda-and-textwrangler/</link>
		<comments>http://magp.ie/2011/03/16/tidy-assignments-in-coda-and-textwrangler/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 08:40:28 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[assignments]]></category>
		<category><![CDATA[coda]]></category>
		<category><![CDATA[indentation]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[textwrangler]]></category>
		<category><![CDATA[tidy code]]></category>
		<category><![CDATA[Unix filter]]></category>
		<category><![CDATA[WordPress coding standards]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=529</guid>
		<description><![CDATA[I have written a simple tool to tidy assignments. It basically takes a group of assignments and uses spaces to make the code more readable. This tool will help code meet the indentation rules in the WordPress coding standards. If &#8230; <a href="http://magp.ie/2011/03/16/tidy-assignments-in-coda-and-textwrangler/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=529&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have written a simple tool to tidy assignments. It basically takes a group of assignments and uses spaces to make the code more readable.</p>
<p>This tool will help code meet the indentation rules in the <a href="http://codex.wordpress.org/WordPress_Coding_Standards#Indentation"> WordPress coding standards</a>.<br />
<span id="more-529"></span><br />
If you have a group of basic assignments like&#8230;</p>
<p><pre class="brush: php;">
$variable1 = 0;
$long_variable2 = 123213123;
$short = 'test';
$s = 'test2';
</pre></p>
<p>This tool will space them so&#8230;</p>
<p><pre class="brush: php;">
$variable1      = 0;
$long_variable2 = 123213123;
$short          = 'test';
$s              = 'test2';
</pre></p>
<p>It will also work associative arrays&#8230;</p>
<p><pre class="brush: php;">
array(
'magpie' =&gt; 0,
'blog' =&gt; 1,
'random' =&gt; 2,
'too_long_string' =&gt; 3
);
</pre></p>
<p>&#8230; with spacing &#8230;</p>
<p><pre class="brush: php;">
array(
'magpie'          =&gt; 0,
'blog'            =&gt; 1,
'random'          =&gt; 2,
'too_long_string' =&gt; 3
);
</pre></p>
<p>The tool is available as a Coda plugin and a TextWrangler UNIX filter.</p>
<h4>For Coda</h4>
<ul>
<li><a href="http://dl.dropbox.com/u/5756988/tidy-assignment.codaplugin.zip">Download the Coda plugin</a></li>
<li>Extract the zip file and double-click the <strong>tidy-assignment.codaplugin</strong> file</li>
<li>Select code, right-click, goto Plug-ins-&gt;Tidy Assignment</li>
</ul>
<p><img src="http://blogalhost.files.wordpress.com/2011/03/highlight.png?w=450&#038;h=261" alt="Highlight and select Tidy Assignment plugin" title="highlight-code" width="450" height="261" class="alignnone size-full wp-image-542" /></p>
<p>To remove/uninstall the plugin;</p>
<ul>
<li>Close Coda</li>
<li>Goto <code>[your_home_folder]/Library/Application Support/Coda/Plug-ins/</code></li>
<li>Delete the file tidy-assignment.codaplugin</li>
</ul>
<h4>For TextWrangler</h4>
<ul>
<li>Open TextWrangler and open a new text file.</li>
<li>Copy and paste the code below into this file.</li>
<p><pre class="brush: php;">
#!/usr/bin/php
&lt;?php

if ( !isset( $_SERVER['argv'] ) &amp;&amp; !isset( $_SERVER['argv'][1] ) )
	die();

$fc    = file_get_contents( $_SERVER['argv'][1] );
$lines = explode( &quot;\n&quot;, $fc );
$clean = array();
$assoc = false;

$longest_line_index  = 0;
$longest_line_length = 0;

foreach ( $lines as $key =&gt; $line ) {
	//remove whitspace
	$line = preg_replace( '/\s\s+/', ' ', trim( $line ) );
	$parts = array();
	
	if ( mb_stripos( $line, '=&gt;' ) !== FALSE ) {
		$parts = explode( &quot;=&gt;&quot;, $line );
		$assoc = true;
	}
	elseif ( mb_stripos( $line, '=' ) !== FALSE ) {
		$parts = explode( &quot;=&quot;, $line );
	}

	if ( !empty( $parts ) &amp;&amp; mb_strlen( $parts[0] ) &gt; $longest_line_length ) {
		$longest_line_index = $key;
		$longest_line_length = mb_strlen( $parts[0] );
	}
	
	if ( mb_strlen( $line ) &gt; 0 )
		$clean[$key] = $line;
}

$longest_line = $clean[$longest_line_index];
$operator = $assoc ? '=&gt;' : '=' ;

//add spaces to line
if ( mb_stripos( $longest_line, $operator ) !== FALSE ) {
	$parts = explode( $operator, $longest_line );
	$longest_line = sprintf( &quot;%s %s %s&quot;, trim( $parts[0] ), $operator, trim( $parts[1] ) );
}
else {
	$longest_line = sprintf( &quot;%s&quot;, trim( $longest_line ) );
}

//now get the position of equals
$pos = mb_stripos( $longest_line, $operator );
if ( $pos === FALSE )
	$pos = mb_strlen( $longest_line );

foreach ( $clean as $key =&gt; &amp;$line ) {
	if ( $key == $longest_line_index )
		$line = $longest_line;
	elseif ( mb_stripos( $line, $operator ) !== FALSE ) {
		$spaces = ' ';
		$parts = explode( $operator, $line );
		if ( !empty( $parts ) )
			while ( mb_stripos( $line, $operator ) &lt; $pos ) {
				$line = sprintf( &quot;%s%s%s %s&quot;, trim( $parts[0] ), $spaces, $operator, trim( $parts[1] ) );
				$spaces .= &quot; &quot;;
			}
	}
	else {
		$line = sprintf( &quot;%s&quot;, trim( $line ) );
	}
}

echo implode( &quot;\n&quot;, $clean );
</pre></p>
<li>Save the file, something like <strong>Tidy Assignment.php</strong>, in the Filters folder.</li>
<li>You can find the filters folder by going to the <em>#! menu</em> and go to the <em>Unix Filters</em> sub-menu, and select the <em>Open Filters Folder</em>, like below.<br />
<img class="alignnone size-full wp-image-98" title="Scripts menu" src="http://blogalhost.files.wordpress.com/2010/02/picture-7.png?w=450" alt=""   /></p>
<li>Now anytime you want to tidy assignments, just go to this menu and select the <strong>Tidy Assignment</strong> script.</li>
<p><img src="http://blogalhost.files.wordpress.com/2011/03/tidy-assignment-textwrangler.png?w=450&#038;h=373" alt="Select tidy assignment script in TextWrangler" title="tidy-assignment-textwrangler" width="450" height="373" class="alignnone size-full wp-image-544" />
</ul>
<p>First time I <a href="http://www.panic.com/coda/developer/">created a coda plugin</a> and I am surprised how simple it is. I may experiment with this in the future if I can think of anything useful.</p>
<br />Filed under: <a href='http://magp.ie/category/code/'>Code</a> Tagged: <a href='http://magp.ie/tag/assignments/'>assignments</a>, <a href='http://magp.ie/tag/coda/'>coda</a>, <a href='http://magp.ie/tag/indentation/'>indentation</a>, <a href='http://magp.ie/tag/plugin/'>plugin</a>, <a href='http://magp.ie/tag/textwrangler/'>textwrangler</a>, <a href='http://magp.ie/tag/tidy-code/'>tidy code</a>, <a href='http://magp.ie/tag/unix-filter/'>Unix filter</a>, <a href='http://magp.ie/tag/wordpress-coding-standards/'>WordPress coding standards</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/529/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/529/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/529/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=529&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/03/16/tidy-assignments-in-coda-and-textwrangler/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<georss:point>53.734700 -8.991280</georss:point>
		<geo:lat>53.734700</geo:lat>
		<geo:long>-8.991280</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>

		<media:content url="http://blogalhost.files.wordpress.com/2011/03/highlight.png" medium="image">
			<media:title type="html">highlight-code</media:title>
		</media:content>

		<media:content url="http://blogalhost.files.wordpress.com/2010/02/picture-7.png" medium="image">
			<media:title type="html">Scripts menu</media:title>
		</media:content>

		<media:content url="http://blogalhost.files.wordpress.com/2011/03/tidy-assignment-textwrangler.png" medium="image">
			<media:title type="html">tidy-assignment-textwrangler</media:title>
		</media:content>
	</item>
	</channel>
</rss>
