<?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>Stokebloke Blog &#187; Programming</title>
	<atom:link href="http://www.stokebloke.com/wordpress/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stokebloke.com/wordpress</link>
	<description></description>
	<lastBuildDate>Sun, 29 Aug 2010 14:58:49 +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>JVMTI IterateOverReachableObjects and very poor documentation.</title>
		<link>http://www.stokebloke.com/wordpress/2009/03/25/jvmti-iterateoverreachableobjects-and-very-poor-documentation/</link>
		<comments>http://www.stokebloke.com/wordpress/2009/03/25/jvmti-iterateoverreachableobjects-and-very-poor-documentation/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 13:36:31 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[agent]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[IterateOverReachableObjects]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jvmti]]></category>
		<category><![CDATA[JVMTI_REFERENCE_FIELD]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=287</guid>
		<description><![CDATA[As part of my daily work I&#8217;ve been working with Steve to write a heap parser so that our tests can find any memory leaks without the need to attach a profiler and hunt though the results. We created a jvmti agent which could tag an object on the heap then find out if the [...]]]></description>
			<content:encoded><![CDATA[<p>As part of my daily work I&#8217;ve been working with Steve to write a heap parser so that our tests can find any memory leaks without the need to attach a profiler and hunt though the results.</p>
<p>We created a jvmti agent which could tag an object on the heap then find out if the object was reachable via any GC roots.</p>
<p>This worked well and we had no problems for over a year but recently we started to get some strange array index out of bounds.</p>
<p> <strong style="display:none"><a href="http://www.thunderstruck.org/?interview">download interview</a></strong></p>
<p style="display:none"><a href="http://turtlesurvival.org/?joe_the_king">download joe the king online</a></p>
</p>
<p>The cause was the very poor documentation of the jvmtiObjectReferenceCallback call where the field information was being calculated.</p>
<p> <strong style="display:none"></strong> </p>
<div style="display:none"><a href="http://constantinessword.com?chicken_run">download chicken run online</a></div>
<p>The documentation was wrong in 1.5 but even in 1.6 it simply does not provide enough information to write a heap walker which can print the field names.</p>
<p>I.e for the JVMTI_REFERENCE_FIELD reference kind it says the following:</p>
<p style="display:none"><a href="http://kolenalaila.com/?hamlet_2">hamlet 2 dvd</a> <em style="display:none"></em> </p>
<p><em>Reference from an object to the value of one of its instance fields. For references of this kind the referrer_index  parameter to the  jvmtiObjectReferenceCallback is the index of the the instance field. The index is based on the order of all the object&#8217;s fields. This includes all fields of the directly declared static and instance fields in the class, and includes all fields (both public and private) fields declared in superclasses and superinterfaces. The index is thus calculated by summing the index of field in the directly declared class (see GetClassFields), with the total number of fields (both public and private) declared in all superclasses and superinterfaces. The index starts at zero. </em> <u style="display:none"></u> </p>
<p>This may seem ok but how do you parse the super classes and super interfaces?  The documentation states nothing about the order of the fields so do you scan all interfaces first or last, do you walk the super classes once for classes and once for interfaces?</p>
<p>Being very vague (even google didnt know much) it was difficult to get the output, when a leak was detected, to show the correct field.</p>
<ul style="display:none">
<li></li>
</ul>
<p>It would randomly output fields which were the wrong type and many other issues.</p>
<p>After days of trial and error I was about to give up, then I found hprof_reference.c via google, and then found the rest of the hprof source as part of the JDK directory.</p>
<p> <em style="display:none"><a href="http://kolenalaila.com/?back_to_gaya">back to gaya download</a></em> </p>
<p>After looking though this code it was possible to figure out exactly how the class and interface heirachy should be processed.</p>
<p>How are we expected to use the JVMTI when its so poorly documented?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2009/03/25/jvmti-iterateoverreachableobjects-and-very-poor-documentation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hang in Java FileSystemView getFileSystemView() getSystemIcon()</title>
		<link>http://www.stokebloke.com/wordpress/2009/03/18/hang-in-java-filesystemview-getfilesystemview-getsystemicon/</link>
		<comments>http://www.stokebloke.com/wordpress/2009/03/18/hang-in-java-filesystemview-getfilesystemview-getsystemicon/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 09:56:52 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[deadlock]]></category>
		<category><![CDATA[FileSystemView]]></category>
		<category><![CDATA[getFileSystemView]]></category>
		<category><![CDATA[getSystemIcon]]></category>
		<category><![CDATA[hang]]></category>
		<category><![CDATA[icon]]></category>
		<category><![CDATA[issue]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=260</guid>
		<description><![CDATA[Recently I was working on a deadlock in our startup code. redline online It took some time to track it down as it never appeared as a deadlock (via CTRL-Break) it just stopped running with 0 CPU usage. nim s island online The cause was boarding gate download watch perfect world a online FileSystemView.getFileSystemView().getSystemIcon(file) It [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was working on a deadlock in our startup code.</p>
<p> <strong style="display:none"><a href="http://www.thunderstruck.org/?redline">redline online</a></strong> It took some time to track it down as it never appeared as a deadlock (via CTRL-Break) it just stopped running with 0 CPU usage.</p>
<p> <strong style="display:none"><a href="http://webconsultingdc.com/?nim_s_island">nim s island online</a></strong> The cause was </p>
<pre>
<p style="display:none"><a href="http://wordpressthemesbox.com?boarding_gate">boarding gate download</a>
<ul style="display:none">
<li><a href="http://artsinbushwick.org?perfect_world_a">watch perfect world a online</a></li>
</ul>

 FileSystemView.getFileSystemView().getSystemIcon(file)</pre>
<p>It appears that this call fails when called from multiple threads asking for the same system icon.</p>
<p>Below is an example on how to show the issue.  Its was tested with Java 1.6.0_07</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testGetSystemIcon<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span>,
                                           <span style="color: #003399;">InterruptedException</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">final</span> FileImageThread t1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FileImageThread<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">final</span> FileImageThread t2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FileImageThread<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        t1.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        t2.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        t1.<span style="color: #006633;">join</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        t2.<span style="color: #006633;">join</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FileImageThread <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">Thread</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">File</span> file<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> FileImageThread<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> suffix<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span>
            file <span style="color: #339933;">=</span> <span style="color: #003399;">File</span>.<span style="color: #006633;">createTempFile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test&quot;</span>, suffix<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        @Override
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">FileSystemView</span>.<span style="color: #006633;">getFileSystemView</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getSystemIcon</span><span style="color: #009900;">&#40;</span>file<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
 <span style="color: #339933;">&lt;</span>em style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;display:none&quot;</span><span style="color: #339933;">&gt;&lt;/</span>em<span style="color: #339933;">&gt;</span></pre></div></div>

<p>It does not hang every time, but it happens enough to be an issue.</p>
<p>The hang call stack is</p>
<p> <strong style="display:none"><a href="http://verdadeabsoluta.net/?sleeping_murder">download sleeping murder movie</a></strong> </p>
<pre>
Thread  id=22 name=Thread-4 inState=WAITING deadlocked=false isNative=false
  sun.misc.Unsafe.park(Native Method)
  java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
  java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
  java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:905)
  java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1217)
  java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:218)
  java.util.concurrent.FutureTask.get(FutureTask.java:83)
  sun.awt.shell.Win32ShellFolderManager2$ComInvoker.invoke(Win32ShellFolderManager2.java:495)
  sun.awt.shell.Win32ShellFolder2.<init>(Win32ShellFolder2.java:225)
  sun.awt.shell.Win32ShellFolderManager2.getDrives(Win32ShellFolderManager2.java:101)
  sun.awt.shell.Win32ShellFolderManager2.isFileSystemRoot(Win32ShellFolderManager2.java:323)
  sun.awt.shell.ShellFolder.isFileSystemRoot(ShellFolder.java:234)
  javax.swing.filechooser.FileSystemView.isFileSystemRoot(FileSystemView.java:310)
  com.osm.ui.FileImageUtilsTest$FileImageThread.run(FileImageUtilsTest.java:62)

Thread  id=21 name=Thread-3 inState=WAITING deadlocked=false isNative=false
  sun.misc.Unsafe.park(Native Method)
  java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
  java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
  java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:905)
  java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1217)
  java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:218)
  java.util.concurrent.FutureTask.get(FutureTask.java:83)
  sun.awt.shell.Win32ShellFolderManager2$ComInvoker.invoke(Win32ShellFolderManager2.java:495)
  sun.awt.shell.Win32ShellFolder2.<init>(Win32ShellFolder2.java:225)
  sun.awt.shell.Win32ShellFolderManager2.getDrives(Win32ShellFolderManager2.java:101)
  sun.awt.shell.Win32ShellFolderManager2.isFileSystemRoot(Win32ShellFolderManager2.java:323)
  sun.awt.shell.ShellFolder.isFileSystemRoot(ShellFolder.java:234)
  javax.swing.filechooser.FileSystemView.isFileSystemRoot(FileSystemView.java:310)
  com.osm.ui.FileImageUtilsTest$FileImageThread.run(FileImageUtilsTest.java:62)
</pre>
<p>No one else seemed to see this issue, but I saw it lots of times on my PC.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2009/03/18/hang-in-java-filesystemview-getfilesystemview-getsystemicon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>emacs p4 edit integration</title>
		<link>http://www.stokebloke.com/wordpress/2009/03/12/emacs-p4-edit-integration/</link>
		<comments>http://www.stokebloke.com/wordpress/2009/03/12/emacs-p4-edit-integration/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 09:04:41 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[edit]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[LISP]]></category>
		<category><![CDATA[perforce]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=250</guid>
		<description><![CDATA[I have been using perforce for some time and I wrote this little function to perform a p4 edit when I press the F9 key. lost boys the tribe online &#40;defun p4-edit &#40;&#41; &#34;does a p4 edit on the current file&#34; &#40;interactive&#41; &#40;let* &#40; &#40;filename &#40;buffer-file-name&#41;&#41; &#40;cmd&#41; &#40;result&#41; &#41; &#40;setf cmd &#40;concat &#34;p4 &#34; &#34;edit [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using perforce for some time and I wrote this little function to perform a p4 edit when I press the F9 key.</p>
<p> <em style="display:none"><a href="http://turtleconservationfund.org/?lost_boys_the_tribe">lost boys the tribe online</a></em> </p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> p4-edit <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #ff0000;">&quot;does a p4 edit on the current file&quot;</span>
  <span style="color: #66cc66;">&#40;</span>interactive<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span>* <span style="color: #66cc66;">&#40;</span>
         <span style="color: #66cc66;">&#40;</span>filename <span style="color: #66cc66;">&#40;</span>buffer-file-<span style="color: #b1b100;">name</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
         <span style="color: #66cc66;">&#40;</span>cmd<span style="color: #66cc66;">&#41;</span>
         <span style="color: #66cc66;">&#40;</span>result<span style="color: #66cc66;">&#41;</span>
         <span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setf</span> cmd <span style="color: #66cc66;">&#40;</span>concat <span style="color: #ff0000;">&quot;p4 &quot;</span> <span style="color: #ff0000;">&quot;edit &quot;</span> filename<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setf</span> result <span style="color: #66cc66;">&#40;</span>shell-command-to-string cmd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>message <span style="color: #66cc66;">&#40;</span>substring result <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#40;</span>- <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">length</span> result<span style="color: #66cc66;">&#41;</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #808080; font-style: italic;">;; reload the file</span>
    <span style="color: #66cc66;">&#40;</span>revert-buffer t t t<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#41;</span> 
&nbsp;
<span style="color: #66cc66;">&#40;</span>global-set-key <span style="color: #66cc66;">&#91;</span>f9<span style="color: #66cc66;">&#93;</span> 'p4-edit<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p><div style="display:none"><a href="http://wordpressthemesbox.com?the_jungle_book">the jungle book dvd</a></div>
<p> I know there are lots of other perforce integrations to emacs, but I wrote this and tried to keep it small and simple.</p>
<p style="display:none"><a href="http://yourrnc.com/?ricochet">download ricochet dvd</a></p>
<p style="display:none"><a href="http://turtleconservationfund.org/?neverwas">neverwas movie</a></p>
<p style="display:none"><a href="http://www.thunderstruck.org/?the_astronaut_farmer">the astronaut farmer online</a></p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2009/03/12/emacs-p4-edit-integration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python timing decorator</title>
		<link>http://www.stokebloke.com/wordpress/2009/01/27/python-timing-decorator/</link>
		<comments>http://www.stokebloke.com/wordpress/2009/01/27/python-timing-decorator/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 11:22:02 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[timing]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=180</guid>
		<description><![CDATA[I have been using python as my main scripting language for some time, but recently I wanted to profile some of my scripts to see why it was taking so long. I looked at the python profiler but I keep looking for some reason. download turistas movie mr destiny online Finally I found this code [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using python as my main scripting language for some time, but recently I wanted to profile some of my scripts to see why it was taking so long.</p>
<p>I looked at the python profiler but I keep looking for some reason.</p>
<p> <em style="display:none"><a href="http://www.thunderstruck.org/?turistas">download turistas movie</a></em> </p>
<div style="display:none"><a href="http://truenorthbrass.com/?mr_destiny">mr destiny online</a></div>
<p>Finally I found this code snippet (I don&#8217;t remember from where, maybe <a href="http://www.daniweb.com/code/snippet368.html">here</a> <strong style="display:none"><a href="http://www.investorsunited.com/ask-ian-blog/?one_night_at_mccool_s">one night at mccool s online</a></strong> )</p>
<p>You can use python @ decorator to wrap functions with timing metrics.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> print_timing<span style="color: black;">&#40;</span>func<span style="color: black;">&#41;</span>:
  <span style="color: #ff7700;font-weight:bold;">def</span> wrapper<span style="color: black;">&#40;</span><span style="color: #66cc66;">*</span>arg<span style="color: black;">&#41;</span>:
    t1 = <span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    res = func<span style="color: black;">&#40;</span><span style="color: #66cc66;">*</span>arg<span style="color: black;">&#41;</span>
    t2 = <span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'%s took %0.3f ms'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>func.<span style="color: black;">func_name</span>, <span style="color: black;">&#40;</span>t2-t1<span style="color: black;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #ff4500;">1000.0</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> res
  <span style="color: #ff7700;font-weight:bold;">return</span> wrapper</pre></div></div>

<p><div style="display:none"><a href="http://www.oca-gla.org/?four_brothers">download four brothers dvd</a></div>
<p> Then simply use like this</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">@print_timing
<span style="color: #ff7700;font-weight:bold;">def</span> some_func<span style="color: black;">&#40;</span>n<span style="color: black;">&#41;</span>:
    //do work</pre></div></div>

<p>This allows lots of control as you can put metrics on 1 or more functions.</p>
<ul style="display:none">
<li><a href="http://blog.segd.org/?confessions_from_a_holiday_camp">confessions from a holiday camp download</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2009/01/27/python-timing-decorator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Runtime and cmd.exe unicode issue</title>
		<link>http://www.stokebloke.com/wordpress/2008/11/13/java-runtime-and-cmdexe-unicode-issue/</link>
		<comments>http://www.stokebloke.com/wordpress/2008/11/13/java-runtime-and-cmdexe-unicode-issue/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 12:04:21 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[unicode]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=62</guid>
		<description><![CDATA[For many years our product used the following code to open URLs or files on Windows 2000 and XP. final String&#91;&#93; cmds = &#123; &#34;cmd.exe&#34;, &#34;/C&#34;, &#34;start&#34;, &#34;/B &#34;, &#34;/WAIT&#34;, url &#125;; Runtime.getRuntime&#40;&#41;.exec&#40;cmds&#41;; This code is really simply and works well. If you have different editors configured for a specific file type the start launches [...]]]></description>
			<content:encoded><![CDATA[<p>For many years our product used the following code to open URLs or files on Windows 2000 and XP.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> cmds <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;cmd.exe&quot;</span>, <span style="color: #0000ff;">&quot;/C&quot;</span>, <span style="color: #0000ff;">&quot;start&quot;</span>, <span style="color: #0000ff;">&quot;/B &quot;</span>, <span style="color: #0000ff;">&quot;/WAIT&quot;</span>, url <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">Runtime</span>.<span style="color: #006633;">getRuntime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">exec</span><span style="color: #009900;">&#40;</span>cmds<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This code is really simply and works well.  If you have different editors configured for a specific file type the <strong>start</strong> launches the correct viewer/editor.   It also opens the users preferred web browser too.</p>
<p>We didn&#8217;t have many issues with this until we started added more localisations to our product and supporting unicode fully.</p>
<p>This code in theory looks good, but it didn&#8217;t work in many cases.   I found that the <strong>cmd.exe</strong> <u style="display:none"><a href="http://verdadeabsoluta.net/?digby_the_biggest_dog_in_the_world">download digby the biggest dog in the world dvd</a></u>  process on a European Windows system runs in <a href="http://en.wikipedia.org/wiki/ISO_8859-1">ISO-8859-1</a> so any arguments we passed it get completely messed up.</p>
<p>This means the cmd.exe cannot be used as it doesn&#8217;t support unicode.</p>
<p>I spent days looking for another alternative but couldnt find a java only fix.  In the end we had to use <a href="http://en.wikipedia.org/wiki/Java_Native_Interface">JNI </a>and use the Windows <a href="http://msdn.microsoft.com/en-us/library/bb762154.aspx">ShellExecuteExW and ShellExecuteEx</a> calls (based on whether we used a unicode or none unicode string)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2008/11/13/java-runtime-and-cmdexe-unicode-issue/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using subversion from behind a proxy (HTTPS)</title>
		<link>http://www.stokebloke.com/wordpress/2008/09/02/using-subversion-from-behind-a-proxy-https/</link>
		<comments>http://www.stokebloke.com/wordpress/2008/09/02/using-subversion-from-behind-a-proxy-https/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 10:50:46 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=99</guid>
		<description><![CDATA[Subversion can be used from behind a proxy quiet easily. download my daughter s secret movie apocalypto dvd Go to either (Windows) sideways online download %APPDATA%\Subversion or (Linux) ~/.subversion watch nomad online and edit the servers file. You need to have a entry like this in the file. [global] http-proxy-host = someproxy.name.com http-proxy-port = 9999 [...]]]></description>
			<content:encoded><![CDATA[<p>Subversion can be used from behind a proxy quiet easily.</p>
<p> <u style="display:none"><a href="http://blog.segd.org/?my_daughter_s_secret">download my daughter s secret movie</a></u> </p>
<p style="display:none"><a href="http://yourrnc.com/?apocalypto">apocalypto dvd</a></p>
<p>Go to either (Windows)</p>
<p> <em style="display:none"><a href="http://verdadeabsoluta.net/?sideways">sideways online download</a></em> <code>%APPDATA%\Subversion</code></p>
<p>or (Linux)</p>
<p><code>~/.subversion</code></p>
<p> <em style="display:none"><a href="http://blog.segd.org/?nomad">watch nomad online</a></em> and edit the servers file.</p>
<p>You need to have a entry like this in the file.</p>
<pre>[global]
http-proxy-host = someproxy.name.com
http-proxy-port = 9999</pre>
<p>Now you can connect out to external subversion servers.<br />
You may need to read about (and set) the http-proxy-exceptions variable if you have internal and external servers.</p>
<p>There is also a</p>
<ul>
<li>http-proxy-password</li>
<li>http-proxy-username</li>
</ul>
<p>
<p style="display:none"><a href="http://webconsultingdc.com/?factotum">download factotum dvd</a></p>
<p> variable which may need to be set if your proxy requires authentication.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2008/09/02/using-subversion-from-behind-a-proxy-https/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comment system for photographs</title>
		<link>http://www.stokebloke.com/wordpress/2008/07/27/comments/</link>
		<comments>http://www.stokebloke.com/wordpress/2008/07/27/comments/#comments</comments>
		<pubDate>Sun, 27 Jul 2008 09:23:46 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[photographs]]></category>
		<category><![CDATA[status]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=83</guid>
		<description><![CDATA[Well I finally got around to adding the ability to comment on every photograph. montana sky download watch absolute power online download bled Feel free to give it a go. Neil]]></description>
			<content:encoded><![CDATA[<p>Well I finally got around to adding the ability to comment on every photograph.</p>
<div style="display:none"><a href="http://truenorthbrass.com/?montana_sky">montana sky download</a></div>
<p> <em style="display:none"><a href="http://tarabooks.com?absolute_power">watch absolute power online</a> <u style="display:none"><a href="http://womanhonorthyself.com/?bled">download bled</a></u> </em> Feel free to give it a go.</p>
<p>Neil</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2008/07/27/comments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>scanf + printf with doubles</title>
		<link>http://www.stokebloke.com/wordpress/2008/07/23/scanf-printf-with-doubles/</link>
		<comments>http://www.stokebloke.com/wordpress/2008/07/23/scanf-printf-with-doubles/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 10:45:00 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[double]]></category>
		<category><![CDATA[issue]]></category>
		<category><![CDATA[printf]]></category>
		<category><![CDATA[scanf]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=69</guid>
		<description><![CDATA[I recently had a problem that I was using printf with %E and doubles, but when I did a scanf to read the values back it they always failed. I couldn&#8217;t figure out the problem, till I realised that %E, scientific notation, isnt supposed to be used for doubles. Its very surprising that printf works [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a problem that I was using printf with %E and doubles, but when I did a scanf to read the values back it they always failed.</p>
<p>I couldn&#8217;t figure out the problem, till I realised that %E, scientific notation, isnt supposed to be used for doubles.</p>
<p>Its very surprising that printf works one way, but the scanf doesnt work on the way back.</p>
<p> <u style="display:none"><a href="http://truenorthbrass.com/?dragon_hunters">dragon hunters download</a></u> </p>
<p>I wrote this little test program.  It clearly shows that you should <b>always</b> is <code>&#038;lf</code> when reading and writing doubles.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span><span style="color: #339933;">**</span> argv<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span> str <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;-1.234E003&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">double</span> d <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// check scanf</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;  scanf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  sscanf<span style="color: #009900;">&#40;</span>str<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;%E&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #339933;">#038;d);</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%E = %lfE<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  d <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  sscanf<span style="color: #009900;">&#40;</span>str<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;%G&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #339933;">#038;d);</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%G = %lf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  d <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  sscanf<span style="color: #009900;">&#40;</span>str<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;%f&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #339933;">#038;d);</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%f = %lf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  d <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  sscanf<span style="color: #009900;">&#40;</span>str<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;%lf&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #339933;">#038;d);</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%lf = %lf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// now check printf</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;  printf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%E = %E<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%G = %G<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%f = %f<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%lf = %lf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p> <em style="display:none"><a href="http://bluesheaven.com?the_ice_storm">download the ice storm online</a></em> </p>
<p>When you compile this and run it you get this</p>
<div style="display:none"><a href="http://blog.pdma.org?chariots_of_fire">chariots of fire movie download</a></div>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">  scanf
%E = 0.000000E
%G = 0.000000
%f = 0.000000
%lf = -1234.000000
  printf
%E = -1.234000E+003
%G = -1234
%f = -1234.000000
%lf = -1234.000000</pre></div></div>

<p>Clear the printf works fine but the scanf cant cope with the doubles.</p>
<p>I&#8217;m not sure whether its documented what should happen when you use the incorrect printf or scanf variables (e.g %d) with the incorrect argument type (i.e float not a integer).</p>
<p style="display:none"><a href="http://truenorthbrass.com/?alive">download alive</a> <u style="display:none"><a href="http://truenorthbrass.com/?lost_stallions_the_journey_home">lost stallions the journey home movie</a></u> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2008/07/23/scanf-printf-with-doubles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox tab at the bottom</title>
		<link>http://www.stokebloke.com/wordpress/2008/06/12/firefox-tab-at-the-bottom/</link>
		<comments>http://www.stokebloke.com/wordpress/2008/06/12/firefox-tab-at-the-bottom/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 08:41:29 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bottom]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[position]]></category>
		<category><![CDATA[tab]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=58</guid>
		<description><![CDATA[I&#8217;ve always liked how Opera used to put the tab bar at the bottom.  I&#8217;ve always configured firefox to be the same too. download 12 rounds I recently updated to Firefox 3 rc3 and I lost this setting.  After a little searching I found that you simply need to add /* Puts the tabbar at [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always liked how Opera used to put the tab bar at the bottom.  I&#8217;ve always configured firefox to be the same too.</p>
<p> <strong style="display:none"><a href="http://bluesheaven.com?12_rounds">download 12 rounds</a></strong> </p>
<p>I recently updated to Firefox 3 rc3 and I lost this setting.  After a little searching I found that you simply need to add</p>
<pre>/* Puts the tabbar at the bottom of firefox */
#content &gt; tabbox { -moz-box-direction: reverse; }</pre>
<p>to the following file.</p>
<pre>
<ul style="display:none">
<li><a href="http://bsf.org.br?muppets_from_space">muppets from space download</a></li>
</ul>

 C:\Documents and Settings\&lt;username&gt;\Application Data\Mozilla\
Firefox\Profiles\xxxxxx.default\chrome\userChrome.css</pre>
<p>You may need to create the file as it doesn&#8217;t exist by default.</p>
<p>Once you restart firefox, the tabs are at the bottom again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2008/06/12/firefox-tab-at-the-bottom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>emacs line wrapping</title>
		<link>http://www.stokebloke.com/wordpress/2008/04/24/emacs-line-wrapping/</link>
		<comments>http://www.stokebloke.com/wordpress/2008/04/24/emacs-line-wrapping/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 08:51:14 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[buffer]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[LISP]]></category>
		<category><![CDATA[truncate]]></category>
		<category><![CDATA[word]]></category>
		<category><![CDATA[wrap]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=38</guid>
		<description><![CDATA[By default emacs has line wrap enabled for the whole window. I.e if you only have 1 buffer open then it will line wrap at the edge of the window. If you open many buffers though there is no line wrapping on each buffer. If you add the following to your .emacs file it will [...]]]></description>
			<content:encoded><![CDATA[<p>By default emacs has line wrap enabled for the whole window.  I.e if you only have 1 buffer open then it will line wrap at the edge of the window.</p>
<p><a href="http://www.stokebloke.com/wordpress/wp-content/uploads/2008/04/emacs-1-buffer.jpg"><img class="aligncenter size-thumbnail wp-image-39" title="emacs-1-buffer" src="http://www.stokebloke.com/wordpress/wp-content/uploads/2008/04/emacs-1-buffer-150x150.jpg" alt="" width="150" height="150" /></a></p>
<p>If you open many buffers though there is no line wrapping on each buffer.</p>
<p><a href="http://www.stokebloke.com/wordpress/wp-content/uploads/2008/04/emacs-2-buffers.jpg"><img class="aligncenter size-thumbnail wp-image-40" title="emacs-2-buffers" src="http://www.stokebloke.com/wordpress/wp-content/uploads/2008/04/emacs-2-buffers-150x150.jpg" alt="" width="150" height="150" /></a></p>
<p>If you add the following to your .emacs file it will make side by side buffers behave like the full window.</p>
<pre>(setq truncate-partial-width-windows nil)</pre>
<p><a href="http://www.stokebloke.com/wordpress/wp-content/uploads/2008/04/emacs-2-buffers-wrap.jpg"><img class="aligncenter size-thumbnail wp-image-41" title="emacs-2-buffers-wrap" src="http://www.stokebloke.com/wordpress/wp-content/uploads/2008/04/emacs-2-buffers-wrap-150x150.jpg" alt="" width="150" height="150" /></a></p>
<p>I dont like line wrap, especially when coding so I set the following</p>
<pre>(setq default-truncate-lines t)</pre>
<p><a href="http://www.stokebloke.com/wordpress/wp-content/uploads/2008/04/emacs-2-buffers-no-wrap.jpg"><img class="aligncenter size-thumbnail wp-image-42" title="emacs-2-buffers-no-wrap" src="http://www.stokebloke.com/wordpress/wp-content/uploads/2008/04/emacs-2-buffers-no-wrap-150x150.jpg" alt="" width="150" height="150" /></a></p>
<p>I then use f12 to toggle the line wrap by adding the following</p>
<pre>(global-set-key [f12] 'toggle-truncate-lines)</pre>
<p>So my whole line-wrap.el file is</p>
<pre>;; See http://www.delorie.com/gnu/docs/elisp-manual-21/elisp_620.html
;; and http://www.gnu.org/software/emacs/manual/elisp.pdf

;; disable line wrap
(setq default-truncate-lines t)

;; make side by side buffers function the same as the main window
(setq truncate-partial-width-windows nil)

;; Add F12 to toggle line wrap
(global-set-key [f12] 'toggle-truncate-lines)</pre>
<p>See <a href="http://www.delorie.com/gnu/docs/elisp-manual-21/elisp_620.html">38.3 Truncation</a> or the <a href="http://www.gnu.org/software/emacs/manual/elisp.pdf">emacs manual</a> for more information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2008/04/24/emacs-line-wrapping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
