<?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>Richard’s Blog-o-Shite &#187; Code</title>
	<atom:link href="http://www.uttertosser.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.uttertosser.com</link>
	<description>Random Bloggy Goodness</description>
	<lastBuildDate>Tue, 03 Aug 2010 10:09:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>JavaScripted e-mail Links in WordPress Pages</title>
		<link>http://www.uttertosser.com/2007/09/25/javascripted-e-mail-links-in-wordpress-pages/</link>
		<comments>http://www.uttertosser.com/2007/09/25/javascripted-e-mail-links-in-wordpress-pages/#comments</comments>
		<pubDate>Tue, 25 Sep 2007 18:49:04 +0000</pubDate>
		<dc:creator>RHM</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Kewl]]></category>
		<category><![CDATA[Spam]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.richardhmorris.com/2007/09/25/javascripted-e-mail-links-in-wordpress-pages/</guid>
		<description><![CDATA[You may want to include an e-mail link in your WordPress Blog&#8217;s &#8220;About&#8221; page or elsewhere, but no doubt you don&#8217;t want this harvested and you&#8217;ve found you can&#8217;t simply add the JavaScript to the post or page as it gets nuked. So how about a workaround? Firstly, you need to create an external Javascript [...]]]></description>
			<content:encoded><![CDATA[<p>You may want to include an e-mail link in your WordPress Blog&#8217;s &#8220;About&#8221; page or elsewhere, but no doubt you don&#8217;t want this harvested and you&#8217;ve found you can&#8217;t simply add the JavaScript to the post or page as it gets nuked.</p>
<p>So how about a workaround?</p>
<p>Firstly, you need to create an external Javascript file with this code (amended for your own needs, obviously):</p>
<p><code><br />
function obfuscate() {<br />
var ppclink = "Click here to e-mail us";<br />
var ppcname = "nospamthanks";<br />
var ppchost = "yourdomainnamegoeshere";<br />
document.write("&lt;a href=" + "mail" + "to:" + ppcname + "@" + ppchost + "&gt;" + ppclink + "")<br />
}<br />
</code></p>
<p>NB: the &#8220;@&#8221; sign is represented in the code as &#8220;&amp; # 64 ;&#8221; with no spaces.</p>
<p>Save it as something like emailobfuscator.js and upload it to your server.</p>
<p>Then in the post or the page you want to include it in, add the following code:</p>
<p><code>&lt;script type="text/javascript"<br />
src="/scripts/emailobfuscator.js" mce_src="/scripts/emailobfuscator.js"&gt;<br />
&lt;/script&gt;<br />
&lt;script type="text/javascript"&gt;<br />
&lt;!--<br />
obfuscate();<br />
//--&gt;<br />
&lt;/script&gt;<br />
</code></p>
<p>You will almost certainly want to uncheck the &#8220;Use visual editor when writing&#8221; checkbox in your User options before this will work.</p>
<p>And the finished result should look like this:</p>
<p><script type="text/javascript" src="/scripts/emailobfuscator.js"></script><script type="text/javascript">    <!--  obfuscate();  //--></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.uttertosser.com/2007/09/25/javascripted-e-mail-links-in-wordpress-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Trouble with Firefox</title>
		<link>http://www.uttertosser.com/2007/08/29/the-trouble-with-firefox/</link>
		<comments>http://www.uttertosser.com/2007/08/29/the-trouble-with-firefox/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 22:05:36 +0000</pubDate>
		<dc:creator>RHM</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://www.richardhmorris.com/2007/08/29/the-trouble-with-firefox/</guid>
		<description><![CDATA[I tend to have a number of web browsers installed on my systems to make sure I can test web pages in a number of up to date browsers, and this includes Firefox ( ) But one issue I have with Firefox is how after a few hours&#8217; use &#8211; especially as my use these [...]]]></description>
			<content:encoded><![CDATA[<p>I tend to have a number of web browsers installed on my systems to make sure I can test web pages in a number of up to date browsers, and this includes Firefox (<script type="text/javascript"><!--
google_ad_client = "pub-3148316290683985";
google_ad_output = "textlink";
google_ad_format = "ref_text";
google_cpa_choice = "CAAQkar2_gEaCByEzMjSiC1gKKm14YcBMAA";
google_ad_channel = "8492926732";
//-->
</script><br />
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>)</p>
<p>But one issue I have with Firefox is how after a few hours&#8217; use &#8211; especially as my use these days tends to include a number of AJAX-based sites, Gmail, etc. &#8211; the amount of memory being consumed sky-rockets despite, or possibly because of, the amount of physical memory on my main work machine.</p>
<p>This evening, I&#8217;ve implemented a number of hacks that may or may not help things out with this supposed memory leak (apparently it&#8217;s working as designed&#8230;), so here we are. This is Firefox version 2.0.0.6, by the way.</p>
<p>Firstly, we want to reduce the amount of RAM being used for Firefox&#8217;s cache. We do this like this:</p>
<p><code>1. Type “about:config” (no quotes) in the browser<br />
2. Find browser.sessionhistory.max_total_viewer<br />
3. Set its value to “0″<br />
4. Restart Firefox</code></p>
<p>Secondly, as minimising the browser window seems to accomplish little, we&#8217;ll try to reduce memory use when it is:</p>
<p><code>1. Type about:config again and then press Enter.<br />
2. Right-click in the page and select New -&gt; Boolean.<br />
3. In the box that pops up enter config.trim_on_minimize. Press Enter.<br />
4. Now select True and then press Enter.<br />
5. Restart Firefox.</code></p>
<p>Still with me? Now we&#8217;ll move on to page rendering speeds and more memory leak hacks, this time from <a target="_blank" href="http://www.havelaptopwilltravel.com/make-firefox-faster-and-prevent-memory-leak/" title="External hyperlink to HLWT">&#8220;Have Laptop Will Travel&#8221;</a>:</p>
<blockquote><p>&#8220;Type in the address bar <strong>about:config</strong>.<br />
Type <strong>pipelining</strong> in the filter bar.<br />
Double-click on <strong>network.http.pipelining</strong> to set its value to <strong>TRUE</strong>.<br />
Double-click on <strong>network.http.pipelining.maxrequests</strong> and change its value to <strong>12</strong> or more if you have broadband.</p>
<p>Play a little with the setting to find a configuration which is best for your connection.</p>
<p>Firefox is most hated for its memory usage. After having browsed some hours, Firefox will easily have taken 250MB or more of memory and slow down your <acronym title="Personal Computer">PC</acronym>. This is because <abbr title="Firefox">FF</abbr> has never been programmed to overwrite the memory it doesn’t use anymore and give free to other programs. Sometimes even closing Firefox won’t speed up your <acronym title="Personal Computer">PC</acronym> anymore. But the leakage can be prevented.</p>
<p>To do so, open a new tab and type about:config in your address bar again.<br />
This time we want to limit the size of the memory cache.<br />
Therefore we need to create a new preference, named <strong>browser.cache.memory.capacity</strong>.<br />
Right click on any free area in the preferences window and choose <strong>New —&gt; String</strong>.<br />
Type now the name <strong>browser.cache.memory.capacity</strong> and in the next window set the value to <strong>20000</strong>.<br />
This will limit the size of the cache in the <acronym title="Random Access Memory">RAM</acronym> to 20000KB and should prevent the annoying memory leak.<br />
Restart your browser now.&#8221;</p></blockquote>
<p>And after I&#8217;d found and implemented these hacks, I discovered them and more at <a target="_blank" href="http://element14.wordpress.com/2006/11/01/firefox-tweaks-revisted-for-20/" title="External hyperlink to element14">the element14 Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.uttertosser.com/2007/08/29/the-trouble-with-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stopping the Leechers</title>
		<link>http://www.uttertosser.com/2007/08/03/stopping-the-leechers/</link>
		<comments>http://www.uttertosser.com/2007/08/03/stopping-the-leechers/#comments</comments>
		<pubDate>Fri, 03 Aug 2007 09:10:34 +0000</pubDate>
		<dc:creator>RHM</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Spam]]></category>

		<guid isPermaLink="false">http://www.richardhmorris.com/2007/08/03/stopping-the-leechers/</guid>
		<description><![CDATA[I was looking at the traffic for some of my sites the other day and spotted a lot of bandwidth (relatively) being used by one particular site. Now that site only really serves up a script to convert RSS feeds to JavaScript files so that I can them embed news items from selected sources into some client [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking at the traffic for some of my sites the other day and spotted a lot of bandwidth (relatively) being used by one particular site. Now that site only really serves up a script to convert RSS feeds to JavaScript files so that I can them embed news items from selected sources into some client sites.</p>
<p>So I looked at the web stats. for that site and discovered that nearly all the traffic was coming from a site in China. I followed a couple of the referring links and found that the pages were basically just generating page after page of potential search terms with embedded news feeds presumably to serve ads. on those pages.</p>
<p>That does beg the question that if they are intelligent to code those pages or that system, why aren&#8217;t they intelligent enough to simply add the scripts to their own site and serve them from there?</p>
<p>Now my site is hosted on a regular Linux box running Apache Web Server, so it was a fairly straightforward task to simply block all traffic from that domain name using an .htaccess file with this code:</p>
<p><code>RewriteEngine on<br />
RewriteCond %{HTTP_REFERER} ^http://(www\.)?baddomain\.com [NC]<br />
RewriteRule .* - [F]</code></p>
<p>So the next day when I checked the stats., there were many thousands of Failed Referrer entries where the code was no longer being leeched by them. Job done!</p>
<p>But it did then appear that my site had some particular attraction to them because they then started running the scripts on a different domain! Now, my first thought was to simply amend the .htaccess file to read as follows:</p>
<p><code>RewriteEngine on<br />
RewriteCond %{HTTP_REFERER} ^http://(www\.)?baddomain\.com [NC,OR]<br />
RewriteCond %{HTTP_REFERER} ^http://(www\.)?anotherbadone\.com [NC]<br />
RewriteRule .* - [F]</code></p>
<p>But I realised I could end up playing cat and mouse with them for life, so instead I have now set the .htaccess file to only allow specific referring domains access to the scripts by using this code:</p>
<p><code>RewriteEngine on<br />
RewriteCond %{HTTP_REFERER} !^http://(www\.)?gooddomain\.co\.uk [NC]<br />
RewriteCond %{HTTP_REFERER} !^http://(www\.)?anothergoodone\.com [NC]<br />
RewriteRule .* - [F]</code></p>
<p>By adding the &#8220;!&#8221;, the expression now says &#8220;if the referrer is <em>not</em> gooddomain, then&#8230;&#8221;. The only difficulty for me then is making sure there are matching entries for all the legitimate referrers (trickier as one of the sites has multiple domain names).</p>
<p>We&#8217;ll see how we get on with this.</p>
<p>[edited to add]</p>
<p>And lo and behold! The blocking is working well, especially as the Leecher in question, <a target="_blank" href="http://corp.163.com/eng/home.shtml" title="External hyperlink to NetEase">hosted by NetEase.com, Inc.</a>, has now started doing it with a third domain name.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.uttertosser.com/2007/08/03/stopping-the-leechers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
