<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Pete Shanahan&apos;s Shack</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/" />
    <link rel="self" type="application/atom+xml" href="http://www.petesh.com/atom.xml" />
    <id>tag:www.petesh.com,2008-06-19://1</id>
    <updated>2010-01-26T07:09:47Z</updated>
    <subtitle>If It Wasn&apos;t For Carbon-14, I Wouldn&apos;t Date At All</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.32-en</generator>

<entry>
    <title>Virtual PC connection to the host while on the road</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2010/01/virtual-machine-network-connection.html" />
    <id>tag:www.petesh.com,2010://1.709</id>

    <published>2010-01-13T14:06:26Z</published>
    <updated>2010-01-26T07:09:47Z</updated>

    <summary>This advice is for Microsoft Virtual PC. When you use software like VMWare, it automatically allows the host to connect directly to the client using the virtual interfaces that have been created. Most of the recommendations with regard to connection...</summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Computers" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Tips" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Windows" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="compatibility" label="compatibility" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mode" label="mode" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="virtualnetwork" label="virtual network" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="virtualpc" label="virtual pc" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="xp" label="XP" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[<p>This advice is for Microsoft Virtual PC. When you use software like VMWare, it automatically allows the host to connect directly to the client using the virtual interfaces that have been created.</p>
<p>Most of the recommendations with regard to connection to/from the Virtual PC client recommend configuring the connection to share/bridge one of the network connections.</p>
<p>All very good and well when you're on a network. I regularly use the system when I have <b>no</b> network available - i.e. I'm completely disconnected. Most of the connection sensing code for network adaptors prevent you from using it while it's not active, plus I don't like having to configure the connection manually and then reconfigure it when I've got a real network.</p>
<p>The simple solution is to add a Microsoft Loopback Adaptor to the host machine, then create a second network interface on the Virtual PC that uses this interface. Manually configure the IP addresses to be on the same private network, making sure that you don't accidentally configure it to use an IP address range that you may end up using for a VPN connection.</p>
<ol><li>Add the Network Adaptor: <a href="http://www.windowsnetworking.com/articles_tutorials/Install-Microsoft-Loopback-adapter-Windows-XP.html">XP</a>, <a href="http://davedotnet.blogspot.com/2006/06/installing-loopback-adaptor-in-windows.html">Vista</a>, <a href="http://www.windowsreference.com/windows-7/how-to-install-a-loopback-adapter-in-windows-7/">Windows 7</a></li>
<li>Configure the IP address manually. Use a <a href="http://en.wikipedia.org/wiki/Private_network">Private Address Range</a>. I chose an IP address of 10.125.1.1 with a netmask of 255.255.255.0 for the host, then chose 10.125.1.2 for the Virtual machine. <a href="http://www.home-network-help.com/set-ip.html">XP</a>, <a href="http://www.home-network-help.com/configuring-ip.html">Vista</a>, Windows 7 - Use the instructions for Vista.</li>
<li>Shutdown the Virtual Machine, Don't hibernate as you can't add the second network interface.</li>
<li>Edit the properties of the virtual machine (in the Virtual Machines folder). Either Right Click on the Virtual Machine Icon, or use the Settings Option in the menu bar.<br/><img alt="Settings Option" src="http://www.petesh.com/archives/Settings%20Option.PNG" width="403" height="140" class="mt-image-none" /></li>
<li>Configure the network to have 2 interfaces, one of which is linked to the 'Microsoft Loopback Adaptor'<br/><img alt="Settings Dialog" src="http://www.petesh.com/archives/Settings%20Dialog.PNG" width="689" height="456" class="mt-image-none" /></li>
<li>Boot up the virtual machine, and follow the instructions for manually configuring the IP address of this new network interface.</li>
</ol>
<p>Direct connections to the IP address of the client virtual machine now work, and you can use it for anything you want.</p>
<p>Following the instructions <a href="http://social.technet.microsoft.com/Forums/en-US/itprovistanetworking/thread/66b42761-1b8e-4302-9134-0bb685139f4e">here</a>, even if they're confusing, once you add a dword key called '*NdisDeviceType', with a value of 1, you don't see the connection as an unknown connection; thus enabling sharing and other features in Vista, Win 7.]]>
        
    </content>
</entry>

