<?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>Development Cycle</title>
	<atom:link href="http://www.development-cycle.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.development-cycle.com</link>
	<description>Binary Bits &#38; Pieces</description>
	<lastBuildDate>Fri, 04 May 2012 05:21:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Quick Recursive Code Count</title>
		<link>http://www.development-cycle.com/2012/05/quick-recursive-code-count/</link>
		<comments>http://www.development-cycle.com/2012/05/quick-recursive-code-count/#comments</comments>
		<pubDate>Fri, 04 May 2012 05:18:03 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Project Metrics]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=548</guid>
		<description><![CDATA[Although the &#8220;lines of code&#8221; in a project is not the worlds most useful metric. Curiosity sometimes gets the better of us and after many days / weeks of typing you think &#8220;gee I wonder exactly how many lines of code are in that project?&#8221;. Wonder no more! By embracing the power of the command [...]]]></description>
			<content:encoded><![CDATA[<p>Although the &#8220;lines of code&#8221; in a project is not the worlds most useful metric. Curiosity sometimes gets the better of us and after many days / weeks of typing you think &#8220;gee I wonder exactly how many lines of code are in that project?&#8221;.</p>
<p>Wonder no more! By embracing the power of the command line you can easily count the lines in every file recursively. Simply execute the following line in the directory of your project (changing .php to the file extension of the files you would like to count the line of):</p>
<p>find . -name &#8216;*.php&#8217; | xargs wc -l</p>
<p><span id="more-548"></span></p>
<p>This will give you a simple breakdown for your project that looks similar to below:</p>
<p>59 ./upload-video.php<br />
15 ./views/settings/configuration_required.php<br />
215 ./views/settings/plugin-settings.php<br />
66 ./views/playlist-management/edit-playlist.php<br />
91 ./views/playlist-management/playlist-management.php<br />
57 ./views/playlist-management/reorder-playlist.php<br />
74 ./views/playlist-management/create-playlist.php<br />
60 ./views/video-management/play-playlist.php<br />
117 ./views/video-management/existing-videos.php<br />
59 ./views/video-management/upload-video.php<br />
44 ./views/video-management/play-video.php<br />
25 ./views/video-management/preview-video.php<br />
58 ./includes/shared.php<br />
29 ./includes/reorder_playlist.php<br />
40 ./includes/plugin_setup.php<br />
100 ./includes/playlist_management.php<br />
1921 ./includes/s3.php<br />
40 ./includes/video_tracking.php<br />
371 ./s3-video.php<br />
3441 total</p>
<p>Sure its not the most detailed or elegant report but its quick and gives you a code count of your project with a minimum of fuss.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2012/05/quick-recursive-code-count/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magic constant not working with require_once</title>
		<link>http://www.development-cycle.com/2012/03/dir-magic-constant-not-working/</link>
		<comments>http://www.development-cycle.com/2012/03/dir-magic-constant-not-working/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 23:29:50 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Constant]]></category>
		<category><![CDATA[Debugging]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=539</guid>
		<description><![CDATA[Its funny when a new feature is added to your language of choice how quickly it gets embraced and used within your code. Today upon uploading some code to a clients shared hosting environment I was greeted by the following error: Uploading a file to display phpinfo() I was able to ascertain the server was [...]]]></description>
			<content:encoded><![CDATA[<p>Its funny when a new feature is added to your language of choice how quickly it gets embraced and used within your code. Today upon uploading some code to a clients shared hosting environment I was greeted by the following error:</p>
<p><a href="http://www.development-cycle.com/wp-content/uploads/2012/03/magic_constant_error.png"><img class="aligncenter size-full wp-image-543" title="magic_constant_error" src="http://www.development-cycle.com/wp-content/uploads/2012/03/magic_constant_error.png" alt="" width="450" height="47" /></a></p>
<p>Uploading a file to display phpinfo() I was able to ascertain the server was running PHP 5.2.17. But after a bit of searching I found the __DIR__ magic constant was not added to PHP until 5.3.</p>
<p>Ends up if your code is going to run on older installs the best solution is to replace __DIR__ with dirname(__FILE__) this provides the same functionality as using the __DIR__ magic constant but works with versions of PHP from 4.0.2.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2012/03/dir-magic-constant-not-working/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replace The Default Firefox Google Search In Linux Mint</title>
		<link>http://www.development-cycle.com/2011/08/replace-the-default-firefox-google-search-in-linux-mint/</link>
		<comments>http://www.development-cycle.com/2011/08/replace-the-default-firefox-google-search-in-linux-mint/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 11:56:14 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Linux Mint]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=524</guid>
		<description><![CDATA[The recent release of Ubuntu&#8217;s Natty Narwhal forced me to reassess my usage of Ubuntu on my work and home machines. As I found the Unity interface drives me crazy and the release on a whole to be very buggy. So I decided to give Linux Mint a go, it has grown in popularity (#2 [...]]]></description>
			<content:encoded><![CDATA[<p>The recent release of Ubuntu&#8217;s Natty Narwhal forced me to reassess my usage of Ubuntu on my work and home machines. As I found the Unity interface drives me crazy and the release on a whole to be very buggy. So I decided to give Linux Mint a go, it has grown in popularity (<a title="Linux Distrowatch" href="http://distrowatch.com/">#2 according to Distrowatch</a>)  over the last few years so I figured they must be doing something right and Linux Mint 11 still uses no frills Gnome 2.32.</p>
<p>The migration went smooth, but by default the Linux Mint Firefox Google search functionality is useless, but luckily it wasn&#8217;t too much effort to fix.<br />
<span id="more-524"></span><br />
<img class="aligncenter size-full wp-image-528" title="linux_mint_google" src="http://www.development-cycle.com/wp-content/uploads/2011/08/linux_mint_google1.png" alt="" width="574" height="198" /></p>
<p>First step is to change the home page by choosing &#8220;preferences&#8221; from the &#8220;edit&#8221; toolbar and changing the URL on the general tab. This still doesn&#8217;t help your results though if you search for something in the search box in the top right corner of the browser. To fix this <a title="Firefox Search Provider Plugins" href="http://mycroft.mozdev.org/google-search-plugins.html" target="_blank">head to this site, and look down the page until you find the link for your countries Google</a> search. Click the link and it will be added to the search providers in the search box.</p>
<p><img class="aligncenter size-full wp-image-527" title="Google_Australia_Search" src="http://www.development-cycle.com/wp-content/uploads/2011/08/Google_Australia_Search.png" alt="" width="831" height="85" /> To remove the Linux Mint search provider and make your selected plugin default click on the search provider icon on the left hand side of the search box and select &#8220;manage search engines&#8221;. Select the default and click the remove button, then highlight your chosen provider and simply move to the top of the list with the &#8220;move up&#8221; button.</p>
<p><img class="aligncenter size-full wp-image-529" title="Manage Search Engines" src="http://www.development-cycle.com/wp-content/uploads/2011/08/manage_search_engines.png" alt="" width="465" height="377" /></p>
<p><strong>Related Posts:</strong></p>
<p><strong></strong><a title="Restore The Refresh Button Placement In Firefox 4" href="http://www.development-cycle.com/2011/03/restore-the-refresh-button-placement-in-firefox-4/">Restore The Refresh Button Placement In Firefox 4</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2011/08/replace-the-default-firefox-google-search-in-linux-mint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Anonymizing CURL Scripts With TOR &amp; Polipo</title>
		<link>http://www.development-cycle.com/2011/08/anonymizing-curl-scripts-with-tor-polipo/</link>
		<comments>http://www.development-cycle.com/2011/08/anonymizing-curl-scripts-with-tor-polipo/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 10:45:09 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[CURL]]></category>
		<category><![CDATA[Polipo]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[TOR]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=511</guid>
		<description><![CDATA[Last week I received a typical run of the mill phishing email littered with the usual bad Engrish making the instructions far from believable but being bored I decided to take a look at the link they were pushing. They had created a believable enough looking Paypal form asking clueless punters to enter their credit [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" title="TOR Logo" src="http://www.development-cycle.com/files/u1/tor_logo.png" alt="" width="200" height="127" />Last week I received a typical run of the mill phishing email littered with the usual bad Engrish making the instructions far from believable but being bored I decided to take a look at the link they were pushing.</p>
<p>They had created a believable enough looking Paypal form asking clueless punters to enter their credit card details in order to avoid having their account being suspended. After playing around with the form for <a title="Firefox Web Development Extension" href="http://getfirebug.com/" target="_blank">awhile in Firebug</a> I decided to create a quick script to poison their data by submitting a new fake 16 digit VISA number along with random card holder name, CVV number and expiry date every couple of seconds.</p>
<p>After running this script for half an hour I decided that the script while it did the job would be a lot better if the posted data was coming from an anonymous IP address. Here I will run you through the process of setting up TOR &amp; Polipo on a machine to add an element of anonymity to the data being sent and received by your CURL based script using.<br />
<span id="more-511"></span><br />
<strong>Installation &amp; Configuration</strong><br />
I am going to use Debian 6 in my examples although getting everything working on your distro of choice shouldn&#8217;t be too complicated.</p>
<p><em>apt-get update</em><br />
<em> apt-get install tor polipo</em></p>
<p>TOR is very easy to use and should straight run out of the box without any configuration, but if you plan on running Polipo on a different box to the TOR service or want to run the service on a different port to the default 9050 you will need to edit the config file at /etc/tor-tsock.conf.</p>
<p>The Polipo configuration is a little more in-depth with a few changes that will have to be made so that the service can forward incoming requests to TOR. Edit the Polipo config file:</p>
<p><em>pico /etc/polipo/config</em></p>
<p>Uncomment line 17 with the &#8220;<em>proxyAddress&#8221;</em> directive and add the external IP address of your machine, mine is set to:</p>
<p><em>proxyAddress = &#8220;192.168.20.123&#8243;</em></p>
<p>Go down to line 23 uncomment the &#8220;<em>allowedClients</em>&#8221; directive and edit to suit your needs in my case its:</p>
<p><em>allowedClients = 127.0.0.1, 192.168.20.0/24</em></p>
<p>Also edit line 40 with the directive <em>&#8220;socksParentProxy&#8221;</em> and change it to point at your TOR service mine is:</p>
<p><em>socksParentProxy = &#8220;localhost:9050&#8243;</em></p>
<p>Uncomment line 41 with the <em>&#8220;socksProxyType</em>&#8221; directive and also uncomment lines 115 &amp; 116 for a bit more security.</p>
<p>Restart the Polipo service so your changes to the configuration file take effect:</p>
<p><em>/etc/init.d/polipo restart</em></p>
<p><strong>Proxy Testing</strong></p>
<p>Its now time to test the set-up and see if its working correctly. I find this test is performed easiest using a browser, simply configure your browser to use your Polipo proxy and visit the site <a title="Find Out Your Current IP Address" href="http://www.whatismyip.com/" target="_blank">whatismyip.com</a>. With any luck you will appear to be coming from a completely different IP to your normal network gateway address.</p>
<p><em>Protip:</em> If you want to use the proxy for anonymous browsing as well, I recommend using the <a title="Foxy Proxy Firefox Plugin" href="https://addons.mozilla.org/en-US/firefox/addon/foxyproxy-standard/" target="_blank">Foxy Proxy plugin for Firefox as it makes switching between</a> your normal gateway and proxies a breeze.</p>
<p><strong>Configuring CURL</strong><br />
By now you should have a configured and tested proxy service now its just a case of fo configuring your script to use the proxy. To use a proxy from CURL you simply need to add the <em>CURLOPT_PROXY</em> option to your script with the IP address and port of your proxy service i.e</p>
<p><em>curl_setopt($ch, CURLOPT_PROXY, &#8216;http://192.168.20.123:8123&#8242;);</em></p>
<p><strong>Further Reading:</strong><br />
<a title="Polipo Homepage" href="http://www.pps.jussieu.fr/~jch/software/polipo/" target="_blank">Polipo Homepage</a><br />
<a title="The Onion Router Project Homepage" href="https://www.torproject.org/" target="_blank">TOR Homepage</a></p>
<p><strong>Related Reading:</strong><br />
<a title="Installing TOR Onion Router On Ubuntu 8.0.4 (Hardy Heron)" href="http://www.development-cycle.com/2008/07/tor-on-ubuntu-hardy/">Installing TOR On Ubuntu 8.04</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2011/08/anonymizing-curl-scripts-with-tor-polipo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Removing Stolen Content From Google</title>
		<link>http://www.development-cycle.com/2011/08/removing-stolen-content-from-google/</link>
		<comments>http://www.development-cycle.com/2011/08/removing-stolen-content-from-google/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 00:28:03 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[plagiarism]]></category>
		<category><![CDATA[Stolen Content]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=501</guid>
		<description><![CDATA[From time to time its not uncommon to find sites stealing your content in its entirety with no link back to its original source whilst plastering ads around their page to make money off your hard work. Getting these plagiarised sites removed from Google used to be a hassle, requiring the copyright owner to file [...]]]></description>
			<content:encoded><![CDATA[<p>From time to time its not uncommon to find sites stealing your content in its entirety with no link back to its original source whilst plastering ads around their page to make money off your hard work. Getting these plagiarised sites removed from Google used to be a hassle, requiring the copyright owner to file a <a title="The Digital Millennium Copyright Act" href="http://en.wikipedia.org/wiki/Digital_Millennium_Copyright_Act" target="_blank">DMCA complaint</a> and then mail or fax (you remember those technologies, right?) it to Google.</p>
<p>Good news though, I found  some stolen content today and it seems the times have finally changed with Google finally allowing web submitted content take down requests. This move has been a long time overdue in my opinion as a majority of these stolen content sites are making their money through Google&#8217;s adsense program. With the old fax and email system it was normally easier just to firewall off the network the offending site was hosted on to stop them scraping your content and move on with life.</p>
<p>Here are some tips on what to do if you suspect someone is stealing your content for their own gains without any attribution:</p>
<p><span id="more-501"></span><strong>Identify possible stolen content</strong></p>
<p>A lot of the time you can identify potential content theft from your webstats, if you see an image that is getting called a lot more than the post it appears in chances are its being hotlinked to from elsewhere, looking at the referring URL&#8217;s is also a good way to spot possible thieves<strong></strong>. Enter your web site URL at <a title="Identify Duplicate Content With Copy Scape" href="http://www.copyscape.com/" target="_blank">Copy Scape</a> and see if it can identify any duplicate content for you.</p>
<p><strong>Get the content taken down</strong></p>
<p>Lookup the IP address of the site using the nslookup command on the offending site e.g</p>
<p><em>nslookup offendingsite.com</em></p>
<p>This should return something similar to:</p>
<p><em></em><em>Server:        61.88.88.88<br />
Address:    61.88.88.88#53</p>
<p>Non-authoritative answer:<br />
Name:    www.enunix.com<br />
Address: 74.82.173.217</p>
<p></em>Now perform a whois on the IP address returned to find out what network the sites is hosted on. This can be done either on the Linux command line using the whois tool or by using a <a title="IP whois lookup" href="http://cqcounter.com/whois/" target="_blank">web based tool</a>. This will give you some information on the network similar to:</p>
<p><em>#</em><br />
<em># Query terms are ambiguous.  The query is assumed to be:</em><br />
<em>#     &#8220;n 74.82.173.217&#8243;</em><br />
<em>#</em><br />
<em># Use &#8220;?&#8221; to get help.</em><br />
<em>#</em></p>
<p><em>#</em><br />
<em># The following results may also be obtained via:</em><br />
<em># http://whois.arin.net/rest/nets;q=74.82.173.217?showDetails=true&amp;showARIN=true</em><br />
<em>#</em></p>
<p><em>American Registry for Internet Numbers NET74 (NET-74-0-0-0-0) 74.0.0.0 &#8211; 74.255.255.255</em><br />
<em>Take 2 Hosting, Inc. T2H-NET4-2 (NET-74-82-160-0-1) 74.82.160.0 &#8211; 74.82.191.255</em></p>
<p><em>#</em><br />
<em># ARIN WHOIS data and services are subject to the Terms of Use</em><br />
<em># available at: https://www.arin.net/whois_tou.html</em><br />
<em>#</em><br />
Here we can see Take 2 Hosting is responsible for this IP range, so you can then Google the company name find out how to contact them and report the offending content. If your lucky sometimes the companies whois record will even include an email address for reporting abuse originating from their network making this step easier. You can also do a whois on the domain of the site itself to find the registration details, 9 / 10 times though those is the content theft line of work will use a domain registrar with a private whois service that obscures the registrant&#8217;s contact details.</p>
<p><strong>Report infringement to Google</strong></p>
<p>Reporting the offending content to Google is a crucial  step, first because they can remove their site from the search listings to limit the sites traffic and as most content thieves make their money from adsense they can ban their adsense account. To report <a title="Request Content Removal From Google" href="http://www.google.com/support/bin/static.py?page=ts.cs&amp;ts=1114905" target="_blank">offending content head to this form and request it removal</a>.</p>
<p>&nbsp;</p>
<p><strong></strong></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2011/08/removing-stolen-content-from-google/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Internet Explorer On Ubuntu Natty</title>
		<link>http://www.development-cycle.com/2011/08/installing-internet-explorer-on-ubuntu-natty/</link>
		<comments>http://www.development-cycle.com/2011/08/installing-internet-explorer-on-ubuntu-natty/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 02:57:45 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Natty]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Wine]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=480</guid>
		<description><![CDATA[For years Internet Explorer 6 was the bane of every web developers life but as with all great tales it seems the characters change but the story always remains the same. While IE6 is generally not expected to be catered for by developers these days its equally twisted offspring IE7 still is. Normally when I [...]]]></description>
			<content:encoded><![CDATA[<p>For years Internet Explorer 6 was the bane of every web developers life but as with all great tales it seems the characters change but the story always remains the same. While IE6 is generally not expected to be catered for by developers these days its equally twisted offspring IE7 still is. Normally when I run need to test or fix Internet Explorer issues I  just boot up a XP virtual machine and try and replicate what ever dramas the end user is experiencing. But the other day I was away from my normal desktop with no copy of Windows handy so running a VM wasn&#8217;t an option.</p>
<p>For years I used rely on the <a href="http://www.tatanka.com.br/ies4linux/page/Main_Page" target="_blank">ies4linux project to get IE running under Linux</a> project to get Internet Explorer working for me, but unfortunately the project no longer seems that active so a new way had to be found. Luckily I found it can be done through wine tricks which is actually easier than the original method.</p>
<p>So here I will run you through the process of installing Internet Explorer 7 on your Ubuntu box with Wine this way you can still manage some basic testing without having to worry about getting a complete copy of Windows.First up make sure your system has <a title="The Wine Project Website" href="http://www.winehq.org/" target="_blank">Wine</a> &amp; <a title="The Winetricks Site" href="http://wiki.winehq.org/winetricks" target="_blank">Winetracks</a> installed:</p>
<p><em>sudo apt-get update</em><br />
<em> sudo apt-get install wine1.2 winetricks</em></p>
<p>If you look under your applications menu you should now have a Wine subfolder with an entry called &#8220;Winetricks&#8221; click on this this to get started.</p>
<p><img class="aligncenter size-full wp-image-489" title="winetricks_start" src="http://www.development-cycle.com/wp-content/uploads/2011/08/winetricks_start.png" alt="" width="500" height="257" />Select the option labelled &#8220;Install a Windows DLL or component&#8221;.</p>
<p><img class="aligncenter size-full wp-image-490" title="Winetricks_Install_DLL" src="http://www.development-cycle.com/wp-content/uploads/2011/08/Winetricks_Install_DLL.png" alt="" width="500" height="375" /></p>
<p>Then select your chosen version of Internet Explorer to install, be warned though don&#8217;t get greedy and try an install them all under the same Wine prefix as they wont play together nicely.<img class="aligncenter size-full wp-image-491" title="winetricks_package_selection" src="http://www.development-cycle.com/wp-content/uploads/2011/08/winetricks_package_selection.png" alt="" width="500" height="224" /></p>
<p>Form here it should be pretty smooth sailing just accept the EULA which you are breaking by installing on Linux and you should be good to go!</p>
<p><img class="aligncenter size-full wp-image-492" title="ie7_install" src="http://www.development-cycle.com/wp-content/uploads/2011/08/ie7_install.png" alt="" width="500" height="350" /></p>
<p>At the end it will say you need a reboot just hit the &#8220;Restart now&#8221; option, it won&#8217;t actually reboot your system Wine will simply simulate a reboot for it. After the process completes simply run:</p>
<p><em>wine &#8216;C:\Program Files\Internet Explorer\iexplore&#8217;</em></p>
<p>For a somewhat buggy but &#8220;good enough&#8221; version of Internet Explorer on your Ubuntu box.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2011/08/installing-internet-explorer-on-ubuntu-natty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Near Realtime File Replication With Lsyncd</title>
		<link>http://www.development-cycle.com/2011/07/near-realtime-file-replication-with-lsyncd/</link>
		<comments>http://www.development-cycle.com/2011/07/near-realtime-file-replication-with-lsyncd/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 08:28:46 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[CentOs]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Lua]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=436</guid>
		<description><![CDATA[Ever wanted real time backups of  directories on your server? To replicate static media files for a website to a separate box to reduce load? An easy solution lays with lsyncd it allows you to watch a directory structure on your file system, and replicate any changes on a remote system. How It Works: inotify [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted real time backups of  directories on your server? To replicate static media files for a website to a separate box to reduce load? An easy <a title="lsyncd home a Google Code" href="http://code.google.com/p/lsyncd/" target="_blank">solution lays with lsyncd</a> it allows you to watch a directory structure on your file system, and replicate any changes on a remote system.</p>
<p title="Rsync Software Homepage"><strong>How It Works:</strong><br />
<a title="inotify wikipedia page" href="http://en.wikipedia.org/wiki/Inotify" target="_blank">inotify is a Linux subsystem available</a> from the 2.6.13 release of the Linux kernel that monitors changes made to a file system and reports these changes to interested applications. lsyncd is an application <a title="The Lua Programming Language" href="http://www.lua.org/" target="_blank">written in lua</a> that uses the inotify service to inform it of changes made to monitored directories and then when notified of a change <a title="Rsync Software Homepage" href="http://rsync.samba.org/" target="_blank">uses rsync to replicate</a> the changes on a remote service.</p>
<p><strong>Getting lsyncd</strong><br />
The <a title="lsyncd downloads" href="http://code.google.com/p/lsyncd/downloads/list" target="_blank">lsyncd sourcecode can be downloaded from Google Code</a> and compiled but depending on the distribution your server is running, the install process be even easier as lsyncd is included in the repositories of many popular Linux distros.</p>
<p><strong>Installing On Debian / Ubuntu</strong><br />
While lsyncd is included in both the repositories of Debian and Ubuntu but unfortunately its an outdated version so check what version you are going to get beforehand with the command:</p>
<p><em>apt-cache show lsyncd</em></p>
<p>If apt-cache tells you that only one of the 1.x versions are available, I would recommend grabbing one of the 2.x versions from the <a title="Debian GNU / Linux" href="http://www.debian.org/" target="_blank">Debian</a> testing repository instead, the <a title="lsyncd 2.0.4 package for amd64" href="http://packages.debian.org/wheezy/amd64/lsyncd/download or the i386" target="_blank">amd64 package can be found here</a>  and one for the <a title="i386 Debian lsyncd 2.0.4 package" href="http://packages.debian.org/wheezy/i386/lsyncd/download" target="_blank">i386 architecture here</a>. Then install using the dpkg command i.e</p>
<p><em>cd /root</em><br />
<em> wget wget http://ftp.au.debian.org/debian/pool/main/l/lsyncd/lsyncd_2.0.4-1_amd64.deb</em><br />
<em> apt-get install lua5.1 rsync</em><br />
<em> dpkg -i lsyncd_2.0.4-1_amd64.deb</em></p>
<p><span id="more-436"></span><strong>CentOS 5 Installation</strong></p>
<p><em>yum install lsyncd.x86_64</em></p>
<p><strong>Preparation</strong><br />
First step for getting started with lsync over two hosts is to create a shared SSH key to allow authentication without a password.</p>
<p><em>ssh-keygen</em></p>
<p>Now transfer the servers newly generated public key to the second server you are going to mirror content to.</p>
<p><em>scp ~/.ssh/id_rsa.pub root@my2ndserver:/tmp</em></p>
<p>After copying the file the second server add the public key to the ssh <em>authorized_keys</em> file.</p>
<p><em>cat /tmp/id_rsa.pub &gt;&gt; ~/.ssh/authorized_keys</em></p>
<p>While you are logged into the second machine also double check that rsync is installed and install it if it isn&#8217;t. Now decide the directory you would like to mirror across your machines. In this example I am just going to keep it simple by starting fresh and creating a new directory in the same location on both of my servers:</p>
<p><em>mkdir /home/mirror</em></p>
<p><strong>Quick Test Run</strong><br />
<em>cd /home/mirror</em><br />
<em>touch test_file</em><br />
<em>lsyncd -log all -nodaemon -rsyncssh /home/mirror sync@my2ndserver /home/mirror</em></p>
<p>(<em><strong>Note:</strong></em> Unlike the <a title="Secure Copy Manpage" href="http://linux.die.net/man/1/scp" target="_blank">scp command</a> the target host and directory are given as two separate arguments to lsyncd at the command line)</p>
<p>Which should produce output that looks something similar to:</p>
<p><em>kernels clocks_per_sec=100</em><br />
<em>Call: configure()</em><br />
<em>Inotify: inotify fd = 3</em><br />
<em>Call: initialize()</em><br />
<em>10:08:17 Function: Inotify.addWatch(/home/mirror/, (true), (nil), (nil))</em><br />
<em>10:08:17 Inotify: addwatch(/home/mirror/)-&gt;1</em><br />
<em>10:08:17 Normal: recursive startup rsync: /home/mirror/ -&gt; sync@192.168.20.127:/home/mirror/</em><br />
<em>10:08:17 Exec: /usr/bin/rsync [--delete] [-r] [-lts] [/home/mirror/] [sync@192.168.20.127:/home/mirror/]</em><br />
<em>10:08:17 Call: getAlarm()</em><br />
<em>10:08:17 Debug: getAlarm returns: (false)</em><br />
<em>10:08:17 Masterloop: going into select (no timeout).</em><br />
<em>10:08:17 Call: collectProcess()</em><br />
<em>10:08:17 Delay: collected an event</em><br />
<em>10:08:17 Normal: Startup of &#8216;/home/mirror/&#8217; finished.</em><br />
<em>10:08:17 Normal: Finished Blanket on /home/mirror/ = 0</em><br />
<em>10:08:17 Delay: Finish of Blanket on /home/mirror/ = 0</em><br />
<em>10:08:17 Call: cycle()</em><br />
<em>10:08:17 Function: invokeActions(&#8216;Sync1&#8242;,(Timestamp: 17184171.29))</em><br />
<em>10:08:17 Call: getAlarm()</em><br />
<em>10:08:17 Debug: getAlarm returns: (false)</em><br />
<em>10:08:17 Masterloop: going into select (no timeout).</em></p>
<p>Look in the mirror directory on the second server and with any luck you should see your test file has migrated across from the first server.</p>
<p><strong>Potential Issues</strong><br />
When performing the test run you may get some output that appears similar to the text below:</p>
<p><em>kernels clocks_per_sec=100</em><br />
<em>Call: configure()</em><br />
<em>Inotify: inotify fd = 3</em><br />
<em>Call: initialize()</em><br />
<em>10:14:39 Function: Inotify.addWatch(/home/mirror/, (true), (nil), (nil))</em><br />
<em>10:14:39 Inotify: addwatch(/home/mirror/)-&gt;1</em><br />
<em>10:14:39 Normal: recursive startup rsync: /home/mirror/ -&gt; root@192.168.20.131:/home/mirror/</em><br />
<em>10:14:39 Exec: /usr/bin/rsync [--delete] [-r] [-lts] [/home/mirror/] [root@192.168.20.131:/home/mirror/]</em><br />
<em>10:14:39 Call: getAlarm()</em><br />
<em>10:14:39 Debug: getAlarm returns: (false)</em><br />
<em>10:14:39 Masterloop: going into select (no timeout).</em><br />
<em>rsync: on remote machine: -sltre.iLsf: unknown option</em><br />
<em>rsync error: syntax or usage error (code 1) at main.c(1231) [server=2.6.8]</em><br />
<em>rsync: connection unexpectedly closed (0 bytes received so far) [sender]</em><br />
<em>rsync error: error in rsync protocol data stream (code 12) at io.c(601) [sender=3.0.7]</em><br />
<em>10:14:39 Call: collectProcess()</em><br />
<em>10:14:39 Delay: collected an event</em><br />
<em>10:14:39 Error: Failure on startup of &#8216;/home/mirror/&#8217;.</em></p>
<p>This tends to happen if you are using an older version of rsync on the 2nd server, no need to stress though I found when creating a config file for lysncd removing the -s rsync option seemed to solve this issue.</p>
<p><strong>Creating A Config File</strong><br />
Fire up your preferred editor and create a new file to store your configuration:</p>
<p><em>nano /etc/lsyncd.conf</em></p>
<p>With the contents:</p>
<p><em>settings = {</em><br />
<em>   logfile    = &#8220;/var/log/lsyncd.log&#8221;,</em><br />
<em>}</em></p>
<p><em>sync{default.rsync, source=&#8221;/home/mirror&#8221;, target=&#8221;192.168.20.131:/home/mirror&#8221;, rsyncOps=&#8221;-rltvu&#8221;}</em></p>
<p>Then start the deamon with the comand:</p>
<p><em>lsyncd /etc/lsyncd.conf</em></p>
<p>This will start the daemon in the background, go create a new file in your mirror directory then watch the log with the tail command:</p>
<p><em>tail -f /var/log/lsyncd.log</em></p>
<p>With any luck you should be able to see your newly created file getting picked up by lsyncd and mirrored on your second server.</p>
<p><em>Sun Jul 17 11:03:09 2011 Normal: Calling rsync with filter-list of new/modified files/dirs</em><br />
<em>/myfile.txt</em><br />
<em>/</em><br />
<em>building file list &#8230; done</em><br />
<em>./</em><br />
<em>myfile.txt</em></p>
<p><em>sent 139 bytes  received 48 bytes  374.00 bytes/sec</em><br />
<em>total size is 0  speedup is 0.00</em><br />
<em>Sun Jul 17 11:03:09 2011 Normal: Finished a list = 0</em></p>
<p>As you can see the process is not instantaneous with around a 5 &#8211; 15 second delay before initiating a transfer and obviously the delay while the file itself transfers across but it is handy for backups and other situations where a small delay is not too much of a concern.</p>
<p><strong>Further Reading:</strong></p>
<p><a title="lsyncd manual" href="http://code.google.com/p/lsyncd/wiki/Lsyncd20Manual" target="_blank">The lsyncd manual<strong></strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2011/07/near-realtime-file-replication-with-lsyncd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Blocking VocusPR Spam With Iptables</title>
		<link>http://www.development-cycle.com/2011/07/blocking-vocuspr-spam-with-iptables/</link>
		<comments>http://www.development-cycle.com/2011/07/blocking-vocuspr-spam-with-iptables/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 01:02:43 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[Spam]]></category>
		<category><![CDATA[VocusPR]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=429</guid>
		<description><![CDATA[VocusPR has a dubious reputation their main line of work is aggregating the contact details of journalists and bloggers and then selling access to that database so companies can contact them. Press releases from Vocus customers come with the required &#8220;unsubscribe&#8221; link down the bottom but the catch is clicking it will only stops the [...]]]></description>
			<content:encoded><![CDATA[<p>VocusPR has a dubious reputation their main line of work is aggregating the contact details of journalists and bloggers and then selling access to that database so companies can contact them. Press releases from Vocus customers come with the required &#8220;unsubscribe&#8221; link down the bottom but the catch is clicking it will only stops the client from contacting you, but not the other multitude of clients spamming your from their database. Today I have had enough contacting them seems to get nowhere so its time for more effective measures. A WHOIS lookup for the IP address of one of their spam servers reports:</p>
<div><em>#</em></div>
<div><em># Query terms are ambiguous.  The query is assumed to be:</em></div>
<div><em>#     &#8220;n 66.77.65.154&#8243;</em></div>
<div><em>#</em></div>
<div><em># Use &#8220;?&#8221; to get help.</em></div>
<div><em>#</em></div>
<div><em>#</em></div>
<div><em># The following results may also be obtained via:</em></div>
<div><em># http://whois.arin.net/rest/nets;q=66.77.65.154?showDetails=true&amp;showARIN=true</em></div>
<div><em>#</em></div>
<div><em>Vocus, Inc. QWEST-IAD-VOCUS1 (NET-66-77-65-128-1) 66.77.65.128 &#8211; 66.77.65.191</em></div>
<div><em>Qwest Communications Company, LLC QWEST-INET-12 (NET-66-77-0-0-1) 66.77.0.0 &#8211; 66.77.255.255</em></div>
<div><em>American Registry for Internet Numbers NET66 (NET-66-0-0-0-0) 66.0.0.0 &#8211; 66.255.255.255</em></div>
<p>&nbsp;</p>
<p>Now for the blocking part, simply logged in to mail server add added the following to my firewall rules to block their IP range:</p>
<p><em>/sbin/iptables -I INPUT -s 66.77.65.128/26 -j DROP</em></p>
<p>&nbsp;</p>
<p>Goodbye VocusPR have a nice life spamtards!</p>
<p><strong>Update:</strong> VocusPR also own the IP ranges 209.3.118.0/24 and 63.232.227.0/26</p>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2011/07/blocking-vocuspr-spam-with-iptables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Logging PHP Errors For Production Environments</title>
		<link>http://www.development-cycle.com/2011/07/logging-php-errors-for-production-environments/</link>
		<comments>http://www.development-cycle.com/2011/07/logging-php-errors-for-production-environments/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 01:16:41 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Error Handling]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=423</guid>
		<description><![CDATA[Good security practices dictate PHP should be configured to never display error messages and notices to screen in a production environment due to its potential to reveal information about your server and application setup. One solution is to enable error logging on the server by setting the log_errors attribute to 1 in your php.ini and [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-424" title="PHP Logo" src="http://www.development-cycle.com/wp-content/uploads/2011/07/php_logo.png" alt="" width="200" height="105" />Good security practices dictate PHP should be configured to never display error messages and notices to screen in a production environment due to its potential to reveal information about your server and application setup. One solution is to enable error logging on the server by setting the <em>log_errors</em> attribute to 1 in your php.ini and reloading Apache. When active by default all errors will be sent to the Apache error log and will appear similar to the line below, unless a different path has been set in the php.ini configuration file using the <em>error_log</em> directive.</p>
<p><span id="more-423"></span><div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="text" style="font-family:monospace;">[Mon Jul 16 10:17:31 2011] [error] [client 58.96.56.198] PHP Fatal error:
Uncaught SoapFault exception: [sf:INVALID_LOGIN] INVALID_LOGIN: Invalid
username, user not active in /var/www/myapp/includes/thirdparty/developerforce/soapclient/SforceBaseClient.
php:162</pre></div></div></p>
<p>Sometimes you may not have permission to edit the php.ini file or don&#8217;t want to effect the error reporting for other applications that live on the same box. This leaves you the option of changing the error reporting setting temporarily either in a .htaccess file or in the script itself. Telling PHP to log errors at runtime is very easy to achieve simply add the line below to your script, be warned though this approach is not an optimal solution in most situations, if there is a parse error in your script the directive will not be run and no errors will be logged.</p>
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><pre class="text" style="font-family:monospace;">ini_set(&quot;log_errors&quot;, 1);</pre></div></div>
<p>A better option is to set the logging directive in a .htaccess file if your server is configured to allow their use. Simply open up your .htaccess files or create a new one in the directory of your application if you don&#8217;t have one already and add a line with the <em>log_errors</em> directive and save:</p>
<div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><pre class="text" style="font-family:monospace;">php_value log_errors 1</pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2011/07/logging-php-errors-for-production-environments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing an elements visibility with jQuery</title>
		<link>http://www.development-cycle.com/2011/07/changing-an-elements-visibility-with-jquery/</link>
		<comments>http://www.development-cycle.com/2011/07/changing-an-elements-visibility-with-jquery/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 10:34:23 +0000</pubDate>
		<dc:creator>Anthony Mills</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.development-cycle.com/?p=410</guid>
		<description><![CDATA[Adjusting the visibility of element within a web page comes in handy from time to time for features like tool tips, extending content after a short excerpt etc. This technique adds greatly to the user experience of your site and has been around for a long time but the jQuery library makes this task a [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-415" title="jquery" src="http://www.development-cycle.com/wp-content/uploads/2011/07/jquery.png" alt="" width="200" height="188" />Adjusting the visibility of element within a web page comes in handy from time to time for features like tool tips, extending content after a short excerpt etc. This technique adds greatly to the user experience of your site and has been around for a long time but the <a title="jQuery Javascript Framework" href="http://jquery.com/" target="_blank">jQuery library</a> makes this task <a title="jQuery hide method" href="http://api.jquery.com/hide/" target="_blank">a lot easier with the hide method</a>.</p>
<p>To get started if you haven&#8217;t already load the jQuery library into the head of your page i.e</p>
<div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><pre class="html4strict" style="font-family:monospace;"><span class="sc2">&lt;<a href="http://december.com/html/4/element/script.html"><span class="kw2">script</span></a> <span class="kw3">src</span><span class="sy0">=</span><span class="st0">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js&quot;</span> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text/javascript&quot;</span>&gt;</span></pre></div></div>
<p><span id="more-410"></span></p>
<p>Then create the element you would like to hide, in this example I am just going to hide a simple div when a anchor is clicked.</p>
<div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;"><pre class="html4strict" style="font-family:monospace;"><span class="sc2">&lt;<a href="http://december.com/html/4/element/script.html"><span class="kw2">script</span></a> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text/javascript&quot;</span>&gt;</span>
$(&quot;#hide&quot;).click(function(){
     $(&quot;#some_content&quot;).hide();
});
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/script.html"><span class="kw2">script</span></a>&gt;</span>
&nbsp;
<span class="sc2">&lt;<a href="http://december.com/html/4/element/a.html"><span class="kw2">a</span></a> <span class="kw3">href</span><span class="sy0">=</span><span class="st0">&quot;#&quot;</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;hide&quot;</span>&gt;</span>Hide<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/a.html"><span class="kw2">a</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/div.html"><span class="kw2">div</span></a> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;some_content&quot;</span>&gt;</span>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin lacus libero, dapibus eget dictum in, laoreet non massa. Aliquam nec felis tellus, quis ullamcorper erat.
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/div.html"><span class="kw2">div</span></a>&gt;</span></pre></div></div>
<p>This works well for hiding the content contained within the element but what if the user accidentally clicked the hide link? They would have to reload the page to be able to see the content again, to avoid this sometimes it is better to use the <a title="jQuery Toggle" href="http://api.jquery.com/toggle/" target="_blank">jQuery toggle method</a> instead allowing the user to change the visibility of the element back and forth.</p>
<div id="wpshdo_6" class="wp-synhighlighter-outer"><div id="wpshdt_6" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_6"></a><a id="wpshat_6" class="wp-synhighlighter-title" href="#codesyntax_6"  onClick="javascript:wpsh_toggleBlock(6)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_6" onClick="javascript:wpsh_code(6)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_6" onClick="javascript:wpsh_print(6)" title="Print code"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.development-cycle.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_6" class="wp-synhighlighter-inner" style="display: block;"><pre class="html4strict" style="font-family:monospace;"><span class="sc2">&lt;<a href="http://december.com/html/4/element/script.html"><span class="kw2">script</span></a> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text/javascript&quot;</span>&gt;</span>
$(&quot;#hide&quot;).click(function(){
     $(&quot;#some_content&quot;).toggle();
});
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/script.html"><span class="kw2">script</span></a>&gt;</span>
&nbsp;
<span class="sc2">&lt;<a href="http://december.com/html/4/element/a.html"><span class="kw2">a</span></a> <span class="kw3">href</span><span class="sy0">=</span><span class="st0">&quot;#&quot;</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;hide&quot;</span>&gt;</span>Change visibility<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/a.html"><span class="kw2">a</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/div.html"><span class="kw2">div</span></a> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;some_content&quot;</span>&gt;</span>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin lacus libero, dapibus eget dictum in, laoreet non massa. Aliquam nec felis tellus, quis ullamcorper erat.
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/div.html"><span class="kw2">div</span></a>&gt;</span></pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.development-cycle.com/2011/07/changing-an-elements-visibility-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.development-cycle.com @ 2012-05-19 20:37:09 -->
