<?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 Ford &#187; Programming</title>
	<atom:link href="http://blog.johnford.org/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.johnford.org</link>
	<description>the things that I remembered to write about</description>
	<lastBuildDate>Fri, 03 Feb 2012 21:48:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Writting a native rm program for Windows</title>
		<link>http://blog.johnford.org/writting-a-native-rm-program-for-windows/</link>
		<comments>http://blog.johnford.org/writting-a-native-rm-program-for-windows/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 17:13:26 +0000</pubDate>
		<dc:creator>John Ford</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.johnford.org/?p=380</guid>
		<description><![CDATA[Our Windows build machines use msys to emulate a posix environment.  Msys is great tool, providing a lot of common posix utilities, like cp, mv, rm.  Sadly there are bugs in the posix emulation.  For us, this manifests in the &#8230; <a href="http://blog.johnford.org/writting-a-native-rm-program-for-windows/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Our Windows build machines use msys to emulate a posix environment.  Msys is great tool, providing a lot of common posix utilities, like cp, mv, rm.  Sadly there are bugs in the posix emulation.  For us, this manifests in the rm program being unable to delete certain files.</p>
<p><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=583129">Bug 583129</a> is about using native Windows tools for file removals.  In that bug, we&#8217;ve looked at a combination of the rmdir and attrib Windows tools.  The problem is that rmdir doesn&#8217;t like to delete files if they have the read-only or system attribute.  To fix that, we need to run attrib to remove those attributes then rmdir to delete them.  Running rmdir is fast but attrib is very slow.</p>
<p>Last year, I spent a bit of time writing a native windows version of rm.  I am by no means a Windows developer, so I spent a couple hours learning the basics of the Windows API.  The API is quite different to what I&#8217;m used to, but the documentation seems to have been written quite well for my purposes.  I was able to get the basics working pretty quickly.  Yesterday, I decided to finish up the program by adding directory deletion, recursive deletes and a command line parser.</p>
<p>I present to you winrm.  The code is available in my <a href="http://hg.mozilla.org/users/jford_mozilla.com/jhford-native-rm/">Mozilla user repo</a>.  This tool works similarly to the standard posix rm utility.  For simplicity&#8217;s sake, only single character options are supported.  These options can be joined, like &#8220;-rf&#8221;, or specified individually, like &#8220;-r -f&#8221;.  The &#8220;&#8211;&#8221; option is also supported, signalling the program to treat all following arguments as files to be deleted.  Because of how the option parser works, files are deleted in reverse order to how they are on the command line.</p>
<pre>jhford@JHFORD-VM ~/mozilla/jhford-native-rm
$ touch a b c d e

jhford@JHFORD-VM ~/mozilla/jhford-native-rm
$ winrm -v -- a b c d e
deleting "e"
deleted "e"
deleting "d"
deleted "d"
deleting "c"
deleted "c"
deleting "b"
deleted "b"
deleting "a"
deleted "a"</pre>
<p>Because my program is written in standard Windows API and is a much simpler program, it is also much faster than the msys rm program.  To test this, I timed deletion of a mozilla-central clone using both mine and msys&#8217; rm.  My program took 37s where the msys program took 113s.</p>
<p>If you know the Windows API and have the cycles, please let me know if you find any glaring errors with my program.   If you want to test the program without having to build it, I&#8217;ve uploaded a copy here <a href="http://blog.johnford.org/wp-content/uploads/2012/02/winrm-0.1.exe">winrm-0.1</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.johnford.org/writting-a-native-rm-program-for-windows/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Using OpenVPN to tunnel all traffic through my home server</title>
		<link>http://blog.johnford.org/openvpn-tunnel-to-home-server/</link>
		<comments>http://blog.johnford.org/openvpn-tunnel-to-home-server/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 07:25:09 +0000</pubDate>
		<dc:creator>John Ford</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.johnford.info/?p=339</guid>
		<description><![CDATA[I want to be able to send all my internet traffic to the Linux machine I have running in my apartment and I am not a networking expert. My motivation for this post is threefold; document my process for future &#8230; <a href="http://blog.johnford.org/openvpn-tunnel-to-home-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I want to be able to send all my internet traffic to the Linux machine I have running in my apartment and I am not a networking expert.  My motivation for this post is threefold; document my process for future reference, share my info and see if people have suggestions for how to do this better.  I am not going to go through every option, just what I did and what worked for me.</p>
<p>The next step was to figure out what I needed to do.  I decided on using openvpn because I already use it for work and because it&#8217;s open source.  I found the <a href="http://openvpn.net/index.php/open-source/documentation/howto.html">how-to document</a> on the openvpn site to be really useful.  I am using Fedora, so I skipped the section on installing openvpn from source and ran &#8220;<code>sudo yum install openvpn</code>&#8220;.  My next step was to copy the pki support files into a directory by running &#8220;<code>cp -r /usr/share/openvpn/easy-rsa/2.0/* .</code>&#8220;.  I then followed the <a href="http://openvpn.net/index.php/open-source/documentation/howto.html#pki">directions</a> for generating the pki infrastructure.</p>
<p>For this to work you need an open port on your server.  I used the openvpn standard of 1194.  I tested that the port was open with netcat by running &#8220;<code>nc -l 1194</code>&#8221; on my server and &#8220;<code>nc server.name 1194</code>&#8220;.  Writing on either terminal will show the output on the other on EOL.</p>
<p>At this point, I needed to set up the server configuration.  I copied the sample config file to my directory by running &#8220;<code>cp cp /usr/share/doc/openvpn-2.1.4/sample-config-files/server.conf server.conf</code>&#8220;.  I found that the sample server config file seemed to work great for me with the following changes:
<pre>
diff -U0 sample-config-files/server.conf config/server.conf
--- sample-config-files/server.conf	2011-12-12 21:43:31.000000000 -0800
+++ config/server.conf	2011-12-12 22:16:46.000000000 -0800
@@ -196,0 +197,2 @@
+push "dhcp-option DNS 0.0.0.0"
+push "dhcp-option DNS 0.0.0.0"
@@ -204 +206 @@
-;client-to-client
+client-to-client
</pre>
<p>The first change pushes DNS servers to my client (fake ips, obviously) and the second change is to allow different clients to talk to each other.  I am not sure how useful the inter-client link will end up being.</p>
<p>I am using the Viscosity client because that&#8217;s the only sane way to do this on OS X and Windows.  Sending all traffic over the vpn link is the default behaviour for Network Manager (Linux).  I started with the sample by running &#8220;<code>cp /usr/share/doc/openvpn-2.1.4/sample-config-files/client.conf .</code>&#8220;.  My changes where pretty basic:
<pre>
diff -U0 sample-client.conf client.conf
--- sample-client.conf	2011-12-12 22:43:11.000000000 -0800
+++ client.conf	2011-12-12 21:49:17.000000000 -0800
@@ -42 +42 @@
-remote my-server-1 1194
+remote server.name 1194
@@ -89,2 +89,2 @@
-cert client.crt
-key client.key
+cert laptop.crt
+key laptop.key</pre>
<p>At this point, the client side configuration was ready to transfer, so I tarred up the needed files with:
<pre>
mkdir ovpn-configs
cp keys/ca.crt keys/laptop.crt keys/laptop.key client.conf ovpn-configs/
tar jcf laptop-openvpn-config.tar.bz2 ovpn-configs</pre>
<p>and used scp to transfer the files over to my laptop.</p>
<p>Once on my laptop, I untarred the files and imported the configuration into Viscosity.  I did this by:
<ul>
<li>clicking on Viscosity menu icon then selecting preferences</li>
<li>clicking on plus arrow with down, selecting &#8220;import connection&#8221; then selecting &#8220;from file&#8221;</li>
<li>selected the client.conf file from the tarball</li>
</ul>
<p>Next, I configured all my traffic to go over vpn.  I selected the &#8220;client&#8221; configuration from the list of configurations and pressed the &#8220;edit&#8221; button.  In the sheet, I navigated to the &#8220;networking&#8221; tab and checked the box for &#8220;send all traffic over VPN connection&#8221;.  My client side configuration was complete.</p>
<p>At this stage, I tested that my machine was able to connect to my openvpn server.  I gathered the various files needed for the openvpn server into a single directory:
<pre>
mkdir ~/openvpn-server/
cp keys/* ~/openvpn-server #lazy
cp server.conf ~/openvpn-server</pre>
<p>and started the server with &#8220;<code>cd ~/openvpn-server &#038;&#038; sudo openvpn server.conf</code>&#8220;.  I connected using viscosity to the server.  The client connected properly, but I was unable to resolve anything on dns or reach anything other than my openvpn server.  Reading the openvpn howto suggested setting up a NAT.  I did some searching and found a <a href="http://www.revsys.com/writings/quicktips/nat.html">page</a> with information on setting up the NAT.  I did:
<pre>
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/sbin/iptables -A FORWARD -i eth0 -o tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i tun0 -o eth0 -j ACCEPT</pre>
<p>At this point, everything worked!  I ran traceroute, and the first hop was my vpn server&#8217;s vpn address (10.8.0.1).  I also used some websites to check my public IP and it was showing as my server&#8217;s IP.</p>
<p>I hope this is useful to others.  If I&#8217;ve done something really dumb, I&#8217;d appreciate any suggestions for how to do it better!  I have left out information about how to start the openvpn service on boot.  This isn&#8217;t really important to me right now but if I ever bother with it, I&#8217;ll update this blog post.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.johnford.org/openvpn-tunnel-to-home-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Screenshots on OS X timeouts</title>
		<link>http://blog.johnford.org/screenshots-on-os-x-timeouts/</link>
		<comments>http://blog.johnford.org/screenshots-on-os-x-timeouts/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 17:20:50 +0000</pubDate>
		<dc:creator>John Ford</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.johnford.info/?p=319</guid>
		<description><![CDATA[As of the mozilla-inbound merge this morning, any time automation.py based tests timeout or crash, a screenshot will be base64 encoded and dumped into the test log on OS X. We&#8217;ve had this support for a while on Linux and &#8230; <a href="http://blog.johnford.org/screenshots-on-os-x-timeouts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As of the mozilla-inbound merge this morning, any time automation.py based tests timeout or crash, a screenshot will be base64 encoded and dumped into the test log on OS X.  We&#8217;ve had this support for a while on Linux and I have matched the output format.  In case you aren&#8217;t familiar with this, your logs will print out something that looks like:</p>
<pre>8217 ERROR TEST-UNEXPECTED-FAIL | /tests/toolkit/content/tests/widgets/test_videocontrols.html | Test timed out.
args: ['/usr/sbin/screencapture', '-C', '-x', '-t', 'png', '/var/folders/Hs/HsDn6a9SG8idoIya6p9mtE+++TI/-Tmp-/mozilla-test-fail_k9Dpdz']
SCREENSHOT: data:image/png;base64,iVBORw0.....</pre>
<p>If you want to see this image, copy everything from &#8216;data:image&#8217;, inclusive, to the end of line and paste it into your browser&#8217;s awesome bar.</p>
<p>In case you want to see what this looks like in the wild, <a href="https://tbpl.mozilla.org/php/getParsedLog.php?id=7171207&#038;full=1&#038;branch=mozilla-inbound#error0" title="sample log with screenshot">here</a> is a sample log with a screenshot.</p>
<p>I am working on getting this enabled on windows as well.  My automation.py.in changes should easily support the win32 screenshot utility written by Ted in <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=414049" title="bug 414049">bug 414049</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.johnford.org/screenshots-on-os-x-timeouts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Disabling PGO for the majority of Firefox Builds.</title>
		<link>http://blog.johnford.org/disabling-pgo-for-the-majority-of-firefox-builds/</link>
		<comments>http://blog.johnford.org/disabling-pgo-for-the-majority-of-firefox-builds/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 17:34:30 +0000</pubDate>
		<dc:creator>John Ford</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.johnford.info/?p=308</guid>
		<description><![CDATA[This project has been discussed in a dev.planning thread, with the work being tracked in bug 658313.  We are going to be turning off PGO for incremental builds on all branches[1] on Wednesday, October 5, 2011.  In the exceedingly rare &#8230; <a href="http://blog.johnford.org/disabling-pgo-for-the-majority-of-firefox-builds/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This project has been discussed in <a title="a dev.planning thread" href="http://groups.google.com/group/mozilla.dev.planning/browse_thread/thread/39f384e288c6ddc2/4762a40a95ee6494?lnk=gst&amp;q=PGO+Build+Proposal#4762a40a95ee6494" target="_blank">a dev.planning thread</a>, with the work being tracked in <a title="bug 658313" href="https://bugzilla.mozilla.org/show_bug.cgi?id=658313" target="_blank">bug 658313</a>.  We are going to be turning off PGO for incremental builds on all branches[1] on Wednesday, October 5, 2011.  In the exceedingly rare chance that you don&#8217;t read every single bug comment and dev.planning thread post, here is what will change:</p>
<ul>
<li>Builds triggered as part of a push will not have PGO enabled on any platform</li>
<li>We will be producing builds every four hours with PGO enabled on Windows and Linux for the following branches:</li>
<ul>
<li>Mozilla-Inbound</li>
<li>Mozilla-Central</li>
<li>Mozilla-Aurora</li>
<li>Mozilla-Beta</li>
</ul>
<li>All nightlies produced for platforms we ship PGO enabled (linux, windows) will have PGO on for the nightly build</li>
<li>Platforms that we ship with PGO enabled will have their PGO talos results report to the current graphserver branch.  This includes nightlies and the new 4-hourly builds</li>
<li>Platforms that we ship with PGO enabled will have their non-PGO talos results to a &#8216;-Non-PGO&#8217; suffixed branch, e.g. Firefox-Non-PGO</li>
<li>Platforms that we <strong>do not</strong> ship with PGO enabled will report both per-push builds and nightlies  to the current graphserver branch</li>
<li><a title="tbpl" href="https://tbpl.mozilla.org/" target="_blank">TBPL</a> was modified in <a title="bug 670037" href="https://bugzilla.mozilla.org/show_bug.cgi?id=670037" target="_blank">bug 670037</a> to make PGO builds special.  The deployment of these changes is being tracked in <a title="bug 691550" href="https://bugzilla.mozilla.org/show_bug.cgi?id=691550" target="_blank">bug 691550</a>.  If this TBPL change isn&#8217;t deployed before we start generating PGO builds, you might see duplicate build and test entries</li>
<li>Yes, we plan to teach try chooser how to optionally do PGO.  For now, please include &#8216;mk_add_options MOZ_PGO=1&#8242;  in your PGO platform&#8217;s mozconfig-extra-$platform file if you wish to have PGO enabled for try.  Your results will be on the Try branch  in graphserver.  This work is being tracked in <a title="bug 691673" href="https://bugzilla.mozilla.org/show_bug.cgi?id=691673" target="_blank">bug 691673</a></li>
<li>Yes, we plan to optimize scheduling so that we only do a build if there has been a push in the previous four hours.  This might allow us to add PGO builds on more branches and is tracked in <a title="bug 691675" href="https://bugzilla.mozilla.org/show_bug.cgi?id=691675" target="_blank">bug 691675</a></li>
</ul>
<p>The motivation for this project is to get results to developers quicker.  It is felt that this reduction in PGO coverage is a safe optimization because there have been very few PGO related bugs found so far.</p>
<p>If you have any concerns, please contact me.  I am jhford in #build on irc.mozilla.org</p>
<p>[1] Well, all active development branches.  We are leaving PGO on for Win32 on branches older than Firefox 5, like mozilla-1.9.2</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.johnford.org/disabling-pgo-for-the-majority-of-firefox-builds/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New hardware for testing Mac OS X 10.6</title>
		<link>http://blog.johnford.org/new-hardware-for-testing-mac-os-x-10-6/</link>
		<comments>http://blog.johnford.org/new-hardware-for-testing-mac-os-x-10-6/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 17:33:00 +0000</pubDate>
		<dc:creator>John Ford</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.johnford.info/?p=313</guid>
		<description><![CDATA[A while ago, we decided that we needed to expand our pool of machines to test Firefox on.  We are just about done getting the new 10.6 machines ready for production!  The machines we will be enabling are MacMini4,1 spec. &#8230; <a href="http://blog.johnford.org/new-hardware-for-testing-mac-os-x-10-6/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A while ago, we decided that we needed to expand our pool of machines to test Firefox on.  We are just about done getting the new 10.6 machines ready for production!  The machines we will be enabling are MacMini4,1 spec.  Internally, we are calling them &#8216;Rev4&#8242; minis.</p>
<p>We won&#8217;t have all 80 of these minis ready for production right away, so we&#8217;ll start with ten.  Once we have 80 rev4 minis in production and every test suite is running reliably green on them, we will turn off the rev3 10.6 minis so they can be moved to other pools.  If there are suites that are orange, we will hide those results while we look into the failures.</p>
<p>In order to differentiate the talos results from these two different spec machines, we are creating a new platform on the graphserver.  When looking for data on graphserver, the platforms drop down will have two Mac OS X 10.6 options:</p>
<ul>
<li>MacOSX 10.6.2 (rev3)</li>
<li>MacOSX 10.6 (rev4)</li>
</ul>
<div>You should treat the &#8216;MacOSX 10.6.2 (rev3)&#8217; results as authoritative for the time being.  If you find any issues with the Rev4 machines that you feel should block us from turning off the Rev3 10.6 machines, please file a bug and have it block <a title="bug 683734" href="https://bugzilla.mozilla.org/show_bug.cgi?id=683734">bug 683734</a>.</div>
<div>Results should start showing up on TBPL some time after the changes are deployed on Wednesday, October 4, 2011.</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.johnford.org/new-hardware-for-testing-mac-os-x-10-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>screenresolution tool for Mac OS X 10.6 release</title>
		<link>http://blog.johnford.org/screenresolution-tool-for-mac-os-x-10-6-release/</link>
		<comments>http://blog.johnford.org/screenresolution-tool-for-mac-os-x-10-6-release/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 18:00:35 +0000</pubDate>
		<dc:creator>John Ford</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.johnford.info/?p=276</guid>
		<description><![CDATA[I have been working on getting our new Mac Mini (macmini4,1) machines ready to become Mac OS X 10.6 testing machines.  One of the last things needed before I start testing on a larger scale is a program to set &#8230; <a href="http://blog.johnford.org/screenresolution-tool-for-mac-os-x-10-6-release/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have been working on getting our new Mac Mini (macmini4,1) machines ready to become Mac OS X 10.6 testing machines.  One of the last things needed before I start testing on a larger scale is a program to set the resolution on the command line.  We need this because our tests depend on having a specific resolution set.  Even if there was no dependency on a specific resolution, the GPU could perform differently depending on the size of the display it is working on.  As well, we run these minis without a real display so its really important that we have active confirmation that the desired resolution is set.</p>
<p>Previously, we used cscreen.  This is a utility that has fallen off the internet and was only ever released as a PowerPC binary.  I needed to decide between finding a replacement for cscreen and installing <a title="Apple's Rosetta" href="http://www.apple.com/asia/rosetta/" target="_blank">Rosetta</a>.  While we currently have Rosetta on our testing slaves, I didn&#8217;t want us to depend on this.  This is because partly because I just don&#8217;t think its good hygiene and partly because I want to prepare for OS X 10.7, where <a title="AppleInsider: Lion has no Rosetta" href="http://www.appleinsider.com/articles/11/02/26/mac_os_x_lion_drops_front_row_java_runtime_rosetta.html" target="_blank">Rosetta has been removed</a>.  I searched the internet for a tool to do this, and sadly, there was nothing that fit the bill.  I tried alternatives like modifying the com.apple.Boot.plist file to specify resolution, but it didn&#8217;t work.  I also found some binary plist files that I could have edited and might have worked, but it seemed like a really flaky solution that would break *all* *the* *time*.  I decided that I&#8217;d have to write something to do this.</p>
<p>I did find a <a title="newscreen" href="http://hintsforums.macworld.com/showpost.php?p=419594&amp;postcount=16" target="_blank">program</a> that looked like it would be a good starting point, however, this program lacked any error checking.  Furthermore, when I investigated the APIs used, it looked like many of the important APIs were deprecated in 10.6 and would not be available in 10.7.  One particularly annoying deprecation was <a title="CGDisplayBestModeForParameters" href="http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/c/func/CGDisplayBestModeForParameters" target="_blank">CGDisplayBestModeForParameters</a>, because it takes the exact data I have (height, width and bit depth) and picked the best mode available.  In the end, I think I have a better solution that iterates through all modes and picks one that matches my inputs exactly.  I also noticed that CGDisplayBestModeForParameters doesn&#8217;t always return a mode that matches exactly to what was requestion, though, it does have facilities to deal with this case.</p>
<p>Alas, I started writing an application called screenresolution.  This program can be used to query the current and available resolutions as well as setting the resolution on one or more screens attached to the system.  This is my first C project in quite some time and I was never a C rockstar to begin with.  If you have a desire for Mozilla testing infrastructure to not suck and know C and CoreGraphics please slide on over to <a href="https://github.com/jhford/screenresolution/blob/master/main.c" title="main.c">the source</a> to check for issues!  I know that I could organize the code better and write a better command line interface, but I don&#8217;t think the benefits of that outweigh the cost of waiting even longer for these new machines.</p>
<p>I have posted the<a title="code on github" href="https://github.com/jhford/screenresolution" target="_blank">code</a> on my github account and have licensed it with the GPL v2 license in hopes that no one ever go through the search engine hell that was Friday Aug 26, 2011.  Below is a build of verison 1.3.  Why not 1.0?  Even though I wrote a test for the program, I neglected to actually run it. Multiple times <img src='http://blog.johnford.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />   Once I started to actually run the tests, I started finding issues before bumping version numbers, gasp!</p>
<p><a title="screenresolution-1.3" href="http://www.johnford.info/screenresolution-1.3.dmg" target="_blank">screenresolution-1.3.dmg</a></p>
<p>Update: Thanks Josh Aas and Richard Newman for reviewing my code and the great suggestions!  I have a new version posted<br />
<a title="screenresolution-1.4" href="http://www.johnford.info/screenresolution-1.4.dmg" target="_blank">screenresolution-1.4.dmg</a></p>
<p>Because this is a command line application, I recorded a video of my machine running the test suite.<br />
<video width="320" height="240" controls="controls" style="background:black;"><source src="http://blog.johnford.info/wp-content/uploads/2011/08/screenresolution.webm" /></video></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.johnford.org/screenresolution-tool-for-mac-os-x-10-6-release/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://blog.johnford.info/wp-content/uploads/2011/08/screenresolution.webm" length="1242005" type="video/webm" />
		</item>
		<item>
		<title>Figuring out which files are touched while installing software</title>
		<link>http://blog.johnford.org/figuring-out-which-files-are-touched-while-installing-software/</link>
		<comments>http://blog.johnford.org/figuring-out-which-files-are-touched-while-installing-software/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 17:34:07 +0000</pubDate>
		<dc:creator>John Ford</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.johnford.info/?p=223</guid>
		<description><![CDATA[We are working on getting our infrastructure up to speed for Maemo 5 and Maemo 5 QT builds. A critical part of Maemo5 building is the scratchbox. This is a toolkit that Nokia uses to make development on for their &#8230; <a href="http://blog.johnford.org/figuring-out-which-files-are-touched-while-installing-software/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We are working on getting our infrastructure up to speed for Maemo 5 and Maemo 5 QT builds.  A critical part of Maemo5 building is the scratchbox.  This is a toolkit that Nokia uses to make development on for their linux based phones easier.  We have enough linux build slaves in production that it is impractical to deploy scratchbox by hand on each machine.  Scratchbox also does internet package downloads which means that we could get different packages each time we try to install the scratchbox.  We already have a fairly old version of scratchbox which is set up with the Chinook sdk that we have used for doing our Maemo builds thus far.  Originally I was under the impression that we were going to need to have 2 totally seperate scratchbox installations but thanks to Doug T. for showing me how to upgrade our existing scratchbox 4 installation to scratchbox 5.  </p>
<p>My concern with this upgrade, however, was that files outside the <code>/builds/scratchbox</code> directory were going to be touched.  I wanted to be thorough so I did an experiment.  I ran <code>find -mount -type f -exec openssl md5 '{}' \; | tee -a /file-list ; find -mount -type f -exec openssl md5 '{}' \; | tee -a /file-list</code> before and after the scratchbox upgrade.  The <code>-mount</code> and two different runs at our two mountpoints was to ensure that we didn&#8217;t hash things like the <code>/dev, /proc, /sys</code> filesystem.  My original intent was to do <code>diff file-list1 file-list2</code> but that resulted in showing me every single file that changed.  I only wanted to know the files that changed outside of my scratchbox root directory of <code>/builds/scratchbox</code>.  My diff was polluted by 77,000 files that resided in the scratcbox root.  I figured that the best option at the time was to hack up a quick python script:</p>
<pre>
#!/usr/bin/python
#This file is a quick script to process the output of
# find / -mount -type f -exec openssl md5 '{}' \; | tee -a
import sys, os.path, re

if not len(sys.argv) == 3:
    print "purple monkey dishwasher"
    exit(1)
filename_a = sys.argv[1]
filename_b = sys.argv[2]
if not os.path.exists(filename_a) or not os.path.exists(filename_b):
    print "insert change into meter and press green button"
    exit(1)
data={}
pattern = re.compile("^MD5\((?P<file>.*)\)= (?P<hash>.*)$")
#Get the data from A
f = open(filename_a, 'r')
for i in f.readlines():
    m = pattern.search(i)
    data[m.group('file')] = m.group('hash')
f.close()
f = open(filename_b, 'r')
sbfile = re.compile("^/builds/scratchbox") #pattern describing files to ignore
#Figure out diff to B
f = open(filename_b, 'r')
for i in f.readlines():
    m = pattern.search(i)
    if not data.has_key(m.group('file')):
        if not sbfile.search(m.group('file')):
            print 'new file - ', m.group('file')
    else:
         if not sbfile.search(m.group('file')):
             if not data[m.group('file')] == m.group('hash'):
                 print 'updated file - ', m.group('file')
</pre>
<p>This is code I have written to scratch my own itch.  I am posting this as it might be useful to someone else.  if you wanted to ignore a different directory you&#8217;d change <code>sbfile = re.compile("^/builds/scratchbox")</code> to be a pattern describing your path to ignore.  If you wanted to find all things that changed over your whole partition you would remove sbfile and all sbfile checks to have a final bit of code like</p>
<pre>
#Figure out diff to B
f = open(filename_b, 'r')
for i in f.readlines():
    m = pattern.search(i)
    if not data.has_key(m.group('file')):
        print 'new file - ', m.group('file')
    else:
         if not data[m.group('file')] == m.group('hash'):
             print 'updated file - ', m.group('file')
</pre>
<p>In the end, I found that the scratchbox upgrade that I did only changed my bash_history and added some tarballs to /tmp.  I am very glad that this is the case as it really simplifies our deployment of the new scratchbox!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.johnford.org/figuring-out-which-files-are-touched-while-installing-software/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Python Frameworks</title>
		<link>http://blog.johnford.org/python-frameworks/</link>
		<comments>http://blog.johnford.org/python-frameworks/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 22:27:00 +0000</pubDate>
		<dc:creator>John Ford</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://johnford.info/blog/?p=58</guid>
		<description><![CDATA[I came to a descision today that I was going to learn a Python ORM framework to use. My project is going to require a lot of database access and using an ORM framework simplifies this. The ORM also hides &#8230; <a href="http://blog.johnford.org/python-frameworks/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I came to a descision today that I was going to learn a Python ORM framework to use.  My project is going to require a lot of database access and using an ORM framework simplifies this.  The ORM also hides many of the complexities.  If you are interested, I&#8217;d highly recomend following this <a href='http://www.sqlalchemy.org/docs/05/ormtutorial.html#building-a-relation'>tutorial</a>.</p>
<p>In doing some research into my CGI + SQLite issue I have been constantly asked &#8220;&#8230;but why are you using CGI&#8221;.  It turns out that CGI + Python is not really used much.  Many people recomend using mod_wsgi, and I think that instead of using raw wsgi I would like to use a framework.  So far, CherryPy is what is sticking out to me because it is very lightweight and includes its own development server.  This makes it easier to test my code because I (hopefully) would be able to use the Eclipse/Pydev debugger.  This is something I have wanted to for quite some time.  The main reason I am looking into CherryPy is that it seems to not worry itself with forcing a templating system on you.</p>
<p>In a related note, I found a JavaScript jQuery plugin which looks really neat and could prove to be very valuable.  It is called TableSorter.  There is an example of a pagination system that really caught my eye <a href='http://tablesorter.com/docs/example-pager.html'>here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.johnford.org/python-frameworks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OSX Development</title>
		<link>http://blog.johnford.org/osx-development/</link>
		<comments>http://blog.johnford.org/osx-development/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 03:16:00 +0000</pubDate>
		<dc:creator>John Ford</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://johnford.info/blog/?p=39</guid>
		<description><![CDATA[I am noticing that a lot of people are having trouble getting used to developing on OSX. I hope that this is useful to those people, I am targeting someone who has at least some experience with Linux or another &#8230; <a href="http://blog.johnford.org/osx-development/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am noticing that a lot of people are having trouble getting used to developing on OSX.  I hope that this is useful to those people, I am targeting someone who has at least some experience with Linux or another unix-like OS.  I haven&#8217;t been using OSX long myself, but I have adapted quickly <img src='http://blog.johnford.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span style="font-weight:bold;">What is XCode?</span><br />XCode is more than an application, it is a complete development environment.  When someone &#8216;installs xcode&#8217; they are installing compilers, frameworks, headers and build tools.  If you can compile a C program you have XCode.  Just to be sure, you can check by using commands like this
<pre>vortex:~ jhford$ which gcc/usr/bin/gccvortex:~ jhford$ which g++/usr/bin/g++vortex:~ jhford$ which make/usr/bin/makevortex:~ jhford$ which xcodebuild/usr/bin/xcodebuild</pre>
<p><span style="font-weight:bold;">What is MacPorts</span><br />MacPorts is a system utility to ease installing non-apple unix software.  This program is used to install things like subversion, mercurial, libidl, autoconf213 and ccache.  Basically, what this program does is fetch sources, patches and build instructions and compiles the program for your system.  This is very similar to BSD ports.  To use the utility, you use the <code>port</code> command.  Some sample uses:
<pre>sudo port install ccache mercurial libidl autoconf213port search subversionport list installed</pre>
<p>The man page is the best place to go for help with MacPorts (<code>man port</code>).  Unlike Fink, which uses Debian/Ubuntu&#8217;s apt-get internally, all things you install through MacPorts are compiled on your machine during install.  Word of warning: don&#8217;t need anything in a hurry!  Our network is <a href="http://jamesboston.ca/cms/?q=node/70">notoriously slow</a> with MacPorts.</p>
<p><span style="font-weight:bold;">What is a .dmg?</span><br />A .dmg is a compressed disc image format.  It contains one or more filessytems, usually HFS+ (read: mac filesystem).  This is how most .app and .pkg files are distributed because it maintains the mac specific file meta data.</p>
<p><span style="font-weight:bold;">What is a .app? .pkg?</span><br />You might have noticed that some applications are just icons, like Firefox or OpenOffice.  To install them you drag the icon into your /Applications folder and boom, intalled.  The most important thing to remember here is .app is just a folder! I will prove it<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_8ipG4VXvP2c/SZJH3qMXGBI/AAAAAAAAADk/DAoPNriNPrc/s1600-h/Picture+1.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 320px;" src="http://2.bp.blogspot.com/_8ipG4VXvP2c/SZJH3qMXGBI/AAAAAAAAADk/DAoPNriNPrc/s400/Picture+1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5301378732913006610" /></a><br />This means that if you want to start an application that is in a .app from the command line to see console output, you can do something like <code>$ /Applications/Firefox.app/Contents/MacOS/firefox</code> or <code>/Applications/OpenOffice.org.app/Contents/MacOS/soffice</code>.  Usually your application will live under <code>Appname.app/Contents/MacOS/</code></p>
<p>A .pkg file is an installer file, kind of like a .run script on linux or a .msi file in windows.  It is too just a folder.  Lots of things that are folders have file extensions on OSX.  If in doubt, run file on it in Terminal</p>
<p><span style="font-weight:bold;">Universal Binary?</span><br />In case you didn&#8217;t know, Macs used to have PowerPC cpus.  To ease the transition from PowerPC to Intel, Apple created something called a &#8216;Universal Binary&#8217;.  These are basically executable files which can be run on either processor.  If you want to check if you have made one you can use the unix command &#8216;file&#8217; on the application.  An example of a Firefox release binary shows that this is a universal binary:
<pre>vortex:Firefox.app jhford$ file Contents/MacOS/firefox-bin Contents/MacOS/firefox-bin: Mach-O universal binary with 2 architecturesContents/MacOS/firefox-bin (for architecture i386): Mach-O executable i386Contents/MacOS/firefox-bin (for architecture ppc): Mach-O executable ppc</pre>
<p>Sometimes the second architecture will mention ppc7440 or something similar, this means it is a G4+ binary (i.e. requires altivec, similar to MMX/SSE).</p>
<p><span style="font-weight:bold;">Command, Option, Control?</span><br />I guess this is only applicable if you are in front of the machine.  Command, Option and Control are similar to but not identical to Start, Alt and Control.  In OSX, things are a little more logical.  If the key combo you want to use involves doing something, say, close a tab, it is Command + W.  In Windows/Linux it is Control + W.  Keep this in mind, nearly all ctrl or alt key combos for GUI programs on Windows or Linux are the same on Mac but with Command.  Option, like the name implies, give you an option.  Say you have save and save as.  Command + S is like save and since save all is so similar, it may have Command + Option + S.  Worst case, you can look around in the menu bar at the top of the screen.  A clover-ish thing means Command, a downward sloping line is Option and an up arrow is Shift.</p>
<p>On the command line, Control works just like ctrl in Windows or Linux.  Control + D will give you EOF, Control + C will quit the application.</p>
<p><span style="font-weight:bold;">Screenshots!</span><br />To take a screenshot simple press one of:<br />  Command + Shift + 3 &#8211; Fullscreen<br />  Command + Shift + 4 &#8211; An area of the screen, like Snipping Tool in Vista<br />  Command + Shift + 4 then release and press space &#8211; A &#8216;view&#8217;, could be a window or a sheet.  Like Alt+Printscreen<br />These commmands will place the pictures on your desktop in the format PictureX.png where X is automatically incrementing.</p>
<p>Hopefully this helps you get the hang of Mac.  If you have any questions feel free to leave a comment or ping me in IRC at <a href="irc://irc.mozilla.org/#seneca">irc://irc.mozilla.org/#seneca</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.johnford.org/osx-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pydoc Server ?!?!</title>
		<link>http://blog.johnford.org/pydoc-server/</link>
		<comments>http://blog.johnford.org/pydoc-server/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 05:33:00 +0000</pubDate>
		<dc:creator>John Ford</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://johnford.info/blog/?p=37</guid>
		<description><![CDATA[For all of you working on anything python:pydoc -p 3500. This will create an http server at http://localhost:3500/ to browse all the python module documentation currently loaded.]]></description>
			<content:encoded><![CDATA[<p>For all of you working on anything python:<code>pydoc -p 3500</code>. This will create an http server at <code>http://localhost:3500/</code> to browse all the python module documentation currently loaded.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.johnford.org/pydoc-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