<entry>
    <title>Programmatically changing environment variables in Windows</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2010/01/programmatically-changing-envi.html" />
    <id>tag:www.petesh.com,2010://1.708</id>

    <published>2010-01-12T19:43:00Z</published>
    <updated>2010-01-12T19:45:24Z</updated>

    <summary>It&apos;s not difficult to set environment variable in Windows. System level variables are stored in HKLM/System/CurrentControlSet/Control/Session Manager/Environment. User level variables are stored in HKCU/Environment. They are either REG_SZ or REG_EXPAND_SZ variables. REG_EXPAND_SZ values use other environment variables to get their...</summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Programming" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Windows" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[<p>It's not difficult to set environment variable in Windows. System level variables are stored in <span style="font-family: monospace">HKLM/System/CurrentControlSet/Control/Session Manager/Environment</span>. User level variables are stored in <span style="font-family: monospace">HKCU/Environment</span>. They are either REG_SZ or REG_EXPAND_SZ variables. REG_EXPAND_SZ values use other environment variables to get their ultimate value, while REG_SZ values are considered 'final destination' variables.</p>  <p>The issue arises when you programmatically change the value and want it reflected in new programs that are launched. You make your changes in the registry, but none of the newly launches applications notice the change. You need to inform all the running applications that the settings have been changed. To do this you send a WM_SETTINGCHANGE message to all the running applications.</p>  <p>The logic is to issue a <a href="http://msdn.microsoft.com/en-us/library/ms644950%28VS.85%29.aspx">SendMessage</a>(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)&quot;Environment&quot;). As the meerkat in the advertisement says 'Seemples'. Unfortunately, I have a couple of applications with badly written message processing loops which don't defer to DefWndProc if they don't handle the message, which causes this function to hang.</p>  <p>The more sensible logic is to use a <a href="http://msdn.microsoft.com/en-us/library/ms644952%28VS.85%29.aspx">SendMessageTimeout</a> call, which has 2 extra parameters, one of which is a flag and the other is a timeout in milliseconds. The timeout is a maximum <strong>per window</strong>, which means that if there are 10 windows causing timeouts and you're issuing it with a 1000 milli-second (1 second) timeout, then you will be stalled for 10 seconds. You have been warned. Most applications should respond in &lt; 100 milli-seconds, and typically there are only a few badly behaved applications.</p>  <p>This brings us to the code. It's short, and it's C and it doesn't do anything fancy at all. Compiled using MinGW as <span style="font-family: monospace">gcc&nbsp;-mwindows&nbsp;settings.c&nbsp;-o&nbsp;settings.exe</span></p> <font face="monospace"><font color="#00ff00">#include </font><font color="#00ffff">&lt;windows.h&gt;</font>     <br />    <br /><font color="#ffa500"><b>int</b></font> APIENTRY WinMain(HINSTANCE hInstance,     <br />&nbsp;&nbsp;HINSTANCE hPrevInstance,     <br />&nbsp;&nbsp;LPSTR lpCmdLine,     <br />&nbsp;&nbsp;<font color="#ffa500"><b>int</b></font> nCmdShow)     <br />{     <br />&nbsp;&nbsp;&nbsp;&nbsp;DWORD output;     <br />&nbsp;&nbsp;&nbsp;&nbsp;SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, <font color="#00ffff">0</font>,     <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(LPARAM)<font color="#00ffff">&quot;Environment&quot;</font>, SMTO_BLOCK, <font color="#00ffff">100</font>, &amp;output);     <br />&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ffffff">return</font> (<font color="#00ffff">0</font>);     <br />}     <br /></font>  <p>Set a variable in the registry. Pop up a <span style="font-family: monospace">cmd</span> window and issue a <span style="font-family: monospace">set</span> command and the change is not reflected in the window. Close the window, run the settings program compiled above, then launch another <span style="font-family: monospace">cmd</span> window and it will now reflect the change to the environment you made in the registry.</p> <p>The message causes Explorer to re-read the environment, which is why newly launched programs see the changes. You are launching your applications from explorer (the start menu, icons on the desktop, the run menu) for the most part.</p>]]>
        
    </content>
</entry>

<entry>
    <title>When will the iPhone support multiple apps?</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2010/01/when-will-the-iphone-support-m.html" />
    <id>tag:www.petesh.com,2010://1.706</id>

    <published>2010-01-02T21:20:00Z</published>
    <updated>2010-01-02T21:19:34Z</updated>

    <summary>It looks like all the built-in iPhone apps support &apos;instant resume&apos; - which means that when you swap applications you get exactly where you were previously. This is the palm ethos - kill the application when switching. It&apos;s pretty efficient....</summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Mobile" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="applications" label="applications" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="energyuse" label="energy use" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="green" label="green" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="iphone" label="iPhone" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="multiple" label="multiple" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="palm" label="palm" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[It looks like all the built-in iPhone apps support 'instant resume' - which means that when you swap applications you get exactly where you were previously.<br>
This is the palm ethos - kill the application when switching. It's pretty efficient. Memory use is reduced because you can reclaim memory from the terminated applications.<br>
On the original Palm platform, there was no memory protection - the processor didn't support it. When the system migrated to the ARM processor, it was emulating the original m68k processor, but with added features like improved speed and optional hardware specific acceleration.<br/>
You were exhorted in the development guides for the palm platform to ensure that when a user returned to your application it was in exactly the same state as when you left it.<br/>
The problem seems to be that an awful lot of applications on the Apple platform do not implement this feature. As a result when you use applications you seem to get kicked to the start of your workflow when you restart it, which is really annoying.<br/>
Until applications can actually implement the palm ethos, then people will continue to cry for multi tasking.<br/>
Honestly, I think there is a place for push/pull based background tasks that would operate on a scheduled basis - that way you could run them all at a burst, consuming only a small amount of power for the entire set of jobs. This is something that is <a href="http://blogs.msdn.com/e7/archive/2009/01/06/windows-7-energy-efficiency.aspx">implemented in Windows 7</a> (see <a href="http://channel9.msdn.com/pdc2008/PC02/">Extending battery life with energy efficient applications</a>). By keeping the overall CPU utilization down energy consumption is kept down.<br/>
Scheduled tasks anyone?]]>
        
    </content>
</entry>

<entry>
    <title>Password recovery from open applications</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2009/12/password-recovery-from-open-ap.html" />
    <id>tag:www.petesh.com,2009://1.707</id>

    <published>2009-12-02T16:48:54Z</published>
    <updated>2009-12-02T17:13:09Z</updated>

    <summary>Well I had a minor hiccup today when I decided it was &apos;password change day&apos;. I duly went around changing the password on all my systems. Then I got back to work. 10 minutes later I turned to my other...</summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Computers" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Linux/Unix" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Notes" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Software" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Tips" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="passwordrecoverymemorysillysecurity" label="password recovery memory silly security" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[Well I had a minor hiccup today when I decided it was 'password change day'. I duly went around changing the password on all my systems. Then I got back to work. 10 minutes later I turned to my other system and typed in the password.<br/>
... It didn't work ...<br/>
I smacked my head and said to myself "D'oh", I need to use the new password. But I couldn't remember all of it. All I had was a few characters I could remember and the fact that my mail program was checking the mail every few minutes and still working.<br/>
<p>First I got the pid of thunderbird...<br/>
<pre>~% ps -fe | grep thunder
1000     17509     1  0 13:19 ?        00:00:00 /bin/sh /usr/bin/thunderbird
1000     17521 17509  0 13:19 ?        00:00:00 /bin/sh /usr/lib/thunderbird/run-mozilla.sh /usr/lib/thunderbird/thunderbird-bin
1000     17526 17521  0 13:19 ?        00:00:24 /usr/lib/thunderbird/thunderbird-bin
1000     19101 19006  0 14:09 pts/10   00:00:00 grep thunder</pre></p>
<p>Then I got the address of the heap from the process' maps<br/>
<pre>~% grep 'heap' /proc/17526/maps
08d02000-0a9ad000 rw-p 08d02000 00:00 0          [heap]</pre></p>
<p>I compiled up <a href="http://securitech.homeunix.org/lmt/current/memory_dumper.c">memory_dumper</a>, and ran it against the process and heap addresses listed.<br/>
<pre>% ./memory_dumper 08d02000 0a46a000 17526 heap</pre></p>
<p>Then I ran strings on the resulting file, looking for the pattern that matched my remembered password</br>
<pre>% strings heap | grep t%7
cheat%7Ladel
cheat%7Ladel
cheat%7Ladel
cheat%7Ladel
%</pre></p>
<p>4 copies of the password in memory in the program. That is just in-freaking-sane. It should be present in the program only once, and should probably be concealed using some form of obfuscation. Mind you, it has kept the new password in my mind now, so I should be grateful.</p>
<p>And just in case you feel like trying the password listed, don't. It's not the real password ;)</p>]]>
        
    </content>
