<?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 &#187; Uncategorized</title>
	<atom:link href="http://www.guyrutenberg.com/category/Uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guyrutenberg.com</link>
	<description>Keeping track of what I do</description>
	<lastBuildDate>Wed, 16 Jun 2010 19:53:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Python&#8217;s base64 Module Fails to Decode Unicode Strings</title>
		<link>http://www.guyrutenberg.com/2010/05/03/pythons-base64-module-fails-to-decode-unicode-strings/</link>
		<comments>http://www.guyrutenberg.com/2010/05/03/pythons-base64-module-fails-to-decode-unicode-strings/#comments</comments>
		<pubDate>Mon, 03 May 2010 18:18:24 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=672</guid>
		<description><![CDATA[If you&#8217;ve got a base64 string as a unicode object and you try to use Python&#8217;s base64 module with altchars set, it fails with the following error:

TypeError: character mapping must return integer, None or unicode

This is pretty unhelpful error message also occurs if you try any method that indirectly use altchars. For example:

base64.urlsafe_b64decode&#40;unicode&#40;'aass'&#41;&#41;
base64.b64decode&#40;unicode&#40;'aass'&#41;,'-_'&#41;

both fail while [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve got a <code>base64</code> string as a <code>unicode</code> object and you try to use Python&#8217;s <a href="http://docs.python.org/library/base64.html"><code>base64</code></a> module with <code>altchars</code> set, it fails with the following error:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">TypeError: character mapping must return integer, None or unicode</pre></div></div>

<p>This is pretty unhelpful error message also occurs if you try any method that indirectly use <code>altchars</code>. For example:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #dc143c;">base64</span>.<span style="color: black;">urlsafe_b64decode</span><span style="color: black;">&#40;</span><span style="color: #008000;">unicode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'aass'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
<span style="color: #dc143c;">base64</span>.<span style="color: black;">b64decode</span><span style="color: black;">&#40;</span><span style="color: #008000;">unicode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'aass'</span><span style="color: black;">&#41;</span>,<span style="color: #483d8b;">'-_'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>both fail while the following works:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #dc143c;">base64</span>.<span style="color: black;">urlsafe_b64decode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'aass'</span><span style="color: black;">&#41;</span>
<span style="color: #dc143c;">base64</span>.<span style="color: black;">b64decode</span><span style="color: black;">&#40;</span><span style="color: #008000;">unicode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'aass'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>While it&#8217;s not complicated to fix it (just convert any <code>unicode</code> string to <code>ascii</code> string), it&#8217;s still annoying.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2010/05/03/pythons-base64-module-fails-to-decode-unicode-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;CC Yourself&#8221; and Spam</title>
		<link>http://www.guyrutenberg.com/2010/02/09/cc-yourself-and-spam/</link>
		<comments>http://www.guyrutenberg.com/2010/02/09/cc-yourself-and-spam/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:27:33 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Spam]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=624</guid>
		<description><![CDATA[Every good web programmer will note that the following contact form markup is probably flawed

&#60;form&#62;
...
    &#60;input type=&#34;hidden&#34; name=&#34;to&#34; value=&#34;support@example.com&#34; /&#62;
...
&#60;/form&#62;

as it is likely that if the value of the &#8220;to&#8221; field changes the message will be sent to the modified address. The problem with this kind of functionality is that it allows [...]]]></description>
			<content:encoded><![CDATA[<p>Every good web programmer will note that the following contact form markup is probably flawed</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;form&gt;
...
    &lt;input type=&quot;hidden&quot; name=&quot;to&quot; value=&quot;support@example.com&quot; /&gt;
...
&lt;/form&gt;</pre></div></div>

<p>as it is likely that if the value of the &#8220;to&#8221; field changes the message will be sent to the modified address. The problem with this kind of functionality is that it allows a malicious user to send emails from your mail server. More specifically,  it can allow spammers to user your benign server t send their spam (and as a side effect you might be flagged as a spammer yourself).</p>
<p>As this case is pretty obvious one doesn&#8217;t see many real-life uses of it anymore (but careless programmers used it more often n the past until they learned better). However one can achieve similar goals (spam-wise) by utilizing a common feature in contact forms: the &#8220;CC yourself&#8221; checkbox.<br />
<a href="http://www.guyrutenberg.com/wp-content/uploads/2010/02/contact_form.png"><img src="http://www.guyrutenberg.com/wp-content/uploads/2010/02/contact_form.png" alt="" title="CC Yourself" width="425" height="320" class="aligncenter size-full wp-image-632" /></a><br />
<span id="more-624"></span><br />
&#8220;CC yourself&#8221;  is a convention used by some people when mailing, to verify that the email was indeed sent. It had found a place in many contact forms, as people wanted a way to make sure the form indeed works. But contact forms (as well as some mail servers) don&#8217;t verify that the email provided as the &#8220;from&#8221; is indeed owned by whoever fills the form. Combine that with the fact that many contact forms don&#8217;t employ CAPTCHAs (to make the form simpler to use), and you&#8217;ll get a situation much like the one discussed above.</p>
<p>In the first case there was a usability advantage to the programmer (who could easily re-use the form&#8217;s backend for other forms), which can be easily sacrificed for enhanced security. This time it&#8217;s worse as this is a usability feature for the user, which many people believe to be very convinient in contact forms.</p>
<p>I think there are several solutions possible:</p>
<ol>
<li>Adding CAPTCHA to the form. This will make life for the spammers harder, but it also hurt the users by raising the bar for filling out the form. Also, nowadays, it getting harder and harder to find a strong yet easy for humans CAPTCHA.</li>
<li>Removing the &#8220;CC yourself&#8221; feature. this hurts the usability of the contact form.</li>
<li>Seperating verified users and unverified. Keeping the feature for registered users, but at the same time, removing it or adding CAPTCHA for unverified users. This seems like a good trade-off, but it requires more work and registration is not applicable for all websites.</li>
</ol>
<p>In my opinion none of the solutions is perfect. It seems that once again spammers hurt the user experience for everybody else in order to fill our inboxes with unsolicited email.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2010/02/09/cc-yourself-and-spam/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Over Looking the Simple Solution</title>
		<link>http://www.guyrutenberg.com/2009/08/01/over-looking-the-simple-solution/</link>
		<comments>http://www.guyrutenberg.com/2009/08/01/over-looking-the-simple-solution/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 10:48:14 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[reStructured Text]]></category>
		<category><![CDATA[TiddlyWiki]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=414</guid>
		<description><![CDATA[Few days ago I&#8217;ve decided to start logging my rowing sessions. I disliked the idea of keeping the log on paper, so I&#8217;ve looked into a computerized solution. I ruled out Concept2&#8217;s online log book, because I wanted something private which wouldn&#8217;t require me to register on yet another website (and sometimes internet access at [...]]]></description>
			<content:encoded><![CDATA[<p>Few days ago I&#8217;ve decided to start logging my rowing sessions. I disliked the idea of keeping the log on paper, so I&#8217;ve looked into a computerized solution. I ruled out Concept2&#8217;s online log book, because I wanted something private which wouldn&#8217;t require me to register on yet another website (and sometimes internet access at my <a href="http://www.rowclub.org">rowing club</a> is broken). Soon I&#8217;ve decided to manage the log using <a href="http://www.tiddlywiki.com">TiddlyWiki</a>, a client-side html+js wiki, which <a href="http://www.guyrutenberg.com/2009/03/28/rtl-tiddlers-in-tiddlywiki/">I wrote about in the past</a>. It some nice features:<br />
1. It fits in a single self contained file that is perfect to put on a usb-stick.<br />
2. It has built-in search features.<br />
3. It allows great flexibility in how to log my sessions &#8211; no predefined format which I need to struggle to fit my sessions into.</p>
<p>The TiddlyWiki solution seemed great, and I&#8217;ve started using it. But as the title says, I merely looked over much simpler, yet as powerful, solution &#8211; a simple text file. Porting my rowing log to a simple, old-fashioned, text file provided me all the relevant features of TiddlyWiki, such as search, flexibility and working from usb-stick, while using less space and editable using a basic text-editor (or the powerful <code>vim</code>). Using <a href="http://docutils.sourceforge.net/rst.html">reStructured Text</a>, I got a nice readable journal that can be later processed into even nicer looking html files.</p>
<p>We all want to believe that we know to match the right tool for a task. But maybe, because we tend to adopt newer technologies and utilities all the time (because for a lot of tasks they do provide better tools), we end up over looking simpler, &#8220;old-fashioned&#8221;, solutions. If I take a moment now to look around, I can come up with several other places where new stuff is used instead of simpler solutions. Take a look around you, and I&#8217;m sure that you will be able to find some too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2009/08/01/over-looking-the-simple-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing Numbering Direction for Hebrew Text in LyX</title>
		<link>http://www.guyrutenberg.com/2009/01/14/fixing-numbering-direction-for-hebrew-text-in-lyx/</link>
		<comments>http://www.guyrutenberg.com/2009/01/14/fixing-numbering-direction-for-hebrew-text-in-lyx/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 07:57:11 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Hebrew]]></category>
		<category><![CDATA[LyX]]></category>
		<category><![CDATA[RTL]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=242</guid>
		<description><![CDATA[On Monday, I&#8217;ve submitted a patch to the LyX developers mailing list with a fix for the numbering direction in Hebrew text. In Hebrew text the dot appeared before the numbering symbol instead of after it as it should.

This behaviour has been this way for years (at least as long as I can remember).

My first [...]]]></description>
			<content:encoded><![CDATA[<p>On Monday, I&#8217;ve submitted a patch to the LyX developers mailing list with a fix for the numbering direction in Hebrew text. In Hebrew text the dot appeared before the numbering symbol instead of after it as it should.<br />
<img src="http://www.guyrutenberg.com/wp-content/uploads/2009/01/before-fix.png" alt="before-fix" title="before-fix" width="403" height="121" class="aligncenter size-full wp-image-243" /><br />
This behaviour has been this way for years (at least as long as I can remember).<br />
<span id="more-242"></span><br />
My first solution was a patch against the actual LyX code, but developers in the mailing list suggested the issue could be solved within the <code>po</code> file for Hebrew (<code>he.po</code>), as the po files are loaded for each paragraph depending on its language.</p>
<p>So I wrote a patch for the <code>he.po</code> file that fixes the problem.</p>

<div class="wp_syntax"><div class="code"><pre class="diff" style="font-family:monospace;">Index: he.po
===================================================================
<span style="color: #888822;">--- he.po	<span style="">&#40;</span>revision <span style="">28095</span><span style="">&#41;</span></span>
<span style="color: #888822;">+++ he.po	<span style="">&#40;</span>working copy<span style="">&#41;</span></span>
<span style="color: #440088;">@@ -<span style="">15050</span>,<span style="">15</span> +<span style="">15050</span>,<span style="">15</span> @@</span>
&nbsp;
 #: src/Buffer.cpp:<span style="">2902</span>
 msgid &quot;\\arabic<span style="">&#123;</span>enumi<span style="">&#125;</span>.&quot;
<span style="color: #991111;">-msgstr &quot;\\arabic<span style="">&#123;</span>enumi<span style="">&#125;</span>.&quot;</span>
<span style="color: #00b000;">+msgstr &quot;.\\arabic<span style="">&#123;</span>enumi<span style="">&#125;</span>&quot;</span>
&nbsp;
 #: src/Buffer.cpp:<span style="">2908</span>
 msgid &quot;\\roman<span style="">&#123;</span>enumiii<span style="">&#125;</span>.&quot;
<span style="color: #991111;">-msgstr &quot;\\roman<span style="">&#123;</span>enumiii<span style="">&#125;</span>.&quot;</span>
<span style="color: #00b000;">+msgstr &quot;.\\roman<span style="">&#123;</span>enumiii<span style="">&#125;</span>&quot;</span>
&nbsp;
 #: src/Buffer.cpp:<span style="">2911</span>
 msgid &quot;\\Alph<span style="">&#123;</span>enumiv<span style="">&#125;</span>.&quot;
<span style="color: #991111;">-msgstr &quot;\\Alph<span style="">&#123;</span>enumiv<span style="">&#125;</span>.&quot;</span>
<span style="color: #00b000;">+msgstr &quot;.\\Alph<span style="">&#123;</span>enumiv<span style="">&#125;</span>&quot;</span>
&nbsp;
 #: src/Buffer.cpp:<span style="">2928</span> src/insets/InsetCaption.cpp:<span style="">293</span>
 msgid &quot;Senseless!!! &quot;</pre></div></div>

<p>While this patch is against the SVN trunk (LyX 2.0), it could also be applied manually to older LyX versions.<br />
After yo apply the patch you should do the following (I assume that you are in the root of the LyX source tree):</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">cd po/
make he.gmo
cd ../
make install</pre></div></div>

<p>Now restart LyX and you will see the numbering appear as it should.<br />
<img src="http://www.guyrutenberg.com/wp-content/uploads/2009/01/after-fix.png" alt="after-fix" title="after-fix" width="426" height="108" class="aligncenter size-full wp-image-245" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2009/01/14/fixing-numbering-direction-for-hebrew-text-in-lyx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Start Trac on Startup &#8211; Init.d Script for tracd</title>
		<link>http://www.guyrutenberg.com/2008/06/04/start-trac-on-startup-initd-script-for-tracd/</link>
		<comments>http://www.guyrutenberg.com/2008/06/04/start-trac-on-startup-initd-script-for-tracd/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 07:12:30 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Trac]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=59</guid>
		<description><![CDATA[As part of a server move, I went on to reinstall Trac. I&#8217;ve tried to install it as FastCGI but I failed to configure the clean URLs properly. I got the clean URLs to work if the user access them, but Trac insisted on addeing trac.fcgi to the beginning of every link it generated. So [...]]]></description>
			<content:encoded><![CDATA[<p>As part of a server move, I went on to reinstall Trac. I&#8217;ve tried to install it as FastCGI but I failed to configure the clean URLs properly. I got the clean URLs to work if the user access them, but Trac insisted on addeing <code>trac.fcgi</code> to the beginning of every link it generated. So I&#8217;ve decided to use the Trac standalone server, <code>tracd</code>.</p>
<p>The next problem I faced was how to start the Trac automatically upon startup. The solution was to use an <code>init.d</code> script for stating Trac. After some searching, I didn&#8217;t find an <code>init.d</code> script for <code>tracd</code> that were satisfactory (mostly poorly written). So I went on an wrote my own <code>init.d</code> script for <code>tracd</code>.<br />
<span id="more-59"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;">### BEGIN INIT INFO</span>
<span style="color: #666666; font-style: italic;"># Provides:          tracd</span>
<span style="color: #666666; font-style: italic;"># Required-Start:    networking</span>
<span style="color: #666666; font-style: italic;"># Required-Stop:     networking</span>
<span style="color: #666666; font-style: italic;"># Default-Start:     2 3 4 5</span>
<span style="color: #666666; font-style: italic;"># Default-Stop:      0 1 6</span>
<span style="color: #666666; font-style: italic;"># Short-Description: Start the tracd standalone Trac web server.</span>
<span style="color: #666666; font-style: italic;">### END INIT INFO</span>
<span style="color: #666666; font-style: italic;"># (C) 2008 Guy Rutenberg &lt;http://www.guyrutenberg.com&gt;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Options you should probably change ##</span>
<span style="color: #007800;">HOSTNAME</span>=127.0.0.1 <span style="color: #666666; font-style: italic;"># to which hostname should we listen</span>
<span style="color: #666666; font-style: italic;"># If you only want to serve one project keep this variable</span>
<span style="color: #666666; font-style: italic;"># empty and set the PROJECT_ENV variable </span>
<span style="color: #007800;">ENV_PARENT_DIR</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>guyru<span style="color: #000000; font-weight: bold;">/</span>trac.guyrutenberg.com
<span style="color: #007800;">PROJECT_ENV</span>=
<span style="color: #007800;">PORT</span>=<span style="color: #000000;">9090</span>
<span style="color: #666666; font-style: italic;"># add any additional options (such as authentication) here. If you only have one</span>
<span style="color: #666666; font-style: italic;"># project you should probably add -s here</span>
<span style="color: #007800;">ADDITIONAL_OPTS</span>=
&nbsp;
<span style="color: #666666; font-style: italic;">## Options you should probably not change ##</span>
<span style="color: #007800;">DAEMON</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>tracd
<span style="color: #007800;">NAME</span>=tracd
<span style="color: #007800;">DESC</span>=<span style="color: #ff0000;">&quot;web server&quot;</span>
<span style="color: #007800;">PIDFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NAME</span>.pid
<span style="color: #007800;">SCRIPTNAME</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NAME</span>
<span style="color: #007800;">SSD</span>=<span style="color: #ff0000;">&quot;/sbin/start-stop-daemon&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-x</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-e</span>
&nbsp;
. <span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>lsb<span style="color: #000000; font-weight: bold;">/</span>init-functions
&nbsp;
<span style="color: #007800;">DAEMON_OPTS</span>=<span style="color: #ff0000;">&quot;--daemonize --pidfile=<span style="color: #007800;">$PIDFILE</span> --port=<span style="color: #007800;">$PORT</span> --hostname=<span style="color: #007800;">$HOSTNAME</span> <span style="color: #007800;">$ADDITIONAL_OPTS</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;">$ENV_PARENT_DIR</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #007800;">DAEMON_OPTS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$DAEMON_OPTS</span> --env-parent-dir=<span style="color: #007800;">$ENV_PARENT_DIR</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #007800;">DAEMON_OPTS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$DAEMON_OPTS</span> <span style="color: #007800;">$PROJECT_ENV</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
  start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
	log_daemon_msg <span style="color: #ff0000;">&quot;Starting <span style="color: #007800;">$DESC</span>&quot;</span> <span style="color: #007800;">$NAME</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #007800;">$SSD</span> <span style="color: #660033;">--start</span> --quiet\
	<span style="color: #660033;">--pidfile</span> <span style="color: #007800;">$PIDFILE</span> <span style="color: #660033;">--exec</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #660033;">--</span> <span style="color: #007800;">$DAEMON_OPTS</span> ; <span style="color: #000000; font-weight: bold;">then</span>
            log_end_msg <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">else</span>
            log_end_msg <span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #000000; font-weight: bold;">;;</span>
  stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
	log_daemon_msg <span style="color: #ff0000;">&quot;Stopping <span style="color: #007800;">$DESC</span>&quot;</span> <span style="color: #007800;">$NAME</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #007800;">$SSD</span> <span style="color: #660033;">--stop</span> <span style="color: #660033;">--retry</span> <span style="color: #000000;">30</span>\
	<span style="color: #660033;">--pidfile</span> <span style="color: #007800;">$PIDFILE</span> ; <span style="color: #000000; font-weight: bold;">then</span>
	    <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$PIDFILE</span>
	    log_end_msg <span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">else</span>
	    log_end_msg <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">;;</span>
  restart<span style="color: #000000; font-weight: bold;">|</span>force-reload<span style="color: #7a0874; font-weight: bold;">&#41;</span>
	$<span style="color: #000000;">0</span> stop
	<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-r</span>  <span style="color: #007800;">$PIDFILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">pidof</span> <span style="color: #660033;">-x</span> <span style="color: #007800;">$NAME</span> <span style="color: #000000; font-weight: bold;">|</span>\
		 <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-q</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$PIDFILE</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null<span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null ; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1</span>; <span style="color: #000000; font-weight: bold;">done</span>
	$<span style="color: #000000;">0</span> start
	<span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: <span style="color: #007800;">$SCRIPTNAME</span> {start|stop|restart|force-reload}&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p>The script begins with a configuration section. You should go over each variable and make sure its value suits you need. The first part is configuration variables you are more likely to change. It includes:</p>
<ul>
<li><code>HOSTNAME</code> &#8211; This tells <code>tracd</code> on what hostname to listen. From my experience setting it to anything other than 127.0.0.1 or localhost will cause it to operate on all available hostnames. If you use <code>tracd</code> in conjunction with <ocde>mod_proxy</code> (this is usually the case if you have Lighttpd) you would want to leave the hostname on 127.0.0.1 so the <code>tracd</code> server won't be accessed directly.</li>
<li><code>ENV_PARENT_DIR</code> - If you have multiple projects (all under then same directory) set this to the parent directory. If you only want to serve one project you should leave this empty and set the next variable.</li>
<li><code>PROJECT_ENV</code> - Set this to the project environment directory of you project if you serve only one. This variable is ignored if <code>ENV_PARENT_DIR</code> is set to anything but empty.</li>
<li><code>PORT</code> - This simply tells <code>tracd</code> on what port to listen.</li>
<li><code>ADDITIONAL_OPTS</code> - This variable allows you to pass additional parameters to the <code>tracd</code>. It's the place to add you authentication flags. If you have only a single project and would like to omit the project name in the url (e.g. something like http://trac.example.com) add the <code>-s</code> flag to this variable.</li>
</ul>
<p>The other part of the configuration allows you to easily adjust the script to your machine. It has variables for specifying the path to the <code>tracd</code> executable and the paths of other things required of the correct operation of the script. In most cases you wouldn't have to change this part.</p>
<p>Now copy the script to <code>/etc/init.d/trac</code> and adjust the configuration to your needs. To enable the script on startup you should use your distro specific tools for managing the <code>rc</code> scripts. On fedora that means you will have to do <code>chkconfig trac on</code>. On Ubuntu you should do <code>update-rc.d trac defaults</code>.</p>
<p>I hope you will find the script useful. If you have any comments or suggestions regarding the script please comment.</p>
<p>UPDATE (13/10/2008):<br />
Here is an version of the script for <a href="/wp-content/uploads/2008/10/trac.gz">download</a>.<br />
UPDATE (17/2/2009):<br />
See <a href="/2009/02/17/starting-tracd-without-root-privileges-at-startup/">Starting tracd without Root Privileges at Startup</a> for a different way to start <code>tracd</code> that doesn't require root privileges.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2008/06/04/start-trac-on-startup-initd-script-for-tracd/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Pull vs. Push MVC Architecture</title>
		<link>http://www.guyrutenberg.com/2008/04/26/pull-vs-push-mvc-architecture/</link>
		<comments>http://www.guyrutenberg.com/2008/04/26/pull-vs-push-mvc-architecture/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 23:56:02 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=30</guid>
		<description><![CDATA[I intended to write this post couple of months ago, when I worked on a pull based MVC framework for some site. Most web-developers are acquainted with the MVC architecture and almost all the major web-frameworks uses this concept, including Ruby on Rails, CakePHP, Django, Symfony and others. So what is MVC and what&#8217;s the [...]]]></description>
			<content:encoded><![CDATA[<p>I intended to write this post couple of months ago, when I worked on a pull based MVC framework for some site. Most web-developers are acquainted with the MVC architecture and almost all the major web-frameworks uses this concept, including Ruby on Rails, CakePHP, Django, Symfony and others. So what is MVC and what&#8217;s the difference between pull and push?<br />
<span id="more-30"></span></p>
<p>MVC stands for Model View Controller, and represent a way to divide the application to three main parts: Model, View Controller. The Model is responsible for database access and executing queries. The Controller&#8217;s task is to handle the business-logic of the application, it should use the Models to access the database along with user-input to construct the information or execute the action the user wishes for. The View is the part visible to the user. Data generated by the Controller part is displayed via the View part, and input that the user enters in the View is passed on to the Controller.</p>
<p>So what pull and push has to do with this? Push and pull describe the relation between the View and the Controller. According to the push model, user actions should be interpreted by the Controller which will generate the data and push it on to the View, hence the &#8220;push&#8221;. On the other hand, the pull model assumes that the user requires some kind of output (like a list items from the database). The View will access the Controller in order to get the data it needs in order to display the user the kind of output he requested. This is much like the View is &#8220;pulling&#8221; data from the Controller.</p>
<p>Today, most web-frameworks only use one of the methods above, and do not implement both &#8220;push&#8221; and &#8220;pull&#8221;. While in the first look, it may seem good enough as in both ways you can achieve the desired functionality. However, some tasks are better suited by one of them than the other.</p>
<p>For example, when a user wants to make a specific action, like sending a comment, he excepts the action will be carried out, he is less interested in the way the output will tell him that his comment was sent. The user wants to initiate a specific action, which would be mapped to a specific method in on of the controllers. This controller will then &#8220;push&#8221; the result of the action to a view which shouldn&#8217;t care who pushed the data into it. As you can see, this is clearly the place to use a &#8220;push&#8221; model, because user actions are easily translated to a specific method in the Controller part, which will &#8220;push&#8221; the output to the View.</p>
<p>The &#8220;pull&#8221; method has its strengths too. Consider a case where a user asks for a list of customers and what products they bought. The user excepts a specific kind of output. The best way to handle this would be to pass his request to a view that will utilize the different controllers (like the one that handles the customers and the one handling the shopping carts of each customer) in order to create the output the user asked for. The way this request was handled was by the view &#8220;pulling&#8221; the data from the controllers.</p>
<p>Of course one can implement each one of the examples in both methods, but trying to do so will show you that implementing it in the other method will be more complicated. We can&#8217;t ignore the fact that &#8220;push&#8221; is much better at performing actions and tasks than the &#8220;pull&#8221; is, and &#8220;pull&#8221; is superior in handling request to show some kind of data. The framework I&#8217;ve built for that site supported both kinds of MVC, allowing us, the developers, to better chose the right way to implement each feature. I would really like to see some more MVC frameworks offering both methods, as I think it can offer great flexibility to the developers. I would really like to read your comments on this matter.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2008/04/26/pull-vs-push-mvc-architecture/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Samba and Firewall Configuration</title>
		<link>http://www.guyrutenberg.com/2007/02/12/samba-and-firewall-configuration/</link>
		<comments>http://www.guyrutenberg.com/2007/02/12/samba-and-firewall-configuration/#comments</comments>
		<pubDate>Mon, 12 Feb 2007 07:34:47 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[samba]]></category>

		<guid isPermaLink="false">http://guy.sikumuna.com/2007/02/12/samba-and-firewall-configuration/</guid>
		<description><![CDATA[I&#8217;ve been using Guarddog as a GUI for iptables for some time. I&#8217;ve configured it to allow to connect to samba network shares but for some reason it won&#8217;t allowed me connect to the shares without the disabling the firewall first. The blockage happened despite the proper configuration in Guarddog. So today I decided to [...]]]></description>
			<content:encoded><![CDATA[<p class="content">I&#8217;ve been using Guarddog as a GUI for iptables for some time. I&#8217;ve configured it to allow to connect to samba network shares but for some reason it won&#8217;t allowed me connect to the shares without the disabling the firewall first. The blockage happened despite the proper configuration in Guarddog. So today I decided to look again at the problem and fix it.</p>
<p>After inspecting the output of &#8216;dmesg&#8217; I found out that it tries to connect to 192.168.2.255 (192.168.2.* is my network), which is the broadcast address for the network. I tried enabling connection to the address and to my surprise this fixed the problem. I guess samba for some reason requires access for the broadcast for some name/address lookup of hosts in the network.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2007/02/12/samba-and-firewall-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.759 seconds -->
