<?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>Life Pattern</title>
	<atom:link href="http://blog.lifepattern.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lifepattern.org</link>
	<description>There must be a better way...</description>
	<lastBuildDate>Tue, 16 Apr 2013 17:00:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>parted command line rant</title>
		<link>http://blog.lifepattern.org/2013/04/16/parted-command-line-rant/</link>
		<comments>http://blog.lifepattern.org/2013/04/16/parted-command-line-rant/#comments</comments>
		<pubDate>Tue, 16 Apr 2013 17:00:21 +0000</pubDate>
		<dc:creator>zimage</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://blog.lifepattern.org/?p=137</guid>
		<description><![CDATA[Long time pet peeve of mine: 1. parted help states, that mkpart command syntax is: # parted /dev/sdb help mkpart mkpart PART-TYPE [FS-TYPE] START END make a partition But, PART-TYPE is actually only supported for msdos and dvh partition tables. For gpt, it&#8217;s silently changed to: mkpart NAME START END There are so many examples [...]]]></description>
				<content:encoded><![CDATA[<p>Long time pet peeve of mine:</p>
<p>1. parted help states, that mkpart command syntax is:<br />
<code><br />
 # parted /dev/sdb help mkpart<br />
  mkpart PART-TYPE [FS-TYPE] START END     make a partition<br />
</code><br />
But, PART-TYPE is actually only supported for msdos and dvh partition tables. For gpt, it&#8217;s silently changed to:<br />
<code><br />
 mkpart NAME START END<br />
</code><br />
There are so many examples around the internet, where people keep typing:<br />
<code><br />
 mkpart primary ext4 1024kb 2tb<br />
</code><br />
and they just end up with partition named &#8220;primary&#8221; usually without even noticing.</p>
<p>2. I cannot find a way to omit partition name from command line. From parted interactive mode one can just hit Enter when prompted for partition name:<br />
<code><br />
 (parted) mkpart<br />
 Partition name?  []?<br />
 File system type?  [ext2]?<br />
</code><br />
but apparently I can&#8217;t find a way to skip it in script mode:<br />
<code><br />
 # parted /dev/sdb mkpart "" 0% 300G<br />
 End? ^C<br />
</code></p>
<p>Rant done <img src='http://blog.lifepattern.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lifepattern.org/2013/04/16/parted-command-line-rant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>workrave tuning</title>
		<link>http://blog.lifepattern.org/2013/02/20/workrave-tuning/</link>
		<comments>http://blog.lifepattern.org/2013/02/20/workrave-tuning/#comments</comments>
		<pubDate>Wed, 20 Feb 2013 09:51:14 +0000</pubDate>
		<dc:creator>zimage</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://blog.lifepattern.org/?p=131</guid>
		<description><![CDATA[I’m using workrave to remind me to take breaks from the computer. It is a program that assists in the recovery and prevention of Repetitive Strain Injury (RSI). The program frequently alerts you to take micro-pauses, rest breaks etc., which in my case is a bit too frequent. I do not deal with RSI — [...]]]></description>
				<content:encoded><![CDATA[<p>I’m using <a href="http://workrave.org/">workrave</a> to remind me to take breaks from the computer. It is a program that assists in the recovery and prevention of Repetitive Strain Injury (RSI). The program frequently alerts you to take micro-pauses, rest breaks etc., which in my case is a bit too frequent. I do not deal with RSI — I just want to avoid prolonged sitting sessions, which might be <a title="Minimal Intensity Physical Activity (Standing and Walking) of Longer Duration Improves Insulin Action and Plasma Lipids More than Shorter Periods of Moderate to Vigorous Exercise in Sedentary Subjects When Energy Expenditure Is Comparable" href="http://www.plosone.org/article/info%3Adoi%2F10.1371%2Fjournal.pone.0055542">detrimental to one&#8217;s health</a>.</p>
<p>There&#8217;s no way to configure idle detection parameters in the workrave UI, but they can be tuned by directly manipulating gsettings (or gconf for older versions). There are 3 parameters of interest (in milliseconds):</p>
<ol>
<li><strong>activity</strong> — how much time between key presses, to register activity (see bellow).</li>
<li><strong>idle</strong> — how long before activity time expires and workrave goes back into idle mode<strong>.</strong></li>
<li><strong>noise</strong> — how long before <strong>activity</strong> timer is reset.</li>
</ol>
<p>By default, single key press isn&#8217;t enough to take workrave out of idle mode — you must press at least two keys (or key + mouse) during the <strong>activity </strong> window to count. With default settings if you press single key every 10 seconds, you are still detected as idle. For example reading a web page, and pressing PgDn every 20 seconds, won&#8217;t register as activity at all. There&#8217;s &#8220;Reading&#8221; mode for this in workrave, but you must remember to turn it on/off when you suddenly go away (long phone call?) from the computer.I&#8217;ve set my workrave to <strong>activity = 0, idle = 30</strong>. This is: every key press is activity and then I&#8217;m in active mode for the following 30 seconds. Here&#8217;s how to do it:</p>
<pre class="brush:shell">$ gsettings set org.workrave.monitor activity 0
$ gsettings set org.workrave.monitor idle 30000

$ gsettings list-recursively org.workrave.monitor
org.workrave.monitor activity 0
org.workrave.monitor idle 30000
org.workrave.monitor noise 9000</pre>
<p>You must restart workrave for settings to take effect. Use gconf-editor for workrave versions < 1.10. If you are using Ubuntu, there&#8217;s 1.10 ppa: https://launchpad.net/~rob-caelers/+archive/workrave</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lifepattern.org/2013/02/20/workrave-tuning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>apache traffic by vhost: quick programming language comparison</title>
		<link>http://blog.lifepattern.org/2013/02/17/apache-traffic-by-vhost-quick-programming-language-comparison/</link>
		<comments>http://blog.lifepattern.org/2013/02/17/apache-traffic-by-vhost-quick-programming-language-comparison/#comments</comments>
		<pubDate>Sun, 17 Feb 2013 17:17:45 +0000</pubDate>
		<dc:creator>zimage</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[it]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blog.lifepattern.org/?p=115</guid>
		<description><![CDATA[500 MB access log file from apache in common log format: www.example.com 1.2.3.4 - - [16/Feb/2013:16:17:04 -0500] "GET /movies/movie-posters/t1234.jpg HTTP/1.1" 200 29670 "http://www.example.com/movies/movie-posters/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2" I want to know how much traffic each web site (virtual host) made. Let&#8217;s start with the results: Lang [...]]]></description>
				<content:encoded><![CDATA[<p>500 MB access log file from apache in common log format:<br />
<code><br />
www.example.com 1.2.3.4 - - [16/Feb/2013:16:17:04 -0500] "GET /movies/movie-posters/t1234.jpg HTTP/1.1" 200 29670 "http://www.example.com/movies/movie-posters/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2"<br />
</code><br />
I want to know how much traffic each web site (virtual host) made. Let&#8217;s start with the results:</p>
<style type="text/css"><!--
tt { 	font-family: courier; } td { 	font-family: helvetica, sans-serif; } caption { 	font-family: helvetica, sans-serif; 	font-size: 14pt; 	text-align: left; }
--></style>
<table cellspacing="0" cellpadding="3">
<tbody>
<tr>
<td align="left" valign="bottom"><b>Lang</b></td>
<td align="left" valign="bottom"><b>Method</b></td>
<td align="left" valign="bottom"><b>CPU sec</b></td>
<td align="left" valign="bottom"><b>CPU usr</b></td>
<td align="left" valign="bottom"><b>CPU sys</b></td>
<td align="left" valign="bottom"><b>% C</b></td>
<td align="left" valign="bottom"><b>% perl</b></td>
</tr>
<tr>
<td align="left" valign="bottom">C (g++ -O2)</td>
<td align="left" valign="bottom">pointer</td>
<td align="right" valign="bottom">1.28</td>
<td align="right" valign="bottom">1.04</td>
<td align="right" valign="bottom">0.23</td>
<td align="right" valign="bottom">100%</td>
<td align="right" valign="bottom">28%</td>
</tr>
<tr>
<td align="left" valign="bottom">C (clang++ -O2)</td>
<td align="left" valign="bottom">pointer</td>
<td align="right" valign="bottom">1.29</td>
<td align="right" valign="bottom">1.05</td>
<td align="right" valign="bottom">0.23</td>
<td align="right" valign="bottom">101%</td>
<td align="right" valign="bottom">28%</td>
</tr>
<tr>
<td align="left" valign="bottom">C++ (clang++ -O2)</td>
<td align="left" valign="bottom">std::string.find()</td>
<td align="right" valign="bottom">1.52</td>
<td align="right" valign="bottom">1.31</td>
<td align="right" valign="bottom">0.19</td>
<td align="right" valign="bottom">119%</td>
<td align="right" valign="bottom">34%</td>
</tr>
<tr>
<td align="left" valign="bottom">C++ (g++ -O2)</td>
<td align="left" valign="bottom">std::string.find()</td>
<td align="right" valign="bottom">1.52</td>
<td align="right" valign="bottom">1.34</td>
<td align="right" valign="bottom">0.17</td>
<td align="right" valign="bottom">119%</td>
<td align="right" valign="bottom">34%</td>
</tr>
<tr>
<td align="left" valign="bottom">C (g++ -O0)</td>
<td align="left" valign="bottom">pointer</td>
<td align="right" valign="bottom">1.97</td>
<td align="right" valign="bottom">1.69</td>
<td align="right" valign="bottom">0.26</td>
<td align="right" valign="bottom">154%</td>
<td align="right" valign="bottom">43%</td>
</tr>
<tr>
<td align="left" valign="bottom">C++ (g++ -O2)</td>
<td align="left" valign="bottom">boost regex</td>
<td align="right" valign="bottom">2.98</td>
<td align="right" valign="bottom">2.78</td>
<td align="right" valign="bottom">0.18</td>
<td align="right" valign="bottom">238%</td>
<td align="right" valign="bottom">67%</td>
</tr>
<tr>
<td align="left" valign="bottom">pypy</td>
<td align="left" valign="bottom">pointer</td>
<td align="right" valign="bottom">3.10</td>
<td align="right" valign="bottom">2.89</td>
<td align="right" valign="bottom">0.19</td>
<td align="right" valign="bottom">242%</td>
<td align="right" valign="bottom">68%</td>
</tr>
<tr>
<td align="left" valign="bottom">pypy</td>
<td align="left" valign="bottom">perl regex</td>
<td align="right" valign="bottom">3.30</td>
<td align="right" valign="bottom">3.07</td>
<td align="right" valign="bottom">0.22</td>
<td align="right" valign="bottom">257%</td>
<td align="right" valign="bottom">73%</td>
</tr>
<tr>
<td align="left" valign="bottom">pypy</td>
<td align="left" valign="bottom">str.split()</td>
<td align="right" valign="bottom">3.50</td>
<td align="right" valign="bottom">3.27</td>
<td align="right" valign="bottom">0.23</td>
<td align="right" valign="bottom">273%</td>
<td align="right" valign="bottom">77%</td>
</tr>
<tr>
<td align="left" valign="bottom">perl</td>
<td align="left" valign="bottom">perl regex</td>
<td align="right" valign="bottom">4.53</td>
<td align="right" valign="bottom">4.34</td>
<td align="right" valign="bottom">0.17</td>
<td align="right" valign="bottom">354%</td>
<td align="right" valign="bottom">100%</td>
</tr>
<tr>
<td align="left" valign="bottom">python</td>
<td align="left" valign="bottom">str.split()</td>
<td align="right" valign="bottom">4.53</td>
<td align="right" valign="bottom">4.34</td>
<td align="right" valign="bottom">0.17</td>
<td align="right" valign="bottom">354%</td>
<td align="right" valign="bottom">100%</td>
</tr>
<tr>
<td align="left" valign="bottom">python</td>
<td align="left" valign="bottom">perl regex</td>
<td align="right" valign="bottom">7.37</td>
<td align="right" valign="bottom">7.16</td>
<td align="right" valign="bottom">0.18</td>
<td align="right" valign="bottom">576%</td>
<td align="right" valign="bottom">163%</td>
</tr>
<tr>
<td align="left" valign="bottom">python</td>
<td align="left" valign="bottom">pointer</td>
<td align="right" valign="bottom">32.96</td>
<td align="right" valign="bottom">32.71</td>
<td align="right" valign="bottom">0.16</td>
<td align="right" valign="bottom">2575%</td>
<td align="right" valign="bottom">728%</td>
</tr>
</tbody>
</table>
<p>All code is listed at the bottom of the article.</p>
<p>Versions: gcc 4.7.2, clang 3.0, perl 5.14.2, python 2.7.3, pypy 1.9.0, boost regex 1.49; everything stock from Ubuntu 12.10.</p>
<p>When I say &#8220;pointer&#8221; in the case of C it&#8217;s really advancing the pointer through the string and comparing character by character. AFAIK, you can&#8217;t go any faster than that, could you? I cheated and used std::map in the C case, because I was lazy and didn&#8217;t want to implement hash map myself, or include external libraries. I went the extra mile and used the map with char* instead of string though, so I guess it&#8217;s as fast as possible.</p>
<p>Although I use the same term &#8220;pointer&#8221; with python, it&#8217;s obviously not the same thing, because it&#8217;s not simple character array as in the C case, but a python str object, which is much higher level etc., so it is expected to be very slow (25x slower than O2 optimized C). The very curious thing is, that when you run the python &#8220;pointer&#8221; variant through pypy, it is only 2.4 times slower than optimized C, which is impressive! Obviously, it has some serious drawbacks too: you have to run it specifically through pypy, or you are going to be penalized heavily if you run it through standard python, and it&#8217;s also almost as verbose as the C variant — but still, you get the benefits of not needing to compile + not having to deal with pointers and all the low level stuff.</p>
<p>One pretty decent compromise in terms of flexibility and speed seems to be C++ with boost regex. Code is quite short and convenient, while only 2.4x slower than optimized C. On the other hand pypy with perl regex is really close behind, so I may still prefer the no-need-to-compile-and-less-arcane syntax solution.</p>
<p>Some day I may try extracting some more complex stats, like grouping by hits, traffic, referrers, requests etc. with pypy vs. perl vs. C++.<del></del> I guess differences are going to be even larger.</p>
<p>&nbsp;</p>
<p>Here&#8217;s the code:</p>
<p>g++ -Wall -O0 access.c -o access-g++-O0</p>
<pre class="brush:cpp">#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;iostream&gt;
#include &lt;cstring&gt;

using namespace std;

struct cmp_str : public std::binary_function&lt;const char*, const char*, bool&gt; {
public:
	bool operator() (const char* str1, const char* str2) const
	{ return std::strcmp(str1, str2) &lt; 0; }
};

int main() {
	#define BUFSZ 8192
	char line[BUFSZ];
	char vhost[BUFSZ];
	char size[BUFSZ];
	int i, p;
	map &lt;const char*, int, cmp_str&gt; vhosts;

	while(fgets(line, BUFSZ, stdin)) {
		for (i=0; i&lt;BUFSZ &amp;&amp; line[i] != '\0' &amp;&amp; line[i] != ' '; i++) {
			vhost[i] = line[i];
		}
		vhost[i] = '\0';

		// fast fwd two '"'
		for (/* keep from prev. for */; i&lt;BUFSZ &amp;&amp; line[i] != '\0' &amp;&amp; line[i] != '"'; i++);
		for (i++; i&lt;BUFSZ &amp;&amp; line[i] != '\0' &amp;&amp; line[i] != '"'; i++);

		// fast fwd two ' '
		for (/* keep from prev. for */; i&lt;BUFSZ &amp;&amp; line[i] != '\0' &amp;&amp; line[i] != ' '; i++);
		for (i++; i&lt;BUFSZ &amp;&amp; line[i] != '\0' &amp;&amp; line[i] != ' '; i++);

		p = 0;
		for (i++; i&lt;BUFSZ &amp;&amp; line[i] != '\0' &amp;&amp; line[i] != ' '; i++) {
			size[p] = line[i];
			p++;
		}
		size[p] = '\0';

		vhosts[strdup(vhost)] += strtoul(size, NULL, 10);
	}

	cout &lt;&lt; "vhosts:" &lt;&lt; vhosts.size() &lt;&lt; endl;

	return 0;
}</pre>
<p>-</p>
<p>g++ -Wall -O2 access.cpp -o access-cpp-g++-O2</p>
<pre class="brush:cpp">#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;iostream&gt;
#include &lt;cstdlib&gt;

using namespace std;

int main() {
	string line;
	string vhost;
	string size;
	map &lt;string, size_t&gt; vhosts;
	size_t b, e;

	ios::sync_with_stdio(false);

	while (getline(cin, line)) {
		e = line.find(' ');
		vhost = line.substr(0, e);

		b = line.find('"', e+1);
		b = line.find(' ', b+1);
		b = line.find(' ', b+1);
		e = line.find(' ', b+1);
		size = line.substr(b, e);

		vhosts[vhost] += strtoul(size.c_str(), NULL, 10);
	}

	cout &lt;&lt; "vhosts:" &lt;&lt; vhosts.size() &lt;&lt; endl;

	return 0;
}</pre>
<p>-</p>
<p>g++     -Wall -O2 access-boostre.cpp -o access-boostre-g++-O2 -lboost_regex</p>
<pre class="brush:cpp">#include &lt;string&gt;
#include &lt;map&gt;
#include &lt;iostream&gt;
#include &lt;boost/regex.hpp&gt;
#include &lt;cstdlib&gt;

int main() {
	std::string line;
	std::string vhost;
	std::string size;

	boost::regex re ("^\\([^[:space:]]+\\) [^[:space:]]+ [^[:space:]]+ [^[:space:]]+ .*? \".*?\" [[:digit:]]+ \\([^[:space:]]+\\)", boost::regex::emacs);
	boost::cmatch m;
	std::string::const_iterator start, end;

	std::map &lt;std::string, size_t&gt; vhosts;

	std::ios::sync_with_stdio(false);
	while (getline(std::cin, line)) {
		start = line.begin();
		end = line.end();
		if (boost::regex_search(line.c_str(), m, re)) {
			vhost = m[1];
			size = m[2];
		} else {
			std::cout &lt;&lt; "Not found." &lt;&lt; std::endl;
		}

		vhosts[vhost] += strtoul(size.c_str(), NULL, 10);
	}

	std::cout &lt;&lt; "vhosts:" &lt;&lt; vhosts.size() &lt;&lt; std::endl;

	return 0;
}</pre>
<p>-</p>
<pre class="brush:perl">#!/usr/bin/perl
use warnings;
use strict;

my %stats;

while (&lt;STDIN&gt;) {
	/^(\S+) \S+ \S+ \S+ \[.*?\] ".*?" \d+ (\S+)/;
	$stats{$1} += $2;
}

printf "vhosts:%d\n", scalar keys %stats;</pre>
<p>-</p>
<pre class="brush:py">#!/usr/bin/pypy

import sys
import re

def f1():
        stats = {}
        prog = re.compile(r'^(\S+) \S+ \S+ \S+ \[.*?\] ".*?" \d+ (\S+)');
        for line in sys.stdin:
                m = prog.match(line)
                (vhost, size) = m.groups()

                if vhost not in stats:
                        stats[vhost] = 0
                else:
                        stats[vhost] += int(size)

        return len(stats.keys())

def f2():
	stats = {}
	for line in sys.stdin:
		vhost = line.split(" ", 1)[0]
		split = line.split('"', 2)
		size = int(split[2].split(" ", 3)[2])

		if vhost not in stats:
			stats[vhost] = 0
		else:
			stats[vhost] += size

	return len(stats.keys())

def f3():
	stats = {}
	for line in sys.stdin:
		llen = len(line)-1

		for i in range(0, llen):
			if (line[i] == ' '):
				vhost = line[0:i]
				break

		for i in range(i+1, llen):
			if (line[i] == '"'):
				break
		for i in range(i+1, llen):
			if (line[i] == '"'):
				break

		for i in range(i+1, llen):
			if (line[i] == ' '):
				break
		for i in range(i+1, llen):
			if (line[i] == ' '):
				break

		s = i
		for i in range(i+1, llen):
			if (line[i] == ' '):
				size = int(line[s:i])
				break

		if vhost not in stats:
			stats[vhost] = 0
		else:
			stats[vhost] += size

	return len(stats.keys())

if len(sys.argv) &lt; 2:
	print "Usage: &lt;fN&gt;\n"
	exit(1)

stats = locals()[sys.argv[1]]()
print "vhosts:%d" % (stats)</pre>
<p>-</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lifepattern.org/2013/02/17/apache-traffic-by-vhost-quick-programming-language-comparison/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My 2012 foray into running</title>
		<link>http://blog.lifepattern.org/2013/01/02/my-2012-foray-into-running/</link>
		<comments>http://blog.lifepattern.org/2013/01/02/my-2012-foray-into-running/#comments</comments>
		<pubDate>Wed, 02 Jan 2013 17:12:40 +0000</pubDate>
		<dc:creator>zimage</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://blog.lifepattern.org/?p=97</guid>
		<description><![CDATA[I wasn’t really into running as a child, or into sports in general for that matter. Of course I participated in some kid games that include some running occasionally, like tag, dodge ball etc. Riding a bike, swimming, moving heavy objects around &#8211; that&#8217;s more my thing, but overall I wasn&#8217;t very interested in sports [...]]]></description>
				<content:encoded><![CDATA[<p>I wasn’t really into running as a child, or into sports in general for that matter. Of course I participated in some kid games that include some running occasionally, like tag, dodge ball etc. Riding a bike, swimming, moving heavy objects around &#8211; that&#8217;s more my thing, but overall I wasn&#8217;t very interested in sports and especially the ones that require a lot of running. In the army I had to run (mandatory military service) and I was mediocre at best &#8211; not that I was trying more than the bare minimum to keep sergeant’s mouth shut.</p>
<p>So, that&#8217;s all about my running until last year. I&#8217;ve never run more than 3 km in my 35 years on earth. So, this last summer I was on a month long business trip to Boston, and I wouldn&#8217;t be able to ride my bike (<a href="http://www.goodeatsfanpage.com/humor/otherhumor/dog_cat_diary.htm">my favourite thing</a>). So, I decided I shall give running a try. Moreover, getting a new GPS/HR unit was in my plans (my old Sigma broke down) and they are quite cheaper in the US than Europe. There you have it: the measuring geek in me + the need to move. To make it more interesting I challenged some friends and we set a date for a friendly 5k run.</p>
<p>I looked around the net for some training plans and started running. I also <a href="http://app.strava.com/athletes/744869">signed with Strava</a> &#8211; it&#8217;s much more fun than Garmin Connect. Initially, I couldn&#8217;t keep my heart rate at the low rates they recommended in the training plans. It seems, despite my MTB induced fitness (hey 2012 I rode 100km around Vitosha in 6:20!), running is too different beast and requires quite a bit of specific training to get the hang of it. All was going well &#8211; I run in the Boston area in July &#038; August, then some more running back in Sofia. In October we went to Sithonia, Greece for few days and from there we drove through all of Greece and much of Italy up to Sardinia <img src='http://blog.lifepattern.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>In Sardinia initially everything was perfect running wise (and otherwise too), but then <a href="http://app.strava.com/activities/21696557">maybe I went too far too fast</a>, and my right knee started to ache a bit. Some searching through the interwebs, made me think it is a case of Iliotibial Band Syndrome (ITBS). Btw, I had somewhat similar case just before &#8220;Vitosha 100&#8243; 2012, but it was my left knee. The interesting thing about both cases is &#8211; they start to hurt some time into the exercise. The pain goes completely away the moment you stop the specific movement that &#8220;aggravates&#8221; it. For example, last year I had to ride my bike for about 45 minutes to an hour before my left knee begins to hurt. No pain whatsoever while walking. Now, this year I have to run for about 5-10 minutes before my knee begins to hurt. No pain whatsoever if I walk or if I ride my bicycle.</p>
<p>I quit running for almost 3 weeks prior to our friendly 5k run. Unfortunately I don&#8217;t have the means to test whether the underlying issue was healed &#8211; I had to run to see, and I was afraid I&#8217;d make it worse, so I restrained. My next run was the 5k itself on 28 October. I took one acetaminophen (paracetamol) 15 minutes before the run, just in case (I know it&#8217;s toxic to the liver). The pain flared up about 10 minutes into the run, but it was bearable, so I pushed through it and finished in 31 minutes. My hope was sub 30 minutes, but it didn&#8217;t work out :-/</p>
<p>November and December were the lazy months. No running at all, only very sporadic weight lifting and cycling to work here and there. I figured I&#8217;d give the knee 2 months of rest and see if it&#8217;s going to recover.</p>
<p>So, my plan is to ease into <a href="http://www.c25k.com/">C25K</a> around mid January 2012 and see how it goes. If I manage to build up without further issues till around 1 March, we&#8217;re gonna stage another friendly run around end of March or early April.</p>
<p>I&#8217;ve also decided to take more active part in MTB racing this year, so I&#8217;m slowly building my base fitness on the bike as well. It&#8217;s great fun commuting to work through the snow and slush <img src='http://blog.lifepattern.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Fingers crossed.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lifepattern.org/2013/01/02/my-2012-foray-into-running/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Safer in-place edit?</title>
		<link>http://blog.lifepattern.org/2012/04/02/safer-in-place-edit/</link>
		<comments>http://blog.lifepattern.org/2012/04/02/safer-in-place-edit/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 17:39:19 +0000</pubDate>
		<dc:creator>zimage</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://blog.lifepattern.org/?p=89</guid>
		<description><![CDATA[Sometimes I need to edit a file in batch mode. Say you have /etc/default/foo and you want to change BAR="-c5" to BAR="-c4". One of the popular methods is using sed in-place edit, like this: sed -i -e 's/BAR="-c5"/BAR="-c4"/' foo If your version of sed is antiquated and doesn&#8217;t support in-place editing you can do the [...]]]></description>
				<content:encoded><![CDATA[<p>Sometimes I need to edit a file in batch mode. Say you have <code>/etc/default/foo</code> and you want to change <code>BAR="-c5"</code> to <code>BAR="-c4"</code>. One of the popular methods is using sed in-place edit, like this:</p>
<blockquote><p><code>sed -i -e 's/BAR="-c5"/BAR="-c4"/' foo</code></p></blockquote>
<p>If your version of sed is antiquated and doesn&#8217;t support in-place editing you can do the same using perl:</p>
<blockquote><p><code>perl -i -p -e 's/BAR="-c5"/BAR="-c4"/' foo</code></p></blockquote>
<p>The problem with this approach is that if the needle doesn&#8217;t exist, sed and perl will silently skip doing the replacement. For example if upstream changes <code>BAR="-c5"</code> to <code>BAR="-c3"</code> then your sed/perl will happily and silently leave it at -c3 instead of changing to -c4 and most probably you will not notice until much later.</p>
<p>One can use patch instead, but it is somewhat clumsy to save a diff file with at least 5 lines in it, just to change one character in the input file&#8230;</p>
<p>There&#8217;s always the possibility to add some more perl code and make it:</p>
<blockquote><p><code>perl -i -pe 's/BAR="-c5"/BAR="-c4"/ and $e|=1; END{exit(!$e)}' foo</code></p></blockquote>
<p>I feel this is hackish and somewhat error prone though.</p>
<p>What&#8217;s your solution?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lifepattern.org/2012/04/02/safer-in-place-edit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Genderplot by last.fm</title>
		<link>http://blog.lifepattern.org/2010/11/14/genderplot-by-last-fm/</link>
		<comments>http://blog.lifepattern.org/2010/11/14/genderplot-by-last-fm/#comments</comments>
		<pubDate>Sun, 14 Nov 2010 21:41:37 +0000</pubDate>
		<dc:creator>zimage</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://blog.lifepattern.org/?p=82</guid>
		<description><![CDATA[]]></description>
				<content:encoded><![CDATA[<p><a href="http://blog.lifepattern.org/wp-content/uploads/2010/11/genderplot.png"><img class="aligncenter size-full wp-image-83" title="genderplot" src="http://blog.lifepattern.org/wp-content/uploads/2010/11/genderplot.png" alt="genderplot" width="600" height="514" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lifepattern.org/2010/11/14/genderplot-by-last-fm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mechanism and function of humor</title>
		<link>http://blog.lifepattern.org/2010/04/30/mechanism-and-function-of-humor/</link>
		<comments>http://blog.lifepattern.org/2010/04/30/mechanism-and-function-of-humor/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 08:36:55 +0000</pubDate>
		<dc:creator>zimage</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[human brain]]></category>
		<category><![CDATA[life pattern]]></category>

		<guid isPermaLink="false">http://blog.lifepattern.org/?p=78</guid>
		<description><![CDATA[Alastair Clarke explains: The theory is an evolutionary and cognitive explanation of how and why any individual finds anything funny. Effectively, it explains that humour occurs when the brain recognizes a pattern that surprises it, and that recognition of this sort is rewarded with the experience of the humorous response, an element of which is [...]]]></description>
				<content:encoded><![CDATA[<p>Alastair Clarke explains:</p>
<blockquote><p>The theory is an evolutionary and  cognitive explanation of how and why any individual finds anything  funny. Effectively, it explains that humour occurs when the brain  recognizes a pattern that surprises it, and that recognition of this  sort is rewarded with the experience of the humorous response, an  element of which is broadcast as laughter.</p></blockquote>
<p>The theory further  identifies the importance of pattern recognition in human evolution:</p>
<blockquote><p>An  ability to recognize patterns instantly and unconsciously has proved a  fundamental weapon in the cognitive arsenal of human beings. The  humorous reward has encouraged the development of such faculties,  leading to the unique perceptual and intellectual abilities of our  species.</p></blockquote>
<p><a href="http://www.eurekalert.org/pub_releases/2008-06/ph-maf062708.php">http://www.eurekalert.org/pub_releases/2008-06/ph-maf062708.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lifepattern.org/2010/04/30/mechanism-and-function-of-humor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TLS SNI &#8211; almost there&#8230; or not?</title>
		<link>http://blog.lifepattern.org/2009/08/14/tls-sni-almost-there-or-not/</link>
		<comments>http://blog.lifepattern.org/2009/08/14/tls-sni-almost-there-or-not/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 20:14:48 +0000</pubDate>
		<dc:creator>zimage</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[it]]></category>

		<guid isPermaLink="false">http://blog.lifepattern.org/?p=76</guid>
		<description><![CDATA[As e-commerce is gaining momentum all over the world, so is the need of e-commerce platforms and infrastructure. For 2008 US eCommerce and Online Retail sales alone projected to reach $204 billion, an increase of 17 percent over 2007. And that&#8217;s not only the big players &#8211; more and more smaller brick and mortar shops [...]]]></description>
				<content:encoded><![CDATA[<p>As e-commerce is gaining momentum all over the world, so is the need of e-commerce platforms and infrastructure. For 2008 US eCommerce and Online Retail sales alone projected to reach $204 billion, an increase of 17 percent over 2007. And that&#8217;s not only the big players &#8211; more and more smaller brick and mortar shops open their on-line versions and many individuals are also selling their products or services on-line.</p>
<p>One very important aspect is the need for secure connection between sellers and prospective buyers. That&#8217;s were SSL/TLS come into play. The TLS protocol allows applications to communicate across Internet in a way designed to prevent eavesdropping, tampering, and message forgery. TLS provides endpoint authentication and communications confidentiality by using cryptography. If we talk about web that&#8217;s the https protocol.</p>
<p>With virtual web hosting, which is the most common type of shared hosting, one web server provides many domains through the same IP address and port. The server examines each request to determine which domain is being served by looking at HTTP request headers.  Unfortunately, when the appropriate headers are received the server has already established the secure connection and cannot change to another SSL certificate.</p>
<p>So, SSL enabled virtual hosting isn&#8217;t exactly possible. Every SSL site need it&#8217;s own dedicated IP address. And there are quite a lot SSL sites out there lately, so quite a lot IP addresses are wasted.</p>
<p>An extension to TLS called Server Name Indication (SNI) addresses this issue. By sending the name of the virtual domain as part of the TLS negotiation it enables the server to &#8220;switch&#8221; to the correct virtual domain early and present the browser with correct SSL certificate.</p>
<p>The most popular web server software on the Internet, the apache web server, has had support for TLS SNI as external patch for some time (in combination with OpenSSL). It&#8217;s integrated since version 2.12 and recently even entered the Debian testing repository.</p>
<p>All major browsers have TLS SNI support as well, so we are almost there. Current versions of Firefox, Internet Explorer, Opera, Google Chrome, Safari do support TLS SNI. Or&#8230; wait&#8230; Internet Explorer for Windows XP doesn&#8217;t support it? Yeah, that&#8217;s right. Seems we are out of luck, because despite Microsoft releasing Vista and Windows 7, the now eight years old Windows XP is still the most popular desktop operating system on the planet.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lifepattern.org/2009/08/14/tls-sni-almost-there-or-not/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Healthy Mind in a Healthy Body</title>
		<link>http://blog.lifepattern.org/2009/07/12/a-healthy-mind-in-a-healthy-body/</link>
		<comments>http://blog.lifepattern.org/2009/07/12/a-healthy-mind-in-a-healthy-body/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 15:32:28 +0000</pubDate>
		<dc:creator>zimage</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[4/4]]></category>
		<category><![CDATA[nutrition]]></category>
		<category><![CDATA[sports]]></category>
		<category><![CDATA[weight management]]></category>

		<guid isPermaLink="false">http://blog.lifepattern.org/?p=60</guid>
		<description><![CDATA[Sit mens sana in corpore sano./ One often overlooked asset that you badly need in order to be productive (or sometimes just to be) is your body. If you get ill or die, your performance may drop dramatically. Maybe one of the reasons so many people neglect their health is because it takes quite a [...]]]></description>
				<content:encoded><![CDATA[<p><em>Sit mens sana in corpore sano.</em>/
<p>One often overlooked asset that you badly need in order to be productive (or sometimes just to be) is your body. If you get ill or die, your performance may drop dramatically.</p>
<p>Maybe one of the reasons so many people neglect their health is because it takes quite a long time to collect enough damage and notice that something is wrong. One can lead a sedentary life, eat too much bad food or overeat, smoke cigarettes, and nothing bad happens overnight. Now, imagine that you are 20 years old and in rather good shape. Add 15 more years and the very next day your teeth and skin are bad, you can’t breath after climbing the stairs up to the 3rd floor, and you find it difficult to bend and tie your shoe laces. I’m sure anyone would panic in this situation. Usually, this happens very gradually. It would take, let say, ten or twenty years and every day you lose just a tiny bit from your health.</p>
<p>The care for your health is definitely a Q2 activity. It is important, but it doesn’t seem urgent.</p>
<p>With reference to evolution, humans need to move a lot. It’s not natural to be sedentary for long periods of time. Frequent and regular physical exercise boosts the immune system, and helps prevent diseases such as heart disease, cardiovascular disease, high blood pressure, diabetes, and obesity. It also improves mental health and helps prevent depression and insomnia. Exercise has been shown to improve cognitive functioning.</p>
<p>At the same time, excessive body weight is associated with various cardiovascular diseases, diabetes, obstructive sleep apnea, certain types of cancer, and osteoarthritis. As a result, it reduces life expectancy.</p>
<p>It is not only the matter of life expectancy that is at stake here but also the quality of life. It feels great to have your full range of motion, to be able to climb a flight of stairs, or to run to catch the bus with ease. These are some of the things that most of us were able to do at some time in our lives. Personally, I’ve found that it’s so much easier to learn to ski, to ice skate, or to discover a new skill once you are in good shape. Being physically fit also allows me to enjoy some outdoor sports like mountain biking for example. Some people may think that the flexibility and the joy of movement and sports is a childhood hallmark, but that’s not true. Sports are not only for professionals either.</p>
<p>If nutrition and physical activity have profound effects on human health, then, why are they so often overlooked? I mean, what is more important that you and your health?</p>
<p>Now, go and put some physical activity on your calendar. Thirty minutes of brisk walking, 5 days a week is a good start. You can also go to work on foot or by riding a bicycle. There are lots of physical activities that you can do aside from what I have already mentioned. <img src='http://blog.lifepattern.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  I’ll cover some of my workouts and results in a future post so stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lifepattern.org/2009/07/12/a-healthy-mind-in-a-healthy-body/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Attack vectors deja vu</title>
		<link>http://blog.lifepattern.org/2009/05/11/attack-vectors-deja-vu/</link>
		<comments>http://blog.lifepattern.org/2009/05/11/attack-vectors-deja-vu/#comments</comments>
		<pubDate>Mon, 11 May 2009 07:01:37 +0000</pubDate>
		<dc:creator>zimage</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[exploit]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[vulnerability]]></category>

		<guid isPermaLink="false">http://blog.lifepattern.org/?p=64</guid>
		<description><![CDATA[I have to keep an eye on the IT security news. You know, “security is a process not product”. Just recently, Linux kernel vulnerability CVE-2009-1337 caught my attention. This even has l33t in its name The more interesting part is, of course, not the CVE number but the attack vector used in a recent exploit. [...]]]></description>
				<content:encoded><![CDATA[<p>I have to keep an eye on the IT security news.  You know, “security is a process not product”. Just recently, Linux kernel vulnerability <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-1337">CVE-2009-1337</a> caught my attention. This even has l33t in its name <img src='http://blog.lifepattern.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  The more interesting part is, of course, not the CVE number but the attack vector used in a recent <a href="http://downloads.securityfocus.com/vulnerabilities/exploits/34405.sh">exploit</a>.  Basically, a core is dumped to the logrotate.d directory.  After this, logrotate executes the malicious code included in this dump since it uses rather naive parsing to find instructions in its configuration files.</p>
<p>Inevitably, this reminded me of a very similar situation from few years ago.  In 2006, <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-2451">CVE-2006-2451</a>, which is another kernel vulnerability, allowed core to be dumped in a directory that the attacker isn’t allowed to write to. A <a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=378153">weakness in cron.d</a> parsing similar to that in recent versions of logrotate was used as attack vector.</p>
<p>Just a few weeks ago, I had another deja vu. There’s a flaw in udev versions before 1.4.1 that allows local users to gain root privileges by not checking whether a NETLINK message originates from kernel (<a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-1185">CVE-2009-1185</a>). It took me some time to remember why this sounded so familiar since the older case is from 2003.  Back then, the zebra routing suite failed to check the NETLINK message originators (<a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-0858">CVE-2003-0858</a>).</p>
<p>Oh well, to err is human, don’t you think?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lifepattern.org/2009/05/11/attack-vectors-deja-vu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