</entry>

<entry>
    <title>Major.Minor.Micro - or we can only do so much</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2009/08/majorminormicro---or-we-can-on.html" />
    <id>tag:www.petesh.com,2009://1.705</id>

    <published>2009-08-11T09:51:54Z</published>
    <updated>2009-08-11T10:09:26Z</updated>

    <summary>When you release a piece of software into the world, then you expect there to be problems. That&apos;s where release number taxonomies come from. Firstly, let&apos;s define things. There is the Major number. This normally means &apos;big things&apos; have changed....</summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="number" label="number" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="taxonomy" label="taxonomy" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="version" label="version" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[When you release a piece of software into the world, then you expect there to be problems. That's where release number taxonomies come from.<br/>
Firstly, let's define things. There is the Major number. This normally means 'big things' have changed. By this, we mean that something so fundamental in the system has changed that there is a good chance that stuff that worked previously won't work now. It is also referred to as a 'sea change' - basically, so much stuff has changed that we can't guarantee that things will work in the new version because too much stuff has changed. This approximates to the differences between IE7 and IE8 - they tried, but the combination of changes made it impossible to guarantee backwards compatibility.<br/>
Then there's Minor number. This generally means that somethings have changed, but it is compatible with the prior version. You should not need to change things in order to work in the new system. You proably can't go back, though.<br/>
Then there's the micro version. This means it's a code change that doesn't affect the product in any way except to fix issues. This means no config changes, no stored data changes. You *should* be able to swap between micro versions without any issue.]]>
        
    </content>
</entry>

<entry>
    <title>They keep forgetting I already paid...</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2009/07/they-keep-forgetting-i-already.html" />
    <id>tag:www.petesh.com,2009://1.704</id>

    <published>2009-07-28T13:12:38Z</published>
    <updated>2009-07-28T20:51:50Z</updated>

    <summary> This is kind of silly... paid and renewed ages ago. There is a huge backlog of checking this, apparently....</summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Complaints" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="dev" label="dev" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="expired" label="expired" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="user" label="user" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[<img alt="Developer Program Expired" src="http://www.petesh.com/archives/MailScreenSnapz003.png" width="588" height="145" class="mt-image-left" style="float: left; margin: 0 20px 20px 0;" /><br/>
This is kind of silly... paid and renewed ages ago. There is a huge backlog of checking this, apparently.]]>
        
    </content>
</entry>

<entry>
    <title>Very heavy requirements</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2009/07/very-heavy-requirements.html" />
    <id>tag:www.petesh.com,2009://1.703</id>

    <published>2009-07-21T21:46:38Z</published>
    <updated>2009-07-21T21:46:38Z</updated>

    <summary>I have been buying sound cards for a loooooong time – my first add-on card was for a 512K Amsdrad PC512 and it produced either MIDI-based sound or replicated sample audio. It was not a cheap purchase at the time...</summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Complaints" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Computers" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Hardware" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Software" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[<p>I have been buying sound cards for a loooooong time – my first add-on card was for a 512K Amsdrad PC512 and it produced either MIDI-based sound or replicated sample audio. It was not a cheap purchase at the time – I can't remember the price any more, but it was quite a bit of savings at the time.</p>  <p>It came with a literal 'wodge' of 5.25&quot; driver diskettes. you could use it to steady a table there were so many of them.</p>  <p>Later on, the disks changed to 3.5&quot;. This meant that they were thicker than the older disks, and amounted to a pile that simply got progressively larger. By the purchase of my last soundblaster card, I was looking at IIRC 10 disks, only a few of which were usable for drivers for DOS, the remainder were 'assistant' programs such as <a href="http://en.wikipedia.org/wiki/Dr._Sbaitso">Dr. Sbaitso</a>, which were to purposes useless.</p>  <p>I spent a long time kind-of caring about my sound card. I bought an SB live card for my main desktop and for several years things just worked. About 2 years ago got an SoundBlaster X-Fi card for notebooks for my Dell Insipron M1710. Honestly, the internal card was better than the add-on card. I didn't really care as I paid for it in Yen, so it didn't count towards cost.</p>  <p>In the last 6 months I bought a new rig. Reasonable price, and harkening back to my memories, I got an SB X-Fi XtremeGamer card. Not a large outlay (&lt;€80). It no longer comes with a wodge of disks – it downloads software and updates from the internet.</p>  <p>The smallest update for this software seems to be 50MB. The sum total of the latest software update (to fix problems and to increase compatibility on Vista) is 235MB. I am 44MB into the update and I'm being told that there's another 2.5 hours to go. I'm not on a slow link either. It just seems to be on their side.</p>  <p>Just to put this into perspective - The download for my soundcard is about 1/2 the size of a reasonable Linux distro… and it's as slow as a wet weekend in June. By the time this update has downloaded I could have watched the entirety of the latest Harry Potter movie and still had time for a pint. It's damned slow.</p>  <p>This is a sound card. Not the World Management Software Suite®. The update for my graphics card was 90MB and that was Driver + Support Software + PhysX Drivers. And it downloaded in less than 10 minutes.</p>  <p>Now that I recall, all the problems I seemed to have on the older machine could always be traced to limitations or issues with my sound card. A driver that wasn't playing by the rules. Maybe it thought it was being edgy? I've seen too many BSODs to want edgy. I just want something that works…. and doesn't need a 250MB update (that's twice the size of OpenOffice)…</p>  <p>Oh, and Windows Live Writer — please convert euro, trademark and em-dash symbols before posting… we're not all using UCS-16 encoding here. Some of us actually try to use the web in a platform independent manner…</p>]]>
        
    </content>
