<?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>John Beales &#187; How To</title>
	<atom:link href="http://johnbeales.com/category/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://johnbeales.com</link>
	<description></description>
	<lastBuildDate>Sun, 20 Nov 2011 02:59:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<atom:link rel='hub' href='http://johnbeales.com/?pushpress=hub'/>
		<item>
		<title>Improving Trac&#8217;s Tickets By Milestone Report</title>
		<link>http://johnbeales.com/20111119/improving-tracs-tickets-by-milestone-report/</link>
		<comments>http://johnbeales.com/20111119/improving-tracs-tickets-by-milestone-report/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 02:59:39 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[milestones]]></category>
		<category><![CDATA[order by date]]></category>
		<category><![CDATA[reports]]></category>
		<category><![CDATA[tickets]]></category>
		<category><![CDATA[trac]]></category>

		<guid isPermaLink="false">http://johnbeales.com/?p=629</guid>
		<description><![CDATA[I entered a ton of tickets &#38; milestones into a Trac installation today and when I was done the Active Tickets report was a mess. Tickets by Milestone was better, but still far from perfect.  Time for report customization. Google helped, and so did the #trac IRC channel. If you&#8217;re lazy &#038; want to just [...]]]></description>
			<content:encoded><![CDATA[<p>I entered a ton of tickets &amp; milestones into a <a href="http://trac.edgewall.org">Trac</a> installation today and when I was done the Active Tickets report was a mess. Tickets by Milestone was better, but still far from perfect.  Time for report customization. Google helped, and so did the #trac IRC channel. If you&#8217;re lazy &#038; want to just jump to the solution, <a href="#trac-by-milestone-solution">do it</a>.</p>
<p>Here&#8217;s what I was looking for in my report:</p>
<ul>
<li>Group tickets by Milestone</li>
<li>Order milestones by due date, (soonest first)</li>
<li>If a milestone had no due date, put it at the end of the report, (if it&#8217;s important it&#8217;ll have a due date set, otherwise it&#8217;s a &#8220;backlog&#8221; item that hasn&#8217;t been prioritized yet.</li>
<li>Display the due dates with the milestone names.</li>
</ul>
<p>To get started, go to the Tickets by Milestone report that&#8217;s in Trac by default and click the &#8220;Copy Report&#8221; button, you&#8217;ll get a copy of Tickets by Milestone to play with. Click the Edit Report button and we&#8217;ll update the SQL to get the report we want. Grouping by Milestone is already done in this query, so we&#8217;ll start with ordering by milestone due date and putting milestones without a due date at the end of the report.</p>
<h3>Order by Milestone Due Date</h3>
<p>To order by date we need to join the milestone table. Add to the line after <code>FROM ticket t</code>:</p>
<p><code>LEFT JOIN milestone ms ON ms.name = t.milestone</code></p>
<p>Then to the beginning of the ORDER BY statement add <code>(ms.due &gt; 0) Desc,ms.due,</code> so the ORDER BY is now:</p>
<p><code>ORDER BY (ms.due &gt; 0) Desc,ms.due, (milestone IS NULL),milestone, CAST(p.value AS integer), t.type, time</code></p>
<p>The <code>(ms.due &gt; 0)</code> Desc part makes milestones that have a due date come first, then ms.due orders those by due date with the soonest first.</p>
<h3>Display Due Dates with Milestone Names</h3>
<p>For Trac 0.12 and above replace the line</p>
<p><code>'Milestone '||milestone AS __group__,</code></p>
<p>with:</p>
<p><code>'Milestone '||(milestone || CASE WHEN ms.due &gt; 0 THEN ', (due ' || datetime(ms.due/1000000, 'unixepoch')  || ' UTC)' ELSE '' END) AS __group__,</code></p>
<p>And for Trac versions below 0.12 replace the line with:</p>
<p><code>'Milestone '||(milestone || CASE WHEN ms.due &gt; 0 THEN ', (due ' || datetime(ms.due, 'unixepoch')  || ' UTC)' ELSE '' END) AS __group__,</code></p>
<p>The difference is that in Trac 0.12 dates, (at least milestone due dates), started to be stored as mircoseconds since the unix epoch, and before that they were stored as a simple unix timestamp, so now, to use SQLite&#8217;s datetime function we have to divide the stored value by 1,000,000.</p>
<p>This statement makes milestone names look like this:</p>
<blockquote><p>Milestone Page Style Updated, (due 2011-11-21 23:00:00 UTC)</p></blockquote>
<p>Note that there&#8217;s a UTC time listed. This is because I can&#8217;t figure out how to get a user&#8217;s timezone offset preference into the query. It would be relatively simple if the time was attached to a ticket, but in this case it&#8217;s attached to a milestone. If anyone knows how to work the proper timezone offset into the SQLite query please let me know.</p>
<h3>Bonus: Link the Milestone Titles to Reports Showing Only That Milestone</h3>
<p>It&#8217;s possible to create a link a list of that milestone&#8217;s tickets. Just add this line after the line that you just altered:</p>
<p><code>(CASE WHEN(milestone IS NOT NULL) THEN '../query?group=status&amp;milestone=' || milestone ELSE NULL END) AS __grouplink__,</code></p>
<p>The __grouplink__ column is a magic column that Trac understands and uses as a link for the group title, (in this case, the milestones).</p>
<h3 id="trac-by-milestone-solution">The Full Solution</h3>
<p>For you lazy folks, here&#8217;s the full query:<br />
<code><br />
SELECT p.value AS __color__,<br />
   'Milestone '||(milestone || CASE WHEN ms.due &gt; 0 THEN ', (due ' || datetime(ms.due/1000000, 'unixepoch')  || ' UTC)' ELSE '' END) AS __group__,<br />
  (CASE WHEN(milestone IS NOT NULL) THEN '../query?group=status&amp;milestone=' || milestone ELSE NULL END) AS __grouplink__,<br />
   id AS ticket, summary, component, version, t.type AS type,<br />
   owner, status,<br />
   time AS created,<br />
   changetime AS _changetime, t.description AS _description,<br />
   reporter AS _reporter<br />
  FROM ticket t<br />
  LEFT JOIN milestone ms ON ms.name = t.milestone<br />
  LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority'<br />
  WHERE status &lt;&gt; 'closed'<br />
  ORDER BY (ms.due &gt; 0) Desc,ms.due, (milestone IS NULL),milestone, CAST(p.value AS integer), t.type, time</code></p>
]]></content:encoded>
			<wfw:commentRss>http://johnbeales.com/20111119/improving-tracs-tickets-by-milestone-report/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Transferring OS X and Boot Camp to a New Hard Drive</title>
		<link>http://johnbeales.com/20110330/transferring-osx-bootcamp-to-new-hard-drive/</link>
		<comments>http://johnbeales.com/20110330/transferring-osx-bootcamp-to-new-hard-drive/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 17:45:28 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[boot camp]]></category>
		<category><![CDATA[change hard drive]]></category>
		<category><![CDATA[disk utility]]></category>
		<category><![CDATA[hard drive]]></category>
		<category><![CDATA[ifixit]]></category>
		<category><![CDATA[macbook]]></category>
		<category><![CDATA[macbook pro]]></category>
		<category><![CDATA[nvidia]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[partition]]></category>
		<category><![CDATA[recall]]></category>
		<category><![CDATA[replacement]]></category>
		<category><![CDATA[sata]]></category>
		<category><![CDATA[superduper]]></category>
		<category><![CDATA[upgrade]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[winclone]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://johnbeales.com/?p=467</guid>
		<description><![CDATA[For Christmas my brother gave me a copy of the game Portal, which required there to be about four gigabytes of available space on my hard drive. There wasn&#8217;t. In fact, every time I&#8217;ve wanted to copy a large file for the last while I&#8217;ve had to re-arrange and purge my hard drive, both in [...]]]></description>
			<content:encoded><![CDATA[<p>For Christmas my brother gave me a copy of the game Portal, which required there to be about four gigabytes of available space on my hard drive.  There wasn&#8217;t.  In fact, every time I&#8217;ve wanted to copy a large file for the last while I&#8217;ve had to re-arrange and purge my hard drive, both in OS X and in my Boot Camp partition.  It was time for a new, upgraded, hard drive, and this is how I was able to copy both my OS X partition and Boot Camp, (Windows), partitions to the new drive, and expand both partitions to fill my drive, all without re-installing any software.</p>
<h4>The Hardware</h4>
<p>First, the hardware.  I use a Macbook Pro that dates from the summer of 2007.  Until I made this change it had its factory-installed 160 GB, 5400 RPM hard drive.  This was an upgrade from the standard 120 GB drive, but three and a half years later it&#8217;s no longer big enough for me. I had dedicated 32 GB to my Boot Camp partition, which with a Vista installed was very cramped, perhaps even more cramped than my OS X partition that made up the balance of the drive.  I ordered a <a href="http://www.amazon.ca/gp/product/B003TOE4PQ?ie=UTF8&#038;tag=johbea03-20&#038;linkCode=as2&#038;camp=15121&#038;creative=390961&#038;creativeASIN=B003TOE4PQ" rel="nofollow">500GB, 7200 RPM Western Digital Scorpio Black </a><img src="http://www.assoc-amazon.ca/e/ir?t=johbea03-20&#038;l=as2&#038;o=15&#038;a=B003TOE4PQ" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, (yes, that&#8217;s an Amazon Affiliate link), hard drive from Amazon to replace the factory-installed drive. Apparently the WD Scorpio Black uses the same amount of power as a normal 5400 RPM drive, but is faster.  I&#8217;m not super concerned with power these days as my 3 1/2 year old battery doesn&#8217;t exactly hold a charge so I&#8217;m always plugged in anyway.</p>
<h5>A note on warranties and recalls:</h5>
<p>My laptop is in the group affected by the <a href="http://support.apple.com/kb/ts2377">NVIDIA Recall</a>, so even though my 3-year AppleCare is expired, (and it was worth it &#8211; a new mainboard and hard drive later), I am still covered for a few months if the video goes kaput.  I called Apple to see if I could change my hard drive without voiding that special coverage and they said that yes, so long as there was no physical damage to the computer, I would still be covered if my video died.</p>
<h4>My Best Way to Transfer Everything, Step by Step</h4>
<h5>Required Equipment</h5>
<ul>
<li>Your Mac, with the old hard drive still installed</li>
<li>Your new hard drive</li>
<li>A way to connect your new hard drive to your Mac, probably a SATA to USB connector, or an external hard drive case.</li>
</ul>
<h5>Required Software</h5>
<ul>
<li><a href="http://www.shirt-pocket.com/SuperDuper/SuperDuperDescription.html">SuperDuper!</a> The free, unregistered, version is fine</li>
<li>WinClone &#8211; The developer seems to have dropped off of the face of the earth, but <a href="http://download.cnet.com/Winclone/3000-2242_4-172338.html">you can still download the WinClone at Cnet</a>.</li>
</ul>
<h5>The Steps</h5>
<ol>
<li>Plug your new hard drive into your Mac, using whatever connector you have.</li>
<li>If your Mac isn&#8217;t already on, boot from your old hard drive</li>
<li>Using Disk Utility format your new hard drive.  Select a GUID Partition table, (so you can start your computer from the drive), and, unless you&#8217;ve specifically chosen another format, OS X Case-Insensitive, Journaled, as the format.  Make the partition as one single partition, (volume), that fills the whole drive.  We&#8217;ll add in a Boot Camp partition later.</li>
<li>Using SuperDuper! copy your OS X partition from your old drive to the new volume you just created on your new hard drive.  Use the &#8220;Backup &#8211; all files&#8221; option in SuperDuper!</li>
<li>Go clean the garage, or plant the garden.  This will take a while.  It took about four hours for me to copy about 115 Gigabytes of data</li>
<li>When SuperDuper! is finished its business shut off your computer and disconnect everything. You&#8217;re about to take your computer apart.</li>
<li>Find your computer on <a href="http://ifixit.com">iFixit.com</a> and make sure you have the appropriate tools.  I only needed two screwdrivers, however one of them was a T6 Torx screwdriver, and the smallest I had was a T8.  My father-in-law also had a T8 as his smallest.  We ended up using a file to give a hexagonal screwdriver a shape closer to a Torx screwdriver.</li>
<li>Follow the instructions on iFixit.com to replace your computer&#8217;s old hard drive with the new one that you copied OS X to in steps 4 &amp; 5.</li>
<li>Once everything&#8217;s connected, but before you&#8217;ve put your whole computer back together, I recommend starting up your computer to make sure everything&#8217;s connected properly.  Be careful not to touch anything inside your computer when it&#8217;s running, you could hurt yourself, (or worse, your computer!), if you touch the wrong thing. Once you know the hard drive is properly connected turn off your computer again and remove the power source.</li>
<li>Re-assemble your computer.</li>
<li>Hook your old hard drive up to your computer the same way you had the new hard drive hooked up before you installed it.</li>
<li>Start your computer.</li>
<li>If you did everything right you should be running off of your new hard drive now.  Check that you are running off of your new hard drive by starting finder and checking the size of your hard drive, or use Disk Utility to check the brand name of your hard drive, or just start without the old drive hooked up and connected it later.</li>
<li>Now we&#8217;re going to move your Boot Camp partition.
<ol>
<li>With the computer booted, and the old hard drive connected externally, start Boot Camp Assistant, (it&#8217;s in Applications > Utilities).</li>
<li>Follow the wizard to create a BootCamp partition. This partition does not need to be the same size as your old Boot Camp partition.  When Boot Camp Assistant asks you to insert a Windows install disk quit Boot Camp Assistant.  Your partition is created.</li>
<li>Install and run WinClone.  It will probably ask you to install the NTFSProgs Binaries, which it needs to do some reading and writing to NTFS-formatted filesystems, (like Windows partitions), these seem to be safe so go ahead and install them.</li>
<li>With WinClone you&#8217;ll first need to make a disk image, (a file that contains the whole contents of your old Boot Camp partition), then restore it to your new Boot Camp partition.  So, you&#8217;ll need OS X formatted space to store this image.  This could be your new hard drive if you&#8217;ve just installed a larger drive like I did, or it could be another external drive.</li>
<li>Tell WinClone to make an image of your old Boot Camp partition.  It took about 1/2 hour for me to image a 32 Gigabyte partition.</li>
<li>Tell WinClone to &#8220;restore&#8221; the data in the disk image you just made to your new Boot Camp partition.  This could take a while.  Grab lunch.</li>
<li>When WinClone is done turn off your Mac and disconnect the old hard drive.</li>
<li>Turn on your Mac holding down the Option key on the keyboard.  You should see your Boot Camp partition as a boot option, (it&#8217;s probably labeled &#8220;Windows&#8221;).  Select it to boot into Windows.</li>
<li>Windows may want to run a chkdisk.  It&#8217;s probably best to let it do so.  It shouldn&#8217;t take crazy long, but will probably take long enough to make a pot of coffee.</li>
<li>After chkdisk runs and you&#8217;re booted in Windows check everything is ok.</li>
</ol>
</li>
<li>That&#8217;s it.  Enjoy your new hard drive!</li>
</ol>
<h4>Notes on Backups</h4>
<p>The first time I connected my Time Machine drive to my Mac after doing the hard drive replacement Time Machine realized that I had installed a new hard drive and did a full backup.  This took a while, (especially because I accidentally pulled the USB cable out of the computer halfway through).  If you&#8217;re using a Time Capsule it is a good idea to plug your computer in to the Time Capsule with an ethernet cable, not do the full backup over the air.</p>
<p><a href="http://www.backblaze.com/partner/af1051">BackBlaze</a>, (again, that&#8217;s an affiliate link), which I use on two computers, didn&#8217;t notice the change in disks and continued as normal. I am pretty happy about that because the initial backup with any online service can take a long time and this saved me from uploading over 60 Gigabytes of data over my DSL connection.</p>
<h4>Notes on Fragmentation</h4>
<p>I took the opportunity to defragment both my Windows and OS X, (I use <a href="http://www.coriolis-systems.com/iDefrag.php">iDefrag</a> to defragment OS X.  In reality there was very little fragmentation on either side, I think that the process of copying everything from the old disk to the new one may have essentially defragmented everything anyway.</p>
<h4>Running my Boot Camp partition in VMWare Fusion</h4>
<p>The first time I tried to launch my Boot Camp partition in <a href="http://www.vmware.com/products/fusion/">VMWare Fusion</a> I got an error because the Boot Camp volume had changed.  It asked me to remove and re-add the virtual hard drive, which I couldn&#8217;t figure out how to do in 5 seconds, so I removed my Boot Camp partition from my Virtual Machine Library.  Then to re-add it I had to click &#8220;Home&#8221; in the VM Library window and choose &#8220;Run Windows from your Boot Camp partition&#8221; on the right hand side.  There&#8217;s a setup that&#8217;ll run for a few minutes, (it took less than 2 minutes for me), and the Boot Camp partition should be re-added to the VM Library. </p>
<h4>Windows Activation</h4>
<p>After I had my Boot Camp partition running for a while in VMWare Fusion Windows informed me that it had been deactivated due to a hardware change and I had to reactivate.  I don&#8217;t know if this was only because of the remove and re-add I did to the Boot Camp virtual machine, or if it was because of the actual hard drive change.  Either way Windows had to be reactivated, which is a pain since activation online never works for me anymore and I always have to activate Windows over the phone.  However, it&#8217;s activated now and seems to work fine.</p>
<h4>Conclusion</h4>
<p>While it seems like there were a lot of steps, and copying everything around took quite a while, it was much, much easier to copy everything from my old hard drive to a new one.  I didn&#8217;t have to re-install any software or any operating systems, something that I was afraid I would have to do.  It&#8217;s something that can be accomplished in about a day, if you have all of the tools and equipment on hand.  If you do it on the weekend then you don&#8217;t have to feel guilty about the downtime.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnbeales.com/20110330/transferring-osx-bootcamp-to-new-hard-drive/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Test ASP.NET apps on your Mac with VMWare Fusion &amp; DD-WRT</title>
		<link>http://johnbeales.com/20100121/test-asp-net-apps-on-your-mac-with-vmware-fusion-dd-wrt/</link>
		<comments>http://johnbeales.com/20100121/test-asp-net-apps-on-your-mac-with-vmware-fusion-dd-wrt/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 20:43:27 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[dd-wrt]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[vmware fusion]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://johnbeales.com/?p=334</guid>
		<description><![CDATA[Today I needed to test and fix mac-specific bugs in a website that is written in ASP.NET, but I generally use a Mac. When I work on the ASP.NET site I boot into Vista using Boot Camp, and the rest of the time I spend happily in OS X. I needed a solution to run [...]]]></description>
			<content:encoded><![CDATA[<p>Today I needed to test <strong>and fix mac-specific bugs in</strong> a website that is written in ASP.NET, but I generally use a Mac.  When I work on the ASP.NET site I boot into Vista using Boot Camp, and the rest of the time I spend happily in OS X.  I needed a solution to run both at the same time, and on the same computer, (this is the only mac I have, but my development environment for the .NET site is on my Boot Camp partition).  It was time to see if Virtualization has gotten any better.  It has.</p>
<p>There are two reasons that virtualization is better: VMWare Fusion 3.0 was released, and I doubled up my RAM, (now at 4GB).  With these two changes, and Aero turned off on the Windows side, Vista runs ok under VMWare Fusion on my ageing Macbook Pro.  Now to see changes made in Vista from OS X.</p>
<p>The simplest way I found to make this happen was to use some of the DHCP features DD-WRT on my router to assign a static IP address to my virtual machine and to map a URL to that IP.  I&#8217;ll do this in steps:</p>
<ol>
<li>Before starting your VM in VMWare, go to the settings for the VM > Network and choose &#8220;Bridged&#8221; then open the advanced section and click the button to generate a MAC address.  Copy the generated MAC address.</li>
<li>To to Services > Services in your DD-WRT web interface and in the DHCP Server box assign a static IP to the Mac address you just copied</li>
<li>In the DNSMasq box enter the following:<code>address=/the-url-you-want-to-map-to-the-vm/THE.IP.YOU.JUST.SET</code> entering, of course, the real values.</li>
<li>Hit Apply and Save at the bottom of the page</li>
<li>Start up your VM</li>
<li>Make sure that Windows Firewall is set up to let HTTP connections through</li>
<li>Type the URL you created in your browser in OS X and you should get the web page served by Windows</li>
<p>Now, there should be a way to make this work without the router, using NAT network mode for the VM and some hosts file edits in OS X.  I&#8217;m going to try to figure out how, but for now I just need to get some bugs fixed in the .NET app.  If anyone has any ideas how to make this happen <em>without</em> involving a router let me know, (or blog about it and leave a note in the comments).</ol>
]]></content:encoded>
			<wfw:commentRss>http://johnbeales.com/20100121/test-asp-net-apps-on-your-mac-with-vmware-fusion-dd-wrt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bringing my External Hard Drive Back to Life</title>
		<link>http://johnbeales.com/20100110/bringing-my-external-hard-drive-back-to-live/</link>
		<comments>http://johnbeales.com/20100110/bringing-my-external-hard-drive-back-to-live/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 20:18:57 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[diy]]></category>
		<category><![CDATA[external hard drive]]></category>
		<category><![CDATA[hard drive]]></category>
		<category><![CDATA[repair]]></category>
		<category><![CDATA[restore]]></category>
		<category><![CDATA[sata to usb]]></category>

		<guid isPermaLink="false">http://johnbeales.com/?p=322</guid>
		<description><![CDATA[Last Monday I wrote about restoring access to an outdated subversion repository after the hard drive in the computer that was being used as a subversion server died. That was my second hard drive failure of 2009, but at the time I thought it was the third. It turns out that what I had thought [...]]]></description>
			<content:encoded><![CDATA[<p>Last Monday I wrote about restoring access to an outdated subversion repository after the hard drive in the computer that was being used as a subversion server died.  That was my second hard drive failure of 2009, but at the time I thought it was the third.  It turns out that what I had thought was my second failure, the failure of the external drive that I use for backup and random storage, was in fact a case failure.  The drive is fine, and it is once again functional in a doctored case.</p>
<p>The drive in question is a 500GB <a href="http://www.trekstor.de/en/products/detail_hdd.php?pid=16">Trekstor Datastation maxi m.u</a> that I got at a boxing day sale at Future Shop a couple of years ago.  As many Canadians know, when something from Future Shop dies you&#8217;re pretty much on your own to fix it, so that&#8217;s what I did.  When the drive stopped working I googled it and discovered that a lot of people have had problems with the power supply to the drive.  Some have been able to fix the problem with new power adapters, so I tried using an all-in-one adapter that I had, but the drive behaved as it had with its own adapter.  Ever hopeful, I opened up the case and brought the drive to the in-laws&#8217; place to test it, and when inserted into a computer it worked, so all I had to do was replace or repair my case and I would have my external hard drive back again.</p>
<p>I looked online at new cases, but it seemed like a waste to get a whole new case when the only thing that was broken was a small circuit board, so I found a stand-alone <a href="http://www.tigerdirect.ca/applications/SearchTools/item-details.asp?Sku=M501-1180">SATA to USB converter</a> with no case and ordered that.  When it arrived I tested it and it worked, so today I set about putting the drive back in the case, but with the new adapter.  First, I removed the old electronics from the case.  However, the holes that were in the back panel were not large enough for the ends of the cables of the new adapter.<br />
<div id="attachment_323" class="wp-caption aligncenter" style="width: 510px"><img src="http://johnbeales.com/wp-content/uploads/2010/01/drive-with-back.jpg" alt="The back of my hard drive case" title="Back of the Hard Drive" width="500" height="152" class="size-full wp-image-323" /><p class="wp-caption-text">None of the new cables will fit through these holes!</p></div></p>
<p>Out came the <a href="http://dremel.com">Dremel</a> and most of the back panel was cut out to make room for cables &#038; electronics.  Once I had made the cut, cleaned up, re-mounted the drive, and re-attached the back plate, I had a good hole through which I could attach my shiny new adapter and keep the drive itself protected.<br />
<div id="attachment_325" class="wp-caption aligncenter" style="width: 510px"><img src="http://johnbeales.com/wp-content/uploads/2010/01/drive-back-out.jpg" alt="The back plate of the drive case has been removed." title="Drive with the back removed" width="500" height="295" class="size-full wp-image-325" /><p class="wp-caption-text">That's better.  I can reach through there.</p></div></p>
<p> My only complaint is that the USB cable on the adapter is a bit short, so I may have to get a hub or something to pretend it&#8217;s an extension able.  For the moment I have just re-arranged my desk slightly.<br />
<div id="attachment_326" class="wp-caption aligncenter" style="width: 510px"><img src="http://johnbeales.com/wp-content/uploads/2010/01/drive-complete.jpg" alt="The drive, in the case, with the new adapter attached." title="Complete" width="500" height="277" class="size-full wp-image-326" /><p class="wp-caption-text">The drive, in the case, with the new adapter attached.</p></div></p>
<p>* A note on image quality:  My camera went missing a while ago, so the best I can do right now is the iSight built in to my laptop.  Sorry!</p>
]]></content:encoded>
			<wfw:commentRss>http://johnbeales.com/20100110/bringing-my-external-hard-drive-back-to-live/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Update an Outdated Subversion Repository from a Working Copy</title>
		<link>http://johnbeales.com/20100104/update-outdated-subversion-repository-from-working-copy/</link>
		<comments>http://johnbeales.com/20100104/update-outdated-subversion-repository-from-working-copy/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 18:33:56 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[recovery]]></category>
		<category><![CDATA[repository]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[working copy]]></category>

		<guid isPermaLink="false">http://johnbeales.com/?p=316</guid>
		<description><![CDATA[Last week the hard drive on my Subversion server failed and I had to rely on my backups to bring up a new server.  My most recent backup was not 100% current, so I ended up with a Subversion repository at revision 935, but a working copy at revision 953.  This is the story of [...]]]></description>
			<content:encoded><![CDATA[<p>Last week the hard drive on my Subversion server failed and I had to rely on my backups to bring up a new server.  My most recent backup was not 100% current, so I ended up with a Subversion repository at revision 935, but a working copy at revision 953.  This is the story of how to reconcile the working copy with the backup so that your latest work is once again in your repository, on a Mac.</p>
<p>First, I looked for a way to simply import my working copy, along with any version info that it might have, but that doesn&#8217;t seem to exist.  Then, I tried just committing a new revision to the repository, (it had the same URL as the one on the failed hard drive), but that lead to subversion errors.  It turns out, that if your working copy has a revision number that is higher than that in the repository, you need to check out a new working copy, then copy changes from your old working copy into your new one, the commit your changes to the new working copy.  It sounds easy enough, but there are a couple of gotchas to watch out for, like those pesky .svn folders, so here is a recipe for merging a working copy with an outdated repository, so that the repository is brought up to date:</p>
<ol>
<li>In your existing working copy, (I&#8217;ll call this the &#8220;old working copy&#8221; from now on), make sure that you&#8217;ve done an <code>svn add</code> for any files that are not yet under version control but you want to make the transfer.</li>
<li>Check out a new working copy from the outdated repository, (I&#8217;ll call this the &#8220;new working copy&#8221;).</li>
<li>On the old working copy, do an <code>svn export</code>.  This gets you all of your most recent files, but without any .svn folders in the mix.</li>
<li>In Terminal copy the exported files into the new working copy by running the command <code>cp -R exported_folder/* new-working-copy-folder</code></li>
<li>[optional] Do an <del><code>svn info</code></del><ins><code>svn status</code></ins> on the new working copy.  It should show that you need to check in all of the changes you made since the repository was last updated, (or since your last backup).</li>
<li>Commit the changes in your new working copy.   You are finished, (you might want to archive the old working copy at this point in case something didn&#8217;t work right).</li>
</ol>
<p>Your new repository should now have the latest work in it from your working copy.  You will have lost the revision history between your latest backup and whatever you had in your working copy, but you won&#8217;t have lost it all, and you will once again be up and running and ready to code, (or write, or whatever).</p>
<p>Of course, you could avoid this whole hassle by making sure your backups are always up to date.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnbeales.com/20100104/update-outdated-subversion-repository-from-working-copy/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Get your Development Server Running after Upgrading to Snow Leopard</title>
		<link>http://johnbeales.com/20090828/get-your-development-server-running-after-upgrading-to-snow-leopard/</link>
		<comments>http://johnbeales.com/20090828/get-your-development-server-running-after-upgrading-to-snow-leopard/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 18:13:22 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[10.6]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[development server]]></category>
		<category><![CDATA[httpd-vhosts.conf]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[mamp]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[timezone]]></category>
		<category><![CDATA[virtualhost]]></category>

		<guid isPermaLink="false">http://johnbeales.com/?p=302</guid>
		<description><![CDATA[After upgrading to Snow Leopard today I tried to access my localhost versions of the websites I have under development and was met by this great message, (impatient? skip to the step-by-step solution): Forbidden You don&#8217;t have permission to access / on this server. Great. I couldn&#8217;t even access http://john-mbp/ &#8211; my computer&#8217;s name, and [...]]]></description>
			<content:encoded><![CDATA[<p>After upgrading to Snow Leopard today I tried to access my localhost versions of the websites I have under development and was met by this great message, (impatient?  <a href="#solution">skip to the step-by-step solution</a>):</p>
<blockquote><p>Forbidden</p>
<p>You don&#8217;t have permission to access / on this server.</p>
</blockquote>
<p>Great.  I couldn&#8217;t even access http://john-mbp/ &#8211; my computer&#8217;s name, and the URL that the System Preferences&#8217; Web Sharing pane tells me I can access.  However, all is not lost.</p>
<h4>Part 1: Get the Virtualhosts Online</h4>
<p>The first place I looked was my httpd-vhosts.conf file, located in /var/apache2/extra, (this has not changed since 10.5), and as I suspected it had been reset to the Apache defaults, (thanks Apple).  I suspected this might happen though, and had made a backup of the file, (actually, I backed up my whole hard drive, then made a separate, easier to find, copy of the file).  Replacing the new httpd-vhosts.conf with the old one and doing an <code>sudo apachectl graceful</code> got the virtualhosts responding to requests again.</p>
<h4>Part 2: Establish a MySQL Connection</h4>
<p>While my virtualhosts were up and running at this point they did not have a MySQL connection.  Maybe this is because <a href="/20090828/getting-macports-to-work-snow-leopard/">my MySQL installation is from MacPorts</a> so the socket is in a different place, or maybe not.  Either way it had to be fixed.</p>
<p>Upon running a <code>phpinfo();</code> I discovered a couple of things.  First, the included version of PHP is now 5.3.0 and second, PHP was not loading any php.ini file, so I went on a php.ini hunt and found 2 files: php.ini.default and php.ini.default-5.2-previous, both located in /etc.  Copying php.ini.default to /etc/php.ini and doing a <code>sudo apachectl graceful</code> brought my MySQL connections back online, leaving one final problem.</p>
<h4>Part 3: Getting rid of the timezone warnings</h4>
<p>Since I usually code with an error reporting level of E_ALL, and PHP 5.3 doesn&#8217;t seem to like not having a timezone set in the php.ini file, (it&#8217;s not set by default, at least not in Snow Leopard), I was getting a bunch of warnings whenever I used the <code>date();</code> function in PHP, so, I needed to set a default timezone in php.ini.  If you don&#8217;t already know the PHP name for your timezone, go to the <a href="http://us3.php.net/manual/en/timezones.php">PHP timezones</a> page and find it, then open php.ini, (<code>sudo vi /etc/php.ini</code> the sudo is important), and search for &#8220;timez&#8221; to find the timezone section of the file.  Now, on the line that says &#8220;;date.timezone = &#8221; add the name of your timezone after the equals sign and remove the semicolon from the beginning of the line. Once you&#8217;ve done that, save the file, (it&#8217;s set as read-only for some reason so in vi you need to do <code>:w!</code> to make it save), then quit your text editor and do one more <code>sudo apachectl graceful</code> and you should be good to go.</p>
<h4 id="solution">Step by Step</h4>
<ol>
<li>before installing, <strong>back up your computer</strong></li>
<li>before installing, make a copy of /etc/apache2/extra/httpd-vhosts.conf and put it somewhere safe</li>
<li>install Snow Leopard</li>
<li>replace the new /etc/apache2/extra/httpd-vhosts.conf with the old one you saved in step 2.  If you don&#8217;t have a backup you&#8217;ll have to re-enter your virtualhosts in the new httpd-vhosts.conf file which isn&#8217;t the end of the world</li>
<li>in Terminal type <code>sudo apachectl graceful</code> and enter your password if prompted to restart apache with the new configuration.  Your virtualhosts should now be online</li>
<li>rename or copy /etc/php.ini.default to /etc/php.ini (<code>sudo cp /etc/php.ini.default /etc/php.ini</code>)</li>
<li>Find the name of your PHP timezone, (look on the <a href="http://us3.php.net/manual/en/timezones.php">PHP timezones page</a>). Write it down.</li>
<li>Edit the new php.ini file to have the correct timezone.
<ol>
<li>open the new php.ini file (<code>sudo vi /etc/php.ini</code>)</li>
<li>find the timezone section, (type <code>/timez</code> and press enter).</li>
<li>move your cursor to the line that says &#8220;;date.timezone = &#8221; using the arrow keys</li>
<li>press the i key to edit the text</li>
<li>add the name of your PHP timezone after the equals sign</li>
<li>remove the semicolon from the beginning of the line</li>
<li>press the escape key to stop editing the text</li>
<li>type <code>:w!</code> to save the file</li>
<li>type <code>:q</code> to quit the text editor</li>
</ol>
</li>
<li>One final <code>sudo apachectl graceful</code> and you should be back up and running.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://johnbeales.com/20090828/get-your-development-server-running-after-upgrading-to-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Getting MacPorts to work Snow Leopard</title>
		<link>http://johnbeales.com/20090828/getting-macports-to-work-snow-leopard/</link>
		<comments>http://johnbeales.com/20090828/getting-macports-to-work-snow-leopard/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 17:30:16 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Hints, Techniques & More]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[10.6]]></category>
		<category><![CDATA[broken]]></category>
		<category><![CDATA[doesn't work]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[fixed]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[solution]]></category>

		<guid isPermaLink="false">http://johnbeales.com/?p=298</guid>
		<description><![CDATA[Impatient? Skip to the process and go right to the solution. I&#8217;m writing this using my shiny new OS X 10.6 Snow Leopard installation. So far it&#8217;s pretty good. I haven&#8217;t tried any heavy lifting so I don&#8217;t know if it&#8217;s really that much faster. This is the first in a series of posts on [...]]]></description>
			<content:encoded><![CDATA[<p>Impatient?  Skip to the process and go right to the <a href="#solution">solution</a>.</p>
<p>I&#8217;m writing this using my shiny new OS X 10.6 Snow Leopard installation.  So far it&#8217;s pretty good.  I haven&#8217;t tried any heavy lifting so I don&#8217;t know if it&#8217;s really that much faster.</p>
<p>This is the first in a series of posts on how to get things working in Snow Leopard that got eaten during the installation.  First up:  MacPorts.</p>
<p>I ran into some issues with <a href="http://mysql.com">MySQL</a>, (more on that later), and since my MySQL install is a <a href="http://macports.org">MacPort</a> I thought I would do an update to make sure things were working properly.  However, this is what happened when I typed <code>sudo port list installed</code>:</p>
<blockquote><p><code>dlopen(/opt/local/share/macports/Tcl/pextlib1.0/Pextlib.dylib, 10): no suitable image found.  Did find:<br />
	/opt/local/share/macports/Tcl/pextlib1.0/Pextlib.dylib: no matching architecture in universal wrapper<br />
    while executing<br />
"load /opt/local/share/macports/Tcl/pextlib1.0/Pextlib.dylib"<br />
    ("package ifneeded Pextlib 1.0" script)<br />
    invoked from within<br />
"package require Pextlib 1.0"<br />
    (file "/opt/local/bin/port" line 40)</code></p></blockquote>
<p>So, I tried <code>sudo port selfupdate</code> and ran into the same problem.  Whatever port command I tried I got the same response, clearly I needed to take some sort of action.  After a quick look at the MacPorts website I figured I should update my Xcode Tools to the Snow Leopard version, so I did that, (there&#8217;s an installer in the Optional Installs folder on the Snow Leopard disk) and tried <code>sudo port list installed</code> again, and got the same response as before.</p>
<p>Some quick Googling &#038; reading resulted in no quick answer, so I figured that since I don&#8217;t really have anything irreplaceable in my MySQL databases I would download the Snow Leopard DMG from the <a href="http://macports.org/install.php">MacPorts download page</a>, install, and see what happened.  That&#8217;s the solution!  <span id="solution">Just download the Snow Leopard DMG and re-install.</span>  All of your ports will still be there, and mine seem to be working so far.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnbeales.com/20090828/getting-macports-to-work-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Using Microsoft&#8217;s VPC Images with VMWare Fusion</title>
		<link>http://johnbeales.com/20090522/using-microsofts-vpc-images-with-vmware-fusion/</link>
		<comments>http://johnbeales.com/20090522/using-microsofts-vpc-images-with-vmware-fusion/#comments</comments>
		<pubDate>Fri, 22 May 2009 13:52:55 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Cool]]></category>
		<category><![CDATA[Hints, Techniques & More]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[virtual pc]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[vmware fusion]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://johnbeales.com/?p=248</guid>
		<description><![CDATA[We all know the sinking feeling when we have to test a website in Internet Explorer. You built the site, it looks beautiful in Firefox and maybe Safari too, but now you have to open up Internet Explorer 6, 7, and 8, and make sure it plays nice with all three of them. Even better, [...]]]></description>
			<content:encoded><![CDATA[<p>We all know the sinking feeling when we have to test a website in Internet Explorer.  You built the site, it looks beautiful in Firefox and maybe Safari too, but now you have to open up Internet Explorer 6, 7, and 8, and make sure it plays nice with all three of them.  Even better, Microsoft has made it so that you can only have one version of IE installed on a computer at a time. True, you can use things like <a href="http://tredosoft.com/Multiple_IE">Multiple IEs</a> or other similar products, but they never play quite right.</p>
<p>Fortunately, Microsoft has supplied us with <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=21eabb90-958f-4b64-b5f1-73d0a413c8ef&#038;displaylang=en">Virtual PC images</a> of Windows with Internet Explorer installed.  Unfortunately, Virtual PC is a Windows-only program so you need a PC to run them on.  Or do you?</p>
<p>You don&#8217;t!  If you&#8217;re using OS X you can use <a href="http://vmware.com/products/fusion/">VMWare Fusion</a> to run those Microsoft VPC images, after a little tweaking.  It is much easier if you have a copy of Windows available to you during the install process, (that&#8217;s how I did it), but I don&#8217;t believe this is an absolute necessity.  Here&#8217;s how it works:</p>
<p>Basically, you need to download the VPC images, extract them, and convert them into VMWare Fusion virtual machines.  It sounds trickier than it is.</p>
<p>First, download and extract the VPC images.  If you can use Windows to do this it&#8217;s easy, (the images have self-extractors), if not try <a href="http://p7zip.sourceforge.net/">p7zip</a>, (see instructions in <a href="http://communities.vmware.com/docs/DOC-7250">this forum thread</a>).</p>
<p>[edit: July 15, 2009]: Then, somehow, you have to convert your VHD files into VMC files.  The easiest way to do this is to use Microsoft&#8217;s VPC to make a new virtual machine from the VHD files, but you do need windows to do that. You will be converting these .VMC files into VMWare native virtual machines.<br />
[/edit]</p>
<p>To convert the VPC images to something else, use <a href="http://www.vmware.com/products/converter/">VMWare vCenter Converter</a>.  It&#8217;s a stand-alone program for Windows or Linux that easily converts VPC images to VMWare Fusion virtual machines, as well as several other formats.  You can even choose between Fusion 1.x and Fusion 2.x.  It will even install the VMWare tools pagkage for you.  I did the conversion under Windows, but there&#8217;s probably a way to get the linux version to run under OS X, at least hopefully.</p>
<p>Once the conversion is complete, fire up OS X &#038; VMWare Fusion and open your new Virtual PC image. There are some things that run on the first startup of each machine, give it a few minutes then hit cancel on all of the &#8220;Please insert the XP SP3 CD&#8221; messages that remain, it doesn&#8217;t seem to hurt Windows.  I think it&#8217;s looking for a battery driver in my case, (maybe I should try to install the Bootcamp battery driver?).</p>
<p>That&#8217;s it, enjoy testing.  I am able to run, slowly, all 3 IE versions with the Windows XP images, and my computer isn&#8217;t as slow as when I run only my Bootcamp Vista install under VMWare Fusion.  I&#8217;m thrilled to have these 3 new debugging tools at my disposal.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnbeales.com/20090522/using-microsofts-vpc-images-with-vmware-fusion/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Using CSS attribute selectors to simulate legacy HTML layout</title>
		<link>http://johnbeales.com/20090202/using-css-attribute-selectors-to-simulate-legacy-html-layout/</link>
		<comments>http://johnbeales.com/20090202/using-css-attribute-selectors-to-simulate-legacy-html-layout/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 22:11:53 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[attribute selector]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[legacy content]]></category>
		<category><![CDATA[legacy html]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://johnbeales.com/?p=199</guid>
		<description><![CDATA[Have you ever created new clean XHTML template, applied it to a CMS with years of back content, and discovered that the years of legacy HTML looks terrible?  Because you&#8217;re using a new XHTML doctype many, if not all, of the presentational attributes in the old HTML no longer work, however, CSS can be used [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever created new clean XHTML template, applied it to a CMS with years of back content, and discovered that the years of legacy HTML looks terrible?  Because you&#8217;re using a new XHTML doctype many, if not all, of the presentational attributes in the old HTML no longer work, however, CSS can be used to fix this.</p>

<p>You may say that the whole point of building a new template with XHTML &amp; CSS is so that we won&#8217;t have any of the old <code>&lt;p align="right"&gt;</code> in our code, and you are right, but in situations when there can be thousands of pages of content it is often not practical to re-code them all using CSS, that&#8217;s where the attribute selectors come in.</p>

<p>Here is a very basic stylesheet that will help get you started:
<code><br />
img[align="right"], table[align="right"] {float:right;}<br />
img[align="left"], table[align="left"] {float:left;}<br />
img[align="center"], table[align="center"] {display:block;margin-left:auto;margin-right:auto;}
<br /><br />
p[align="center"] {text-align:center;}<br />
p[align="left"] {text-align:left;}<br />
p[align="right"] {text-align:right;}
<br /><br />
table[border="2"], table[border="2"] td {border:1px solid #000;}<br />
table[border="1"], table[border="1"] td {border:1px solid #000;}<br />
table[border="0"], table[border="0"] td {border:0;}</code></p>

<p>Although it would be nice to have one master stylesheet that we could drop in to a document and automatically have the old HTML look great, I believe that stylesheet would have to be extremely large, so I recommend using a base set of styles, (like the one above), and adding any extra styles to it that may be needed, (for example, <code>img[border="5"] {border:5px solid #000}</code> would not be needed every time).</p>

<p>What about browser compatibility? I&#8217;ve tested in FireFox 3, Safari 3, Internet Explorer 7, and Internet Explorer 6, and, if I remember correctly, Opera 9.  The only browser that didn&#8217;t render the styles as I would have liked to see them was IE6, which is no surprise, but also has a rapidly diminishing market share.</p>

<p>If you are looking for a way to keep your legacy HTML from looking terrible that doesn&#8217;t involve recoding it all, this may be the way for you to go.</p>]]></content:encoded>
			<wfw:commentRss>http://johnbeales.com/20090202/using-css-attribute-selectors-to-simulate-legacy-html-layout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using VLC to transcode an Axis Camera&#8217;s video stream, and stream it out again</title>
		<link>http://johnbeales.com/20080820/using-vlc-to-transcode-an-axis-cameras-video-stream-and-stream-it-out-again/</link>
		<comments>http://johnbeales.com/20080820/using-vlc-to-transcode-an-axis-cameras-video-stream-and-stream-it-out-again/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 14:28:18 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Hints, Techniques & More]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[axis]]></category>
		<category><![CDATA[camera]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[h.264]]></category>
		<category><![CDATA[ip camera]]></category>
		<category><![CDATA[live streaming]]></category>
		<category><![CDATA[live video]]></category>
		<category><![CDATA[streaming]]></category>
		<category><![CDATA[transcode]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[vlc]]></category>
		<category><![CDATA[wowza]]></category>
		<category><![CDATA[wowza media server pro]]></category>

		<guid isPermaLink="false">http://johnbeales.com/?p=123</guid>
		<description><![CDATA[VLC likes to die when transcoding an rtsp stream from an Axis camera then re-streaming it.  However, by using a named pipe and two instances of VLC it is possible to make this work.]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve been working on streaming live video from IP cameras to a Flash player on a website.  It sounds simple, but not so much, (if you&#8217;re in a hurry, <a href="#vlc-transcode-solution">skip to the solution</a>).</p>
<p>The problem is that most IP cameras are not made for streaming live, full-motion, events to the web.  They&#8217;re made for surveillance at 11 <abbr title="Frames Per Second">FPS</abbr> in Motion JPEG format, (that&#8217;s just a bunch of JPEG images coming one after another).  This is obviously not ideal from a bandwidth perspective at all.  The cameras that our project uses are <a href="http://www.axis.com">Axis</a> 207 and 210 cameras.  These cameras are capable of streaming MPEG-4 video, and when you look at the video in a web browser it looks pretty good.  When I first saw that, I was excited &#8211; I could just stream into a Flash media server, (We&#8217;re using <a href="http://www.wowzamedia.com/">Wowza Media Server Pro</a> at the moment), and that would send everything off to the player, right?  Wrong.</p>
<p>It turns out that most, if not all, Axis products stream in MPEG4-ES, which flash cannot understand, and therefore our server rejects.  I had to find a way to change MP4V-ES to h.264.</p>
<p>The obvious solution to transcoding the video stream from MP4V-ES to h.264 is <a href="http://www.videolan.org">VLC</a>.  While it looks like a media player that can handle a lot of formats, under the surface lies a powerful, command-line based, transcoding and streaming program.  I discovered that, in theory, I should be able to issue one command to VLC and have it receive the MPEG4-ES stream from the camera, transcode it to h.264, and stream it to the Wowza, which would handle the rest.</p>
<p>I started by opening a file, transcoding it to h.264, and streaming it to Wowza:</p>
<p><code>vlc -vvv /path/to/file/Extremists.m4v --sout "#transcode{venc=x264,vcodec=x264,vb=500,scale=1,acodec=mp4a,ab=32,channels=2,samplerate=22100}:rtp{dst=SERVER-IP-ADDRESS,sdp=file:///path/to/wowza/content/myStream.sdp}"</code></p>
<p>It was a little rough, as the testing server doesn&#8217;t have a lot of processing power, but it worked.  Awesome.  Now I just have to hook it up to the stream from the camera, right?</p>
<p>I added the camera as the source and removed the sound:</p>
<p><code>vlc -vvv rtsp://camera-ip-address:554/mpeg4/1/media.amp --no-sout-audio --sout "#transcode{venc=x264,vcodec=x264,vb=200,scale=1}:rtp{dst=SERVER-IP-ADDRESS,sdp=file:///absolute/path/to/wowza/content/myStream.sdp}"</code></p>
<p>With Wowza already running on the server, I typed that in to terminal, and it started to look good.  Then PAF! I get this error:</p>
<p><code>[00000385] access_output_udp private debug: mmh, hole (147841635484807 &gt; 2s) -&gt; drop</code></p>
<p>VLC seems to think that a frame, or some piece of information has been delayed 147841635484807 seconds.  I highly doubt that, but VLC is convinced.  Try as I might, I was not able to get VLC to realize that the frame, (or whatever bit of info), was simply missing a timestamp or something.</p>
<p>So, I figured I would debug just the connection to the camera.  I opened a VNC session, and ran this:</p>
<p><code>vlc -vvv rtsp://camera-ip-address:554/mpeg4/1/media.amp</code></p>
<p>To see if I could view the video.  I could, so I tried saving it to a file:</p>
<p><code>vlc -vvv rtsp://CAMERA-IP-ADDRESS:554/mpeg4/media.amp --no-drop-late-frames --no-sout-audio --sout "#std{mux=ts,access=file,dst=/tmp/camstream.m4v}"</code></p>
<p>This worked also.  It appears that the problem only occurs when I am trying to open, transcode, and send out the stream all at once.</p>
<p id="vlc-transcode-solution">I realized, if I can transcode from a file and stream, and if I can capture a stream and save it to a file, I should be able to do both at the same time.  It works!  The steps are, make the pipe:</p>
<p><code>mkpipe /tmp/vpipe</code></p>
<p>Then capture the stream and save it to the pipe:</p>
<p><code>vlc -vvv rtsp://CAMERA-IP-ADDRESS:554/mpeg4/media.amp --no-drop-late-frames --no-sout-audio --sout "#std{mux=ts,access=file,dst=/tmp/vpipe}"</code></p>
<p>And finally read from the pipe, transcode, and stream to the flash server:</p>
<p><code>vlc -vvv /tmp/vpipe --no-sout-audio --sout "#transcode{venc=x264,vcodec=x264,vb=500,scale=1}:rtp{dst=SERVER-IP-ADDRESS,sdp=file:///path/to/wowza/content/myStream.sdp}"</code></p>
<p>Shazam!</p>
<p>There are a couple of caveats, though:</p>
<ul>
<li>This sucks major processing horsepower.  Make sure you&#8217;ve got enough</li>
<li>To make a stream work this way you have to have 2 copies of VLC running, plus your flash server.  That&#8217;s a lot of parts that could have a problem</li>
</ul>
<p>Because of these caveats, I am still looking for an alternate solution, and may stream MPEG-4 to browsers until Axis has its h.264 products ready later this year.</p>
<p>Yesterday, I did find a second possible solution.  Instead of using the first instance of VLC to capture the stream, it is sometimes possible to use Darwin Streaming Server to capture the stream, then use 1 instance of VLC to transcode it. This seems to use much less processing power, but is not 100% reliable either.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnbeales.com/20080820/using-vlc-to-transcode-an-axis-cameras-video-stream-and-stream-it-out-again/feed/</wfw:commentRss>
		<slash:comments>54</slash:comments>
		</item>
	</channel>
</rss>

