﻿<?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>Roy van de Water</title>
	<atom:link href="http://royvandewater.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://royvandewater.com</link>
	<description>Android apps on Rails</description>
	<lastBuildDate>Mon, 31 Jan 2011 01:18:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Rails Authentication with Devise</title>
		<link>http://royvandewater.com/2011/01/rails-authentication-with-devise/</link>
		<comments>http://royvandewater.com/2011/01/rails-authentication-with-devise/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 20:15:55 +0000</pubDate>
		<dc:creator>Roy</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[devise]]></category>
		<category><![CDATA[presentations]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[slippy]]></category>

		<guid isPermaLink="false">http://royvandewater.com/?p=153</guid>
		<description><![CDATA[I recently gave a presentation on using Devise as the authentication mechanism for Rails 3 applications at the January 25th Phoenix Rails User Group meeting. The slides are available at the following link: authentication with devise. The following topics are covered: Basic Setup Email Verification Custom Views Overriding login/logout actions Custom encryptors Token authentication Permanent access [...]]]></description>
			<content:encoded><![CDATA[<p>I recently gave a presentation on using Devise as the authentication mechanism for Rails 3 applications at the January 25th <a href="http://phxrails.com">Phoenix Rails User Group</a> meeting. The slides are available at the following link: <a href="http://presentations.royvandewater.com/authentication-with-devise.html">authentication with devise</a>.</p>
<p>The following topics are covered:</p>
<ul>
<li><a href="http://presentations.royvandewater.com/authentication-with-devise.html#4">Basic Setup</a></li>
<li><a href="http://presentations.royvandewater.com/authentication-with-devise.html#6">Email Verification</a></li>
<li><a href="http://presentations.royvandewater.com/authentication-with-devise.html#7">Custom Views</a></li>
<li><a href="http://presentations.royvandewater.com/authentication-with-devise.html#8">Overriding login/logout actions</a></li>
<li><a href="http://presentations.royvandewater.com/authentication-with-devise.html#9">Custom encryptors</a></li>
<li><a href="http://presentations.royvandewater.com/authentication-with-devise.html#10">Token authentication</a></li>
<li>Permanent access token</li>
<li><a href="http://presentations.royvandewater.com/authentication-with-devise.html#11">Single access token</a></li>
<li><a href="http://presentations.royvandewater.com/authentication-with-devise.html#12">Using Http Basic Auth</a></li>
<li><a href="http://presentations.royvandewater.com/authentication-with-devise.html#13">Simple Administrative Access</a></li>
<li><a href="http://presentations.royvandewater.com/authentication-with-devise.html#14">Dual User Roles</a></li>
<li><a href="http://presentations.royvandewater.com/authentication-with-devise.html#15">Let user login using either username or email</a></li>
</ul>
<p>As a bonus, I created a <a href="http://github.com/royvandewater/devise-samples">simple rails application on github</a> with devise all set up. All of the covered topics have been implemented in a separate branches so you merge in the features you want or diff between the branches to see all the things that need to be modified to activate that feature.</p>
<p>The presentation itself was recorded, and is <a title="Authentication with Devise, Presentation by Roy van dewater" href="http://vimeo.com/19280867">available on Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://royvandewater.com/2011/01/rails-authentication-with-devise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Uploading a file to FTP with Android</title>
		<link>http://royvandewater.com/2010/10/uploading-a-file-to-ftp-with-android/</link>
		<comments>http://royvandewater.com/2010/10/uploading-a-file-to-ftp-with-android/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 23:11:56 +0000</pubDate>
		<dc:creator>Roy</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://royvandewater.com/blog/?p=140</guid>
		<description><![CDATA[At Integrum, we ran in to a situation where we had to upload a file from the Android file system to an FTP server. We found that documentation on the matter was rather sparse so I decided to post about our solution. We ended up using the Apache commons-net-ftp library that can be found here: [...]]]></description>
			<content:encoded><![CDATA[<p>At <a href="http://www.integrumtech.com">Integrum</a>, we ran in to a situation where we had to upload a file from the Android file system to an FTP server. We found that documentation on the matter was rather sparse so I decided to post about our solution.</p>
<p><span id="more-140"></span></p>
<p>We ended up using the Apache commons-net-ftp library that can be found here: <a href="http://www.docjar.com/jar_detail/commons-net-ftp-2.0.jar.html">http://www.docjar.com/jar_detail/commons-net-ftp-2.0.jar.html</a></p>
<p>After adding that jar to the build path, the implementation was pretty straightforward:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.commons.net.ftp.FTPClient</span><span style="color: #339933;">;</span>
&nbsp;
FTPClient ftpClient <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FTPClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
    ftpClient.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">InetAddress</span>.<span style="color: #006633;">getByName</span><span style="color: #009900;">&#40;</span>SERVER<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    ftpClient.<span style="color: #006633;">login</span><span style="color: #009900;">&#40;</span>USERNAME, PASSWORD<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    ftpClient.<span style="color: #006633;">changeWorkingDirectory</span><span style="color: #009900;">&#40;</span>PATH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ftpClient.<span style="color: #006633;">getReplyString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">contains</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;250&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        ftpClient.<span style="color: #006633;">setFileType</span><span style="color: #009900;">&#40;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">commons</span>.<span style="color: #006633;">net</span>.<span style="color: #006633;">ftp</span>.<span style="color: #006633;">FTP</span>.<span style="color: #006633;">BINARY_FILE_TYPE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">BufferedInputStream</span> buffIn <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        buffIn <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileInputStream</span><span style="color: #009900;">&#40;</span>FULL_PATH_TO_LOCAL_FILE<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        ftpClient.<span style="color: #006633;">enterLocalPassiveMode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        ProgressInputStream progressInput <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ProgressInputStream<span style="color: #009900;">&#40;</span>buffIn, progressHandler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">boolean</span> result <span style="color: #339933;">=</span> ftpClient.<span style="color: #006633;">storeFile</span><span style="color: #009900;">&#40;</span>localAsset.<span style="color: #006633;">getFileName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, progressInput<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        buffIn.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        ftpClient.<span style="color: #006633;">logout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        ftpClient.<span style="color: #006633;">disconnect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">SocketException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    Log.<span style="color: #006633;">e</span><span style="color: #009900;">&#40;</span>SorensonApplication.<span style="color: #006633;">TAG</span>, e.<span style="color: #006633;">getStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">UnknownHostException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    Log.<span style="color: #006633;">e</span><span style="color: #009900;">&#40;</span>SorensonApplication.<span style="color: #006633;">TAG</span>, e.<span style="color: #006633;">getStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    Log.<span style="color: #006633;">e</span><span style="color: #009900;">&#40;</span>SorensonApplication.<span style="color: #006633;">TAG</span>, e.<span style="color: #006633;">getStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The ProgressInputStream is a custom version of InputStream that takes an instance of android.os.Handler in constructer. the overridden read method sends an update to the Handler after every 10KB transfered (Thanks to <a href="http://stackoverflow.com/questions/3739626/upload-file-or-inputstream-to-s3-with-a-progress-callback">Steven Schlansker on Stackoverflow</a>). The following excerpt contains the general idea of how to pass information back to the UI thread.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.royvandewater.utils</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.InputStream</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Bundle</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Handler</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Message</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ProgressInputStream <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">InputStream</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">/* Key to retrieve progress value from message bundle passed to handler */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> PROGRESS_UPDATE <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;progress_update&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> TEN_KILOBYTES <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1024</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">InputStream</span> inputStream<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> Handler handler<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">long</span> progress<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">long</span> lastUpdate<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">boolean</span> closed<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> ProgressInputStream<span style="color: #009900;">&#40;</span><span style="color: #003399;">InputStream</span> inputStream, Handler handler<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">inputStream</span> <span style="color: #339933;">=</span> inputStream<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">handler</span> <span style="color: #339933;">=</span> handler<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">progress</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">lastUpdate</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">closed</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Override
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> read<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">int</span> count <span style="color: #339933;">=</span> inputStream.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">return</span> incrementCounterAndUpdateDisplay<span style="color: #009900;">&#40;</span>count<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    @Override
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> read<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> b, <span style="color: #000066; font-weight: bold;">int</span> off, <span style="color: #000066; font-weight: bold;">int</span> len<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">int</span> count <span style="color: #339933;">=</span> inputStream.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span>b, off, len<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">return</span> incrementCounterAndUpdateDisplay<span style="color: #009900;">&#40;</span>count<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    @Override
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> close<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>closed<span style="color: #009900;">&#41;</span>
                <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">IOException</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;already closed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            closed <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> incrementCounterAndUpdateDisplay<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> count<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>count <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
            progress <span style="color: #339933;">+=</span> count<span style="color: #339933;">;</span>
        lastUpdate <span style="color: #339933;">=</span> maybeUpdateDisplay<span style="color: #009900;">&#40;</span>progress, lastUpdate<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> count<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">long</span> maybeUpdateDisplay<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">long</span> progress, <span style="color: #000066; font-weight: bold;">long</span> lastUpdate<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>progress <span style="color: #339933;">-</span> lastUpdate <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> TEN_KILOBYTES<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            lastUpdate <span style="color: #339933;">=</span> progress<span style="color: #339933;">;</span>
            sendLong<span style="color: #009900;">&#40;</span>PROGRESS_UPDATE, progress<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> lastUpdate<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> sendLong<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> key, <span style="color: #000066; font-weight: bold;">long</span> value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Bundle data <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Bundle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        data.<span style="color: #006633;">putLong</span><span style="color: #009900;">&#40;</span>key, value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        Message message <span style="color: #339933;">=</span> Message.<span style="color: #006633;">obtain</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        message.<span style="color: #006633;">setData</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        handler.<span style="color: #006633;">sendMessage</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://royvandewater.com/2010/10/uploading-a-file-to-ftp-with-android/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Eclipse plugin for running Django tests.</title>
		<link>http://royvandewater.com/2010/04/eclipse-plugin-for-running-django-tests/</link>
		<comments>http://royvandewater.com/2010/04/eclipse-plugin-for-running-django-tests/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 19:31:23 +0000</pubDate>
		<dc:creator>Roy</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://royvandewater.com/blog/?p=128</guid>
		<description><![CDATA[I&#8217;ve recently been reading Foundations of Agile Python Development and tried the PyDev plugin for Eclipse at its recommendation. I had been under the impression that the plugin was still rather immature but have since been pleasantly surprised. Besides unexpected stability, PyDev even has support for writing Django applications. There was, however, one issue with [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently been reading <a href="https://www.amazon.com/gp/product/B001W0Z8Q8">Foundations of Agile Python Development</a> and tried the <a href="http://pydev.org/">PyDev</a> plugin for <a href="http://www.eclipse.org/">Eclipse</a> at its recommendation. I had been under the impression that the plugin was still rather immature but have since been pleasantly surprised. Besides unexpected stability, PyDev even has support for writing Django applications. There was, however, one issue with the plugin that I had some umbrage with. Although there are shortcut/run configuration possibilities for running Python Unittests and even the  Django test suite, there was no way (that I found) to run individual tests without creating a custom run configuration for each one.</p>
<p><span id="more-128"></span></p>
<p>Since the existing plugin was not capable of meeting that requirement, Josh Wolfe from <a href="http://thejoshwolfe.blogspot.com/">ResultOf(programming) = Moods.happy</a> and I collaborated to create a custom plugin that provides exactly this functionality. The latest development code for the plugin can be found on GitHub at <a href="http://github.com/royvandewater/django_testing">django_testing</a> and a packaged build can be found here: <a href="http://storage.royvandewater.com/Apps/com.royvandewater.django_testing_1.0.1.jar">com.royvandewater.django_testing_1.0.1.jar</a></p>
<p>To install, simply drop it into your eclipse plugins directory (it was ~/.eclipse/org.eclipse.platform_3.5.0_x/plugins/). To use, place the cursor anywhere within a file containing Django tests and press Alt+Shift+F11. If your cursor is currently inside of a specific test method, it will run only that method. If it is outside any test methods but still within the class, the plugin will execute all test methods in that class. Lastly, if you are in a function where the name is not prefixed with &#8220;test&#8221;, the plugin will execute the last run test. This is great for writing a test and running it from another file as you write the implementation.</p>
]]></content:encoded>
			<wfw:commentRss>http://royvandewater.com/2010/04/eclipse-plugin-for-running-django-tests/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ubuntu wallpaper slideshow</title>
		<link>http://royvandewater.com/2009/12/ubuntu-wallpaper-slideshow/</link>
		<comments>http://royvandewater.com/2009/12/ubuntu-wallpaper-slideshow/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 00:40:20 +0000</pubDate>
		<dc:creator>Roy</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[slideshow]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://royvandewater.com/blog/?p=97</guid>
		<description><![CDATA[The desktop background switcher included with Karmic Koala has a cool feature, a wallpaper slideshow that rotates images at a predetermined interval. However, getting it to cycle through your own set of images isn&#8217;t exactly user friendly. In order to get a sequence of images to display, the wallpaper picker must be supplied with an [...]]]></description>
			<content:encoded><![CDATA[<p>The desktop background switcher included with Karmic Koala has a cool feature, a wallpaper slideshow that rotates images at a predetermined interval. However, getting it to cycle through your own set of images isn&#8217;t exactly user friendly. In order to get a sequence of images to display, the wallpaper picker must be supplied with an xml file with the following structure:<br />
<span id="more-97"></span></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">        1795.0
        /path/to/image1.jpg
&nbsp;
        5
        /path/to/image1.jpg
        /path/to/image2.jpg
&nbsp;
        1795.0
        /path/to/image2.jpg
&nbsp;
        5
        /path/to/image2.jpg
        /path/to/image1.jpg</pre></div></div>

<p>Where all paths are absolute. The xml file can be chosen as a wallpaper in the standard gnome wallpaper picker by going pressing add and choosing &#8220;All files&#8221; from the file filter drop down.</p>
<p><a href="http://royvandewater.com/blog/wp-content/uploads/2009/12/wallpaper.png"><img class="alignnone size-medium wp-image-137" title="wallpaper" src="http://royvandewater.com/wp-content/uploads/2009/12/wallpaper-300x225.png" alt="" /></a></p>
<p>To make the process of creating these xml files a bit simpler, I made a <a href="http://www.python.org/">python</a> script that takes all images in a directory and generates an xml file for them. To use it, simply run it in the directory where the images are located and it will generate a file called &#8220;desktop.xml&#8221;. The default transition time is 1795 seconds (30 minutes). To change the switch time, supply the new interval in seconds as an argument:</p>
<p><code>./ubuWallGen 1200</code></p>
<p>You can get the latest version of the script using <a href="http://git-scm.com/">git</a>:</p>
<p><code>git clone git://github.com/royvandewater/ubuWallGen.git</code></p>
<p>You can also download the script directly <a title="Ubuntu Slideshow Wallpaper Script" href="http://storage.royvandewater.com/Apps/ubuWallGen/ubuWallGen.py">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://royvandewater.com/2009/12/ubuntu-wallpaper-slideshow/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Incomplete Wikipedia</title>
		<link>http://royvandewater.com/2009/10/incomplete-wikipedia/</link>
		<comments>http://royvandewater.com/2009/10/incomplete-wikipedia/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 18:33:40 +0000</pubDate>
		<dc:creator>Roy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://royvandewater.com/blog/?p=88</guid>
		<description><![CDATA[I am currently the president of Women in Computer Science, a student organization at Arizona State University. One of the things the WCS does is go to various high schools in the area and talk about the field of computer science to students that are trying to figure out their college majors. Recently, we have [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently the president of Women in Computer Science, a student organization at Arizona State University. One of the things the WCS does is go to various high schools in the area and talk about the field of computer science to students that are trying to figure out their college majors. Recently, we have switched our presentation style from a static, boring power point to something more along the lines of an anti-conference. We have students shout out topics that they are interested in and we discuss them as they relate to computer science, ASU and college life in general. One of the things that always gets me is when the subject of Wikipedia comes up.</p>
<p><span id="more-88"></span></p>
<p>Students often shout &#8220;Wikipedia is bad&#8221; and &#8220;Wikipedia is inaccurate&#8221;. They are going to high school in a generation where Wikipedia has already existed and high school teachers have already taken a position on it. It seems they have taken the stand that Wikipedia is bad and they tout its inaccuracy as the reason why. I believe that telling students this is a disservice while understanding their position. Teachers realize that as students trust and become reliant on Wikipedia, they will lose the education required at this stage in their life to go out and perform their own research. This is certainly a justified concern and should be addressed. I just don&#8217;t think that claiming it is inaccurate is the correct way to go about it.</p>
<p>Although the potential for inaccuracy exists due to Wikipedia&#8217;s user-generated content, case studies show that in general, Wikipedia is more accurate than more widely respected published sources. Because of their unpublished nature, Wiki articles can be corrected immediately when errors are discovered. On the other hand, an encyclopedia serving the same information would have to wait until the release of a new edition, or at least the release of an errata, before correcting their mistake. This lends Wikipedia much more flexibility in the face of inevitable human error.</p>
<p>Instead of its falsely perceived inaccuracy, what teachers should be demonstrating to students is Wikipedia&#8217;s incompleteness. The purpose of Wikipedia, or any other encyclopedia for that matter, is to provide a broad overview of a topic and not a detailed accounting of all aspects relating to the subject. One should use Wikipedia to become versed in a subject they had previously not heard of. After gaining a general picture of the concept, the researcher could then go into depth by reading specific journal articles and books on the topic. By having this relatively vague mental picture of the subject matter, the researcher is in a much better position to understand the in-depth material.</p>
<p>Wikipedia should not be seen as the enemy of research and neither should it be perceived as the compendium of all information. It should be used as a tool to gain a general understanding in a particular subject to prime the learner for in-depth research. Technical inaccuracies in Wiki articles are not of a major concern when Wikipedia is used in this way; the researcher will generally discover the inaccuracy when they dive into the specialized books and journal articles and can then quickly correct the mistake for the benefit of the next passer-by (citing their recently read article as the source). In the mean time, little harm was done because the researcher was not attempting to gain knowledge about specific details on the topic at the time the error was read.</p>
<p>In conclusion, I believe that if students were taught to use Wikipedia as a research tool, in the same way deprecated encyclopedias were used in previous generations, it will greatly enhance their learning and researching capabilities.</p>
]]></content:encoded>
			<wfw:commentRss>http://royvandewater.com/2009/10/incomplete-wikipedia/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Shell in VIM Solved</title>
		<link>http://royvandewater.com/2009/10/shell-in-vim-solved/</link>
		<comments>http://royvandewater.com/2009/10/shell-in-vim-solved/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 18:57:34 +0000</pubDate>
		<dc:creator>Roy</dc:creator>
				<category><![CDATA[VIM]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://royvandewater.com/blog/?p=79</guid>
		<description><![CDATA[I found a great solution to the shell in vim problem. Namely, don&#8217;t have a shell in vim. Instead, I&#8217;ve been using Terminator. Terminator allows you to quickly split the terminal window either vertically or horizontally, much in the same way as vim&#8217;s sp and vsp commands. This way I can run vim in the [...]]]></description>
			<content:encoded><![CDATA[<p>I found a great solution to the shell in vim problem. Namely, don&#8217;t have a shell in vim. Instead, I&#8217;ve been using <a title="Terminator Shell" href="http://software.jessies.org/terminator/">Terminator</a>. Terminator allows you to quickly split the terminal window either vertically or horizontally, much in the same way as vim&#8217;s <abbr title="Horizontal Split"><strong>sp</strong></abbr> and <abbr title="Vertical Split"><strong>vsp</strong></abbr> commands. This way I can run vim in the top half and my interpreter in the bottom half. This has worked very well while programming in Python and Lisp. It&#8217;s also not dependent on the vim build or the plugins installed on vim. I can run vim and the interpreter remotely via parallel SSH sessions.</p>
]]></content:encoded>
			<wfw:commentRss>http://royvandewater.com/2009/10/shell-in-vim-solved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shell in VIM</title>
		<link>http://royvandewater.com/2009/08/shell-in-vim/</link>
		<comments>http://royvandewater.com/2009/08/shell-in-vim/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 15:03:01 +0000</pubDate>
		<dc:creator>Roy</dc:creator>
				<category><![CDATA[VIM]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://royvandewater.com/blog/?p=17</guid>
		<description><![CDATA[I&#8217;ve been looking for a good shell-in-vim solution. Emacs does it pretty well, but I&#8217;d rather stick with VIM since I&#8217;ve been using it as my primary editor for a while. The two solutions I&#8217;ve found so far are vimsh and vim-shell. I&#8217;ve gotten vimsh to do what I&#8217;d like to do., but there are [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking for a good shell-in-vim solution. Emacs does it pretty well, but I&#8217;d rather stick with VIM since I&#8217;ve been using it as my primary editor for a while. The two solutions I&#8217;ve found so far are <a title="vimsh" href="http://www.vim.org/scripts/script.php?script_id=165">vimsh</a> and <a title="Vim-shell" href="http://www.wana.at/vimshell/">vim-shell</a>. I&#8217;ve gotten vimsh to do what I&#8217;d like to do., but there are some problems, discussed below, that prevent it from being an ideal solution.<br />
<span id="more-17"></span><br />
Vimsh is the more convenient of the two because it will work with vim as long as it has python support compiled  in. (The package <a title="Apt Url" href="apt://vim-full">vim-full</a> in the Ubuntu repository has the python support compiled in. The standard package, <a title="Apt Url" href="apt://vim-tiny">vim-tiny</a>, may also have the python support, but I&#8217;m not sure.) In order to use it, just download and unpackage the <a title="www.vim.org" href="http://www.vim.org/scripts/download_script.php?src_id=2877">vimsh.tar</a> and map a shortcut in your .vimrc</p>

<div class="wp_syntax"><div class="code"><pre class="vim" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;">&quot;activate vimsh</span>
<span style="color: #804040;">map</span> ,<span style="color: #668080;">sh</span> <span style="color: #000000;">:</span>source <span style="color: #000000;">/</span><span style="color: #668080;">path</span><span style="color: #000000;">/</span><span style="color: #668080;">to</span><span style="color: #000000;">/</span>vimsh<span style="color: #000000;">/</span>vimsh<span style="color: #000000;">.</span>vim</pre></div></div>

<p>This is the most basic call, causing the current buffer to split horizontally and open a shell in the top window. I use a slight variation of this shortcut to make sure that the shell is always opened at the bottom of the screen. Just append Ja to the last shortcut:</p>

<div class="wp_syntax"><div class="code"><pre class="vim" style="font-family:monospace;"><span style="color: #804040;">map</span><span style="color: #000000;">...</span>vimsh<span style="color: #000000;">.</span>vimJa</pre></div></div>

<p>If you would like vim to open a python prompt, just add python:</p>

<div class="wp_syntax"><div class="code"><pre class="vim" style="font-family:monospace;"><span style="color: #804040;">map</span><span style="color: #000000;">...</span>vimsh<span style="color: #000000;">.</span>vimJapython</pre></div></div>

<p>To have it execute the python file you are currently editing and then remain in interactive shell mode afterwards, use the following (note that the post-execution interactive shell is only supported on python3):</p>

<div class="wp_syntax"><div class="code"><pre class="vim" style="font-family:monospace;"><span style="color: #804040;">map</span><span style="color: #000000;">...</span>vimsh<span style="color: #000000;">.</span>vimJapython3 <span style="color: #000000;">-</span>i #</pre></div></div>

<p>If you would like to have the shell execute the python script, but not go into the interactive python shell afterwards, omit the &#8220;-i&#8221; from the above command. This is great for running unit test programs.</p>
<p>The major drawback to vimsh is that the commands listed above work only once. If you terminate the shell session and close the window so you are left with your original document (A state that <em>seems</em> to be identical to the state before we opened the shell) and try to execute the command again, it creates the shell terminal inside of the currently active window instead of splitting it like it did the first time. This issue might be resolved by changing some configuration options, but the application is not well documented. The documentation basically says &#8220;Look in the source file if you want to find out what the configuration options are&#8221;, something I&#8217;ll have to get around to eventually. Another issue with vimsh is that the shell has some display issues with more complex programs. This prevents the shell window from opening lynx, irssi and most other ncurses applications.</p>
<p>As for vim-shell, I haven&#8217;t tried it yet as it requires a recompilation of vim. I&#8217;ll make another post once I&#8217;ve found the time to get it working.</p>
]]></content:encoded>
			<wfw:commentRss>http://royvandewater.com/2009/08/shell-in-vim/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Avatar Trailer</title>
		<link>http://royvandewater.com/2009/08/avatar-trailer/</link>
		<comments>http://royvandewater.com/2009/08/avatar-trailer/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 16:21:07 +0000</pubDate>
		<dc:creator>Roy</dc:creator>
				<category><![CDATA[Movies]]></category>
		<category><![CDATA[Science Fiction]]></category>

		<guid isPermaLink="false">http://royvandewater.com/blog/?p=9</guid>
		<description><![CDATA[Just got around to watching the new Avatar Trailer. It seems interesting that most blogs, news and social media sites on the net dislike the trailer, yet the comments on the news sites (such as slashdot) seem to be generally in favor of the trailer and anticipate the movie. It seemed, for a while, that [...]]]></description>
			<content:encoded><![CDATA[<p>Just got around to watching the new <a title="Apple Trailers" href="http://www.apple.com/trailers/fox/avatar/hd/">Avatar Trailer</a>. It seems interesting that most blogs, news and social media sites on the net dislike the trailer, yet the comments on the news sites (such as slashdot) seem to be generally in favor of the trailer and anticipate the movie. It seemed, for a while, that science fiction movies had gone out of style. I&#8217;m glad to see that movies like District 9 are a <a title="District 9 Box Office Data" href="http://www.boxofficemojo.com/movies/?id=district9.htm">box office success</a> and investors are making a return on their money. I hope we continue to see original takes on the SciFi genre in the next few years. One of my major problems with the movie industry&#8217;s take on the genre is their need to make every SciFi movie an action movie. I rather like some of the older movies that address more philosophical and social issues of dealing with extraterrestrial life or advanced technology, such as Stanley Kubric&#8217;s 2001, Contact or many of the Star Trek: <acronym title="The Next Generation">TNG</acronym> episodes.</p>
]]></content:encoded>
			<wfw:commentRss>http://royvandewater.com/2009/08/avatar-trailer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Hosting Provider</title>
		<link>http://royvandewater.com/2009/07/new-hosting-provider/</link>
		<comments>http://royvandewater.com/2009/07/new-hosting-provider/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 05:45:39 +0000</pubDate>
		<dc:creator>Roy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Hosting]]></category>

		<guid isPermaLink="false">http://royvandewater.com/blog/?p=3</guid>
		<description><![CDATA[Just switched to a new hosting provider, MediaTemple. I have worked with MediaTemple several times in the past while working at Translucent Developments and have always had good luck with their service. I&#8217;m hoping that their Django support is a little better than GoDaddy (It should be, considering that DjangoProject is hosted by mediatemple).]]></description>
			<content:encoded><![CDATA[<p>Just switched to a new hosting provider, <a title="MediaTemple" href="http://mediatemple.net" target="_blank">MediaTemple</a>. I have worked with MediaTemple several times in the past while working at <a title="Translucent Developments" href="http://www.tdevelopments.com" target="_blank">Translucent Developments</a> and have always had good luck with their service. I&#8217;m hoping that their Django support is a little better than GoDaddy (It should be, considering that <a title="Django" href="http://www.djangoproject.com/" target="_blank">DjangoProject</a> is hosted by mediatemple).</p>
]]></content:encoded>
			<wfw:commentRss>http://royvandewater.com/2009/07/new-hosting-provider/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