</entry>

<entry>
    <title>Can you people please collate FFS</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2009/07/can-you-people-please-collate.html" />
    <id>tag:www.petesh.com,2009://1.702</id>

    <published>2009-07-16T22:04:59Z</published>
    <updated>2009-07-16T22:26:16Z</updated>

    <summary>Nothing more than a rant.... It&apos;s not that tough - when using most english locales, we sort case insensitively. a==A, B==B and so on. Pragmatically, the only reason for picking a locale other than UTF-8.generic is because I would really,...</summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Complaints" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Computers" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Linux/Unix" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Mac" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="collate" label="collate" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="l10n" label="l10n" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="language" label="language" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="whine" label="whine" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[<p>Nothing more than a rant....    <br />It's not that tough - when using most english locales, we sort case insensitively. a==A, B==B and so on. Pragmatically, the only reason for picking a locale other than UTF-8.generic is because I would really, really like these rules obeyed.     <br />I am sick to death of having to work around stupidity.     <br />I'm just complaining as I look at the output from ls and it's pretty much a case sensitive sort. I'm sure that accents are sorted correctly in EN_ie - after all á is the same as a, but apparently it's different to A.     <br />Sorting it difficult... the rules are so complicated... stop complaining! you're able to perform at least 600 <b>million</b> operations per second, and a table lookup for a case insensitive sort is probably going to cost 20.     <br />Bear in mind that the number above was a quick back of the envelope number of an iPhone. I'm sure a real computer will be able to do something a little better...</p>  <p><strong>Update</strong>:</p>  <blockquote>   <p>Looks like it's not Linux, it's only Leopard that doesn't understand EN_ie collation. Oh well, that's life I suppose…      </p></blockquote>]]>
        
    </content>
</entry>

<entry>
    <title>Vodafone Ireland IPCC file for the iphone</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2009/07/vodafone-ireland-ipcc-file-for.html" />
    <id>tag:www.petesh.com,2009://1.701</id>

    <published>2009-07-07T07:50:31Z</published>
    <updated>2009-07-07T08:30:24Z</updated>

    <summary>Created a little icon (it&apos;s the white quote mark in the red loop), added MMS information and tethering support. To install it, rename the downloaded file without the .zip extension (it should be Vodafone_ie.ipcc). Quit iTunes. On the mac open...</summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Computers" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="vodafoneirelandipccfile" label="vodafone ireland ipcc file" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[Created a little icon (it's the white quote mark in the red loop), added MMS information and tethering support.<br/>
To install it, rename the downloaded file without the .zip extension (it should be Vodafone_ie.ipcc). Quit iTunes.<br/>
On the mac open a terminal and type: <span class="code">defaults write com.apple.iTunes carrier-testing -bool TRUE</span><br/>
On windows(32 bit) in a cmd prompt type: <span class="code">"%CommonProgramFiles%\Apple\Mobile Device Support\bin\defaults.exe" write com.apple.iTunes carrier-testing -bool TRUE</span><br/>
On windows(64 bit) type: <span class="code">"%CommonProgramFiles(x86)%\Apple\Mobile Device Support\bin\defaults.exe" write com.apple.iTunes carrier-testing -bool TRUE</span><br/>
Restart iTunes, option/alt click on the 'Check for updates' button in the iphone's Summary page.<br/>
Get the <a href="http://www.petesh.com/archives/Vodafone_ie.ipcc.zip">Vodafone Ireland IPCC file</a>.]]>
        
    </content>
</entry>

<entry>
    <title>Internet bandwidth usage</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2009/06/internet-bandwidth-usage.html" />
    <id>tag:www.petesh.com,2009://1.700</id>

    <published>2009-06-28T17:55:59Z</published>
    <updated>2009-06-28T18:57:01Z</updated>

    <summary><![CDATA[This is one of those odd things. For several years I have paid a data plan on my mobile phone to read my email. I think at the first time I paid it, they were looking for about &euro;10 for...]]></summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Complaints" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="charges" label="charges" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="internet" label="internet" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mobile" label="mobile" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="phone" label="phone" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="system" label="system" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[This is one of those odd things. For several years I have paid a data plan on my mobile phone to read my email. I think at the first time I paid it, they were looking for about &euro;10 for 10MB of data (up and down). As time has passed I have still been paying this internet tax for the phone, only in the last two years with the purchase of a Nokia N95 has it become something of a complete fraud.<br/>
I've just lost this entry due to it being (a) a web 2.0 item and (b) not capable of dealing with the downing of my internet connection. Not making me a happy camper.<br/>
I bought the phone, while I still had my &euro;13 for 10MB data connection plan. There was nothing better available. I assumed (more fool me) that there would be an option for a better data plan as I was buying a phone which required a half decent packet connection. Apparently, my mobile company were unaware of the fact that my phone was using the packet connection until I was in excess of &euro;300 in the hole, and that was a paltry 2 weeks after getting the phone. Something to do with them being complete pillocks.<br/>
After a while, a plan became available that allowed for 1GB data per month. I barely use 100MB on the phone (I have a broadband dongle and am paying for broadband access in two locations simulataneously). I will be using my phone to tether my laptop. This is a given.<br/>
Apparently, the new phone plans for the iPhone and tethering will ask for a supplemental &euro;15 which is epletivingly ridiculous. You cowboys have been charging us 10cent per 160 7bit message which is 64cent a KB or &euro;655 a MB. All the code to deal with these is built into the system. The messages themselves pass through a mostly unused D-channel. They are free. Stop taking the piss. Data access should be a right - just like food and shelter.]]>
        
    </content>
</entry>

