<?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>Stickblog &#187; Uncategorized</title>
	<atom:link href="http://the-stickman.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://the-stickman.com</link>
	<description>Random developer notes</description>
	<lastBuildDate>Thu, 18 Aug 2011 13:14:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Internet Explorer, HTTPS and file downloads: &#8220;The file could not be written to the cache&#8221;</title>
		<link>http://the-stickman.com/uncategorized/internet-explorer-https-and-file-downloads-the-file-could-not-be-written-to-the-cache/</link>
		<comments>http://the-stickman.com/uncategorized/internet-explorer-https-and-file-downloads-the-file-could-not-be-written-to-the-cache/#comments</comments>
		<pubDate>Wed, 17 Aug 2011 10:53:08 +0000</pubDate>
		<dc:creator>Stickman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://the-stickman.com/?p=257</guid>
		<description><![CDATA[[Please see update below for a proper fix] Today I received an email from a client that had just moved their site over to SSL (i.e. HTTPS) &#8212; they were no longer able to download files in Internet Explorer. When they tried to do so, a message would appear: Unable to download...[file name] The file [...]]]></description>
			<content:encoded><![CDATA[<p>[Please see update below for a proper fix]</p>
<p>Today I received an email from a client that had just moved their site over to SSL (i.e. HTTPS) &#8212; they were no longer able to download files in Internet Explorer. When they tried to do so, a message would appear:</p>
<p><code>Unable to download...[file name]</code></p>
<p><code>The file could not be written to the cache</code></p>
<p>(an alternative error message is &#8220;Internet Explorer cannot download [file name] from [site].<br />Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.&#8221;)</p>
<p>I tried various suggestions: different response headers, settings to do with saving encrypted files, and even tried (and failed) to install a couple of hotfixes.</p>
<p>In the end, I&#8217;d nearly given up when I found <a href="http://support.microsoft.com/kb/323308" target="_blank">this knowledgebase article</a> and decided to have a go at manually adding the <em>BypassSSLNoCacheCheck</em> registry key.</p>
<p>Short story, it worked. It&#8217;s not great since it requires the user to do something &#8212; I couldn&#8217;t fix it server-side &#8212; but it was OK in this case because the site was an intranet so their IT people could sort it. Anyway, I hope this helps someone else out there&#8230;</p>
<p><strong>UPDATE: </strong>OK, after a lot more experimentation I found a proper solution that doesn&#8217;t involve registry updates!</p>
<p>It&#8217;s a long story but it turns out that PHP was automatically sending an extra header (&#8220;Pragma: no-cache&#8221;) that I hadn&#8217;t noticed. So, I set the headers as follows:</p>
<p><code>header("Cache-Control: private");</code><br /> <code>header( "Pragma: private" );</code></p>
<p>&#8230;which overrides the automated headers and appears to solve the problem. Hurray!</p>
]]></content:encoded>
			<wfw:commentRss>http://the-stickman.com/uncategorized/internet-explorer-https-and-file-downloads-the-file-could-not-be-written-to-the-cache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PayPal Error: Sorry, an Error Occurred After You Clicked the Last Link</title>
		<link>http://the-stickman.com/uncategorized/paypal-error-sorry-an-error-occurred-after-you-clicked-the-last-link/</link>
		<comments>http://the-stickman.com/uncategorized/paypal-error-sorry-an-error-occurred-after-you-clicked-the-last-link/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 15:09:24 +0000</pubDate>
		<dc:creator>Stickman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://the-stickman.com/uncategorized/paypal-error-sorry-an-error-occurred-after-you-clicked-the-last-link/</guid>
		<description><![CDATA[I&#8217;m just coming to the end of a project that required checkout via PayPal. The system is to be hosted in an iframe embedded in a third party site&#8217;s page, but when redirecting to PayPal the iframe &#8216;pops out&#8217; to take over the whole page (PayPal forces this behaviour). All was working smoothly using the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m just coming to the end of a project that required checkout via PayPal. The system is to be hosted in an iframe embedded in a third party site&#8217;s page, but when redirecting to PayPal the iframe &#8216;pops out&#8217; to take over the whole page (PayPal forces this behaviour).</p>
<p>All was working smoothly using the &#8216;PayPal sandbox&#8217; testing domain, but when it came to testing a live transaction in Internet Explorer I received the following error:</p>
<p>&#8220;Sorry, an Error Occurred After You Clicked the Last Link&#8221;</p>
<p>&#8230;followed by a lengthy but rather unhelpful block of text suggesting various courses of action &#8212; none of which was any use at all.</p>
<p><a href="http://www.google.co.uk/search?q=paypal+%22Sorry,+an+error+occurred+after+you+clicked+the+last+link%22">Consulting Google</a>, it seems that this is far from an unusual occurrence but there&#8217;s little consensus as to the cause. In the end, I tried adding target=&#8221;_top&#8221; to the form that submits to PayPal (thus forcing the &#8216;pop-out&#8217; of the iframe), and presto, all is now fine again.</p>
]]></content:encoded>
			<wfw:commentRss>http://the-stickman.com/uncategorized/paypal-error-sorry-an-error-occurred-after-you-clicked-the-last-link/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Converting latitude and longitude coordinates to map x and y values</title>
		<link>http://the-stickman.com/uncategorized/converting-latitude-and-longitude-coordinates-to-map-x-and-y-values/</link>
		<comments>http://the-stickman.com/uncategorized/converting-latitude-and-longitude-coordinates-to-map-x-and-y-values/#comments</comments>
		<pubDate>Tue, 19 May 2009 08:37:18 +0000</pubDate>
		<dc:creator>Stickman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://the-stickman.com/?p=212</guid>
		<description><![CDATA[I&#8217;m currently working on a project to convert an existing Flash map, which uses location data that&#8217;s been manually entered and maintained, to use data that comes from a database and uses latitude and longitude values. The original data is stored in an XML file so updating it dynamically is not a problem but as [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently working on a project to convert an existing Flash map, which uses location data that&#8217;s been manually entered and maintained, to use data that comes from a database and uses latitude and longitude values. The original data is stored in an XML file so updating it dynamically is not a problem but as you&#8217;ll know if you&#8217;ve ever tried it, plotting latitude and longitude values on a map isn&#8217;t as simple as it might sound.</p>
<p>Briefly, the problem arises from the fact that the world is a sphere and representing it in two dimensions is not a straightforward task. There are various &#8216;projections&#8217; to choose from, each of which uses a different method for mapping points &#8212; you can find out more in <a href="http://en.wikipedia.org/wiki/Map_projection">this Wikipedia article</a>. The most common choice is the <a href="http://en.wikipedia.org/wiki/Mercator_projection">Mercator projection</a>, where lines of latitude are spaced equally, and fortunately for me it&#8217;s the type of map used in the project I&#8217;m working on.</p>
<p>So, being somewhat mathematically inept, I decided that Google would save me from a day&#8217;s head-scratching. That turned out not to be the case, as I tried a good half-dozen different suggestions before finally stumbling across one that actually produced accurate results. To save others from the same fate I decided to reproduce here the code I ended up with, which is based heavily on code found in <a href="http://groups.google.com/group/Google-Maps-API/browse_thread/thread/a45947d72c27cc73#d21b6238fae63a7c">this newsgroup post</a>. My implementation is PHP, but it shouldn&#8217;t be hard to convert it to another platform (see the original thread for a Javascript implementation). Apologies for the rubbish formatting, WordPress isn&#8217;t great at handling code:</p>
<pre>function LongitudeToX( $lat, $lon, $map_zoom, $scale_value, $x_offset = 0 )
{
  $offset=16777216;
  $radius=$offset / pi();
  return ( ( ($offset+$radius*$lon*pi()/180)&gt;&gt;$map_zoom ) * $scale_value ) + $x_offset;
}
function LatitudeToY( $lat, $lon, $map_zoom, $scale_value, $y_offset = 0 )
{
  $offset=16777216;
  $radius=$offset / pi();
  return ( ( ($offset-$radius*log((1+sin($lat*pi()/180))/(1-sin($lat*pi()/180)))/2)&gt;&gt;$map_zoom ) * $scale_value ) + $y_offset;
}</pre>
<p>A few notes about using these functions:</p>
<ul>
<li>From what I can tell, the above code is based on Google Maps and the $map_zoom relates in some way to the &#8216;zoom level&#8217; of the map. I set it at 15 and it seemed to work OK.</li>
<li>Because the dimensions of your own map might not exactly match the assumed dimensions of the map used in the calculation, the $scale_value parameter allows you to adjust the output to fit more precisely. I had to specify two decimal places of scaling to get an exact fit.</li>
<li>Finally, the calculation assumes that the &#8216;origin point&#8217; of the map (x=0, y=0) will be at the top, left-hand corner. This isn&#8217;t the case on the map I&#8217;m working on (the origin is at the centre) so I included $x_offset and $y_offset parameters so that I could adjust the output values accordingly.</li>
</ul>
<p>In order to find the best values for the above parameters, I manually placed three widely-spaced temporary markers on the Flash map marking points whose latitude and longitude I already knew. Then I had the code render these points and adjusted the various parameters until the position of the generated points exactly matched the manually-placed markers.</p>
<p>I hope this code helps someone avoid wasting the sort of time I did yesterday!</p>
]]></content:encoded>
			<wfw:commentRss>http://the-stickman.com/uncategorized/converting-latitude-and-longitude-coordinates-to-map-x-and-y-values/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MySQL UPDATE with SELECT on the same table in the same query</title>
		<link>http://the-stickman.com/uncategorized/mysql-update-with-select-on-the-same-table-in-the-same-query/</link>
		<comments>http://the-stickman.com/uncategorized/mysql-update-with-select-on-the-same-table-in-the-same-query/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 12:55:04 +0000</pubDate>
		<dc:creator>Stickman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://the-stickman.com/?p=194</guid>
		<description><![CDATA[I&#8217;ve been having a week where there&#8217;s a ton of stuff to be done in a short time, yet everything seems to take much longer than it should and every task seems to present multiple unforseen obstacles.  Yesterday, for example, I was working on something that had already taken several days of my time when [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been having a week where there&#8217;s a ton of stuff to be done in a short time, yet everything seems to take much longer than it should and every task seems to present multiple unforseen obstacles. </p>
<p>Yesterday, for example, I was working on something that had already taken several days of my time when I&#8217;d hoped to get it done in hours. The final straw came when I found myself facing what appeared to be an intractable problem: a process that needed to insert multiple rows in a table, and increment a certain column in each row to get a unique value. I couldn&#8217;t use an auto-increment value in this case (there was one already), and using a separate query caused concurrency problems (resulting in non-unique values). I should just point out that this is a system that I&#8217;ve inherited, not one that I developed myself.</p>
<p>I started out with a simple update, like this:</p>
<p>UPDATE my_table SET some_value = ( MAX( some_value ) + 1 ) WHERE id = 123;</p>
<p>&#8230;which in hindsight was never going to work but anyway, it gave me this error:</p>
<p><code>#1111 - Invalid use of group function</code></p>
<p>So I thought about it a bit and then struck on this:</p>
<p> <code>UPDATE my_table SET some_value =<br />
(<br />
(<br />
SELECT MAX( some_value )<br />
FROM my_table<br />
) +1<br />
)<br />
WHERE id = 123</code><br />
&#8230;which gave me this error:</p>
<p><code>#1093 - You can't specify target table 'my_table' for update in FROM clause</code></p>
<p>&#8230;damn. I was starting to bang my head on the desk at this point, but Google came to my rescue by pointing me at <a href="http://www.xaprb.com/blog/2006/06/23/how-to-select-from-an-update-target-in-mysql/">this thread</a>, which suggested using a nested sub-select. The result was the following rather ugly query:</p>
<p><code>UPDATE my_table<br />
SET<br />
my_value =<br />
(<br />
(<br />
SELECT selected_value<br />
FROM<br />
(<br />
SELECT MAX( my_value ) AS selected_value<br />
FROM my_table<br />
)<br />
AS sub_selected_value<br />
)<br />
+ 1<br />
)<br />
WHERE id = 123</code></p>
<p>&#8230;which works. It&#8217;s not great  from a performance point of view since it uses a temporary table, but it does what it needs to. I hope in future that I will be given time to go back and rewrite this part of the system so as to entirely remove the issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://the-stickman.com/uncategorized/mysql-update-with-select-on-the-same-table-in-the-same-query/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Enhanced (&#8216;encouraged&#8217;) blog commenting</title>
		<link>http://the-stickman.com/uncategorized/enhanced-encouraged-blog-commenting/</link>
		<comments>http://the-stickman.com/uncategorized/enhanced-encouraged-blog-commenting/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 10:47:19 +0000</pubDate>
		<dc:creator>Stickman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://the-stickman.com/?p=191</guid>
		<description><![CDATA[Here&#8217;s a great blog post discussing a technique to simplify and encourage commenting on a blog, in particular by quoting text snippets. I might well try to find the time to implement it here on StickBlog.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s <a title="Encouraged commentary" href="http://donttrustthisguy.com/2009/01/04/encouraged-commentary/">a great blog post</a> discussing a technique to simplify and encourage commenting on a blog, in particular by quoting text snippets. I might well try to find the time to implement it here on StickBlog.</p>
]]></content:encoded>
			<wfw:commentRss>http://the-stickman.com/uncategorized/enhanced-encouraged-blog-commenting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

