<?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>Fellinghaug Blog</title>
	<atom:link href="http://asbjorn.fellinghaug.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://asbjorn.fellinghaug.com/blog</link>
	<description>&#62;&#62;&#62; from fellinghaug import asbjorn; asbjorn.play()</description>
	<lastBuildDate>Thu, 19 Nov 2009 21:22:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating Python extensions in C</title>
		<link>http://asbjorn.fellinghaug.com/blog/2009/11/creating-python-extensions-in-c/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2009/11/creating-python-extensions-in-c/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 21:22:01 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[C extension]]></category>
		<category><![CDATA[fortran]]></category>
		<category><![CDATA[HPC]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=210</guid>
		<description><![CDATA[Hi there!
In my current work I&#8217;m working on optimizing some parallel software, and basically tries to make programs run faster. Within this work there are focus areas such as I/O and memory utilization, which are key areas when trying to optimize software. Generally when people think of highly optimized software, they think of C/C++ and [...]]]></description>
			<content:encoded><![CDATA[<p>Hi there!</p>
<p>In my current work I&#8217;m working on optimizing some parallel software, and basically tries to make programs run faster. Within this work there are focus areas such as I/O and memory utilization, which are key areas when trying to optimize software. Generally when people think of highly optimized software, they think of C/C++ and possible assembly.</p>
<p>Python is very simple in its syntax, and its speed is not at all bad. From a HPC (<em>High Performance Computing</em>) perspective Python may not look that interesting, but combining Python&#8217;s simplicity with C&#8217;s speed, you&#8217;ll get the best from both worlds.</p>
<p>Since many of the core modules, and Python itself is written in C, it is possible to further extend Python in C. Even the official Python documentation (<a title="Python official documentation" href="http://docs.python.org">http://docs.python.org</a>) have a whole section covering the Python C API. By downloading the Python development files (and of course the GNU compiler; <em>apt-get install build-essential</em>), then you&#8217;re ready to create C extensions for Python. The overall goal for your C extensions should be to only do the very compute intensive tasks, and keep the other stuff in Python. A key observation here is to identify which parts of your program you may need to create a C extension for &#8211; and for this to be found you can use a profiler. Included in Python (<em>&#8220;batteries included&#8221;</em>) there are a couple of profilers:</p>
<ul>
<li>import profile</li>
<li>import cProfile</li>
<li>import hotshot</li>
</ul>
<p>I will not cover  these python profilers here, but rather inspire you to try them out. They might save you a lot of work and give you valuable knowledge of your software. Do some reading of python profiling <a title="Python profiling" href="http://docs.python.org/library/profile.html">here</a>.</p>
<p>Now lets create a very simple (and extremely stupid) python extension in C. We want it to contain two methods:</p>
<ol>
<li>a method which allows you to run shell commands by passing a string</li>
<li>a method which returns some text based on your input</li>
</ol>
<p>To create this extension we follow these steps: a) decide the python module name b) create the C file with the same name as the python module name c) start programming C! Let&#8217;s name our module for &#8220;cool&#8221; (not the best name)..</p>
<p>This is our <strong>cool.c</strong> file:</p>

<div class="wp_syntax"><div class="code"><pre class="c c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdlib.h&gt;</span>
<span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;Python.h&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*
 * Takes a string argument, which is the shell command, and runs it.
 * Returns the return code of the system(cmd) call.
 * */</span>
<span style="color: #993333;">static</span> PyObject <span style="color: #339933;">*</span>cool_command<span style="color: #009900;">&#40;</span>PyObject <span style="color: #339933;">*</span>self<span style="color: #339933;">,</span> PyObject <span style="color: #339933;">*</span>args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>cmd;
    <span style="color: #993333;">int</span> retval;
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>PyArg_ParseTuple<span style="color: #009900;">&#40;</span>args<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;s&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>cmd<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">NULL</span>;
&nbsp;
    retval <span style="color: #339933;">=</span> system<span style="color: #009900;">&#40;</span> cmd <span style="color: #009900;">&#41;</span>;
    <span style="color: #b1b100;">return</span> Py_BuildValue<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;i&quot;</span><span style="color: #339933;">,</span> retval<span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*
 * Takes a string argument, and assembles it into a new python string
 * object and returns it.
 * */</span>
<span style="color: #993333;">static</span> PyObject <span style="color: #339933;">*</span>cool_greet<span style="color: #009900;">&#40;</span>PyObject <span style="color: #339933;">*</span>self<span style="color: #339933;">,</span> PyObject <span style="color: #339933;">*</span>args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>input;
    <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>resp <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Hi there: &quot;</span>;
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>PyArg_ParseTuple<span style="color: #009900;">&#40;</span>args<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;s&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>input<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">NULL</span>;
&nbsp;
    <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>retstr <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> malloc<span style="color: #009900;">&#40;</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>strlen<span style="color: #009900;">&#40;</span>input<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span>strlen<span style="color: #009900;">&#40;</span>resp<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span> <span style="color: #009900;">&#41;</span>; <span style="color: #666666; font-style: italic;">// +1 &amp;lt;- null termination</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>retstr <span style="color: #339933;">==</span> <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">NULL</span>;
&nbsp;
    PyObject <span style="color: #339933;">*</span>retString;
&nbsp;
    strcpy<span style="color: #009900;">&#40;</span> retstr<span style="color: #339933;">,</span> resp <span style="color: #009900;">&#41;</span>;
    strcat<span style="color: #009900;">&#40;</span>retstr<span style="color: #339933;">,</span> input<span style="color: #009900;">&#41;</span>;
&nbsp;
    retString <span style="color: #339933;">=</span> Py_BuildValue<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;s&quot;</span><span style="color: #339933;">,</span> retstr<span style="color: #009900;">&#41;</span>;
    Py_INCREF<span style="color: #009900;">&#40;</span>retString<span style="color: #009900;">&#41;</span>;
    free<span style="color: #009900;">&#40;</span>retstr<span style="color: #009900;">&#41;</span>;
&nbsp;
    <span style="color: #b1b100;">return</span> retString;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* an array of PyMethodDef structure. A PyMethodDef structure is
used to describe a method of an extension type. */</span>
<span style="color: #993333;">static</span> PyMethodDef CoolMethods<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;command&quot;</span><span style="color: #339933;">,</span> cool_command<span style="color: #339933;">,</span> METH_VARARGS<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Execute a shell command.&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;greet&quot;</span><span style="color: #339933;">,</span> cool_greet<span style="color: #339933;">,</span> METH_VARARGS<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Returns a greeting to the caller.&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span><span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color:#800080;">0</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>;
&nbsp;
PyMODINIT_FUNC initcool<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span> Py_InitModule<span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">&quot;cool&quot;</span><span style="color: #339933;">,</span> CoolMethods <span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This C extension file is built up with the following key sections:</p>
<ul>
<li>Inclusion of headers.</li>
<li>static PyObject methods which constitutes the visible python functions of our extension module.</li>
<li>An array of PyMethodDef structures. A PyMethodDef structure describes a method of an extension type.</li>
<li>A initialization method which is named &#8220;<em>init&lt;modulename&gt;</em>&#8220;. This method has the sole purpose of calling the Py_InitModule function which takes the name and the PyMethodDef array.</li>
</ul>
<p>So there you go, this is our Python extension implemented in C with the help of the Python development headers. Now we&#8217;ll have a look at our Distutils script (<em>setup.py</em>) that will assist us with the compilation and creation of the actual python module.</p>
<p>This is our <strong>setup.py</strong> file:</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">distutils</span>.<span style="color: black;">core</span> <span style="color: #ff7700;font-weight:bold;">import</span> setup, Extension
&nbsp;
module1 = Extension<span style="color: black;">&#40;</span><span style="color: #483d8b;">'cool'</span>,
        sources = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'cool.c'</span><span style="color: black;">&#93;</span> <span style="color: black;">&#41;</span>
&nbsp;
setup <span style="color: black;">&#40;</span> name = <span style="color: #483d8b;">'CoolPackage'</span>,
        version = <span style="color: #483d8b;">'0.1'</span>,
        description = <span style="color: #483d8b;">'A descriptive and informal C extension to Python'</span>,
        ext_modules = <span style="color: black;">&#91;</span>module1<span style="color: black;">&#93;</span> <span style="color: black;">&#41;</span></pre></div></div>

<p>jada..</p>
<p>This file is much self-explained. We have basically one method named &#8220;setup&#8221; which takes a bunch of arguments. These arguments is the package name, version, description and a set of <em>Extension</em> objects. These <em>Extension</em> objects describes our C extension files. By simply running this command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">python setup.py build</pre></div></div>

<p>When the compilation is done, you&#8217;ll have a build folder in the same directory as the setup.py. Go into the &#8220;<em>build/lib.linux-i686-2.6/</em>&#8220;. Then type &#8220;python&#8221; or &#8220;ipython&#8221;, and then &#8220;import cool&#8221;. Now you actually have loaded the &#8220;cool&#8221; module, and you may call &#8220;cool.greet(&#8217;Alex&#8217;)&#8221; and/or &#8220;cool.command(&#8217;ls /&#8217;)&#8221; and the actual computing happens in the C world instead of the Python world.</p>
<p>Now, keep in mind that this C extension isn&#8217;t actual doing anything useful. But, given that you have some algorithm or other problem to solve, and the time is of the essence, then utilizing the power which lays in this C extensions can give you significant time savings.</p>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2009/11/creating-python-extensions-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Discovering python&#8217;s functools.partial powers</title>
		<link>http://asbjorn.fellinghaug.com/blog/2009/11/discovering-pythons-functools-partial-powers/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2009/11/discovering-pythons-functools-partial-powers/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 13:21:15 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=283</guid>
		<description><![CDATA[Hi there.
I just recently discovered the power of the functional function named partial inside the python module &#8220;functools&#8221;. Functools provides: &#8220;Tools for working with functions and callable objects&#8221;, and comes with python v2.5 and up.
But, let&#8217;s illustrate some of the beauty with examples.

import functools
def check_balance&#40;amount, limit=0&#41;:
    if amount &#38;lt;= limit:
   [...]]]></description>
			<content:encoded><![CDATA[<p>Hi there.</p>
<p>I just recently discovered the power of the functional function named partial inside the python module &#8220;functools&#8221;. Functools provides: &#8220;Tools for working with functions and callable objects&#8221;, and comes with python v2.5 and up.</p>
<p>But, let&#8217;s illustrate some of the beauty with examples.</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> functools
<span style="color: #ff7700;font-weight:bold;">def</span> check_balance<span style="color: black;">&#40;</span>amount, limit=0<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> amount <span style="color: #66cc66;">&amp;</span>lt;= limit:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">False</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span>
positive_account_balance = functools.<span style="color: black;">partial</span><span style="color: black;">&#40;</span> check_balance, limit=<span style="color: #ff4500;">1</span> <span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># new func object to check if account is more than 0</span>
rich_dude = functools.<span style="color: black;">partial</span><span style="color: black;">&#40;</span> check_balance, limit=<span style="color: #ff4500;">1000</span> <span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># new func object to check if this person has more than 1000 in his account</span>
poor_dude = functools.<span style="color: black;">partial</span><span style="color: black;">&#40;</span> check_balance, limit=-<span style="color: #ff4500;">100</span> <span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># new func object to check if this person is poor (i.e. less than 100)</span></pre></div></div>

<p>So, let me explain some of this code. We are first defining a function named &#8220;check_balance&#8221; which takes two arguments (amount and limit). This function is very simple, as it only checks if amount is less than or equal to limit and returns a boolean value.</p>
<p>So, what really does the partial function do? It returns a new function object based on the function object passed in as the first argument, and the predefined arguments provided. In other words we construct new function objects where some or all of the arguments is given, and then call that particular function later on, thus saving us from writing the function arguments again.</p>
<p>Another example could be that you want a function to check if a username is also and administrator:</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> functools
groups = <span style="color: black;">&#123;</span><span style="color: #483d8b;">'admin'</span>: <span style="color: black;">&#91;</span><span style="color: #483d8b;">'asbjorn'</span><span style="color: black;">&#93;</span>, <span style="color: #483d8b;">'users'</span>: <span style="color: black;">&#91;</span><span style="color: #483d8b;">'asbjorn'</span>, <span style="color: #483d8b;">'lolcat'</span>, <span style="color: #483d8b;">'frank'</span><span style="color: black;">&#93;</span><span style="color: black;">&#125;</span>
is_admin = functools.<span style="color: black;">partial</span><span style="color: black;">&#40;</span> <span style="color: #ff7700;font-weight:bold;">lambda</span> <span style="color: #dc143c;">user</span>, group: <span style="color: #dc143c;">user</span> <span style="color: #ff7700;font-weight:bold;">in</span> groups.<span style="color: black;">get</span><span style="color: black;">&#40;</span>group<span style="color: black;">&#41;</span>, group=<span style="color: #483d8b;">&quot;admin&quot;</span> <span style="color: black;">&#41;</span>
is_admin<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;asbjorn&quot;</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># will return True</span></pre></div></div>

<p>This functionality makes it very simple to create detailed and specific functions based on more generic designed functions. This also makes it simpler to follow the design approach <em>Domain-driven Design (DDD)</em> and  create a <em>Domain Specific Language</em>, as its easier to create domain specific functions.</p>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2009/11/discovering-pythons-functools-partial-powers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Shiretoko 3.5.2 in Ubuntu Jaunty</title>
		<link>http://asbjorn.fellinghaug.com/blog/2009/09/using-shiretoko-3-5-2-in-ubuntu-jaunty/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2009/09/using-shiretoko-3-5-2-in-ubuntu-jaunty/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 14:49:12 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=268</guid>
		<description><![CDATA[Hi there.
Recently I installed the Shiretoko 3.5.2, which is not an official Firefox release, but more a release candidate so do speak. One major problem I discovered was that for many major websites it loses its sessions (i.e. on Facebook at least).
Now, it turns out that this is a mistake shared between this Shiretoko and [...]]]></description>
			<content:encoded><![CDATA[<p>Hi there.</p>
<p>Recently I installed the Shiretoko 3.5.2, which is not an official Firefox release, but more a release candidate so do speak. One major problem I discovered was that for many major websites it loses its sessions (i.e. on Facebook at least).</p>
<p>Now, it turns out that this is a mistake shared between this Shiretoko and Facebook, as Facebook tries to recognize the web browser used, and performs its actions based on that. When it doesn&#8217;t recognize the web browser clearly something undefined behavior happens. Well, undefined is maybe a little harsh, but at least the behavior is very strange.</p>
<p>But, I found out that if you change the settings &#8220;general.useragent.extra.firefox&#8221; in the about:config page from &#8220;Shiretoko/3.5.X&#8221; to &#8220;Firefox/3.5.X&#8221;, then your back in buisness.</p>
<p>Hope that they can finish and put a final Firefox 3.5 release into Ubuntu. Its not a good idea to wait 6 months for a new web browser release, as its the policy of the ubuntu release cycles. They should include such software releases during the 6 months period.</p>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2009/09/using-shiretoko-3-5-2-in-ubuntu-jaunty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Absolute path to running C program</title>
		<link>http://asbjorn.fellinghaug.com/blog/2009/08/absolute-path-to-running-c-program/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2009/08/absolute-path-to-running-c-program/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 21:47:09 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[general IT]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[absolute path]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[hack]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=235</guid>
		<description><![CDATA[One day I needed to make an embedded Python interpreter in a Fortran/C program aware of its path, since it should search for a predefined python source code file in the same directory from the binary is located.
Now, this introduces some issues, as the Fortran/C program can be runned in many ways:

Absolute path (/home/asbjorn/test1/main)
Standing in [...]]]></description>
			<content:encoded><![CDATA[<p>One day I needed to make an embedded Python interpreter in a Fortran/C program aware of its path, since it should search for a predefined python source code file in the same directory from the binary is located.</p>
<p>Now, this introduces some issues, as the Fortran/C program can be runned in many ways:</p>
<ol>
<li>Absolute path (/home/asbjorn/test1/main)</li>
<li>Standing in the directory and run ./main</li>
<li>Having the /home/asbjorn/test1/ in your $PATH variable (Linux/UNIX), and type &#8216;main&#8217;.</li>
</ol>
<p>Now, the simplest approach is to use the &#8220;int argc, char *argv[]&#8221; variables inside your &#8216;int main()&#8217; method. Then the &#8220;argv[0]&#8221; would contain the binary file name, including any absolute path if that what being used. But, if your application is in your $PATH variable, it wont work.</p>
<p>A &#8216;dirty&#8217; trick could be to use:</p>

<div class="wp_syntax"><div class="code"><pre class="c c" style="font-family:monospace;"><span style="color: #993333;">char</span> path<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#93;</span>;
path <span style="color: #339933;">=</span> system<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;which main&quot;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>but, its not recommended using this approach. Another very hackish and cool solution is the following:</p>

<div class="wp_syntax"><div class="code"><pre class="c c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdlib.h&gt;</span>
<span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;sys/param.h&gt;</span>
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span><span style="color: #339933;">*</span> argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   <span style="color: #993333;">char</span> path<span style="color: #009900;">&#91;</span>MAXPATHLEN<span style="color: #009900;">&#93;</span>;
   <span style="color: #993333;">int</span> length;
   length <span style="color: #339933;">=</span> readlink<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;/proc/self/exe&quot;</span><span style="color: #339933;">,</span> path<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>path<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>length<span style="color: #339933;">&lt;</span><span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      fprintf<span style="color: #009900;">&#40;</span>stderr<span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;error resolving /proc/self/exe!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span>;
      exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #009900;">&#125;</span>
   path<span style="color: #009900;">&#91;</span>length<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\0</span>'</span>;
   <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;The absolute path to this running binary is: %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> path<span style="color: #009900;">&#41;</span>;
&nbsp;
   <span style="color: #b1b100;">return</span> <span style="color:#800080;">0</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Another approach which is often used is to include some kind of configuration file that contains this path. Or, in my case, I could specify another folder which should hold my Python files. This approach would probably make more sense in the long run, as it is more flexible.</p>
<p>So, in case you find yourself in this situation, then feel free to copy-paste the code and save the day <img src='http://asbjorn.fellinghaug.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Have a good summer people!</p>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2009/08/absolute-path-to-running-c-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integrating Fortran and C</title>
		<link>http://asbjorn.fellinghaug.com/blog/2009/07/integrating-fortran-and-c/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2009/07/integrating-fortran-and-c/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 12:45:00 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[fortran]]></category>
		<category><![CDATA[integration]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=250</guid>
		<description><![CDATA[Hi there!
&#8220;Wow&#8221; you may think. Are people still using the Fortran programming language?? I know, I was shocked too. But, apparently, Fortran is very much used within large mathematical problems / scientific work, and can therefor be seen within HPC communities. As I&#8217;m currently an IT-consultant which is working within this kind of environment, I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>Hi there!</p>
<p>&#8220;Wow&#8221; you may think. Are people still using the Fortran programming language?? I know, I was shocked too. But, apparently, Fortran is very much used within large mathematical problems / scientific work, and can therefor be seen within HPC communities. As I&#8217;m currently an IT-consultant which is working within this kind of environment, I&#8217;ve got some hands-on experience with C and Fortran.</p>
<p>One of the applications I&#8217;m working on is a mix of Fortran and some C. Since I&#8217;m a software developer at heart and I have almost never ever touched Fortran, I prefer C code over Fortran. However, rewriting all the Fortran code is not an option as it is very time consuming, and that one should respect the saying &#8220;if it works, don&#8217;t change it&#8221;. But, one of my tasks is to try to optimize the code, and running the whole application through the GNU gprof tools reveals some bad code. I&#8217;m not going to dive into exactly what it was, but to solve it I wanted to use C instead of Fortran. So, then I discovered that I could simply reimplement the subroutine (basically just a function in C terms) in C and append a &#8220;_&#8221; at the end of the function name.</p>
<p>This fortran program for example calls the C function &#8220;my_c_func&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="fortran fortran" style="font-family:monospace;"><span style="color: #b1b100;">program</span> testme
    <span style="color: #000066;">implicit</span> <span style="color: #000066;">none</span>
    <span style="color: #000066;">integer</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">4</span> dx, dy, direction, i, j
    <span style="color: #666666; font-style: italic;">!real*4 dimension(:,:), allocateable :: data</span>
    <span style="color: #000066;">real</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">4</span> <span style="color: #000066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span>,<span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span>
    dx <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span>
    dy <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span>
    direction <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span>
&nbsp;
    <span style="color: #b1b100;">do</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span>, dy
      <span style="color: #b1b100;">do</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span>, dx
          <span style="color: #000066;">data</span><span style="color: #009900;">&#40;</span>i,j<span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span>j<span style="color: #009900;">&#41;</span><span style="color: #339933;">**</span><span style="color: #cc66cc;">2</span>
      <span style="color: #b1b100;">end</span> <span style="color: #b1b100;">do</span>
    <span style="color: #b1b100;">end</span> <span style="color: #b1b100;">do</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">! call our C library function</span>
    <span style="color: #b1b100;">call</span> my_func<span style="color: #009900;">&#40;</span>dx, dy, <span style="color: #000066;">data</span>, direction<span style="color: #009900;">&#41;</span>
&nbsp;
    write <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>,<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;Hello world!&quot;</span>
<span style="color: #b1b100;">end</span> <span style="color: #b1b100;">program</span> testme</pre></div></div>

<p>And then this is the C function &#8220;my_c_func&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="c c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdlib.h&gt;</span>
<span style="color: #339933;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #993333;">void</span> my_func_<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> <span style="color: #339933;">*</span>dx<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> <span style="color: #339933;">*</span>dy<span style="color: #339933;">,</span> <span style="color: #993333;">float</span> <span style="color: #339933;">*</span>data<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> <span style="color: #339933;">*</span>direction<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">int</span> i<span style="color: #339933;">,</span>j;
&nbsp;
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;You are now inside the C function.<span style="color: #000099; font-weight: bold;">\n</span>Awesome, right?<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span>;
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;dx=%d, dy=%d, direction=%d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">*</span>dx<span style="color: #339933;">,</span> <span style="color: #339933;">*</span>dy<span style="color: #339933;">,</span> <span style="color: #339933;">*</span>direction<span style="color: #009900;">&#41;</span>;
&nbsp;
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Lets go through our data matrix..<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color:#800080;">0</span>;i<span style="color: #339933;">&lt;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>dy<span style="color: #009900;">&#41;</span>;i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span><span style="color:#800080;">0</span>;j<span style="color: #339933;">&lt;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>dx<span style="color: #009900;">&#41;</span>;j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
          <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;data[%d][%d] = %.2f<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> i<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> j<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> data<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>dy<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>i<span style="color: #339933;">+</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>;
      <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Lets call the fortran file for test.f90 and the C file for c_lib.c, and lets create a <a title="Scons build system" href="http://www.scons.org">Scons</a> file instead of a Makefile to compile this example. Also, I have only tested this with the &#8220;gfortran v4.2&#8243; compiler, and gcc v4.3.3.</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
env = Environment<span style="color: black;">&#40;</span> env = <span style="color: #dc143c;">os</span>.<span style="color: black;">environ</span> <span style="color: black;">&#41;</span>
&nbsp;
env.<span style="color: black;">Program</span><span style="color: black;">&#40;</span> target = <span style="color: #483d8b;">&quot;program1&quot;</span>, source = <span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;for.f90&quot;</span>, <span style="color: #483d8b;">&quot;c_lib.c&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>And now for the grand finally. Type <strong>scons</strong>, and the compilation should run. There should now be a binary named &#8220;program1&#8243;. Run it, and have a closer look at the info.</p>
<p>So, to summarize, the only requirement for Fortran files to call C functions is that the respective C function has a underscore right after its function name. Also, before the fortran compilation, the C file containing the function needs to be compiled into a object file and be reachable.</p>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2009/07/integrating-fortran-and-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache, subversion and LDAP group authentication</title>
		<link>http://asbjorn.fellinghaug.com/blog/2009/06/apache-subversion-and-ldap-group-authentication/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2009/06/apache-subversion-and-ldap-group-authentication/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 07:30:00 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[general IT]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[authenticate]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[ldap-filter]]></category>
		<category><![CDATA[ldap-group]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=222</guid>
		<description><![CDATA[Hellu!
Lately I&#8217;ve been working on securing some web accessible resource, especially Subversion access to repositories through the Apache webserver. One aspect we found very difficult was to secure subversion access through our apache server, when we had a Active Directory server to authenticate against (I know..).
Apache have some directives such as &#8220;Require valid-user&#8221; which signals [...]]]></description>
			<content:encoded><![CDATA[<p>Hellu!</p>
<p>Lately I&#8217;ve been working on securing some web accessible resource, especially Subversion access to repositories through the Apache webserver. One aspect we found very difficult was to secure subversion access through our apache server, when we had a Active Directory server to authenticate against (I know..).</p>
<p>Apache have some directives such as &#8220;Require valid-user&#8221; which signals that a user has to be authenticated against some authentication provider. This is in most cases a standard &#8220;.htaccess&#8221; and &#8220;.htpasswd&#8221; combination which provides this. For small projects, this may be a working approach. However, in a large-scale organization where you want a dynamic handling of users and their access, then using groups to reflect the users access to resources may be a better working solution.</p>
<p>For one of our projects, we wanted all LDAP (AD) users to have read access, while members of certain groups have read and write access. We solved this with the following Apache config:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="apache apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">Location</span> /wicked_project&gt;
   DAV svn
   SVNParentPath /var/svn/wicked_project
   AuthzLDAPAuthoritative <span style="color: #0000ff;">off</span>
   <span style="color: #00007f;">AuthType</span> basic
   AuthBasicProvider ldap
   <span style="color: #00007f;">AuthName</span> <span style="color: #7f007f;">&quot;Need to authenticate here&quot;</span>
   AuthLDAPBindDN <span style="color: #7f007f;">&quot;ldap_user@domain.net&quot;</span>
   AuthLDAPBindPassword secretPassword
   AuthLDAPURL <span style="color: #7f007f;">&quot;ldap://ad.domain.net/dc=domain,dc=net?sAMAccountName?sub?(objectClass=*)&quot;</span>
&nbsp;
   &lt;Limit GET PROPFIND <span style="color: #00007f;">OPTIONS</span> CHECKOUT&gt;
      <span style="color: #00007f;">Require</span> valid-<span style="color: #00007f;">user</span>
   &lt;/Limit&gt;
   &lt;Limit REPORT MKACTIVITY PROPPATCH PUT MKCOL MOVE COPY DELETE LOCK UNLOCK MERGE&gt;
   <span style="color: #00007f;">Require</span> ldap-filter |(memberOf=CN=Staff,OU=GROUPS,DC=DOMAIN,DC=NET) \
                (memberOf=CN=Wicked_project_rw,OU=GROUPS,DC=DOMAIN,DC=NET)
   &lt;/Limit&gt;
&lt;/<span style="color: #000000; font-weight:bold;">Location</span>&gt;</pre></td></tr></table></div>

<p>Another LDAP directive which can work if you only need one group to have read and write access is the &#8220;ldap-group&#8221; directive. However, in our case we needed multiple groups, which is not supported by the &#8220;ldap-group&#8221; directive.</p>
<p>To solve this problem we used &#8220;ldap-filter&#8221; with multiple group filters inside the same filter, and divide them with the boolean OR. I don&#8217;t know if there are any more elegant ways of achieving the same result, but this solved our problems.</p>
<p>Having a second look at this &#8220;ldap-fiter&#8221; directive, I see that it have a significant strength in terms of flexibility. However, one aspect I have not considered is the performance of this approach. Without looking in-depth into the mod_ldap apache module, I can guess that for each filter inside the ldap-filter directive, it have to make a query to the LDAP (AD) server to retrieve the wanted resource. So, for each group filter inside the ldap-filter, you need a call. In our approach, we need two LDAP queries. As you now may see, the more groups to filter, the more LDAP queries, hence the performance will degrade the more complex the ldap-filter is.</p>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2009/06/apache-subversion-and-ldap-group-authentication/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Vim marks to move around in source codes</title>
		<link>http://asbjorn.fellinghaug.com/blog/2009/04/using-vim-marks-to-move-around-in-source-codes/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2009/04/using-vim-marks-to-move-around-in-source-codes/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 07:43:24 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[VIM]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[efficient]]></category>
		<category><![CDATA[mark]]></category>
		<category><![CDATA[programmer]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=224</guid>
		<description><![CDATA[Hi there.
These days is all about being efficient in your working process. Now, I find myself using Vim a lot, bot for regular text processing, e-mail, Wiki page edit (Firefox + ViewSourceWith), and Python/C/C++ programming.
I should be clear on that the usage of Vim as an IDE pretty much relies on the size of the [...]]]></description>
			<content:encoded><![CDATA[<p>Hi there.</p>
<p>These days is all about being efficient in your working process. Now, I find myself using Vim a lot, bot for regular text processing, e-mail, Wiki page edit (Firefox + ViewSourceWith), and Python/C/C++ programming.</p>
<p>I should be clear on that the usage of Vim as an IDE pretty much relies on the size of the software project. If we are making a very small software, then most often I find Vim most efficient. But, however, if the project is large, then maybe Eclipse or KDevelop is more efficient. I should also state that I keep Java programming in the Eclipse IDE.</p>
<p>So, how can you use Vim Marks to be more efficient? Well, given that you have a large source code file, and you find yourself moving a lot between some blocks of code. Then, a way of saving you for the trouble of actually holding in your keys until your at the requested position, you just jump to a previously declared mark.</p>
<div id="attachment_226" class="wp-caption alignnone" style="width: 488px"><a href="http://asbjorn.fellinghaug.com/blog/wp-content/uploads/2009/04/my_vim_2.png"><img class="size-medium wp-image-226" title="my_vim_2" src="http://asbjorn.fellinghaug.com/blog/wp-content/uploads/2009/04/my_vim_2-261x300.png" alt="Vim screenshot" width="478" height="444" /></a><p class="wp-caption-text">Vim screenshot</p></div>
<p>Now, if we were have the marker over some frequently used function/class/variable (or something), and we want to store a VIM marker there, we hit the keys:<code>ma</code>.</p>
<p>This stores a <em>marker</em> in registry <code>a</code>. So, if we&#8217;re somewhere else in our file, and want to jump back, we may type: <code>'a</code>.</p>
<p>Notice however that there is a distinction between lowercase and uppercase registry definition. If we type <code>mA</code> instead of <code>ma</code>, then we are able to jump between files (often you&#8217;re writing source code in multiple files). You may store these <em>markers</em> in registers from a-z for in-file references, and A-Z for between file references.</p>
<p>To delete your marker, type: <code>d'a</code>. If you only want to replace it with a new marker, then simply type <code>ma</code>. You may also list all known markers with:</p>
<div class="code"><code><br />
:markers</code></div>
<p>I would recommend reading this <a title="Vim marks" href="http://vim.wikia.com/wiki/Using_marks">Vim wiki page</a> regarding these Vim markes. I find them very useful, hopefully also you will.</p>
<div id="attachment_227" class="wp-caption alignnone" style="width: 466px"><a href="http://asbjorn.fellinghaug.com/blog/wp-content/uploads/2009/04/my_vim_1.png"><img class="size-medium wp-image-227" title="my_vim_1" src="http://asbjorn.fellinghaug.com/blog/wp-content/uploads/2009/04/my_vim_1-300x203.png" alt="Vim screenshot" width="456" height="307" /></a><p class="wp-caption-text">Vim screenshot</p></div>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2009/04/using-vim-marks-to-move-around-in-source-codes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python 3.1 is now released</title>
		<link>http://asbjorn.fellinghaug.com/blog/2009/03/python-31-is-now-released/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2009/03/python-31-is-now-released/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 19:19:22 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python 3000 v3.1]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=217</guid>
		<description><![CDATA[Since the very important and big release of Python v3.0 (also knowed as &#8220;Python 3000&#8243;) in december, there has been some minor bugfixes and further improvements. Now, in Python v3.1, we may get to feel these bugfixes and enhancements.
Of important changes we may highlight such as:

The IO module have been reimplemented in C for gaining [...]]]></description>
			<content:encoded><![CDATA[<p>Since the very important and big release of Python v3.0 (also knowed as &#8220;Python 3000&#8243;) in december, there has been some minor bugfixes and further improvements. Now, in Python v3.1, we may get to feel these bugfixes and enhancements.</p>
<div id="attachment_146" class="wp-caption alignnone" style="width: 310px"><a href="http://asbjorn.fellinghaug.com/blog/wp-content/uploads/2008/12/python-logo-master-v3-tm.png"><img class="size-medium wp-image-146" title="python logo" src="http://asbjorn.fellinghaug.com/blog/wp-content/uploads/2008/12/python-logo-master-v3-tm-300x101.png" alt="Python Logo" width="300" height="101" /></a><p class="wp-caption-text">Python Logo</p></div>
<p>Of important changes we may highlight such as:</p>
<ul>
<li>The IO module have been reimplemented in C for gaining even more speed</li>
<li>Decoding of utf-8, utf-16 and latin1 is know from 2x to 4x times faster than before</li>
<li>int and str comparisons is know faster</li>
</ul>
<p>So, for all Python v3.0 people out there, I would suggest upgrading to this lastest version. Visit this site: <a title="Python v3.1" href="http://www.python.org/download/releases/3.1/">http://www.python.org/download/releases/3.1/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2009/03/python-31-is-now-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AC/DC was awesome</title>
		<link>http://asbjorn.fellinghaug.com/blog/2009/02/acdc-was-awesome/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2009/02/acdc-was-awesome/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 18:14:07 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[acdc]]></category>
		<category><![CDATA[concert]]></category>
		<category><![CDATA[oslo]]></category>
		<category><![CDATA[telenor arena]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=203</guid>
		<description><![CDATA[I was on the AC/DC Black Ice concert in Oslo 18.Feb, and I must say, it was an incredible live performance of the AC/DC. The concert was held in the new &#8220;Telenor Arena&#8221;
Classic songs like &#8220;Highway to hell&#8221;, &#8220;Thunderstruck&#8221;, &#8220;T.N.T.&#8221;.. Also the fact that these guys ain&#8217;t getting any younger, the sure did impress me. [...]]]></description>
			<content:encoded><![CDATA[<p>I was on the AC/DC Black Ice concert in Oslo 18.Feb, and I must say, it was an incredible live performance of the AC/DC. The concert was held in the new &#8220;Telenor Arena&#8221;</p>
<div id="attachment_205" class="wp-caption alignnone" style="width: 310px"><a href="http://asbjorn.fellinghaug.com/blog/wp-content/uploads/2009/02/acdc.jpg"><img class="size-medium wp-image-205" title="acdc" src="http://asbjorn.fellinghaug.com/blog/wp-content/uploads/2009/02/acdc-300x283.jpg" alt="AC/DC" width="300" height="283" /></a><p class="wp-caption-text">AC/DC</p></div>
<p>Classic songs like &#8220;Highway to hell&#8221;, &#8220;Thunderstruck&#8221;, &#8220;T.N.T.&#8221;.. Also the fact that these guys ain&#8217;t getting any younger, the sure did impress me. I would serious consider attending to another concert with these guys, even it means I have to put my arse on a plain to another country.</p>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2009/02/acdc-was-awesome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Concerning my master thesis</title>
		<link>http://asbjorn.fellinghaug.com/blog/2009/01/concerning-my-master-thesis/</link>
		<comments>http://asbjorn.fellinghaug.com/blog/2009/01/concerning-my-master-thesis/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 14:36:37 +0000</pubDate>
		<dc:creator>Asbjørn Alexander Fellinghaug</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[bigram]]></category>
		<category><![CDATA[bigram index]]></category>
		<category><![CDATA[fellinghaug]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[master]]></category>
		<category><![CDATA[master thesis]]></category>
		<category><![CDATA[search engine]]></category>

		<guid isPermaLink="false">http://asbjorn.fellinghaug.com/blog/?p=181</guid>
		<description><![CDATA[Hi everyone.
I just want to inform that I&#8217;ve taken some further steps to describe and provide my master thesis. I have written a page (http://asbjorn.fellinghaug.com/blog/master-thesis/) who&#8217;s goal is to summeraize and further describe the overall goals and design of my master thesis.
I will also &#8211; in time &#8211; further work on the bigram index, as [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everyone.</p>
<p>I just want to inform that I&#8217;ve taken some further steps to describe and provide my master thesis. I have written a page (<a title="Master thesis" href="http://asbjorn.fellinghaug.com/blog/master-thesis/">http://asbjorn.fellinghaug.com/blog/master-thesis/</a>) who&#8217;s goal is to summeraize and further describe the overall goals and design of my master thesis.</p>
<p>I will also &#8211; in time &#8211; further work on the <strong>bigram index</strong>, as I want to see its full working potential one a more <em>real-life</em> collection. In the beginning I will use the dumps provided by the wonderful Wikipedia foundation. These dumps are several gigabytes with pure text (and some metadata). I realize that the content of each wikipedia article may not fully reflect typical websites on the internet, but it is a start. The next step I&#8217;ve made myself is to find a sufficiently large website, and then index all the data on it. Then, to check how the bigram index performs on it.</p>
<p>I will most likely keep further developments in the Java programming language, as it is the language which Apache Lucene is written in. However, I&#8217;m also quite interessted in writing a Python analyzer for the PyLucene package (Python port of Lucene).</p>
]]></content:encoded>
			<wfw:commentRss>http://asbjorn.fellinghaug.com/blog/2009/01/concerning-my-master-thesis/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