<entry>
    <title>On the assumption that these are monthly stats...</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2009/06/on-the-assumption-that-these-a.html" />
    <id>tag:www.petesh.com,2009://1.699</id>

    <published>2009-06-07T09:33:52Z</published>
    <updated>2009-06-07T09:53:53Z</updated>

    <summary>This is a list of the top players of a game from GameTap. Kind of similar to the stats that are maintained by steam. The only issue is that those numbers are a little large - after all there&apos;s only...</summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Humor" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="statsdamnedstatisticsquestionably" label="stats damned statistics questionably" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="Monthly Stats" src="http://www.petesh.com/archives/WebKitScreenSnapz011.png" width="412" height="146" class="mt-image-left" style="float: left; margin: 0 20px 20px 0;" /></span>This is a list of the top players of a game from <a href="http://gametap.com/">GameTap</a>. Kind of similar to the stats that are maintained by steam. The only issue is that those numbers are a little large - after all there's only 744 hours in a 31 day month. It's not actually a good piece of information to be displaying - 2032 hours is almost 3 *solid* months of gaming. If you flip over to another game you see 10274 hours - which is 428 days. These stats are kind of scary.<br/>
The total number of hours this month for may: 1053020, Number of sessions: 10376 which is 101.5 hours per session for the month of may. Assuming that a session is one launch -> termination of the game this is a really insanely long time.<br/>
I question the veracity of the statistics.<br/>
Anyone got any World of Warcraft stats?]]>
        
    </content>
</entry>

<entry>
    <title>URL shortening...</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2009/05/url-shortening.html" />
    <id>tag:www.petesh.com,2009://1.698</id>

    <published>2009-05-19T21:28:26Z</published>
    <updated>2009-05-20T08:09:42Z</updated>

    <summary>Not a lot of code. We create a rewrite rule for apache to remap any 5 character requests at root to this script. RewriteRule ^/([A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9])$ /cgi-bin/shorten.cgi?$1 [PT]. Requests for http://site/..... lookup the entry in the database, requests to shorten.cgi?URL return...</summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Computers" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Linux/Unix" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="urlshortenperlexamplecode" label="url shorten perl example code" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[Not a lot of code. We create a rewrite rule for apache to remap any 5 character requests at root to this script.<br/>
