<?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>Snowulf &#187; Code</title>
	<atom:link href="http://snowulf.com/category/Code/feed/" rel="self" type="application/rss+xml" />
	<link>http://snowulf.com</link>
	<description>We're big in Poland</description>
	<lastBuildDate>Wed, 08 Sep 2010 17:00:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Developing on an Android device under Windows 7</title>
		<link>http://snowulf.com/2010/04/22/developing-on-an-android-device-under-windows-7/</link>
		<comments>http://snowulf.com/2010/04/22/developing-on-an-android-device-under-windows-7/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 17:00:00 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[android sdk]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[developing]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[nexus one]]></category>
		<category><![CDATA[sdk]]></category>

		<guid isPermaLink="false">http://wp.snowulf.com/?p=816</guid>
		<description><![CDATA[One of the first things I did after getting my shiny new Nexus One was to plug it into my computer for development. After all, development was the entire reason I bought this very expensive new toy (well, it might not be the only reason, but it is the one I use to justify actually [...]]]></description>
			<content:encoded><![CDATA[<p>One of the first things I did after getting my shiny new Nexus One was to plug it into my computer for development.  After all, development was the entire reason I bought this very expensive new toy (well, it might not be the <span style="text-decoration: underline;">only</span> reason, but it is the one I use to justify actually plunking down and buying it when I already had a fine and functional iPhone).  I thought it would be as simple as plugging in the device and going, unfortunately it wasn&#8217;t quite that easy.  The instructions on developer.android.com aren&#8217;t very good &#8211; especially since they leave out the very critical step of turning on USB debug on the phone.  Since I had to stab my way through this, I thought I&#8217;d share the process with you.  <strong>One important note:</strong> Have the Android SDK downloaded &amp; updated already (that includes the USB drivers).</p>
<ul>
<li>Plug phone in to your computer</li>
<li><span style="text-decoration: underline;">On the phone</span> &#8211; Open Settings</li>
<li>Applications</li>
<li>Development</li>
<li>Check &#8220;USB Debugging&#8221;</li>
<li>Click OK</li>
<li><span style="text-decoration: underline;">On your computer</span> &#8211; Right click on My Computer</li>
<li>Manage</li>
<li>Go to Device Manager</li>
<li>Find &#8220;Other Devices&#8221;</li>
<li>Right Click on &#8220;Nexus One&#8221;</li>
<li>Click &#8220;Update Driver Software&#8221;</li>
<li>Click &#8220;Browse my computer for driver software&#8221;</li>
<li>Select the location in which you installed the SDK, and previously downloaded the sdk</li>
<li>Click Next</li>
<li>When windows security prompts you, click &#8220;Install&#8221;</li>
<li>After a few minutes, you&#8217;ll be able to close the window</li>
<li>Launch a Command prompt (Start &gt; Run &gt; cmd)</li>
<li>Change to your sdk install location \tools</li>
<li>enter &#8220;adb devices&#8221;</li>
</ul>
<p>At this point it should read something like &#8220;HT02LP901416    device&#8221;.  As long as it doesn&#8217;t start with &#8220;emulator-&#8221;, you&#8217;re good to go.  If not, it still isn&#8217;t recognizing your phone.</p>
<p>If you haven&#8217;t already, you need to add <em>android:debuggable=&#8221;true&#8221;</em> under <em>&lt;application&gt;</em> of your <span style="text-decoration: underline;">AndroidManifest.xml</span> file. Now you should be able to simply go into build your application normally.  When it goes to deploy, it will automatically deploy to the device instead of launching an emulator.  Good luck &amp; <a title="[youtube] Developers" href="http://www.youtube.com/watch?v=KMU0tzLwhbE">happy developing</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://snowulf.com/2010/04/22/developing-on-an-android-device-under-windows-7/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>AndroiDev: Leaky Windows</title>
		<link>http://snowulf.com/2010/04/13/androidev-leaky-windows/</link>
		<comments>http://snowulf.com/2010/04/13/androidev-leaky-windows/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 17:00:00 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://wp.snowulf.com/?p=809</guid>
		<description><![CDATA[This is one of those errors that popped up on me that initially left me baffled and amused. Once you look up and find out the explanation for &#8220;Activity has lead window&#8221;, it makes sense, but the idea of an application having &#8220;leaky windows&#8221; is still quite hilarious to me (unlike memory leaks, which suck [...]]]></description>
			<content:encoded><![CDATA[<p>This is one of those errors that popped up on me that initially left me baffled and amused.  Once you look up and find out the explanation for &#8220;Activity has lead window&#8221;, it makes sense, but the idea of an application having &#8220;leaky windows&#8221; is still quite hilarious to me (unlike memory leaks, which suck and are not humorous at all).  Basically, Android is communicating to you that you&#8217;ve tried to put a popup in a location that no longer exists, or you don&#8217;t have access to.  Here&#8217;s my error text as an example:</p>
<blockquote><p>04-11 06:02:01.973: ERROR/WindowManager(1176): <strong>Activity org.wikinews.en.wikinewsreader.SubmitBug has leaked window </strong>com.android.internal.policy.impl.PhoneWindow$DecorView@43801c78 that was originally added here<br />
04-11 06:02:01.973: ERROR/WindowManager(1176): android.view.WindowLeaked: Activity org.wikinews.en.wikinewsreader.SubmitBug has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43801c78 that was originally added here</p></blockquote>
<p>Now let me show you the code I used that crashed, and the fixed version.  At the end, I&#8217;ll explain &#8220;why&#8221; (to the best of my understanding) this happens the way it does.</p>
<p><strong>The original (crashing) code:</strong><code><br />
Builder builder = new AlertDialog.Builder(SubmitBug.this);<br />
builder.setTitle("Thank you");<br />
builder.setMessage("Your bug has been submitted to the developers.  They may contact you if they have further questions.");<br />
builder.setPositiveButton("Close", null);<br />
builder.show();<br />
<u>finish();</u></code></p>
<p><strong>The functional code:</strong><code><br />
Builder builder = new AlertDialog.Builder(SubmitBug.this);<br />
builder.setTitle("Thank you");<br />
builder.setMessage("Your bug has been submitted to the developers.  They may contact you if they have further questions.");<br />
builder.setPositiveButton("Close", new DialogInterface.OnClickListener() {<br />
&nbsp;public void onClick(DialogInterface dialog, int id) {<br />
&nbsp;&nbsp;<u>SubmitBug.this.finish();</u><br />
&nbsp;}<br />
});<br />
builder.show();</code></p>
<p>Ok, so first, the difference.  As you can see in the first example I use builder to create a pop up box with a &#8220;Close&#8221; button (which is tied to nothing) and then finish() which will close the activity.  The second version of the code is the same builder, but this time the &#8220;Close&#8221; button gets an OnClickListener that when triggered, will close the activity.  If you&#8217;re wondering why I did the first way &#8211; I&#8217;ve been doing procedural programming for a long, long time.  I thought that the finish() line wouldn&#8217;t be called until the builder window went away.  That is, in fact, not the case and the entire cause of the problem.</p>
<p>Put simply, Android files the request to a different portion of the software stack to show the builder, but may not immediately process it.  In the mean time, the code for the application continues to run and the very next thing it sees is finish().  So the application initiates the process of shutting down, unaware of the builder window.  Of course, that builder window comes back into play, but it is too late because the activity is gone.  Hence the window (the builder) has &#8220;leaked&#8221; out of the area it was supposed to be in.</p>
<p>As an additional note: I&#8217;ve seen this error pop up when I used builder (with the OnClickListner finish()) in combination with a try/catch to alert the user of critical errors that require the application be shut down.  In my particular case I&#8217;m running multiple threads and sometimes have multiple builder popups.  One would &#8220;finish&#8221; the application with the second still on screen and would again cause this error.  I worked around that issue by setting a flag to prevent a second builder popup if one had already been shown (after all, the user doesn&#8217;t care how many ways the application crashed, just simply that it did) (<em>Editor&#8217;s note: Basically, setting up the popup as a semi-<a href="http://en.wikipedia.org/wiki/Singleton_%28mathematics%29" title="[wiki] Singleton (mathematics)">Singleton</a> instance.</em>)</p>
]]></content:encoded>
			<wfw:commentRss>http://snowulf.com/2010/04/13/androidev-leaky-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AndroiDev: The project so far &#8211; Wikinews Reader</title>
		<link>http://snowulf.com/2010/04/08/androidev-the-project-so-far-wikinews-reader/</link>
		<comments>http://snowulf.com/2010/04/08/androidev-the-project-so-far-wikinews-reader/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 17:00:00 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Wiki World]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[wikinews]]></category>

		<guid isPermaLink="false">http://wp.snowulf.com/?p=806</guid>
		<description><![CDATA[A lot of the code I post and tech bits I fix are things I find while working. Sometimes I can&#8217;t explain the bigger picture, sometimes it simply doesn&#8217;t matter. Most people don&#8217;t care about the why, but simply the how (to fix something) like the &#8220;Cannot Save Attachment&#8221; message in Outlook 2007. But with [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of the code I post and tech bits I fix are things I find while working.  Sometimes I can&#8217;t explain the bigger picture, sometimes it simply doesn&#8217;t matter.  Most people don&#8217;t care about the <em>why</em>, but simply the <em>how</em> (to fix something) like the &#8220;<a title="[blog] Outlook 2007 &quot;Cannot save the attachment&quot;" href="http://snowulf.com/archives/554-Outlook-2007-Cannot-save-the-attachment.html">Cannot Save Attachment</a>&#8221; message in Outlook 2007.  But with the recent <a title="[blog] Category: Code" href="http://snowulf.com/categories/4-Code">AndroiDev posts</a> I can actually share with you the &#8220;big picture&#8221;, and I think people might enjoy it.</p>
<div class="serendipity_imageComment_left" style="width: 73px;">
<div class="serendipity_imageComment_img"><!-- s9ymdb:199 --><img class="serendipity_image_left" src="/uploads/wikinewsiphone.serthb.jpg" alt="" width="73" height="110" /></div>
<div class="serendipity_imageComment_txt">Wikinews on the iPhone &#8211; Not so nice.</div>
</div>
<div class="serendipity_imageComment_right" style="width: 74px;">
<div class="serendipity_imageComment_img"><!-- s9ymdb:198 --><img class="serendipity_image_right" src="/uploads/2010-04-08latestnews.serthb.png" alt="" width="74" height="110" /></div>
<div class="serendipity_imageComment_txt">Wikinews Reader on Android &#8211; Much nicer.</div>
</div>
<p>I&#8217;ve been writing a &#8220;reader&#8221; application for Wikinews.  By reader I mean it is an app that provides a simple, low bandwidth interface to allow you to read Wikinews on a mobile (specifically, Android) phone.  By default, &#8220;big web&#8221; sites (ones for your computer) don&#8217;t generally work too well on the mobile web.  Yes, you can get by, and sometimes they aren&#8217;t too terribly bad, but in the end you download a LOT of formatting &amp; images that you can&#8217;t use, you don&#8217;t want, and sometimes can&#8217;t even see.</p>
<p>Take Wikinews for example, loading the homepage ONLY right now (downloading <em>everything</em> you need: HTML, images, JS, CSS, etc) is <strong>272.7 KB</strong>.  That is HUGE if you&#8217;re on (say) an EDGE connection (or pay per MB).  Now lets say you happen to have a custom written reader application.  The download size for the Wikinews front page AND the article text for the 20 most recent articles? <strong>12.1 KB</strong>.  That isn&#8217;t an exaggeration; the honest-to-(insert deity here) difference is 260.6 KB.</p>
<p>After the size, of course, is the formatting issue.  To the left I have a screen shot of the Wikinews homepage from the iPhone, which most people argue has the best mobile browser, I think Android&#8217;s is about the same, but it doesn&#8217;t matter for this test. You can&#8217;t really read anything; of course you can zoom in, but that is more clicks, drags, and multitouches than you should have to do.  On the right is the main page of the Wikinews Reader, it is readable and easy to scroll through the entire list.  Of course the reader app is &#8220;reader&#8221; not &#8220;writer&#8221;, so you can&#8217;t edit (not that I personally would want to try and wiki-edit from a phone).</p>
<p>Anyways&#8230; I just wanted to show off a little bit of the app I&#8217;ve been working on.  I&#8217;ll fully admit that it isn&#8217;t anything fancy, but it does the job &#8211; you can read the news.  If you&#8217;re interested, there are a <a href="http://enwikinews.googlecode.com/svn/ScreenShots/">few more screen shots</a>.  As this is Wikinews endeavor, the project is open source.  You can stop by our <a href="http://code.google.com/p/enwikinews/">Google Code project</a> and check it out.  We&#8217;re always looking for new help, be it coders, graphic artists, testers, translation or even just documentation help.</p>
]]></content:encoded>
			<wfw:commentRss>http://snowulf.com/2010/04/08/androidev-the-project-so-far-wikinews-reader/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AndroiDev: UnknownHostException</title>
		<link>http://snowulf.com/2010/04/06/androidev-unknownhostexception/</link>
		<comments>http://snowulf.com/2010/04/06/androidev-unknownhostexception/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 17:00:00 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://wp.snowulf.com/?p=801</guid>
		<description><![CDATA[Recently I was messing around on Android with the BrowserView&#8217;s and BrowserIntent&#8217;s. When trying out one of the examples, I got: InetAddress: Unknown host www.google.com throwing UnknownHostException Every URL I entered, it displayed a &#8220;Page cannot be found&#8221; type error. At first I thought it was the site I was trying to use, but obviously [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was messing around on Android with the BrowserView&#8217;s and BrowserIntent&#8217;s.  When trying out one of the examples, I got:</p>
<p><strong>InetAddress: Unknown host www.google.com throwing UnknownHostException</strong></p>
<p>Every URL I entered, it displayed a &#8220;Page cannot be found&#8221; type error.  At first I thought it was the site I was trying to use, but obviously sites like Google were up.  Then I thought it might be the network connection on the emulator, but I tested its browser application and it worked fine.  So that left my application.</p>
<p>It turns out that if you don&#8217;t have permission to use the internet, and try to &#8211; even if it is to launch the browser (and not run your own), your request is denied.  Fairly good idea, in the end, although the lack of error message makes it a bit difficult to track down.  In the end I realized this lack of permission was the issue and added the necessary permission (below) to my AndroidManifest.xml file.</p>
<p><strong>&lt;uses-permission android:name=&#8221;android.permission.INTERNET&#8221; /&gt;</strong></p>
<p>After that and a quick rebuild, the application was much happier. I was free to abuse the internet once again. (<em>Editor&#8217;s note: Cue maniacal laughter.</em>)</p>
]]></content:encoded>
			<wfw:commentRss>http://snowulf.com/2010/04/06/androidev-unknownhostexception/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AndroiDev: TextView.setText crash</title>
		<link>http://snowulf.com/2010/03/31/androidev-textview-settext-crash/</link>
		<comments>http://snowulf.com/2010/03/31/androidev-textview-settext-crash/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 17:00:00 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://wp.snowulf.com/?p=797</guid>
		<description><![CDATA[One thing I yearn for when I am programming is a debugger like Perl&#8217;s interpreter. If you had a bug in your code, it would tell you almost exactly where it was, and even suggest fixes sometimes (Ex: You probably forgot a semicolon at the end of line X). Unfortunately, that isn&#8217;t the case with [...]]]></description>
			<content:encoded><![CDATA[<p>One thing I yearn for when I am programming is a debugger like Perl&#8217;s interpreter.  If you had a bug in your code, it would tell you almost exactly where it was, and even suggest fixes sometimes (Ex: You probably forgot a semicolon at the end of line X).  Unfortunately, that isn&#8217;t the case with most languages.  In the case of Android, it throws typically Java error messages, which 90% of the time are useful, but 10% of the time you get stuff like this:</p>
<blockquote><p>03-26 06:08:13.068: ERROR/AndroidRuntime(426): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.snowulf.quickclick/com.snowulf.quickclick.QuickClick}: java.lang.NullPointerException</p></blockquote>
<p>I realize what a Null Pointer Exception is, but it isn&#8217;t very helpful.  Here&#8217;s the (stripped down) code I was using:<br />
<code><br />
public class QuickClick extends Activity {<br />
&nbsp;&nbsp;@Override<br />
&nbsp;&nbsp;public void onCreate(Bundle savedInstanceState) {<br />
&nbsp;&nbsp;&nbsp;super.onCreate(savedInstanceState);</p>
<p>&nbsp;&nbsp;&nbsp;SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);<br />
&nbsp;&nbsp;&nbsp;String userName = settings.getString("userName", null);</p>
<p>&nbsp;&nbsp;&nbsp;final TextView txtHi = (TextView) findViewById(R.id.greeting_message);<br />
&nbsp;&nbsp;&nbsp;<strong>txtHi.setText("Greetings " + userName);<br />
</strong><br />
&nbsp;&nbsp;&nbsp;<strong>setContentView(R.layout.main);</strong><br />
&nbsp;&nbsp;}<br />
}<br />
</code></p>
<p>If you were to try and debug this the good old fashion way (as I did), commenting out blocks/lines of code , recompiling and rerunning until the problem goes away you&#8217;d (eventually) find out that the problem line is <strong>txtHi.setText()</strong>.  This really shouldn&#8217;t be a shock as that is the topic of this post.  Actually, the <u>real problem</u> is <strong>setContentView()</strong> in combination.  You must setContentView() <u>before</u> you try to manipulate the value of the objects it creates.  Quite simply, R.id.greeting_message (and by proxy txtHi) doesn&#8217;t exist until you use setContentView.</p>
<p>So quick fix, put setContentView() way up at the top.</p>
]]></content:encoded>
			<wfw:commentRss>http://snowulf.com/2010/03/31/androidev-textview-settext-crash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Starting Android Development</title>
		<link>http://snowulf.com/2010/03/25/starting-android-development/</link>
		<comments>http://snowulf.com/2010/03/25/starting-android-development/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 17:00:00 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://wp.snowulf.com/?p=794</guid>
		<description><![CDATA[A long time ago (like last year) in a state far far away (Nevada), my job wasn&#8217;t terribly busy so I got permission to start learning iPhone development. I went ahead and purchased The iPhone Developers Cookbook, setup the MacBook Air and got started with learning. Of course just a few days later I got [...]]]></description>
			<content:encoded><![CDATA[<p>A long time ago (like last year) in a state far far away (Nevada), my job wasn&#8217;t terribly busy so I got permission to start learning iPhone development.  I went ahead and purchased <a href="http://www.amazon.com/iPhone-Developers-Cookbook-Building-Applications/dp/0321659570/?tag=snowulf-20" title="[amazon] The iPhone Developer's Cookbook: Building Applications with the iPhone 3.0 SDK (2nd Edition) (Paperback)">The iPhone Developers Cookbook</a>, setup the MacBook Air and got started with learning.  Of course just a few days later I got busy and have stayed busy up until recently.  Once I got unbusy I started to switch gears back to iPhone development.  The problem is, it is in objective-C, and fairly complicated just to get started (<em>Editor&#8217;s note: Yes, yes it is.</em>)(<em>Un-Editors Note: John actually writes code for a living and even he finds Objective-C evil, see!</em>)(<em>Editor&#8217;s note: It&#8217;s the devil!  Well, not the actual devil, maybe a minor demon</em>).  I&#8217;m sure once you get the hang of it, it isn&#8217;t too bad, but my C/C++ skills are minimal at best.  On a whim I decided to checkout <a href="http://developer.android.com/index.html">Android development</a> and it&#8217;s all gone down hill from there.</p>
<p>Android applications are written in Java (with a side of XML) but compiled using something called <a href="http://en.wikipedia.org/wiki/Dalvik_virtual_machine" title="[wiki] Dalvik virtual machine">Dalvik</a>.  This makes it easy for new developers as many people know Java.  On the flip side, since it is not true Java, it puts limits on it that many experienced Java devs run into.  As for me, I haven&#8217;t written Java in many years.  Back in college I had several Java classes, I didn&#8217;t necessarily enjoy them (simply because of my general hating on all things Java), but I could write the code.  It looked easy enough though, and a one of my coworkers raves about how easy it is to do most things in the language.</p>
<p>So into Android development I went.  I downloaded and installed the <a href="http://java.sun.com/javase/downloads/index.jsp">Java Development Kit (JDK)</a>, <a href="http://www.eclipse.org/">Eclipse</a>, and the <a href="http://developer.android.com/sdk/index.html">Android SDK</a>.  After a little research I also went and bought myself a beta (eBook) version of <a href="http://www.amazon.com/Hello-Android-Introducing-Development-Platform/dp/1934356565/?tag=snowulf-20" title="[amazon] Hello, Android: Introducing Google's Mobile Development Platform (Paperback)">Hello, Android (3rd Edition)</a>.  I found the 2nd edition book at the local brick &#038; mortar store and it seemed fairly decent, but of course with there being a newer version in the works, I had to get that instead.  After just a a few days of going though the book, I was making simple applications.  Most of it was copy and paste, but I got enough of it from code tinkering.</p>
<p>After a couple days I switched to writing my own micro application.  It isn&#8217;t anything to write home about (which of course makes it blog worthy), but I wrote it from scratch without copy and paste from the book.  It was&#8230; challenging&#8230; but not impossible.  My issues go along these lines:<br />
<strong>First off</strong>, I&#8217;m relearning Java as I go.  Some of it comes back fairly quickly, but some bits require much googling to explain.  I&#8217;ve really never enjoyed Java per se because applets are dumb and it makes for some hellishly slow desktop applications, but I can accept that in this case it works fairly decently.<br />
My <strong>second</strong> major issue is learning to properly work in object oriented programming styles.  See, I started in <a href="http://en.wikipedia.org/wiki/Qbasic" title="[wiki] Qbasic">QBasic</a>, moved on to <a href="http://en.wikipedia.org/wiki/Visual_Basic" title="[wiki] Visual Basic">Visual Basic</a>, then <a href="http://www.perl.org/">Perl</a> and eventually <a href="http://www.php.net">PHP</a>.  While PHP does support working in object oriented mode, the first 3 don&#8217;t (well, Perl might now, but I don&#8217;t believe it did when I started).  I&#8217;ve ALWAYS worked in a procedural style, which I feel is just fine.  I stumbled through object oriented previously and while I understand the concepts, I&#8217;ve never worked with it extensively.<br />
<strong>Third</strong> and lastly, I&#8217;m learning how to write event driven programs.  All my recent code has been written in PHP which fires on call, but doesn&#8217;t wait for user input.  Again, it isn&#8217;t challenging to understand that I&#8217;ve got to invoke event listeners on buttons, then tell them what functions to call, but it is a bit odd. I keep trying to work in my A-to-B-to-C procedural style and it doesn&#8217;t quite mesh.</p>
<p>Well, it should be interesting.  Should I actually learn how to make reasonable programs, I&#8217;ll try to get them out on the market.  Of course, I&#8217;ll have to get myself an Android powered phone first for testing.  Not that I really get a choice, but there are just so many cool ones out right now.  The <a href="http://www.google.com/phone">Nexus One</a> will probably be it.  Though the HTC Supersonic looks SWEET (granted I don&#8217;t have Sprint) and the Samsung Galaxy S has a shot (depends on the carrier).</p>
]]></content:encoded>
			<wfw:commentRss>http://snowulf.com/2010/03/25/starting-android-development/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Bafflingly stupid programming &amp; error reporting</title>
		<link>http://snowulf.com/2010/02/09/bafflingly-stupid-programming-error-reporting/</link>
		<comments>http://snowulf.com/2010/02/09/bafflingly-stupid-programming-error-reporting/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 18:00:00 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Games]]></category>

		<guid isPermaLink="false">http://wp.snowulf.com/?p=757</guid>
		<description><![CDATA[Last night I was playing Star Trek Online for the first time in a few days. I played a good couple of hours before the game took a dump on me. After they got over the initial hurdles of the launch, the game has been relatively smooth to play so I&#8217;ve been happy. Plus the [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I was playing <a href="http://www.amazon.com/Star-Trek-Online-Pc/dp/B002673XJA/ref=sr_1_1?ie=UTF8&#038;s=videogames&#038;qid=1265733802&#038;sr=8-1&#038;tag=snowulf-20" title="[amazon] Star Trek Online">Star Trek Online</a> for the first time in a few days.  I played a good couple of hours before the game took a dump on me.  After they got over the initial hurdles of the launch, the game has been relatively smooth to play so I&#8217;ve been happy.  Plus the problem occurred during a load from one zone to another after a quest was completed, so I didn&#8217;t &#8220;lose&#8221; anything.  I got a message saying that I was &#8220;Disconnected From Server&#8221;, but it doesn&#8217;t give me any options to do anything about it (like quit, or reconnect).  Being the good little QA minion that I am, I like to report these type of issues to the developers so they can fix them.  I knew there was a tool that came with STO for this exact purpose.  It wasn&#8217;t widely published, that I know of, but I ran across the EXE once.  So I dug into the folder, found and launched &#8220;crypticError.exe&#8221; and then it started to crumble.</p>
<p>The first screen is fairly simple, you select the running process name and explain what you did/what went wrong.  Simple enough; I did so then it started collecting data.  Great, after about 10 minutes I came back to find it still uploading a dump.  I thought this was a little odd so I looked closer.  The &#8220;dump&#8221; was over 1 GIGABYTE in size, which corresponded directly to the exact size in RAM the game was taking up.  It was uploading the ENTIRE game&#8217;s RAM state.  Now, don&#8217;t get me wrong, I understand how that can be useful&#8230; but this is a VIDEO GAME on a CONSUMER&#8217;S machine.  You launch the thing and it is taking up over 300MB of RAM.  Even on my go go speedy DSL line, it was going to take about an hour and a half to upload the entire dump.  My DSL is also fast, and uncapped.  What about those people who have 1.5meg lines, and have bandwidth limits.</p>
<p>Seeing things like this just blow my mind.  It wasn&#8217;t like I clicked some checkbox that said &#8220;Upload over 1GB of RAM state&#8221;, because you don&#8217;t have any checkboxes to hit.  Plus, I hate to say this, but there is no damn reason for the error reporter to upload the entire RAM state.  Why does one need to upload all the texture data?  Report the file names loaded into memory and the checksums.  If a checksum doesn&#8217;t match, then that could have been the culprit.</p>
<p>It is safe to say that shitty design like this is why some error reporting tools never get used.  I wouldn&#8217;t be surprised if the devs were actually shocked the first time anyone let this tool run it&#8217;s full course (provided anyone has been that dumb).</p>
]]></content:encoded>
			<wfw:commentRss>http://snowulf.com/2010/02/09/bafflingly-stupid-programming-error-reporting/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP: &#8220;Only variables can be passed by reference&#8221;</title>
		<link>http://snowulf.com/2010/01/05/php-only-variables-can-be-passed-by-reference/</link>
		<comments>http://snowulf.com/2010/01/05/php-only-variables-can-be-passed-by-reference/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 18:00:00 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://wp.snowulf.com/?p=729</guid>
		<description><![CDATA[&#60;?php $dir = "./mydirectory/"; if ($handle = opendir($dir)) { &#160;&#160;while (false !== ($file = readdir($handle))) { &#160;&#160;&#160;&#160;if (preg_match("/^\..*/",$file,$junk) &#124;&#124; preg_match("/^BAD.*/",$file,$junk) &#124;&#124; preg_match("/^TEST.*/",$file,junk){ &#160;&#160;&#160;&#160;&#160;&#160;//Skip it &#160;&#160;&#160;&#160;&#160;&#160;print "Skip: $file\n"; &#160;&#160;&#160;&#160;}else{ &#160;&#160;&#160;&#160;&#160;&#160;//We want to edit this file &#160;&#160;&#160;&#160;&#160;&#160;print "--EDITING--: $file\n"; &#160;&#160;&#160;&#160;} &#160;&#160;} &#160;&#160;closedir($handle); } ?&#62; This isn&#8217;t exactly the most complicated piece of code, but it was extremely [...]]]></description>
			<content:encoded><![CDATA[<p><code><br />
&lt;?php<br />
$dir = "./mydirectory/";</p>
<p>if ($handle = opendir($dir)) {<br />
&nbsp;&nbsp;while (false !== ($file = readdir($handle))) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<strong>if (preg_match("/^\..*/",$file,$junk) || preg_match("/^BAD.*/",$file,$junk) || preg_match("/^TEST.*/",$file,junk){</strong><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Skip it<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "Skip: $file\n";<br />
&nbsp;&nbsp;&nbsp;&nbsp;}else{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//We want to edit this file<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "--EDITING--: $file\n";<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;closedir($handle);<br />
}<br />
?&gt;<br />
</code><br />
This isn&#8217;t exactly the most complicated piece of code, but it was extremely annoying when I got the error &#8220;Only variables can be passed by reference&#8221; back from PHP.  Getting this error really made me miss Perl again.  Perl&#8217;s interpreter had the most fantastic error catching.  It would (generally) tell you what the error was in language that was very easy to understand, and in some cases even suggest the fix (Like you forgot a semicolon on line X).  PHP on the other hand, loves these damned messages that make no sense.</p>
<p><strong>So what&#8217;s wrong here?</strong>  The preg_match line, the final &#8220;$junk&#8221; is actually just &#8220;junk&#8221;. I forgot the string symbol ($).  Very simple issue, very easy to fix&#8230; but very difficult to find information on.  Normally a quick google reveals all, but for this error&#8230; Nada.  So if you happen to google this error and land here, hopefully this solves your issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://snowulf.com/2010/01/05/php-only-variables-can-be-passed-by-reference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &amp; CURL &#8211; Expectation Failed</title>
		<link>http://snowulf.com/2009/08/17/php-curl-expectation-failed/</link>
		<comments>http://snowulf.com/2009/08/17/php-curl-expectation-failed/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 17:00:00 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://wp.snowulf.com/?p=662</guid>
		<description><![CDATA[I&#8217;ve been doing some reasonable amount of programming as of late, working for miscellaneous projects around the Wikimedia universe. I&#8217;ll announce the specific projects as I get things to a &#8220;finished&#8221; or releasable point. For now I thought I&#8217;d tease you with random bits of &#8220;fun&#8221; I encounter when working with PHP. Today&#8217;s posting is [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing some reasonable amount of programming as of late, working for miscellaneous projects around the Wikimedia universe.  I&#8217;ll announce the specific projects as I get things to a &#8220;finished&#8221; or releasable point.  For now I thought I&#8217;d tease you with random bits of &#8220;fun&#8221; I encounter when working with PHP.</p>
<p>Today&#8217;s posting is not the failure of PHP to live up to my expectations, it is about <a href="http://en.wikipedia.org/wiki/HTTP_417#4xx_Client_Error" title="[wiki] HTTP 417">HTTP Error 417</a> &#8220;Expectation Failed&#8221;.  I was writing a file upload bot to push images up to Mediawiki sites, and on my local testing environment it worked perfectly.  I then re-pointed the script to upload to <a href="http://commons.wikimedia.org/wiki/Main_Page">Wikimedia Commons</a> and it went all to hell.  I started getting HTTP Error 417, which for as long as I&#8217;ve been around the net, I had never before seen.  I turned on the debug info for curl:<br />
&nbsp;&nbsp;&nbsp;&nbsp;<code>curl_setopt($ch, CURLOPT_VERBOSE, TRUE);</code></p>
<p>I watched the headers closely and saw that my application was sending &#8220;Expect: 100-continue&#8221; and after a bit of googling I found that it was something from the HTTP/1.1 spec on negotiating data upload.  This is great, but my application sends that it is playing in HTTP/1.0.  Obviously this isn&#8217;t a good thing, and it has been <a href="http://curl.haxx.se/mail/lib-2004-08/0237.html">known about</a> for a while.  Why it still does it, beats me, but there is an easy way to &#8220;fix&#8221; it in a PHP application:<br />
&nbsp;&nbsp;&nbsp;&nbsp;<code>curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Expect:' ) );</code></p>
<p><strong><u>That&#8217;s it</u></strong>.<br />
This way curl will send an empty &#8220;Expect:&#8221; instead of the full &#8220;Expect: 100-continue&#8221;, and subsequently it will get ignored by the server you&#8217;re talking to.  I&#8217;ve found that Apache handles this sort of issue gracefully, which is why my local tests worked.  The issue is <a href="http://www.squid-cache.org/">Squid</a> (which the Wikimedia Foundation <a href="http://upload.wikimedia.org/wikipedia/commons/thumb/4/4f/Wikimedia-servers-2009-04-05.svg/1024px-Wikimedia-servers-2009-04-05.svg.png">uses as reverse proxies</a>) which is much more of a stickler for standards compliance.</p>
]]></content:encoded>
			<wfw:commentRss>http://snowulf.com/2009/08/17/php-curl-expectation-failed/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Why don&#8217;t people build mobile sites?</title>
		<link>http://snowulf.com/2009/04/20/why-dont-people-build-mobile-sites/</link>
		<comments>http://snowulf.com/2009/04/20/why-dont-people-build-mobile-sites/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 00:00:00 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://wp.snowulf.com/?p=598</guid>
		<description><![CDATA[Over the years as I&#8217;ve spent more time on my cell phone for data access (markedly more since I got a company phone), I&#8217;ve wondered why more websites don&#8217;t have a mobile version. Of course there are a few big companies that have mobile versions (like Google) that are basically as good as their regular [...]]]></description>
			<content:encoded><![CDATA[<p>Over the years as I&#8217;ve spent more time on my cell phone for data access (markedly more since I got a company phone), I&#8217;ve wondered why more websites don&#8217;t have a mobile version.  Of course there are a few big companies that have mobile versions (like <a href="http://www.google.com/m">Google</a>) that are basically as good as their regular site (granted Google&#8217;s regular website isn&#8217;t terribly complex).  Some companies (such as <a href="http://mobile.starbucks.com/starbucks/">Starbucks</a>) have mobile sites, but the functionality is reduced heavily from their &#8220;<a href="http://en.wikipedia.org/wiki/World_Wide_Web">big web</a>&#8221; sites.  And then there is most other sites, simply have no mobile version at all.  This is extremely frustrating when you are forced to do regular work on a mobile browser.</p>
<p>Recently people have been trying to build the &#8220;rich mobile web&#8221;, bringing all sorts of cool features that you find on the &#8220;big web&#8221; down to the mobile web.  This is of course a fantastic idea as the direction we are headed is that in which everyone has a cell phone with a data plan.  The Japanese are way ahead of most of the world in this respect with Mobile TV, <a href="http://en.wikipedia.org/wiki/QR_Code">QR Codes</a>, and all sorts of other cool stuff.  That fantastic idea aside, we (in the United States) simply don&#8217;t have the bandwidth (yet) to have a rich mobile web.  In fact just visiting a normal website on a mobile phone can leave you hanging for a minute or more while all the miscellaneous media is downloaded.  It is a truly miserable experience.</p>
<p>So to the question of the day (AKA the post topic) is: Why don&#8217;t more people build mobile sites?<br />
Answer: It is a freaking pain in the ass.<br />
This I am finding out from personal experience.  I recently started making our company&#8217;s website (one of them) mobile compatible.  The site itself is extremely simple, only a handful of pages.  I had recently converted it to use PHP for a simple template system.  I figure it would be easy to change the header &#038; footer for mobile browsers, dump some images and &#8220;Voila! Mobile compatible website&#8221;.  Yea, not nearly that easy.  HTML Transitional 4.01 (which I did the site in) is not &#8220;Standards compliant&#8221; for the mobile web, so I am supposed to use the XHTML-MP 1.2 profile.  Well, obviously, XHTML != HTML so the entire site is very standards un-compliant on the mobile (according to the <a href="http://validator.w3.org/">W3C Validator</a>, but it works in IEMobile &#038; Safari Mobile).  I spent most of the day working on the site and got it from a 1 or &#8220;bad&#8221; to a 4 or &#8220;good&#8221; according to <a href="http://ready.mobi/launch.jsp?locale=en_EN">Ready.mobi</a> (a mobile-readiness evaluator).  An entire day for a handful of pages to be &#8220;good&#8221; and that doesn&#8217;t even take into account the TONS of errors the W3C has with my hack.</p>
<p>I&#8217;m continuing my fight, but so far it seems like the only real option a person has when building a mobile website, is to build a completely separate site.  Either that or build a site in a middle-ware that will convert it to the appropriate version, which seems even more complicated (but easier to maintain).  Not fun.  But it does explain why the mobile web is not a popular web.</p>
]]></content:encoded>
			<wfw:commentRss>http://snowulf.com/2009/04/20/why-dont-people-build-mobile-sites/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
