<?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>scienceoss.com &#187; utilities</title>
	<atom:link href="http://scienceoss.com/categories/utilities/feed/" rel="self" type="application/rss+xml" />
	<link>http://scienceoss.com</link>
	<description>useful tidbits for using open source software in science</description>
	<lastBuildDate>Wed, 26 May 2010 03:34:19 +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>Record screencasts, convert to Flash, and embed on your site</title>
		<link>http://scienceoss.com/record-screencasts-convert-to-flash-and-embed-on-your-site/</link>
		<comments>http://scienceoss.com/record-screencasts-convert-to-flash-and-embed-on-your-site/#comments</comments>
		<pubDate>Sat, 03 May 2008 18:30:41 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[utilities]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flv]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://scienceoss.com/?p=124</guid>
		<description><![CDATA[Here&#8217;s a step-by-step tutorial of creating a screencast, converting it into an .flv file, and uploading it to your site with an embedded Flash player. The tools ffmpeg (On Ubuntu: sudo apt-get install ffmpeg) gtk-recordmydesktop (On Ubuntu: sudo apt-get install gtk-recordmydesktop) Jeroen Wijering&#8217;s embedded Flash player wizard (brilliant!) The process 1. Record a screencast Fire [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a step-by-step tutorial of creating a screencast, converting it into an .flv file, and uploading it to your site with an embedded Flash player.<span id="more-124"></span></p>
<h3>The tools</h3>
<ul>
<li><a href="http://ffmpeg.mplayerhq.hu/">ffmpeg</a>
<p>    (On Ubuntu: <span class="c">sudo apt-get install ffmpeg</span>)</li>
<li><a href="http://recordmydesktop.iovar.org/about.php">gtk-recordmydesktop</a>
<p>    (On Ubuntu: <span class="c">sudo apt-get install gtk-recordmydesktop</span>)</li>
<li>Jeroen Wijering&#8217;s <a href="http://www.jeroenwijering.com/?page=wizard">embedded Flash player wizard</a> (brilliant!)</li>
</ul>
<h3>The process</h3>
<h4>1. Record a screencast</h4>
<p>Fire up gtk-recordmydesktop.  The screen looks like this:<br />
<a href='http://scienceoss.com/wp-content/uploads/2008/04/screenshot-recordmydesktop.png'><img src="http://scienceoss.com/wp-content/uploads/2008/04/screenshot-recordmydesktop-300x137.png" alt="" title="gtk-recordmydesktop screenshot" width="300" height="137" class="alignnone size-medium wp-image-125" /></a></p>
<p>Optionally press &#8220;Select Window&#8221; and click on a window to select it for recording.</p>
<p>Press record, and do your thing.</p>
<p>By default, it saves the file as <span class="c">out.ogg</span> in your home directory.  (more info on the <a href="http://en.wikipedia.org/wiki/Ogg">Ogg</a> format).  </p>
<h4>2. Convert the <span class="c">.ogg</span> to <span class="c">.flv</span></h4>
<p>You need to convert this into a Flash <span class="c">.flv</span> format.  Easiest way is to use <span class="c">ffmpeg</span>:</p>
<pre class="prettyprint"><code class="code">ffmpeg -i out.ogg out.flv</code></pre>
<p>or, optionally resize so that the output file will be 320&#215;250:</p>
<pre class="prettyprint"><code class="code">ffmpeg -i out.ogg -s 320x250 out.flv</code></pre>
<h4>3. Upload the .flv to your site</h4>
<p>Upload the new <span class="c">.flv</span> to your site (and remember where you put it).</p>
<h4>4. Use the embedded Flash player wizard</h4>
<p>Then go to Jeroen Wijering&#8217;s <a href="http://www.jeroenwijering.com/?page=wizard">embedded Flash player wizard</a>.  Paste the link to your newly uploaded <span class="c">.flv</span>.</p>
<p>Double check that the file shows up in the preview of the wizard.  When you&#8217;re happy with it, copy the source code shown in the wizard and paste it in your site.</p>
<h4>A note on embedding in WordPress</h4>
<p>Copying and pasting the code into the edit window for a post did not work properly at first in WordPress (even in the non-visual editor).  The source code showed up as plain text.  To fix this, I had to delete all the newlines so that the <code>embed</code> tag was all on one line.</p>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/record-screencasts-convert-to-flash-and-embed-on-your-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use Sphinx for documentation</title>
		<link>http://scienceoss.com/use-sphinx-for-documentation/</link>
		<comments>http://scienceoss.com/use-sphinx-for-documentation/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 02:45:20 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[utilities]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[sphinx]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://scienceoss.com/?p=117</guid>
		<description><![CDATA[Update: After some folks requested it in the comments, I wrote another post, A minimal Sphinx setup for autodocumenting Python modules. You might want to check this out if you&#8217;re specifically interested in automatically documenting your code with Sphinx. I&#8217;ve been doing quite a bit of code documentation lately, and I decided to try and [...]]]></description>
			<content:encoded><![CDATA[<p><em><strong>Update:</strong> After some folks requested it in the comments, I wrote another post, <a href="http://scienceoss.com/minimal-sphinx-setup-for-autodocumenting-python-modules/">A minimal Sphinx setup for autodocumenting Python modules</a>.  You might want to check this out if you&#8217;re specifically interested in automatically documenting your code with Sphinx.</em></p>
<p>I&#8217;ve been doing quite a bit of code documentation lately, and I decided to try and figure out the best tool to use.  I found it.  It&#8217;s called <a href="http://sphinx.pocoo.org/">Sphinx</a>, and you can see what the documentation looks like by checking out the documentation for Python itself (v. <a href="http://docs.python.org/dev/">2.6</a> and <a href="http://docs.python.org/dev/3.0/">3.0</a>).<br />
Here&#8217;s how to get started using Sphinx. <span id="more-117"></span><br />
Sphinx is the name of the program that takes your plain text files and converts them into hyperlinked, nicely formatted HTML documents.  It knows what to link and how to format based on simple formatting commands in the text files (specifically, it uses the <a href="http://docutils.sourceforge.net/rst.html">ReStructured Text (ReST)</a> markup language).</p>
<h3>Installation</h3>
<p>It is really, really easy.</p>
<p>If you have easy_install on your machine, running</p>
<pre class="brush: plain; title: ; notranslate">
easy_install sphinx -U
</pre>
<p> from the command line will do it.</p>
<p>If you don&#8217;t have easy_install yet, <a href="http://peak.telecommunity.com/DevCenter/EasyInstall#installing-easy-install">download and install it</a>, then run <span class="c">easy_install sphinx</span> from the command line. </p>
<h3>Run <span class="c">sphinx-quickstart</span> to automatically setup a directory structure</h3>
<p>Navigate to the directory that you want to generate documentation for.  Run <span class="c">sphinx-quickstart</span> from the command line.  You will get a series of questions that lead you through the process of setting up the directories and some files that Sphinx needs.  Most questions have defaults that you can just accept no prob.  When it comes to version name, you can just make something up.</p>
<p>If you accepted all the defaults (you conformist, you!) there are now a couple of new files and directories:</p>
<pre class="brush: plain; title: ; notranslate">
New directory contents:
/.build
/.templates
/.static
index.rst
conf.py</pre>
<p>In a moment we&#8217;ll look at index.rst and conf.py.  But first . . .</p>
<h3>Create some content</h3>
<p>Time to make some content.  All content is created in plain text files.  Create a new text file in the same directory as <span class="c">index.rst</span> and <span class="c">conf.py</span>.  Call it <span class="c">chapter1.rst</span> or something . . . what&#8217;s important though is that you give it the &#8220;.rst&#8221; extension (if you chose the default option for &#8220;Source file suffix&#8221; when you ran <span class="c">sphinx-build</span>, otherwise the extension must be whatever you chose in that step). Sphinx will recognize files that should be included based on their extension.  Since I tend to have random, non-documentation .txt files laying around which Sphinx will ask me about, I prefer to use .rst instead of .txt.</p>
<p>Inside <span class="c">chapter1.rst</span>, type some stuff.  You could be documenting the code that&#8217;s in the current directory, for example.  Here are some formatting elements you can try for now.  The Sphinx site has <a href="http://sphinx.pocoo.org/rest.html">lots more info on formatting</a>.</p>
<pre class="brush: plain; title: ; notranslate">
This is a header
================
Some text, *italic text*, **bold text**

* bulleted list.  There needs to be a space right after the &quot;*&quot;
* item 2

.. note::
    This is a note.

Here's some Python code:

&gt;&gt;&gt; for i in range(10):
...     print i
</pre>
<p>Once Sphinx is set up, it will read in the plain text above and convert it into some nicely formatted HTML.  The results of the above plain text will look something like this:<br />
<a href='http://scienceoss.com/wp-content/uploads/2008/04/documentation-preview.png'><img src="http://scienceoss.com/wp-content/uploads/2008/04/documentation-preview-300x161.png" alt="" title="documentation preview" width="300" height="161" class="aligncenter size-medium wp-image-120" /></a></p>
<p>But first you have to run it through Sphinx in order for it to look that way, and before you can do that you have to tell Sphinx to include this document in its processing.</p>
<h3>Tell <span class="c">index.rst</span> what files to include</h3>
<p>Now we have to edit <span class="c">index.rst </span>to tell Sphinx that chapter1.rst should be included in the documentation.  By default, <span class="c">index.rst</span> looks like this:</p>
<h4>Change this . . .</h4>
<pre class="brush: plain; title: ; notranslate">
Welcome to my project's documentation!
======================================

Contents:

.. toctree::
   :maxdepth: 2

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
</pre>
<h4>To this . . .</h4>
<p>(Just add the <span class="c">chapter1.rst</span> line)</p>
<pre class="brush: plain; title: ; notranslate">
Welcome to my project's documentation!
======================================

Contents:

.. toctree::
    :maxdepth: 2

    chapter1.rst

Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
</pre>
<p>The indentation of the chapter1.rst line is important.  So is the blank line above, and the blank line below.</p>
<p>BE CAREFUL . . . this burned me the first time, and took a while to figure out.  See the :maxdepth: 2 line?  <strong>It&#8217;s only indented 3 spaces.</strong>  It doesn&#8217;t have to be 3 spaces, it just happens to be in this auto-generated file.  If you have your text editor set for 4 spaces, or anything other than 3 spaces, when you hit tab on another line your indentation will be inconsistent, resulting in errors.</p>
<p>Usually I just add a space to make the :maxdepth: 2 line a 4-space indentation.</p>
<h3>Build the documentation</h3>
<p>Back at the command line, make a new directory to hold your documentation.  I&#8217;m going to call mine <span class="c">doc</span>.</p>
<pre>mkdir doc</pre>
<p>Then, in the same directory as <span class="c">index.rst</span>, run</p>
<pre>sphinx-build . doc</pre>
<p>You&#8217;ll get some output that tells you what it&#8217;s doing.  </p>
<h3>View the result</h3>
<p>Now you can open up doc/index.html to view your newly generated documentation.  It looks something like this:<br />
<a href='http://scienceoss.com/wp-content/uploads/2008/04/documentation0.png'><img src="http://scienceoss.com/wp-content/uploads/2008/04/documentation0-300x132.png" alt="" title="first look at documentation" width="300" height="132" class="aligncenter size-medium wp-image-118" /></a></p>
<p>Clicking on the &#8220;This is a header&#8221; link shows you the content you added in chapter1.rst, and it looks something like this:<br />
<a href='http://scienceoss.com/wp-content/uploads/2008/04/documentation1.png'><img src="http://scienceoss.com/wp-content/uploads/2008/04/documentation1-300x157.png" alt="" title="first look at documentation, next page" width="300" height="157" class="aligncenter size-medium wp-image-119" /></a></p>
<h3>So what&#8217;s the big deal?</h3>
<p>The above example could have been done with a little work in Microsoft Word.  Where Sphinx really shines, though, is when you use it to document Python code.</p>
<p>Sphinx can auto-document by reading in a module, then displaying the docstrings of objects in that source code.  It hyperlinks modules, classes, methods, attributes, etc.  It can even take the code you write as a tutorial and use it as doctests, which test your code to ensure that it is correct.  With a little more setup, you can generate LaTeX (and then PDF files) of your code, along with the good-looking syntax highlighting.  (see upcoming posts for how to do all of this)</p>
<p>I feel that other documentation tools, like <a href="http://epydoc.sourceforge.net/">epydoc</a>, have too much of an auto-generated look, and it&#8217;s too easy to include extraneous content.  In order to include tutorial info in epydoc documents, you have to add text to the beginning of a module.  While epydoc has some nice formatting (allowing you to tag text as parameters or return values), it tends to look ugly&#8211;sometimes to the point of unreadability.</p>
<p>I like Sphinx because it allows you to insert auto-generated documentation when you need it but tends to focus on high-quality, handwritten, tutorial-style content which I think is the most effective kind of documentation.</p>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/use-sphinx-for-documentation/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Persistent SSH sessions</title>
		<link>http://scienceoss.com/persistent-ssh-sessions/</link>
		<comments>http://scienceoss.com/persistent-ssh-sessions/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 03:41:47 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[utilities]]></category>
		<category><![CDATA[screen]]></category>

		<guid isPermaLink="false">http://scienceoss.com/persistent-ssh-sessions/</guid>
		<description><![CDATA[The screen program, among other useful things, lets you keep an SSH session running even after you disconnect from SSH. Here&#8217;s how to use it. SSH in. ssh user@hostname.com Once on the remote machine, set up a named screen: screen -S myscreen In another terminal, open another SSH connnection and start another screen: screen -S [...]]]></description>
			<content:encoded><![CDATA[<p>The <span class="c">screen</span> program, among other useful things, lets you keep an SSH session running even after you disconnect from SSH.  Here&#8217;s how to use it.</p>
<p>SSH in.</p>
<pre class="prettyprint"><code class="code">ssh user@hostname.com</code></pre>
<p>Once on the remote machine, set up a named screen:</p>
<pre class="prettyprint"><code class="code">screen -S myscreen</code></pre>
<p>In another terminal, open another SSH connnection and start another screen:</p>
<pre class="prettyprint"><code class="code">screen -S mysecondscreen</code></pre>
<p>You can see they are there by using, in either of the terminals,</p>
<pre class="prettyprint"><code class="code">screen -ls</code></pre>
<p>This does NOT start screen, just lists the different screens.</p>
<p>You can now disconnect the SSH connections.  When you reconnect, you can use</p>
<pre class="prettyprint"><code class="code">screen -r myscreen</code></pre>
<p>or</p>
<pre class="prettyprint"><code class="code">screen -r mysecondscreen</code></pre>
<p>to reconnect to the one you want.</p>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/persistent-ssh-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up and using an SVN repository</title>
		<link>http://scienceoss.com/setting-up-and-using-an-svn-repository/</link>
		<comments>http://scienceoss.com/setting-up-and-using-an-svn-repository/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 03:36:40 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[utilities]]></category>
		<category><![CDATA[revision control]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://scienceoss.com/setting-up-and-using-an-svn-repository/</guid>
		<description><![CDATA[Install subversion (Ubuntu) sudo apt-get install subversion Make a directory to store the repositories mkdir /path/to/repository Create the repository svnadmin create /path/to/repository Import existing files into repository svn import /path/name/to/foo file:///path/to/repository when you checkout this repository, it will create the directory foo. So to get the svn repository in my ~/work directory as ~/work/foo I [...]]]></description>
			<content:encoded><![CDATA[<p>Install subversion (Ubuntu)</p>
<pre class="prettyprint"><code class="code">sudo apt-get install subversion</code></pre>
<p>Make a directory to store the repositories</p>
<pre class="prettyprint"><code class="code">mkdir /path/to/repository</code></pre>
<p>Create the repository</p>
<pre class="prettyprint"><code class="code">svnadmin create /path/to/repository</code></pre>
<p>Import existing files into repository</p>
<pre class="prettyprint"><code class="code">svn import /path/name/to/foo file:///path/to/repository</code></pre>
<p>when you checkout this repository, it will create the directory <span class="c">foo</span>. So to get the svn repository in my<span class="c"> ~/work</span> directory as <span class="c">~/work/foo</span> I would go to <span class="c">~/work</span>, then</p>
<pre class="prettyprint"><code class="code">svn co file:///path/to/repository</code></pre>
<p>that is, don&#8217;t make a new dir dir called <span class="c">foo</span> and import into there . . . it will make its own dir.</p>
<p>Check out locally</p>
<pre class="prettyprint"><code class="code">svn checkout file:///path/to/repository /local/workdir</code></pre>
<p>Check out remotely through an ssh connection</p>
<pre class="prettyprint"><code class="code">svn checkout svn+ssh://user@hostname/path/to/repository/on/remotehost /local/workdir</code></pre>
<p>Update local copy from SVN</p>
<pre class="prettyprint"><code class="code">svn update</code></pre>
<p>Check what&#8217;s been changed</p>
<pre class="prettyprint"><code class="code">svn status</code></pre>
<p>Resolve a conflict</p>
<pre class="prettyprint"><code class="code">svn resolved filename</code></pre>
<p>Send these changes to SVN (editor will prompt for revision notes, must be non-empty)</p>
<pre class="prettyprint"><code class="code">svn commit</code></pre>
<p>Send these changes to SVN, and specify logfile to send as comments</p>
<pre class="prettyprint"><code class="code">svn commit -F logfile</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/setting-up-and-using-an-svn-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A more secure SSH configuration</title>
		<link>http://scienceoss.com/a-more-secure-ssh-configuration/</link>
		<comments>http://scienceoss.com/a-more-secure-ssh-configuration/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 03:25:49 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[utilities]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://scienceoss.com/a-more-secure-ssh-configuration/</guid>
		<description><![CDATA[Some easy ways to configure SSH to be a little more secure: Edit /etc/ssh/sshd_config as root. Change the port (default is 22) Change “PermitRootLogin yes” to “PermitRootLogin no” AddUser username save and quit restart the ssh server: sudo /etc/init.d/ssh restart More info here: http://ubuntu-tutorials.com/2007/02/14/what-you-ought-to-know-about-securing-ssh/]]></description>
			<content:encoded><![CDATA[<p>Some easy ways to configure SSH to be a little more secure:</p>
<p>Edit <span class="c">/etc/ssh/sshd_config</span> as root.</p>
<ul>
<li>Change the port (default is 22)</li>
<li>Change “PermitRootLogin yes” to “PermitRootLogin no”</li>
<li>AddUser username</li>
<li>save and quit</li>
<li>restart the ssh server: <span class="c">sudo /etc/init.d/ssh restart</span></li>
</ul>
<p>More info here:<br />
<a href="http://ubuntu-tutorials.com/2007/02/14/what-you-ought-to-know-about-securing-ssh/">http://ubuntu-tutorials.com/2007/02/14/what-you-ought-to-know-about-securing-ssh/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/a-more-secure-ssh-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH: Add public key to remote server</title>
		<link>http://scienceoss.com/ssh-add-public-key-to-remote-server/</link>
		<comments>http://scienceoss.com/ssh-add-public-key-to-remote-server/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 03:20:41 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[utilities]]></category>
		<category><![CDATA[public key]]></category>

		<guid isPermaLink="false">http://scienceoss.com/ssh-add-public-key-to-remote-server/</guid>
		<description><![CDATA[Easy way to add public key of this machine to a remote machine: ssh-copy-id -i ~/.ssh/id_dsa.pub root@fileserver01 More good info here: http://ubuntu-tutorials.com/2007/02/05/unattended-ssh-login-public-key-ssh-authorization-ssh-automatic-login/]]></description>
			<content:encoded><![CDATA[<p>Easy way to add public key of this machine to a remote machine:</p>
<pre class="prettyprint"><code class="code">ssh-copy-id -i ~/.ssh/id_dsa.pub root@fileserver01</code></pre>
<p>More good info here:<br />
<a href="http://ubuntu-tutorials.com/2007/02/05/unattended-ssh-login-public-key-ssh-authorization-ssh-automatic-login/">http://ubuntu-tutorials.com/2007/02/05/unattended-ssh-login-public-key-ssh-authorization-ssh-automatic-login/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/ssh-add-public-key-to-remote-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remote MySQL using SSH</title>
		<link>http://scienceoss.com/remote-mysql-using-ssh/</link>
		<comments>http://scienceoss.com/remote-mysql-using-ssh/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 03:19:32 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[utilities]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[port forwarding]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://scienceoss.com/remote-mysql-using-ssh/</guid>
		<description><![CDATA[Step 1: SSH forwarding First, forward the local port 3307 to 3306. That is, when you access the local port 3307, it will redirect it to port 3306 on the remote host. ssh -fNg4 -L 3307:127.0.0.1:3306 user@hostname -f sends SSH to the background -g allows remote hosts to connect to local forwarded ports -N don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<h2>Step 1: SSH forwarding</h2>
<p>First, forward the local port 3307 to 3306. That is, when you access the local port 3307, it will redirect it to port 3306 on the remote host.</p>
<pre class="prettyprint"><code class="code">ssh -fNg4 -L 3307:127.0.0.1:3306 user@hostname</code></pre>
<p><span class="c">-f</span> sends SSH to the background<br />
<span class="c">-g</span> allows remote hosts to connect to local forwarded ports<br />
<span class="c">-N</span> don&#8217;t execute a remote command<br />
<span class="c">-4</span> this was key! Forces IPv4. Kept getting &#8220;bind: Address already in use&#8221; errors because I didn&#8217;t have this.<br />
<span class="c">-L</span> the forwarding magic happens here . . . syntax is localport:localhost:remoteport</p>
<h2>Step 2: Connect to mysql on port 3307</h2>
<p>. . . which will redirect to port 3306 on remote host.</p>
<pre class="prettyprint"><code class="code">mysql -u root -h 127.0.0.1 -P 3307 -p</code></pre>
<p>and you&#8217;re in!</p>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/remote-mysql-using-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting between SVG, EPS, and PDF</title>
		<link>http://scienceoss.com/converting-between-svg-eps-and-pdf/</link>
		<comments>http://scienceoss.com/converting-between-svg-eps-and-pdf/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 21:13:20 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[utilities]]></category>
		<category><![CDATA[converting]]></category>
		<category><![CDATA[eps]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[svg]]></category>

		<guid isPermaLink="false">http://scienceoss.com/converting-between-svg-eps-and-pdf/</guid>
		<description><![CDATA[Sometimes you want to be able to tweak a plot in R that was saved as a PDF or an EPS. Use this to convert an eps into svg for editing in Inkscape: pstoedit -f plot-svg input.eps output.svg Then save the SVG in Inkscape as a &#8220;Plain SVG&#8221;, and use convert input.svg output.pdf]]></description>
			<content:encoded><![CDATA[<p>Sometimes you want to be able to tweak a plot in R that was saved as a PDF or an EPS.</p>
<p>Use this to convert an eps into svg for editing in Inkscape:</p>
<pre class="prettyprint"><code class="code">pstoedit -f plot-svg input.eps output.svg</code></pre>
<p>Then save the SVG in Inkscape as a &#8220;Plain SVG&#8221;, and use</p>
<pre class="prettyprint"><code class="code">convert input.svg output.pdf
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/converting-between-svg-eps-and-pdf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Split the pages out of a PDF, or merge PDFs into one</title>
		<link>http://scienceoss.com/split-the-pages-out-of-a-pdf-or-merge-pdfs-into-one/</link>
		<comments>http://scienceoss.com/split-the-pages-out-of-a-pdf-or-merge-pdfs-into-one/#comments</comments>
		<pubDate>Sun, 27 Jan 2008 21:49:12 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[utilities]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://scienceoss.com/?p=79</guid>
		<description><![CDATA[Using the free open source program PDF Toolkit, you can operate on PDFs quite easily. Install the open-source PDF Toolkit Get the PDF Toolkit package, available for Windows, Mac OSX 10.3+ (or build from source for earlier Mac OSs) and Linux. It&#8217;s in the Ubuntu repositories: sudo apt-get install pdftk Split pages from a PDF [...]]]></description>
			<content:encoded><![CDATA[<p>Using the free open source program PDF Toolkit, you can operate on PDFs quite easily.<span id="more-79"></span></p>
<h3>Install the open-source PDF Toolkit</h3>
<p>Get the <a href="http://www.accesspdf.com/article.php/20041130153545577">PDF Toolkit</a> package, available for Windows, Mac OSX 10.3+ (or build from source for earlier Mac OSs) and Linux.</p>
<p>It&#8217;s in the Ubuntu repositories:</p>
<pre class = "prettyprint"><code class = "code">sudo apt-get install pdftk </code></pre>
<h3>Split pages from a PDF</h3>
<p>To split out pages 10-15 and page 19 of <span class="c">whole.pdf</span> into a separate PDF, <span class="c">piece.pdf</span>, run</p>
<pre class = "prettyprint"><code class = "code">
pdftk whole.pdf cat 10-15 19 output piece.pdf
</code></pre>
<h3>Merge multiple PDFs into one</h3>
<p>To combine <span class="c">first.pdf</span>, <span class="c">second.pdf</span>, and <span class="c">third.pdf</span> into <span class="c">big.pdf</span>, use</p>
<pre class = "prettyprint"><code class = "code">pdftk first.pdf second.pdf third.pdf cat output big.pdf</code></pre>
<p>Other examples <a href="http://www.accesspdf.com/article.php/20041129175231241">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/split-the-pages-out-of-a-pdf-or-merge-pdfs-into-one/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Convert images into a movie with mencoder</title>
		<link>http://scienceoss.com/convert-images-into-a-movie-with-mencoder/</link>
		<comments>http://scienceoss.com/convert-images-into-a-movie-with-mencoder/#comments</comments>
		<pubDate>Sat, 26 Jan 2008 17:10:51 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[utilities]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[jpeg]]></category>
		<category><![CDATA[lavc]]></category>
		<category><![CDATA[mencoder]]></category>
		<category><![CDATA[mf]]></category>
		<category><![CDATA[mpeg4]]></category>
		<category><![CDATA[mplayer]]></category>
		<category><![CDATA[vcodec]]></category>

		<guid isPermaLink="false">http://scienceoss.com/?p=71</guid>
		<description><![CDATA[Here&#8217;s how to create a movie out of a collection of images, along with a more detailed example on creating multiple images with nested folders of images. The basic idea You&#8217;ll need the command line utility mencoder (which comes with mplayer) for this. The command to create a movie out of a list of files [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to create a movie out of a collection of images, along with a more detailed example on creating multiple images with nested folders of images.<span id="more-71"></span></p>
<h3>The basic idea</h3>
<p>You&#8217;ll need the command line utility <span class="c"><a href="http://www.mplayerhq.hu/design7/news.html">mencoder</a></span> (which comes with mplayer) for this.</p>
<p>The command to create a movie out of a list of files is this (note this command should all be on one line, but it needs to be wrapped to be displayed here):</p>
<pre class = "prettyprint"><code class = "code">
mencoder "mf://@temp.txt" -mf fps=25 -o output.avi -ovc lavc
 -lavcopts vcodec=mpeg4
</code></pre>
<p><span class="c">temp.txt</span> is a file containing a list of image files, and the new movie will be called <span class="c">output.avi</span>.</p>
<h3>A specific example</h3>
<p>This a Python script for my future reference, but perhaps someone will find it useful.<br />
The problem was this:</p>
<ul>
<li>I had many subfolders with up to 20,000 jpeg images per folder.  Each image was named after the experiment and had a number at the end specifying the frame number.</li>
<li>Some of those subfolders had up to three different experiments in them.  Each experiment needed its own movie.</li>
<li>It was OK to have multiple movies for a single experiment.</li>
</ul>
<p>Directory structure was something like this;</p>
<pre class = "prettyprint"><code class = "code">
workingDir
    -- day1
            -- a_001.jpg
            -- a_002.jpg
            ...
            -- a_21999.jpg
            -- b_001.jpg
            -- b_002.jpg
            ...
            -- b_487.jpg
    --  day2
            -- c_001.jpg
            -- c_002.jpg
            ...
            -- c_1478.jpg
    -- day3
            ...
    ...
    -- day20
</code></pre>
<p>I decided to use Python to parse an input file containing a list of the directories (created using <span class="c"> ls workingDir > folders-to-run.txt</span>).  If I wanted to have a movie created from the contents of a folder, I marked that folder by putting a &#8220;*&#8221; as the first character on the line.</p>
<p>I parsed the contents of each marked directory, separated out files that had different base names, then sorted by the frame number.  I decided on a movie length of 2000 frames to keep file sizes manageable.  For each batch of 2000 images from an experiment, I wrote the filenames to temp.txt and fed that to mencoder.</p>
<p><span class="c">folders-to-run.txt</span> looked like this:</p>
<pre class = "prettyprint"><code class = "code">day1
*day2
*day3
...
day20</code></pre>
<p>(Since only day2 and day3 had a *, they would be the only ones run)</p>
<p>In the end, I&#8217;ll end up with movies called:</p>
<pre class = "prettyprint"><code class = "code">
a_0-2000.avi
a_2000-4000.avi
a_4000-6000.avi
...
a_20000-22000.avi
b_0-2000.avi
c_0-2000.avi
...</code></pre>
<p>Those last two will be smaller than each of the &#8220;a&#8221; movies, since they have less frames, but that&#8217;s OK for my purposes.</p>
<p>Here&#8217;s the working Python script.</p>
<pre class = "prettyprint"><code class = "code">
"""A Python script for creating movies out of directories of jpegs.
Requires mencoder to be installed."""

import os
import re

directory = 'images/workingDir''

# Parse the list of folders to run from the input file.
folderlist = open('folders-to-run.txt')
folders = [line.rstrip() for line in folderlist if line.startswith('*')]
folders = [i.replace('*','') for i in folders]

# Set up regular expressions for later
RE = re.compile('.*-(\d*)\.jpg')
fbRE = re.compile('(.*)-.*\.jpg')

# How many frames to use per movie
framestep = 2000

for folder in folders:

    print '\n\n\tlisting contents of %s . . .'%folder
    files = os.listdir(os.path.join(directory,folder))
    print '%s files found.\n\n' % len(files)

    # If a file is called "asdf-003.jpg", the basename will be 'asdf'.
    basenames = [fbRE.match(i).groups()[0] for i in files if fbRE.match(i)]

    # Get the set of unique basenames.  In the
    basenames = list(set(basenames))

    print '\t***There are %s different runs here.***' % len(basenames)

    # This loop will only execute once if there was only a single experiment
    # in the folder.
    for j,bn in enumerate(basenames):
        these_files = [i for i in files if bn in i]

        # Sort using the "decorate-sort-undecorate" approach
        these_sorted_files = [(int(RE.match(i).groups()[0]),i) for i in these_files if RE.match(i)]
        these_sorted_files.sort()
        these_sorted_files = [i[1] for i in these_sorted_files]

        # these_sorted_files is now a list of the filenames a_001.jpg, a_002.jpg, etc.
        for k in range(0, len(these_sorted_files), framestep):

            frame1 = k
            frame2 = k+framestep

            # Name the output file based on the folder, basename, a number
            # to indicate if it was a second basename in the folder, and the
            # frame range.  Then replace any spaces with "_" so as not
            # to confuse the mencoder command
            this_output_name = '%s_%s_%s_%s-%s.avi' % (folder,bn,j,frame1,frame2
            this_output_name = this_output_name.replace(' ','-')
            print '\n\n\toutput will be %s.' % this_output_name

            #Create a temporary text file that will contain pathnames.  This
            # will be passed to mencoder.
            f = open('temp.txt','w')
            filenames = [os.path.join(directory,folder,i)+'\n' \
                                for i in these_sorted_files[frame1:frame2]]
            f.writelines(filenames)
            f.close()

            # Finally!  Now execute the command to create the video.
            cmd = 'mencoder "mf://@temp.txt" -mf fps=25 -o %s -ovc lavc\
            -lavcopts vcodec=mpeg4' % this_output_name

            os.system(cmd)
            print '\n\nDONE with %s' % this_output_name
print 'Done with all marked folders.'</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://scienceoss.com/convert-images-into-a-movie-with-mencoder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