<code>RewriteRule ^/([A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9])$ /cgi-bin/shorten.cgi?$1 [PT]</code>.<br/>
Requests for http://site/..... lookup the entry in the database, requests to shorten.cgi?URL return the shortened uri in a text/plain output when it works.<br/>
There isn't a lot of checking, and you probably need to create the db/ directory with mode 777 so you can update the database under cgi, but it... works on my box ;)<br/>
<font face="monospace" color="#00ffff">
<font color="#ff80ff">#!/usr/bin/perl -w</font><br>
<font color="#80a0ff"># shorten or unshorten a url passed in</font><br>
<font color="#aa4444"><b>use strict</b></font>;<br>
<font color="#aa4444"><b>use </b></font>DBI;<br>
<font color="#aa4444"><b>use </b></font>Sys::Hostname;<br>
<br>
<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">%keys</font>;<br>
<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$value</font>=<font color="#ff00ff">0</font>;<br>
<font color="#80a0ff"># 26 + 26 + 10 = 62</font><br>
<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$keys</font>&nbsp;= <font color="#aa4444"><b>join</b></font>(<font color="#ff00ff">&quot;&quot;</font>, <font color="#ff00ff">'</font><font color="#ff00ff">A</font><font color="#ff00ff">'</font>..<font color="#ff00ff">'</font><font color="#ff00ff">Z</font><font color="#ff00ff">'</font>) . <font color="#aa4444"><b>join</b></font>(<font color="#ff00ff">&quot;&quot;</font>, <font color="#ff00ff">'</font><font color="#ff00ff">a</font><font color="#ff00ff">'</font>..<font color="#ff00ff">'</font><font color="#ff00ff">z</font><font color="#ff00ff">'</font>) . <font color="#aa4444"><b>join</b></font>(<font color="#ff00ff">&quot;&quot;</font>, <font color="#ff00ff">'</font><font color="#ff00ff">0</font><font color="#ff00ff">'</font>..<font color="#ff00ff">'</font><font color="#ff00ff">9</font><font color="#ff00ff">'</font>);<br>
<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">@keys</font>&nbsp;= <font color="#aa4444"><b>split</b></font>(<font color="#aa4444"><b>//</b></font>, <font color="#40ffff">$keys</font>);<br>
<font color="#ffffff">for</font>&nbsp;<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$i</font>&nbsp;(<font color="#40ffff">@keys</font>) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#40ffff">$keys</font>{<font color="#40ffff">$i</font>} = <font color="#40ffff">$value</font>++;<br>
}<br>
<br>
<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$file</font>&nbsp;= <font color="#ff00ff">&quot;</font><font color="#ff00ff">shorten.db</font><font color="#ff00ff">&quot;</font>;<br>
<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$dir</font>;<br>
<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$var</font>;<br>
<br>
<font color="#ffffff">if</font>&nbsp;(<font color="#ff0000">defined</font>(<font color="#40ffff">$ENV</font>{<font color="#ff00ff">'</font><font color="#ff00ff">SCRIPT_FILENAME</font><font color="#ff00ff">'</font>})) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#40ffff">$var</font>&nbsp;= <font color="#40ffff">$ENV</font>{<font color="#ff00ff">'</font><font color="#ff00ff">SCRIPT_FILENAME</font><font color="#ff00ff">'</font>};<br>
} <font color="#ffffff">else</font>&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#40ffff">$var</font>&nbsp;= <font color="#40ffff">$0</font>;<br>
}<br>
<br>
(<font color="#40ffff">$dir</font>) = <font color="#40ffff">$var</font>&nbsp;=~ <font color="#aa4444"><b>m/</b></font><font color="#ff0000">(.*)</font><font color="#ff0000">\/</font><font color="#ff00ff">[^</font><font color="#ff0000">\/</font><font color="#ff00ff">]</font><font color="#ff0000">+</font><font color="#aa4444"><b>/</b></font>;<br>
<br>
<font color="#40ffff">$file</font>&nbsp;= <font color="#40ffff">$dir</font>&nbsp;. <font color="#ff00ff">&quot;</font><font color="#ff00ff">/db/</font><font color="#ff00ff">&quot;</font>&nbsp;. <font color="#40ffff">$file</font>;<br>
<br>
<font color="#ffffff">if</font>&nbsp;(! <font color="#aa4444"><b>-d</b></font>&nbsp;<font color="#40ffff">$dir</font>&nbsp;. <font color="#ff00ff">&quot;</font><font color="#ff00ff">/db</font><font color="#ff00ff">&quot;</font>) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>mkdir</b></font>(<font color="#40ffff">$dir</font>&nbsp;. <font color="#ff00ff">&quot;</font><font color="#ff00ff">/db</font><font color="#ff00ff">&quot;</font>, <font color="#ff00ff">0777</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>chmod</b></font>(<font color="#ff00ff">0777</font>, <font color="#40ffff">$dir</font>&nbsp;. <font color="#ff00ff">&quot;</font><font color="#ff00ff">/db</font><font color="#ff00ff">&quot;</font>);<br>
}<br>
<br>
<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$dbh</font>&nbsp;= DBI-&gt;<font color="#aa4444"><b>connect</b></font>(<font color="#ff00ff">&quot;</font><font color="#ff00ff">dbi:SQLite:dbname=</font><font color="#40ffff">$file</font><font color="#ff00ff">&quot;</font>, <font color="#ff00ff">&quot;&quot;</font>, <font color="#ff00ff">&quot;&quot;</font>) || <font color="#aa4444"><b>die</b></font>&nbsp;<font color="#ff00ff">&quot;</font><font color="#ff00ff">Could not open </font><font color="#40ffff">$file</font><font color="#ff00ff">&quot;</font>;<br>
<font color="#aa4444"><b>chmod</b></font>(<font color="#ff00ff">0666</font>, <font color="#40ffff">$file</font>);<br>
<br>
<font color="#40ffff">$dbh</font>-&gt;<font color="#ffffff">do</font>(<font color="#ff00ff">&quot;</font><font color="#ff00ff">create table if not exists mapping (id INTEGER PRIMARY KEY, url TEXT)</font><font color="#ff00ff">&quot;</font>);<br>
<font color="#40ffff">$dbh</font>-&gt;<font color="#ffffff">do</font>(<font color="#ff00ff">&quot;</font><font color="#ff00ff">create index if not exists mappurl on mapping(url)</font><font color="#ff00ff">&quot;</font>);<br>
<br>
<font color="#aa4444"><b>exit</b></font>(<font color="#ff00ff">0</font>) <font color="#ffffff">if</font>&nbsp;(!<font color="#ff0000">defined</font>(<font color="#40ffff">$ENV</font>{<font color="#ff00ff">'</font><font color="#ff00ff">QUERY_STRING</font><font color="#ff00ff">'</font>}));<br>
<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$qs</font>&nbsp;= <font color="#40ffff">$ENV</font>{<font color="#ff00ff">'</font><font color="#ff00ff">QUERY_STRING</font><font color="#ff00ff">'</font>};<br>
<br>
<font color="#ffffff">if</font>&nbsp;(<font color="#aa4444"><b>length</b></font>(<font color="#40ffff">$qs</font>) == <font color="#ff00ff">5</font>) { <font color="#80a0ff"># from short -&gt; long</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$key</font>&nbsp;= <font color="#ff00ff">0</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>map</b></font>&nbsp;{ <font color="#40ffff">$key</font>&nbsp;= <font color="#40ffff">$key</font>&nbsp;* <font color="#ff00ff">62</font>&nbsp;+ <font color="#40ffff">$keys</font>{<font color="#40ffff">$_</font>} } <font color="#aa4444"><b>split</b></font>(<font color="#aa4444"><b>//</b></font>, <font color="#40ffff">$qs</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$ary</font>&nbsp;= <font color="#40ffff">$dbh</font>-&gt;selectall_arrayref(<font color="#ff00ff">&quot;</font><font color="#ff00ff">select url from mapping where id = </font><font color="#40ffff">$key</font><font color="#ff00ff">&quot;</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ffffff">if</font>&nbsp;(<font color="#40ffff">$ary</font>) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">@ary</font>=<font color="#40ffff">@$ary</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>print</b></font>&nbsp;<font color="#ff00ff">&quot;</font><font color="#ff00ff">Location: </font><font color="#ff00ff">&quot;</font>&nbsp;. <font color="#40ffff">$ary</font>[<font color="#ff00ff">0</font>][<font color="#ff00ff">0</font>] . <font color="#ff00ff">&quot;</font><font color="#ff0000">\n\n</font><font color="#ff00ff">&quot;</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
} <font color="#ffffff">else</font>&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$sth</font>&nbsp;= <font color="#40ffff">$dbh</font>-&gt;prepare(<font color="#ff00ff">&quot;</font><font color="#ff00ff">select id from mapping where url = ?</font><font color="#ff00ff">&quot;</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$ret</font>&nbsp;= <font color="#40ffff">$sth</font>-&gt;execute(<font color="#40ffff">$qs</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>die</b></font>&nbsp;<font color="#ff00ff">&quot;</font><font color="#ff00ff">Failed to execute </font><font color="#ff00ff">&quot;</font>&nbsp;. <font color="#40ffff">$sth</font>-&gt;errstr <font color="#ffffff">unless</font>(<font color="#40ffff">$ret</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">@row</font>&nbsp;= <font color="#40ffff">$sth</font>-&gt;fetchrow_array();<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$value</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ffffff">if</font>&nbsp;(!<font color="#40ffff">@row</font>) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#40ffff">$sth</font>&nbsp;= <font color="#40ffff">$dbh</font>-&gt;prepare(<font color="#ff00ff">&quot;</font><font color="#ff00ff">insert or replace into mapping (url) values (?)</font><font color="#ff00ff">&quot;</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#40ffff">$sth</font>-&gt;execute(<font color="#40ffff">$qs</font>) <font color="#ff0000">or</font>&nbsp;<font color="#aa4444"><b>die</b></font>&nbsp;<font color="#ff00ff">&quot;</font><font color="#ff00ff">Failed to insert</font><font color="#ff00ff">&quot;</font>&nbsp;. <font color="#40ffff">$sth</font>-&gt;errstr;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#40ffff">$value</font>&nbsp;= <font color="#40ffff">$dbh</font>-&gt;last_insert_id(<font color="#ff00ff">&quot;&quot;</font>,<font color="#ff00ff">&quot;&quot;</font>,<font color="#ff00ff">&quot;&quot;</font>,<font color="#ff00ff">&quot;&quot;</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;} <font color="#ffffff">else</font>&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#40ffff">$value</font>&nbsp;= <font color="#40ffff">$row</font>[<font color="#ff00ff">0</font>];<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ffffff">if</font>&nbsp;(<font color="#ff0000">defined</font>(<font color="#40ffff">$value</font>) &amp;&amp; (<font color="#40ffff">$value</font>&nbsp;&gt; <font color="#ff00ff">0</font>)) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$op</font>&nbsp;= <font color="#ff00ff">&quot;&quot;</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ffffff">while</font>(<font color="#aa4444"><b>length</b></font>(<font color="#40ffff">$op</font>) != <font color="#ff00ff">5</font>) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#40ffff">$op</font>&nbsp;= <font color="#40ffff">$keys</font>[<font color="#40ffff">$value</font>&nbsp;% <font color="#ff00ff">62</font>] . <font color="#40ffff">$op</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#40ffff">$value</font>&nbsp;/= <font color="#ff00ff">62</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>my</b></font>&nbsp;<font color="#40ffff">$base</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ffffff">if</font>&nbsp;(!<font color="#ff0000">defined</font>(<font color="#40ffff">$ENV</font>{<font color="#ff00ff">'</font><font color="#ff00ff">HTTP_HOST</font><font color="#ff00ff">'</font>})) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#40ffff">$base</font>&nbsp;= hostname();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <font color="#ffffff">else</font>&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#40ffff">$base</font>&nbsp;= <font color="#40ffff">$ENV</font>{<font color="#ff00ff">'</font><font color="#ff00ff">HTTP_HOST</font><font color="#ff00ff">'</font>};<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>print</b></font>&nbsp;<font color="#ff00ff">&quot;</font><font color="#ff00ff">Content-Type: text/plain</font><font color="#ff0000">\n\n</font><font color="#ff00ff"><a href="http://">http://</a></font><font color="#ff00ff">&quot;</font>&nbsp;. <font color="#40ffff">$base</font>&nbsp;. <font color="#ff00ff">&quot;</font><font color="#ff00ff">/</font><font color="#ff00ff">&quot;</font>&nbsp;. <font color="#40ffff">$op</font>&nbsp;. <font color="#ff00ff">&quot;</font><font color="#ff0000">\n</font><font color="#ff00ff">&quot;</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;} <font color="#ffffff">else</font>&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>print</b></font>&nbsp;<font color="#ff00ff">&quot;</font><font color="#ff00ff">Content-Type: text/plain</font><font color="#ff0000">\n\n</font><font color="#ff00ff">Failed to shorten </font><font color="#40ffff">$qs</font><font color="#ff00ff">.</font><font color="#ff00ff">&quot;</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa4444"><b>exit</b></font>(<font color="#ff00ff">0</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
}<br>
<br>
<font color="#80a0ff"># vim: ts=4:sw=4:et</font><br>
</font>]]>
        
    </content>
