<?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>Guy Rutenberg</title>
	<atom:link href="http://www.guyrutenberg.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guyrutenberg.com</link>
	<description>Keeping track of what I do</description>
	<lastBuildDate>Fri, 04 May 2012 17:11:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Installing culmus-latex on Ubuntu 11.10</title>
		<link>http://www.guyrutenberg.com/2012/04/20/installing-culmus-latex-on-ubuntu-11-10/</link>
		<comments>http://www.guyrutenberg.com/2012/04/20/installing-culmus-latex-on-ubuntu-11-10/#comments</comments>
		<pubDate>Fri, 20 Apr 2012 11:51:37 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[culmus-latex]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=1000</guid>
		<description><![CDATA[After someone complained to me that he can&#8217;t install culmus-latex on Ubuntu 11.10, I decided to check the issue. Apparently culmus-latex can&#8217;t be installed as-is on Ubuntu 11.10 (and probably other new versions of Debian and Ubuntu). The problem have been reported in few places such as Whatsup, but as I don&#8217;t frequent the forum [...]]]></description>
			<content:encoded><![CDATA[<p>After someone complained to me that he can&#8217;t install <a href="http://www.guyrutenberg.com/culmus-latex/" title="culmus-latex">culmus-latex</a> on Ubuntu 11.10, I decided to check the issue. Apparently culmus-latex can&#8217;t be installed as-is on Ubuntu 11.10 (and probably other new versions of Debian and Ubuntu). The problem have been reported in few places such as <a href="http://whatsup.org.il/index.php?name=PNphpBB2&#038;file=viewtopic&#038;t=58307">Whatsup</a>, but as I don&#8217;t frequent the forum lately, I wasn&#8217;t aware of it. Skip bellow if you&#8217;re just interested in the workaround.</p>
<h3>Technical Details</h3>
<p>The problem manifests itself as:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo make install
... snipped for brevity ...
mktexlsr: Done.
updmap-sys --enable Map=culmus.map
updmap: This is updmap, version $Id: updmap 14402 2009-07-23 17:09:15Z karl $
updmap: using transcript file `/var/lib/texmf/web2c/updmap.log'
updmap: initial config file is `/var/lib/texmf/web2c/updmap.cfg'
make: *** [install] Error 2</pre></div></div>

<p>But if you look at updmap&#8217;s manpage there is no documentation for the return codes. Also there is no explicit place where it exits with return code 2 in the code. After some straceing I found the culprit in the combination of the <code>set -e</code> in the top of <code>/usr/bin/updmap</code> and the function <code>pickLocalFile</code> in <code>/usr/share/tex-common/debianize-upddmap</code> which overrides certain behaviors in <code>updmap</code>. The <code>pickLocalFile</code> uses the following lines</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">localfile</span>=<span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #007800;">localfile</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`ls $debDirname/*local*cfg 2&gt;/dev/null`</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$localfile</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span></pre></div></div>

<p>To check if there is a local configuration file under <code>/etc/texmf/updmap.d</code>. If such file doesn&#8217;t exist, instead of creating one (as the maintainers of <code>debianize-updmap</code> intended) it fails due to the <code>set -e</code> in <code>/usr/bin/updmap</code>. Thus <code>updmap</code> exists with error code 2, instead of completing the installation.</p>
<p>Meanwhile, until the bug is fixed, there is a simple workaround</p>
<h3>Workaround</h3>
<p>Before installing, execute</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>texmf<span style="color: #000000; font-weight: bold;">/</span>updmap.d<span style="color: #000000; font-weight: bold;">/</span>10local.cfg</pre></div></div>

<p>And now the regular <code>sudo make install</code> installation should finish successfully.</p>
<p>As the problem is a result of a Debian bug, I don&#8217;t expect to release a new version of culmus-latex, instead I&#8217;ll report the bug to the Debian team.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2012/04/20/installing-culmus-latex-on-ubuntu-11-10/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>mechanize &#8211; Writing Bots in Python Made Simple</title>
		<link>http://www.guyrutenberg.com/2012/03/29/mechanize-writing-bots-in-python-made-simple/</link>
		<comments>http://www.guyrutenberg.com/2012/03/29/mechanize-writing-bots-in-python-made-simple/#comments</comments>
		<pubDate>Thu, 29 Mar 2012 21:36:04 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=988</guid>
		<description><![CDATA[I&#8217;ve been using python to write various bots and crawler for a long time. Few days ago I needed to write some simple bot to remove some 400+ spam pages in Sikumuna, I took an old script of mine (from 2006) in order to modify it. The script used ClientForm, a python module that allows [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using python to write various bots and crawler for a long time. Few days ago I needed to write some simple bot to remove some 400+ spam pages in <a href="http://www.sikumuna.co.il/">Sikumuna</a>, I took an old script of mine (from 2006) in order to modify it. The script used ClientForm, a python module that allows you to easily parse and fill html forms using python. I quickly found that ClientForm is now deprecated in favor of <a href="http://wwwsearch.sourceforge.net/mechanize/">mechanize</a>. In the beginning I was partly set back by the change, as ClientForm was pretty easy to use, and <code>mechanize</code>&#8216;s documentation could use some improvement. However, I quickly changed my mind about <code>mechanize</code>. The basic interface for <code>mechanize</code> is a simple browser object, that litteraly allows you to browse using python. It takes care of handling cookies and such and it got similar form-filling abilities to ClientForm, but this time they are integrated into the browser object.</p>
<p>For future reference for myself, and as another code example to <code>mechanizes</code> sparse documentation I&#8217;m giving bellow the gist of the simple bot I wrote:<br />
<span id="more-988"></span></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">        <span style="color: #008000;">self</span>.<span style="color: black;">browser</span> = mechanize.<span style="color: black;">Browser</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">browser</span>.<span style="color: black;">set_handle_robots</span><span style="color: black;">&#40;</span><span style="color: #008000;">False</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> login<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    <span style="color: #008000;">self</span>.<span style="color: black;">browser</span>.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">login_url</span><span style="color: black;">&#41;</span>
    <span style="color: #008000;">self</span>.<span style="color: black;">browser</span>.<span style="color: black;">select_form</span><span style="color: black;">&#40;</span>name=<span style="color: #483d8b;">&quot;userlogin&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #008000;">self</span>.<span style="color: black;">browser</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;wpName&quot;</span><span style="color: black;">&#93;</span> = <span style="color: #008000;">self</span>.<span style="color: black;">username</span>
    <span style="color: #008000;">self</span>.<span style="color: black;">browser</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;wpPassword&quot;</span><span style="color: black;">&#93;</span> = <span style="color: #008000;">self</span>.<span style="color: black;">password</span>
    res = <span style="color: #008000;">self</span>.<span style="color: black;">browser</span>.<span style="color: black;">submit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> find_pages<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, prefix<span style="color: black;">&#41;</span>:
    <span style="color: #008000;">self</span>.<span style="color: black;">browser</span>.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">find_pages_url</span><span style="color: black;">&#41;</span>
    <span style="color: #008000;">self</span>.<span style="color: black;">browser</span>.<span style="color: black;">select_form</span><span style="color: black;">&#40;</span>nr=<span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
    <span style="color: #008000;">self</span>.<span style="color: black;">browser</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;from&quot;</span><span style="color: black;">&#93;</span> = prefix
    res = <span style="color: #008000;">self</span>.<span style="color: black;">browser</span>.<span style="color: black;">submit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    data = res.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    link_regex = <span style="color: #dc143c;">re</span>.<span style="color: #008000;">compile</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'&lt;td&gt;&lt;a href=&quot;([^&quot;]*)&quot;[^&lt;]*&lt;/a&gt;&lt;/td&gt;'</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> link_regex.<span style="color: black;">findall</span><span style="color: black;">&#40;</span>data<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> delete_page<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, page_url<span style="color: black;">&#41;</span>:
    <span style="color: #008000;">self</span>.<span style="color: black;">browser</span>.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span>page_url + <span style="color: #483d8b;">&quot;&amp;action=delete&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #483d8b;">&quot;Kindle&quot;</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">browser</span>.<span style="color: black;">title</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #008000;">self</span>.<span style="color: black;">browser</span>.<span style="color: black;">title</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">raw_input</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Confirm: &quot;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;y&quot;</span>:
            <span style="color: #ff7700;font-weight:bold;">return</span>
    <span style="color: #008000;">self</span>.<span style="color: black;">browser</span>.<span style="color: black;">select_form</span><span style="color: black;">&#40;</span>nr=<span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
    <span style="color: #008000;">self</span>.<span style="color: black;">browser</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;wpReason&quot;</span><span style="color: black;">&#93;</span> = <span style="color: #483d8b;">&quot;Spam&quot;</span>
    <span style="color: #008000;">self</span>.<span style="color: black;">browser</span>.<span style="color: black;">submit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> run<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, prefix<span style="color: black;">&#41;</span>:
    <span style="color: #008000;">self</span>.<span style="color: black;">login</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    pages = <span style="color: #008000;">self</span>.<span style="color: black;">find_pages</span><span style="color: black;">&#40;</span>prefix<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Found %d page&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>pages<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> i,page <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">enumerate</span><span style="color: black;">&#40;</span>pages<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Deleting&quot;</span>, i
        <span style="color: #008000;">self</span>.<span style="color: black;">delete_page</span><span style="color: black;">&#40;</span>page<span style="color: black;">&#41;</span></pre></div></div>

<p>This isn&#8217;t a complete code example, as the rest of the code is just mundane, but you can clearly see how simple it is to use <code>mechanize</code>.</p>
<p>The interesting parts are:</p>
<ul>
<li>Initializing the browser object using <code>mechanize.Browser()</code></li>
<li>Openning pages: <code>browser.open(url)</code></li>
<li>Selecting forms: <code>browser.select_form(name="userlogin")</code> (selecting forms by name) <code>browser.select_form(nr=0)</code> (selecting forms by their sequential number in the page).</li>
<li>Filling forms is done by assigning values to the form fields on the browser object: <code>browser["wpName"] = self.username</code></li>
<li>Submitting: <code>browser.submit()</code></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2012/03/29/mechanize-writing-bots-in-python-made-simple/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bye Bye OmniCppComplete, Hello Clang Complete</title>
		<link>http://www.guyrutenberg.com/2012/03/12/bye-bye-omnicppcomplete-hello-clang-complete/</link>
		<comments>http://www.guyrutenberg.com/2012/03/12/bye-bye-omnicppcomplete-hello-clang-complete/#comments</comments>
		<pubDate>Mon, 12 Mar 2012 21:56:38 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[c/c++]]></category>
		<category><![CDATA[clang]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=983</guid>
		<description><![CDATA[For years OmniCppComplete has been the de facto standard for C++ completion in Vim. But as time progressed, I got more and more annoyed by it&#8217;s shortcomings. OmniCppComplete is based on tokenizing provided by ctags. The ctags parsing of C++ code is problematic, you can&#8217;t even run it on libstdc++ headers (you need to download [...]]]></description>
			<content:encoded><![CDATA[<p>For years <a href="http://www.vim.org/scripts/script.php?script_id=1520">OmniCppComplete</a> has been the de facto standard for C++ completion in Vim. But as time progressed, I got more and more annoyed by it&#8217;s shortcomings. OmniCppComplete is based on tokenizing provided by ctags. The ctags parsing of C++ code is problematic, you can&#8217;t even run it on libstdc++ headers (you need to download <a href="http://www.vim.org/scripts/script.php?script_id=2358">modified headers</a>). You want to use an external library? You&#8217;ll need to run <a href="<a href="http:///2008/02/23/setting-up-omnicomplete-autocompletion-for-wxwidgets-in-vim/" title="Setting Up OmniComplete (Autocompletion) for wxWidgets in Vim">ctags seperatly on each library</a>. Not to mention it&#8217;s inablity to deduce types of anything more than trivial. The core of the problem is that OmniCppComplete isn&#8217;t a compiler and you can&#8217;t expect something that isn&#8217;t a compiler to fully understand code. This what makes Visual Studio&#8217;s IntelliSense so great: it uses the Visual C++ compiler for parsing, it isn&#8217;t making wild guess at types and what is the current scope &#8211; it knows it.<br />
<span id="more-983"></span><br />
With this on my mind, I set out to look for a better alternative. The first thing I looked for is getting GCC to give me type info. Apparently, GCC doesn&#8217;t like to play nice with other and provide this information (I read in couple of places people cite RMS/FSF saying it&#8217;s deliberately in order not to allow proprietary software to use GCC without linking against it, like crashing your car so nobody wants to steal it &#8211; plain dumb). The only solution is to patch like <a href="http://cx4a.org/software/gccsense/">GCCSense</a>, which does exactly what I looked for, compiler based auto-completion. But patching GCC only to work around perverted FSF policies seems like not the most elegant solution. This is where <a href="http://clang.llvm.org/">clang</a>, a modular and developer friendly compiler, came to my mind. </p>
<p>After a quick searching I came across <a href="http://www.vim.org/scripts/script.php?script_id=3302">clang complete</a>. This plugin uses clang to parse your code and suggest completion. Auto-complete worked out of the box for the standard library, STL and Boost, and it worked properly (already better than OmniCppComplete). If you want to use libraries which aren&#8217;t in your default search path, i.e. gcc need you to specify <code>-I</code> flags or you need <code>-D</code> flags, you&#8217;ll need to pass them on to clang. This may sound difficult, but the developers of the vim script provide a wrapper to automatically understand what should be the proper flags from your build system. All you need to do is pass <code>CXX='~/.vim/bin/cc_args.py g++'</code> to <code>make</code> and the script will record your flags in a <code>.clang_complete</code> file, which it will use from now on. After you do it (except a little glitch, see bellow), omni-completion will work for every library in your code base.</p>
<p>There are still some glitches that need to be polished. First of all, the suggested way to invoke <code>cc_args.py</code> isn&#8217;t perfect. Make changes working dirs as it recurses through your code base, so <code>cc_args.py</code>&#8216;s working-dir isn&#8217;t the same as yours, but the plugin will search for the <code>.clang_complete</code> file in your working-dir (the one vim has). The solution is just to move the <code>.clang_complete</code> files to the main directory of the project, from whatever subdirectory it created them in, and merge them (simpler than it sounds). Also this task needs to be done once for every project, so no big deal.</p>
<p>There are two other problems that still bother me. The plugin&#8217;s author says that if you set the plugin to use <code>libclang</code> it would work much faster and use caching. However, <code>libclang</code> isn&#8217;t currently packaged for Ubuntu 11.10. This should be solve next month with the release of Ubuntu 12.04, which provides it. The second problem is a weird bug in clang. When I try to compile a C++11 file with clang (providing the <code>-std=c++0x</code> flag, it segfaults, pretty weird. But I guess a bit more searching and maybe some bug-reporting will fix this issue (sadly, this means that the plugin can&#8217;t autocomplete c++11 features as well).</p>
<p>Despite some rough edges it&#8217;s way better than any previous C++ completion for Vim I ever seen. At the begging I hesitated when I had to remove OmniCppComplete due to conflicts with clang complete, and now after a (very) shot time using clang complete I don&#8217;t think I&#8217;ll miss it anytime soon.</p>
<p>Update May 2, 2012: Ubuntu 12.04 got released, so I finally checked the status of the completion using libclang. Apparently, you also need to install the <code>libclang-dev</code> package (in addition to <code>libclang1</code>, or else, clang_complete will output cryptic error messages. The clang 3.0 that comes with Ubuntu 12.04 no longer segfaults on c++11 code, but it refuses the compile anything with boost&#8217;s shared_ptr, due to issues with move semantics.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2012/03/12/bye-bye-omnicppcomplete-hello-clang-complete/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Some Tips on Scanning Lecture Notes</title>
		<link>http://www.guyrutenberg.com/2012/03/10/some-tips-on-scanning-lecture-notes/</link>
		<comments>http://www.guyrutenberg.com/2012/03/10/some-tips-on-scanning-lecture-notes/#comments</comments>
		<pubDate>Sat, 10 Mar 2012 20:43:55 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[pdftk]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=976</guid>
		<description><![CDATA[The new semester just begun, and I&#8217;ve decided (again) to try to digitize my notes from the courses I&#8217;ve studied. I&#8217;ve dubbed my hands at the task for several times over the years and I thought it would be nice to share my 2 cents worth of tips on how to do it properly. Things [...]]]></description>
			<content:encoded><![CDATA[<p>The new semester just begun, and I&#8217;ve decided (again) to try to digitize my notes from the courses I&#8217;ve studied. I&#8217;ve dubbed my hands at the task for several times over the years and I thought it would be nice to share my 2 cents worth of tips on how to do it properly.<br />
<span id="more-976"></span></p>
<h3>Things You&#8217;ll Need</h3>
<ul>
<li>A scanner with automatic document feeder (ADF). The ADF is really important, without it, scanning is a nightmare. If you don&#8217;t have one, get one (they&#8217;re really cheap). You&#8217;re office probably has one with duplex scanning which is even better.</li>
<li>A good scanning software that support creating PDFs. I use <a href="http://www.xsane.org/">XSane</a>, the GUI isn&#8217;t great but it does the job. I&#8217;ve also tried Simple Scan, which didn&#8217;t work properly for me, and the default HP software for windows (I can&#8217;t describe a bigger bloatware).</li>
<li><a href="http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/">pdftk</a> - A great program to manipulate PDFs.</li>
</ul>
<h3>The Scanning Process</h3>
<p>There are three relevant scanning options in my opinion for hand-written notes:</p>
<ul>
<li>300DPI gray-scale. This results in around 550kb for each page of notes. Quality is great, but sometimes you can see the writing on the other side of the page in a slight gray.</li>
<li>600DPI black and white. Quality is a bit lower than gray-scale, but the size is about half, just 200kb per page. It takes longer to scan, but an ADF usually means it&#8217;s not an issue.</li>
<li>300DBI BW. This will again reduce the size. But this time at a noticeable loss in quality. I recommend this only if file-size is your greatest concern.</li>
</ul>
<p>In order to make the choice a bit less vague here are some example scanned pages: <a href="http://www.guyrutenberg.com/wp-content/uploads/2012/03/300gray.pdf">300 Gray</a>,<a href="http://www.guyrutenberg.com/wp-content/uploads/2012/03/300bw.pdf"> 300 BW</a> and <a href="http://www.guyrutenberg.com/wp-content/uploads/2012/03/600bw.pdf">600 BW</a>. The notes are written using a rollerball pen (pilot v-ball grip). Here is a another <a href="http://www.guyrutenberg.com/wp-content/uploads/2012/03/comparison.pdf">comparison</a>, this time using a ballpoint (Fisher Space Pen). As you can see the quality difference is more pronounced in the ballpoint. Hence, if you want you&#8217;re scans to be smaller and keep the quallity, use a rollerball and 600dpi. If you use a ballpoint, pay the price and go for 300dpi grayscale. Also, stay away from blue pens, they are less readable in grayscale and might be unreadable at all in BW (I&#8217;ve tried to make some simple image manipulations to improve <a title="Scanning Documents Written in Blue Ink – biscan" href="2008/03/19/scanning-documents-written-in-blue-ink-biscan/">scanning blue-ink to black and white</a>, which I have some improvements which hopefully I&#8217;ll release some time).</p>
<p>I&#8217;ll also use plain white paper intended for printers. I find it of higher quality (and cheaper) than ruled paper, and it results in better scans.</p>
<h4>Page Reordering</h4>
<p>If you&#8217;ve a duplex scanner this tip isn&#8217;t for you. For the rest of us, the most convenient method to scan paper I found, is to make one scan for the odd pages and then take the pile flip and scan the even pages (back pages) from back to front (reverse order). Afterwards use pdftk to join them:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">pdftk A=odd.pdf B=complexity-even.pdf shuffle A Bend-1 output final.pdf</pre></div></div>

<p lang="text">Thats my 2 cents on scanning lecture notes. If you got other great tips, comment and share them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2012/03/10/some-tips-on-scanning-lecture-notes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Starting Djano upon Reboot using Cron</title>
		<link>http://www.guyrutenberg.com/2012/02/27/starting-djano-upon-reboot-using-cron/</link>
		<comments>http://www.guyrutenberg.com/2012/02/27/starting-djano-upon-reboot-using-cron/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 19:52:10 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=970</guid>
		<description><![CDATA[Three years ago I wrote about starting services as user via cron instead of init.d (specifically Trac). However this method has a serious downside: it has no support for dependencies. This really bothered me when I used cron to start a Django server, has it would attempt to load before MySQL was running. This made [...]]]></description>
			<content:encoded><![CDATA[<p>Three years ago I wrote about starting services as user via cron instead of <code>init.d</code> (<a href="/2009/02/17/starting-tracd-without-root-privileges-at-startup/">specifically Trac</a>). However this method has a serious downside: it has no support for dependencies. This really bothered me when I used cron to start a Django server, has it would attempt to load before MySQL was running. This made the cron useless, as always after rebooting I would receive an error email saying it couldn&#8217;t connect to the MySQL server, and I would have to login and start the Django Server manually. Yesterday I got sick of it, and decided to hack something that will work properly. So I had something that looked like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">@reboot python ./manage.py runfcgi ...</pre></div></div>

<p>which I changed into:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">@reboot until status mysql | grep start ; do echo &quot;Mysql isn't running yet...&gt;&amp;2&quot;; sleep 1; done; python ./manage.py runfcgi ...</pre></div></div>

<p>Basically it loops and checks whether the MySQL service got started. If so, it would start Django as it did before. On the other hand, if MySQL isn&#8217;t running it would just sleep for a second and repeat the check.</p>
<p>A small issue is that if for some reason MySQL won&#8217;t start at all, it will loop for ever. If this happens, it would mean that I&#8217;ll have to manually kill that cronjob, but I would have to login anyway to see what wrong with the MySQL. So, while this method can&#8217;t support dependencies like <code>init.d</code> does, it does provide a good-enough solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2012/02/27/starting-djano-upon-reboot-using-cron/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Gmail backup: getmail vs. OfflineIMAP</title>
		<link>http://www.guyrutenberg.com/2012/01/14/gmail-backup-getmail-vs-offlineimap/</link>
		<comments>http://www.guyrutenberg.com/2012/01/14/gmail-backup-getmail-vs-offlineimap/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 11:30:25 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[duplicity]]></category>
		<category><![CDATA[getmail]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[OfflineIMAP]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=956</guid>
		<description><![CDATA[I&#8217;m currently reviewing my backup plans and decided it&#8217;s a good occasion to finally start backing up my Gmail account. Firstly, I didn&#8217;t seriously consider Desktop clients as the main backup tool, as they are hard to automate. The two main options are: OfflineIMAP and getamil. Both are available from Ubuntu&#8217;s repositories, so installation is [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently reviewing my backup plans and decided it&#8217;s a good occasion to finally start backing up my Gmail account. Firstly, I didn&#8217;t seriously consider Desktop clients as the main backup tool, as they are hard to automate. The two main options are: <a href="http://offlineimap.org/">OfflineIMAP</a> and <a href="http://pyropus.ca/software/getmail/">getamil</a>. Both are available from Ubuntu&#8217;s repositories, so installation is easy with both and both have good tutorials, <a href="http://www.mattcutts.com/blog/backup-gmail-in-linux-with-getmail/">Matt Cutts&#8217; getmail</a> and <a href="http://www.enigmacurry.com/2008/02/22/backing-up-my-online-brain/">EnigmaCurry&#8217;s OfflineIMAP</a>.</p>
<p>OfflineIMAP claims to be faster, but I haven&#8217;t really checked it (and I&#8217;m not sure how important that is giving that it runs in the background). From what I saw configuring them is mainly a task of cut-and-paste, but getmail requires to list every label you want to backup, which I consider is a major downside. As both are able to save the mails to maildir format, it should be easy to back it up using <a href="duplicity.nongnu.org">duplicity</a>.</p>
<p>Conclusion: This was a short comparison, mainly to guide me in choosing the right backup for me, you may have different opinions (which, of course, I would gladly hear). I finally chose OfflineIMAP, mainly due to the labels issue.</p>
<p>Note on desktop clients: It seems that every decent one can be configured to work with a local maildir, so you can use them to read the backups. As I prefer Gmail&#8217;s interface, I will only use desktop clients in case I&#8217;m offline, so read-only access from desktop client seems good enough for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2012/01/14/gmail-backup-getmail-vs-offlineimap/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The annoying eBook vs. Paperback Pricing</title>
		<link>http://www.guyrutenberg.com/2011/12/30/the-annoying-ebook-vs-paperback-pricing/</link>
		<comments>http://www.guyrutenberg.com/2011/12/30/the-annoying-ebook-vs-paperback-pricing/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 10:17:24 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Kindle]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=949</guid>
		<description><![CDATA[I&#8217;m an avid Kindle user for more than a year. However once in a while, I come across something like this when I shopping for a new book: As you can see, Amazon sells Kindle edition for higher price than a paperback. This book of course isn&#8217;t the only example for this ridiculous pricing method, and if [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m an avid Kindle user for more than a year. However once in a while, I come across something like this when I shopping for a new book:</p>
<p><a href="http://www.guyrutenberg.com/wp-content/uploads/2011/12/screenshot_ebook_price.png"><img class="aligncenter size-medium wp-image-950" title="screenshot_ebook_price" src="http://www.guyrutenberg.com/wp-content/uploads/2011/12/screenshot_ebook_price-300x228.png" alt="" width="300" height="228" /></a></p>
<p>As you can see, Amazon sells Kindle edition for higher price than a paperback. This book of course isn&#8217;t the only example for this ridiculous pricing method, and if one browses the Kindle store he will surely find more.</p>
<p>This really upsets me, as there is no honest reason to price an electronic edition higher than a real dead-tree paper edition. In both cases, the author and the publisher get their royalities and share of the profits. But the Kindle editions doesn&#8217;t have many related expenses, like storage, transportation (from the publisher to Amazon), and above all printing costs.</p>
<p>I don&#8217;t know who is to blame for this absurd thing, Amazon or the publisher (or even both). But the few things I know are that this bad for everyone, the customer because he pays more and Amazon/publisher as in the long run, this encourages piracy as the customer feels he&#8217;s being unfairly treated thus he will be more willing to play an unfair game as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2011/12/30/the-annoying-ebook-vs-paperback-pricing/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Creating a Deb for an Updated Version</title>
		<link>http://www.guyrutenberg.com/2011/12/17/creating-a-deb-for-an-updated-version/</link>
		<comments>http://www.guyrutenberg.com/2011/12/17/creating-a-deb-for-an-updated-version/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 16:16:04 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=928</guid>
		<description><![CDATA[Say you&#8217;ve an existing package like gitg and you want to use the new version of gitg or even apply your own patches. You could directly make install but you will probably regret it as soon as you&#8217;ll want to upgrade/uninstall, and you want to create a better package than the one created by checkinstall. [...]]]></description>
			<content:encoded><![CDATA[<p>Say you&#8217;ve an existing package like <code>gitg</code> and you want to use the new version of <code>gitg</code> or even apply your own patches. You could directly <code>make install</code> but you will probably regret it as soon as you&#8217;ll want to upgrade/uninstall, and you want to create a better package than the one created by <a href="">checkinstall</a>. Apperantly, creating a <code>deb</code> package for a new version of already packaged <code>deb</code> isn&#8217;t complicated.</p>
<h3>Getting Started</h3>
<p>Start by pulling the sources for the already available package. I&#8217;ll by using <code>gitg</code> as an example throughout this tutorial.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ apt-get source gitg</pre></div></div>

<p>This will create a folder according to the version of the package, something like <code>gitg-0.2.4</code>. Extract the new version besides it and <code>cd</code> into its directory. The next step is to copy the <code>debian/</code> directory from the old source package the code you&#8217;ve just extracted.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ cp -R ../gitg-0.2.4/debian/ .</pre></div></div>

<h3>Dependencies</h3>
<p>There are some dependencies you&#8217;ll need:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ sudo apt-get install devscripts
$ sudo apt-get install dpkg-dev</pre></div></div>

<p>You&#8217;ll probably want to do:</p>
<pre>
$ sudo apt-get build-dep gitg
</pre>
<p>in order to make sure you&#8217;ve all the relevant build time dependencies.</p>
<h3>Update <code>debian/</code> Files</h3>
<p>The next step is to update the files under the <code>debian/</code> sub-directory.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ DEBEMAIL=&quot;Guy Rutenberg &lt;myemail@domain.com&gt;&quot; debchange --nmu</pre></div></div>

<p>This will update the <code>debian/changelog</code> and set the new version. <code>--nmu</code> will create a new &#8220;non maintainer upload&#8221; version, meaning if the current version was <code>0.2.4-0ubuntu1</code>, it will change it to <code>0.2.4-0ubuntu1.1</code>. This will make sure that there won&#8217;t be any collision between your package and an official one. If you update to a new upstream version. It might be more suitable to use something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ debchange --newversion 0.2.5+20111211.git.20391c4</pre></div></div>

<p>If necessary, update the <code>Build-Depends</code> and <code>Depends</code> sections of <code>debian/control</code>.</p>
<h3>Building the Package</h3>
<p>If your building a package directly from version control and not part of an official release, you may need to run</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ ./autogen</pre></div></div>

<p>at this point.</p>
<p>Now to the actual building:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ debuild -us -uc -i -I -B</pre></div></div>

<p><code>-us -uc</code> tells the script not to sign the <code>.dsc</code> and <code>.changes</code> files accordingly. <code>-i</code> and <code>-I</code> makes the script ignore common version control files. <code>-B</code> tells <code>debuild</code> to only create binary packages. You can also pass <code>-j</code> followed by the number of simultaneous jobs you wish to allow (e.g. <code>-j3</code>, like in <code>make</code>) which an significantly speed things up.</p>
<h3>Installing the Package</h3>
<p>The package will reside in the parent directory, for example:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">../gitg_0.2.5+20111211.git.20391c4_amd64.deb</pre></div></div>

<p>At this point you&#8217;re basically done. If you want to install the package you can use</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo debi</pre></div></div>

<p>while you&#8217;re still inside the build directory.</p>
<h3>Creating Source Packages</h3>
<p>If you want to go the extra mile and create source packages, it will make things easier for others to build their own packages based on yours.</p>
<p>You&#8217;ll need to create a an &#8220;orig&#8221; tarball</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">../gitg_0.2.5+20111211.git.20391c4.orig.tar.bz2</pre></div></div>

<p>that hould contain the original source-code without the debian specific patches.</p>
<p>Now you can run the <code>debuild</code> command like before but without the <code>-B</code> flag.<br />
This will create the following files:</p>
<pre lang="text">
../gitg_0.2.5+20111211.git.20391c4.debian.tar.gz<br />
../gitg_0.2.5+20111211.git.20391c4.dsc</p>
<h3>References</h3>
<ul>
<li><a href="https://help.ubuntu.com/community/UpdatingADeb">UpdatingADeb</a></li>
<li>Man pages for <code>debuild</code>, <code>dpgk-genchanges</code>, <code>dpgk-buildpackage</code>.<br />
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2011/12/17/creating-a-deb-for-an-updated-version/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using gitg without installing</title>
		<link>http://www.guyrutenberg.com/2011/12/10/using-gitg-without-installing/</link>
		<comments>http://www.guyrutenberg.com/2011/12/10/using-gitg-without-installing/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 21:54:31 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[gitg]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=922</guid>
		<description><![CDATA[I&#8217;m working on adding spell checking support to gitg. If you intend to use gitg without installing it, a little hack is necessary. You&#8217;ll need to symlink the gitg directory (the one with the source files) as ui. ln -s gitg ui ./configure /pathto/below/gitg The reason is that gitg will look for Glade UI files [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on adding spell checking support to <a href="http://git.gnome.org/browse/gitg/">gitg</a>. If you intend to use gitg without installing it, a little hack is necessary. You&#8217;ll need to symlink the <code>gitg</code> directory (the one with the source files) as <code>ui</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">ln -s gitg ui
./configure /pathto/below/gitg</pre></div></div>

<p>The reason is that <code>gitg</code> will look for Glade UI files under <code>$(datadir)/gitg/ui</code> and in gitg&#8217;s source the UI files are in the <code>gitg</code> directory and not in <code>ui</code>.</p>
<p><a href="http://www.guyrutenberg.com/wp-content/uploads/2011/12/gitg-spellchecking.png"><img src="http://www.guyrutenberg.com/wp-content/uploads/2011/12/gitg-spellchecking.png" alt="" title="gitg-spellchecking" width="525" height="410" class="aligncenter size-full wp-image-923" /></a></p>
<p>You can see above a screenshot of <code>gitg</code> with spell checking enabled. Hopefully I&#8217;ll be done with the changes soon and they will be merged to upstream quickly.</p>
<p>Update: There are couple more things to do in order to get gsettings&#8217; schemas right.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mkdir glib-2.0
ln -s ../data glib-2.0/schemas
glib-compile-schemas data/
XDG_DATA_DIRS=&quot;.:/usr/share/&quot; ./gitg/gitg</pre></div></div>

<p>For the schemas thing see <a href="http://developer.gnome.org/gio/2.31/glib-compile-schemas.html">glib-compile-schemas</a>&#8216; man page.</p>
<p>Update 2011-12-17: Jesse (gitg&#8217;s maintainer) hasn&#8217;t responded to my email regarding the new feature, so I&#8217;ve open a bug (<a href="https://bugzilla.gnome.org/show_bug.cgi?id=666406">#666406</a>) for it. If you&#8217;re willing to try the changes yourself, you can pull them from <code>git://github.com/guyru/gitg.git spellchecker</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2011/12/10/using-gitg-without-installing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GNOME_COMPILE_WARNINGS(maximum)  &#8211; Syntax Error in configure</title>
		<link>http://www.guyrutenberg.com/2011/12/10/gnome_compile_warningsmaximum-syntax-error-in-configure/</link>
		<comments>http://www.guyrutenberg.com/2011/12/10/gnome_compile_warningsmaximum-syntax-error-in-configure/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 17:23:48 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[GNOME]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=918</guid>
		<description><![CDATA[I&#8217;m still encountering migration issues from Gentoo to Ubuntu. Apperantly, Gentoo is much more user friendly than Ubuntu when it comes to compiling packages. In Gentoo you&#8217;ve got almost all the major dependencies you need. In Ubuntu, on the other hand, you need to hunt them down. It&#8217;s much easier with the main ones, as [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m still encountering migration issues from Gentoo to Ubuntu. Apperantly, Gentoo is much more user friendly than Ubuntu when it comes to compiling packages. In Gentoo you&#8217;ve got almost all the major dependencies you need. In Ubuntu, on the other hand, you need to hunt them down. It&#8217;s much easier with the main ones, as they are listed. But there are some small ones which are harder to track. I came across the following error while trying to compile <a href="http://git.gnome.org/browse/gitg/">gitg</a>, a GUI for Git, today:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">./configure: line 14447: syntax error near unexpected token `maximum'
./configure: line 14447: `GNOME_COMPILE_WARNINGS(maximum)'</pre></div></div>

<p>After not so short investigation I found out I was missing <code>gnome-common</code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo apt-get install gnome-common</pre></div></div>

<p>Why can&#8217;t be one distribution which is user-friendly like Ubuntu and in the same time developer-friendly like Gentoo?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2011/12/10/gnome_compile_warningsmaximum-syntax-error-in-configure/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.520 seconds -->
<!-- Cached page served by WP-Cache -->