</entry>

<entry>
    <title>Classy error from XCode</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2009/04/classy-error-from-xcode.html" />
    <id>tag:www.petesh.com,2009://1.697</id>

    <published>2009-04-01T21:34:38Z</published>
    <updated>2009-04-01T16:36:04Z</updated>

    <summary> Apparently I forgot to plug out my null before quitting the application. That&apos;s a shame as I thought I had two or three nulls floating around...</summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Computers" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Mac" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="nullunplugxcodeerror" label="null unplug xcode error" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="XcodeScreenSnapz001 - nullity null" src="http://www.petesh.com/archives/XcodeScreenSnapz001.png" width="405" height="140" class="mt-image-left" style="float: left; margin: 0 20px 20px 0;" /></span>
Apparently I forgot to plug out my null before quitting the application. That's a shame as I thought I had two or three nulls floating around]]>
        
    </content>
</entry>

<entry>
    <title>bash pip-isms or right hand side of pipe variables</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2009/03/bash-pip-isms-or-right-hand-si.html" />
    <id>tag:www.petesh.com,2009://1.696</id>

    <published>2009-03-31T18:37:12Z</published>
    <updated>2009-03-31T08:53:03Z</updated>

    <summary>bash works as designed, it just doesn&apos;t work as desired.</summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Linux/Unix" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Programming" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="bashpipevariableassignment" label="bash pipe variable assignment" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[Unlike my default shell (zsh), bash has a <em>wonderful</em> feature where it doesn't keep variables that are set at the other end of a pipe, so for example:<br/>
<font face="monospace"><font color="#40ffff">i</font>=<br>
cat foo | <font color="#aa4444"><b>while </b></font><font color="#aa4444"><b>read</b></font><font color="#ffffff">&nbsp;bar</font><font color="#dd0805">;</font><font color="#ffffff">&nbsp;</font><font color="#ffffff">do</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#40ffff">i</font>=<font color="#ff80ff">$bar</font><br>
<font color="#ffffff">done</font><br>
<font color="#aa4444"><b>echo</b></font><font color="#f10883">&nbsp;</font><font color="#ff80ff">$i</font></font><br/>

Yields an empty line. I've been stung once or twice on this as I prototype the code initially in an interactive shell, which doesn't exhibit the issue.<br/>
The simplest solution is to use a named pipe.<br/>
<br>
<font face="monospace"><font color="#40ffff">i</font>=<br>
mkfifo /tmp/foo<font color="#ff80ff">$$</font><br>
cat foo <font color="#dd0805">&gt;</font>/tmp/foo<font color="#ff80ff">$$</font>&amp;<br>
<font color="#40ffff">pid</font>=<font color="#ff80ff">$!</font><br>
<font color="#aa4444"><b>while </b></font><font color="#aa4444"><b>read</b></font><font color="#ffffff">&nbsp;bar</font><font color="#dd0805">;</font><font color="#ffffff">&nbsp;</font><font color="#ffffff">do</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#40ffff">i</font>=<font color="#ff80ff">$bar</font><br>
<font color="#ffffff">done</font>&nbsp;<font color="#dd0805">&lt;</font>/tmp/foo<font color="#ff80ff">$$</font></font>
<br>
This gives the last line of the file in the i variable.]]>
        
    </content>
</entry>

<entry>
    <title>Lies my computer told me... (threads != processes)</title>
    <link rel="alternate" type="text/html" href="http://www.petesh.com/archives/2009/03/lies-my-computer-told-me-threa.html" />
    <id>tag:www.petesh.com,2009://1.695</id>

    <published>2009-03-17T06:47:32Z</published>
    <updated>2009-03-16T17:07:08Z</updated>

    <summary>So there I am looking at the sysinfo from a particular machine and I look at the content of the procs field. It looked to be a bit out. Went hunting through the kernel source and noticed that the procs...</summary>
    <author>
        <name>Pete Shanahan</name>
        <uri>http://www.petesh.com/</uri>
    </author>
    
        <category term="Computers" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Linux/Unix" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="threadsprocesseslinuxsysinfocalculation" label="threads processes linux sysinfo calculation" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.petesh.com/">
        <![CDATA[So there I am looking at the sysinfo from a particular machine and I look at the content of the procs field. It looked to be a bit out. Went hunting through the kernel source and noticed that the procs field is filled with the value of the number of threads in the system. This is a little bit odd, as I'm used to separating my threads from my processes.<br/>
Turns out that there is an nr_processes() call, which returns the number of processes in the system, rather than the number of threads. A little bit of a change, rebuild and testing now gives me the correct number of processes from the proc field, and I also have a separate result for the number of threads.<br/>
There we go, much more sensible ;)<br/>
<font face="monospace"><font color="#60ff60"><b>diff -Naur linux-2.6.25.18/include/linux/kernel.h linux-2.6.25.18.new/include/linux/kernel.h</b></font><br>
<font color="#60ff60"><b>--- linux-2.6.25.18/include/linux/kernel.h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2008-10-09 03:58:32.000000000 +0100</b></font><br>
<font color="#60ff60"><b>+++ linux-2.6.25.18.new/include/linux/kernel.h&nbsp;&nbsp;2009-03-16 16:23:39.000000000 +0000</b></font><br>
<font color="#aa4444"><b>@@ -415,7 +415,8 @@</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unsigned long totalhigh;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Total high memory size */<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unsigned long freehigh;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Available high memory size */<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unsigned int mem_unit;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Memory unit size in bytes */<br>
<font color="#dd0805">-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */</font><br>
<font color="#40ffff">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsigned int threads;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Number of current threads */</font><br>
<font color="#40ffff">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char _f[20-2*sizeof(long)-2*sizeof(int)];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Padding: libc5 uses this.. */</font><br>
&nbsp;};<br>
&nbsp;<br>
&nbsp;/* Force a compilation error if condition is true */<br>
<font color="#60ff60"><b>diff -Naur linux-2.6.25.18/kernel/compat.c linux-2.6.25.18.new/kernel/compat.c</b></font><br>
<font color="#60ff60"><b>--- linux-2.6.25.18/kernel/compat.c&nbsp;&nbsp;&nbsp;&nbsp; 2008-10-09 03:58:32.000000000 +0100</b></font><br>
<font color="#60ff60"><b>+++ linux-2.6.25.18.new/kernel/compat.c 2009-03-16 16:43:31.000000000 +0000</b></font><br>
<font color="#aa4444"><b>@@ -1031,7 +1031,8 @@</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;u32 totalhigh;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;u32 freehigh;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;u32 mem_unit;<br>
<font color="#dd0805">-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char _f[20-2*sizeof(u32)-sizeof(int)];</font><br>
<font color="#40ffff">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; u32 threads;</font><br>
<font color="#40ffff">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char _f[20-2*sizeof(u32)-2*sizeof(int)];</font><br>
&nbsp;};<br>
&nbsp;<br>
&nbsp;asmlinkage long<br>
<font color="#aa4444"><b>@@ -1076,7 +1077,8 @@</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;__put_user (s.procs, &amp;info-&gt;procs) ||<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;__put_user (s.totalhigh, &amp;info-&gt;totalhigh) ||<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;__put_user (s.freehigh, &amp;info-&gt;freehigh) ||<br>
<font color="#dd0805">-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __put_user (s.mem_unit, &amp;info-&gt;mem_unit))</font><br>
<font color="#40ffff">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __put_user (s.mem_unit, &amp;info-&gt;mem_unit) ||</font><br>
<font color="#40ffff">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __put_user (s.threads, &amp;info-&gt;threads))</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return -EFAULT;<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;<br>
<font color="#60ff60"><b>diff -Naur linux-2.6.25.18/kernel/timer.c linux-2.6.25.18.new/kernel/timer.c</b></font><br>
<font color="#60ff60"><b>--- linux-2.6.25.18/kernel/timer.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2008-10-09 03:58:32.000000000 +0100</b></font><br>
<font color="#60ff60"><b>+++ linux-2.6.25.18.new/kernel/timer.c&nbsp;&nbsp;2009-03-16 16:20:02.000000000 +0000</b></font><br>
<font color="#aa4444"><b>@@ -37,6 +37,7 @@</b></font><br>
&nbsp;#include &lt;linux/delay.h&gt;<br>
&nbsp;#include &lt;linux/tick.h&gt;<br>
&nbsp;#include &lt;linux/kallsyms.h&gt;<br>
<font color="#40ffff">+#include &lt;linux/sched.h&gt;</font><br>
&nbsp;<br>
&nbsp;#include &lt;asm/uaccess.h&gt;<br>
&nbsp;#include &lt;asm/unistd.h&gt;<br>
<font color="#aa4444"><b>@@ -1166,7 +1167,8 @@</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;info-&gt;loads[1] = avenrun[1] &lt;&lt; (SI_LOAD_SHIFT - FSHIFT);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;info-&gt;loads[2] = avenrun[2] &lt;&lt; (SI_LOAD_SHIFT - FSHIFT);<br>
&nbsp;<br>
<font color="#dd0805">-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info-&gt;procs = nr_threads;</font><br>
<font color="#40ffff">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info-&gt;procs = nr_processes();</font><br>
<font color="#40ffff">+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info-&gt;threads = nr_threads;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} while (read_seqretry(&amp;xtime_lock, seq));<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;si_meminfo(info);<br>
</font><br/>
The <a href="/archives/linux-2.6.25.18-sysinfo.patch">Full patch</a>.]]>
        
    </content>
</entry>

</feed>
