<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
     xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     >
  <channel>
    <title>codeape.org</title>
    <link>http://www.codeape.org/blog</link>
    <description>A blog about a programmer</description>
    <pubDate>Tue, 21 Feb 2012 21:21:27 GMT</pubDate>
    <generator>Blogofile</generator>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>W3C validator does not like css3</title>
      <link>http://www.codeape.org/blog/2012/02/20/w3c-validator-does-not-like-css3</link>
      <pubDate>Mon, 20 Feb 2012 22:15:47 CET</pubDate>
      <category><![CDATA[www]]></category>
      <guid isPermaLink="true">http://www.codeape.org/blog/2012/02/20/w3c-validator-does-not-like-css3</guid>
      <description>W3C validator does not like css3</description>
      <content:encoded><![CDATA[<p>
If you use a referer url
(<code>http://jigsaw.w3.org/css-validator/check/referer</code>) to the w3c
validator for your css3, the validator will tell you that you have a broken css.
This is because css3 is not a finished standard (from w3c point of view) and the
validator will assume that you use css 2.1 by default. I discovered this when I
<a href="/blog/2012/02/18/responsive-design-and-css3-media-queries/">added css3
media queries to my blogs css</a> and the validation returned errors. However
you can force the w3c validator to validate css3 by appending
<code>?profile=css3</code> to the referer url like this:
<code>http://jigsaw.w3.org/css-validator/check/referer?profile=css3</code>
</p>]]></content:encoded>
    </item>
    <item>
      <title>Responsive Design and CSS3 Media Queries</title>
      <link>http://www.codeape.org/blog/2012/02/18/responsive-design-and-css3-media-queries</link>
      <pubDate>Sat, 18 Feb 2012 13:45:19 CET</pubDate>
      <category><![CDATA[Inspiration]]></category>
      <guid isPermaLink="true">http://www.codeape.org/blog/2012/02/18/responsive-design-and-css3-media-queries</guid>
      <description>Responsive Design and CSS3 Media Queries</description>
      <content:encoded><![CDATA[<p>
Today I added responsive design to my little corner on the web. The idea with
responsive design is to have a web page layout that changes with the screen size
of the device the viewer is currently using to display the web page.
</p>

<p>
Do you want to see how it works? Well, the resize width of the web browser
window you are using to browse this site and let it be narrower than the content
and the sidebar (the sidebar contains the last 5 posts and the categories). You
will now see that the sidebar is relocated to be just bellow the title banner of
this web page.
</p>

<p>
Do you want to read more? A good starting point is this
<a href="http://deanhume.com/Home/BlogPost/responsive-design-and-css3-media-queries/60">
grate blog post</a> by Dean Hume.
</p>]]></content:encoded>
    </item>
    <item>
      <title>Sshguard needs a test run</title>
      <link>http://www.codeape.org/blog/2011/11/04/sshguard-needs-a-test-run</link>
      <pubDate>Fri, 04 Nov 2011 13:36:46 CET</pubDate>
      <category><![CDATA[Sysadmin]]></category>
      <guid isPermaLink="true">http://www.codeape.org/blog/2011/11/04/sshguard-needs-a-test-run</guid>
      <description>Sshguard needs a test run</description>
      <content:encoded><![CDATA[<p>
After <a href="http://www.codeape.org/blog/2011/11/03/fail2ban-is-good-stuff/">
posting about Fail2ban</a> yester day I remembered that there is one more cool
tool. The tool is <a href="http://www.sshguard.net/">Sshguard</a> and is similar
to Fail2ban. However, Sshguard is implemented in C and not a scripting language
like Fail2ban (python). Sshguard also increases the ban time exponentially ...
and that is nice.
</p>

<p>
I have not tested Sshguard yet but one of my friends highly recommends it.
</p>]]></content:encoded>
    </item>
    <item>
      <title>Fail2ban is good stuff</title>
      <link>http://www.codeape.org/blog/2011/11/03/fail2ban-is-good-stuff</link>
      <pubDate>Thu, 03 Nov 2011 22:25:16 CET</pubDate>
      <category><![CDATA[Sysadmin]]></category>
      <guid isPermaLink="true">http://www.codeape.org/blog/2011/11/03/fail2ban-is-good-stuff</guid>
      <description>Fail2ban is good stuff</description>
      <content:encoded><![CDATA[<p>
<a href="http://www.fail2ban.org/">Fail2ban</a> is a handy little script for
anyone who wants to protect them self from hackers brute force attacks.
Fail2ban scans log files like <code>/var/log/pwdfail</code> or
<code>/var/log/apache/error_log</code> and bans IP that makes too many password
failures. It updates firewall rules to reject the IP address. It works with SSH,
HTTP, FTP, Mail services etc.
</p>]]></content:encoded>
    </item>
    <item>
      <title>Note to self - remember how run-parts work</title>
      <link>http://www.codeape.org/blog/2011/11/02/note-to-self---remember-how-run-parts-work</link>
      <pubDate>Wed, 02 Nov 2011 21:44:21 CET</pubDate>
      <category><![CDATA[Sysadmin]]></category>
      <guid isPermaLink="true">http://www.codeape.org/blog/2011/11/02/note-to-self---remember-how-run-parts-work</guid>
      <description>Note to self - remember how run-parts work</description>
      <content:encoded><![CDATA[<p>
A couple weeks ago I wrote a bash script and tested it and the script worked. I
copied the bash script to the daily cron jobs (<code>/etc/cron.daily</code>)
and after a couple of days I noted that it had never been run. After 2 hours of
debuging I syill could not get it to run. However, then I rembered that the
cron jobs are executed by <code>run-parts</code>. I opened the man page and what
did I find:
</p>

<pre>
If neither the --lsbsysinit option nor the --regex option is given then the
names must consist entirely of upper and lower case letters, digits,
underscores, and hyphens.
</pre>

<p>
The filename of my bash script had a dot in it (<code>scriptname.sh</code>) and
crontab does not use <code>run-parts</code> with the <code>--lsbsysinit</code>
option nor the <code>--regex</code> option. This is the second time I have
screwed up a cron script name like this.
</p>

<p>
The simple solution was to remove the suffix from the filename of the script.
</p>]]></content:encoded>
    </item>
    <item>
      <title>Makefiles for building many binary flavors</title>
      <link>http://www.codeape.org/blog/2011/11/01/makefiles-for-building-many-binary-flavors</link>
      <pubDate>Tue, 01 Nov 2011 15:00:49 CET</pubDate>
      <category><![CDATA[make]]></category>
      <guid isPermaLink="true">http://www.codeape.org/blog/2011/11/01/makefiles-for-building-many-binary-flavors</guid>
      <description>Makefiles for building many binary flavors</description>
      <content:encoded><![CDATA[<p>
If you want to share code for several binaries you would normally organize this
code as a shared or static library. This is usually how I do it, but recently I
came across a situation where this actually became a clumsy way of doing it.
</p>

<p>
The real life scenario is the following. We have a binary that make a lot of
syntactical and type checks for a configuration file format. If the
configuration file is ok the binary starts to generate system configuration
files. We will label this binary as tool. Additional to the tool binary we want
a binary that only do the checks and is not able to generate files and that
binary is labeled tool-simple. The code base is a huge directory tree with many
Makefiles, like this:
</p>

<pre>
|-Makefile
|-pkg/
|-src/
| |-proj1/
| | |-Makefile
| | |-main.c
| |-proj2/
| | |-Makefile
. . .
. . .
. . .
</pre>

<p>
In this case proj1 contains the source code for the binary called tool. However,
proj1 needs to be built in two binary different flavors from the exact same
source files but with different define arguments to gcc. This could have easily
been done by running make twice (traverse the build tree twice) in the normal
case. However, because the binaries will be packaged in the same tgz file we can
only traverse the build tree once if we want to make a sane build environment. 
The solution is to create a structure for project q that look like this:
</p>

<pre>
|-src/
| |-proj1/
| | |-Makefile
| | |-tool/
| | | |-Makefile
| | | |-cmd.c
| | | |-cmd.h
| | | |-common.inc
| | | |-main.c
| | |-tool-simple/
| | | |-Makefile
</pre>

<p>
Lets consentrate on the files in the project1 dirextory tree.
</p>

<pre>proj1/Makefile</pre>

<table class="pygments_nativetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3
4
5
6
7
8
9</pre></div></td><td class="code"><div class="pygments_native"><pre><span class="nf">all</span><span class="o">:</span>
    make -C tool all
    make -C tool-simple all

<span class="nf">clean</span><span class="o">:</span>
    make -C tool clean
    make -C tool-simple clean

<span class="c">#eof</span>
</pre></div>
</td></tr></table>

<p>
There is nothing special about this Makefile and that is the nice thing about it.
Lets keep things simple and clean where we can and all the special cases
isolated.
</p>

<pre>proj1/tool/cmd.c</pre>

<table class="pygments_nativetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19</pre></div></td><td class="code"><div class="pygments_native"><pre><span class="cp">#include &quot;cmd.h&quot;</span>
<span class="cp">#include &lt;stdio.h&gt;</span>

<span class="kt">void</span> <span class="nf">tool_func</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">printf</span><span class="p">(</span><span class="s">&quot;Do tool stuff</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">);</span>
<span class="p">}</span>

<span class="kt">void</span> <span class="nf">simple_func</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">printf</span><span class="p">(</span><span class="s">&quot;Do simple stuff</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">);</span>
<span class="p">}</span>

<span class="kt">void</span> <span class="n">common_end</span><span class="p">(){</span>
<span class="cp">#ifdef SIMPLE</span>
    <span class="n">printf</span><span class="p">(</span><span class="s">&quot;Simple end</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">);</span>
<span class="cp">#else</span>
    <span class="n">printf</span><span class="p">(</span><span class="s">&quot;Tool end</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">);</span>
<span class="cp">#endif</span>
<span class="p">}</span>
<span class="c1">//eof</span>
</pre></div>
</td></tr></table>

<pre>proj1/tool/cmd.h</pre>

<table class="pygments_nativetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11</pre></div></td><td class="code"><div class="pygments_native"><pre><span class="cp">#ifndef CMD_H</span>
<span class="cp">#define CMD_H</span>

<span class="kt">void</span> <span class="n">tool_func</span><span class="p">();</span>

<span class="kt">void</span> <span class="n">simple_func</span><span class="p">();</span>

<span class="kt">void</span> <span class="n">common_end</span><span class="p">();</span>

<span class="cp">#endif</span>
<span class="c1">//eof</span>
</pre></div>
</td></tr></table>

<pre>proj1/tool/main.c</pre>

<table class="pygments_nativetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17</pre></div></td><td class="code"><div class="pygments_native"><pre><span class="cp">#include &quot;cmd.h&quot;</span>
<span class="cp">#include &lt;stdio.h&gt;</span>

<span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span><span class="o">**</span> <span class="n">argv</span><span class="p">)</span> <span class="p">{</span>

<span class="n">simple_func</span><span class="p">();</span>

<span class="cp">#ifndef SIMPLE</span>
    <span class="n">printf</span><span class="p">(</span><span class="s">&quot;Tool working ...</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">);</span>
    <span class="n">tool_func</span><span class="p">();</span>
<span class="cp">#endif</span>

<span class="n">common_end</span><span class="p">();</span>

<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
<span class="c1">//eof</span>
</pre></div>
</td></tr></table>

<p>
The only thing interesting in these 3 C files (main.c, cmd.c and cmd.h) are the
ifdefs and ifndefs that are used to include and exclude code depending on the
build. From the real scenario the shared code for the binaries are rather 80%
than the few percent that are used in these files.
</p>

<pre>proj1/tool/common.inc</pre>

<table class="pygments_nativetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3
4
5
6</pre></div></td><td class="code"><div class="pygments_native"><pre><span class="nv">CC</span><span class="o">=</span>gcc

<span class="nv">OBJ</span> <span class="o">=</span> main.o <span class="se">\</span>
    cmd.o

<span class="c">#eof</span>
</pre></div>
</td></tr></table>

<p>
The file common.inc mainly contains the list of all object files that should be
produced. In this case we have also included the common definition of CC.
</p>

<pre>proj1/tool/Makefile</pre>

<table class="pygments_nativetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17</pre></div></td><td class="code"><div class="pygments_native"><pre><span class="cp">include common.inc</span>

<span class="nv">TARGET</span><span class="o">=</span>tool

all: <span class="k">$(</span>TARGET<span class="k">)</span>

<span class="k">$(</span>TARGET<span class="k">)</span>: <span class="k">$(</span>OBJ<span class="k">)</span>
    <span class="k">$(</span>CC<span class="k">)</span> -o <span class="nv">$@</span> <span class="nv">$^</span>

%.o: %.c
    <span class="k">$(</span>CC<span class="k">)</span> -Wall -c -o <span class="nv">$@</span> <span class="nv">$&lt;</span>

clean:
    rm -f <span class="k">$(</span>TARGET<span class="k">)</span> <span class="k">$(</span>OBJ<span class="k">)</span>

<span class="c">#eof</span>
</pre></div>
</td></tr></table>

<p>
The Makefile in the tool directory is a very normal Makefile with the include of
common.inc as the only deviation.
</p>

<pre>proj1/tool-simple/Makefile</pre>

<table class="pygments_nativetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19</pre></div></td><td class="code"><div class="pygments_native"><pre><span class="cp">include ../tool/common.inc</span>

<span class="err">vpath</span> <span class="err">%.h</span> <span class="err">../tool</span>
<span class="err">vpath</span> <span class="err">%.c</span> <span class="err">../tool</span>

<span class="nv">TARGET</span><span class="o">=</span>tool-simple

all: <span class="k">$(</span>TARGET<span class="k">)</span>

<span class="k">$(</span>TARGET<span class="k">)</span>: <span class="k">$(</span>OBJ<span class="k">)</span>
    <span class="k">$(</span>CC<span class="k">)</span> -o <span class="nv">$@</span> <span class="nv">$^</span>

%.o: %.c
    <span class="k">$(</span>CC<span class="k">)</span> -Wall -c -o <span class="nv">$@</span> <span class="nv">$&lt;</span> -DSIMPLE

clean:
    rm -f <span class="k">$(</span>TARGET<span class="k">)</span> <span class="k">$(</span>OBJ<span class="k">)</span>
<span class="c">#eof</span>
</pre></div>
</td></tr></table>

<p>
The interesting stuff is found in the Makefile contained in the tool-simple
directory  In this Makefile we also include the common.inc file from the tools
directory. The tools-simple directory does not contain any C files that can be
compiled to the object files declared in common.inc though. We will compile  the
.c and .h files from the tools directory in to the tools-simple directory
with the help of the <code>vpath</code> directive. Note the lower case of the
directive <code>vpath</code> because <code>vpath</code> and <code>VPATH</code>
are two different directives. <code>VPATH</code> specifies a list of directories
that make should search. Similar to the <code>VPATH</code> directive, but more
selective, is the <code>vpath</code> directive , which allows you to specify a
search path for a particular class of file names: those that match a particular
pattern. Also note that we define SIMPLE in this Makefile with the argument
-DSIMPLE when we build our object files for tool-simple  By defining SIMPLE we
will not compile some code as you can see from the C files above.
</p>

<p>
Go and have fun with some Makefiles!
</p>]]></content:encoded>
    </item>
    <item>
      <title>Awesome EM Based Layout</title>
      <link>http://www.codeape.org/blog/2011/10/13/awesome-em-based-layout</link>
      <pubDate>Thu, 13 Oct 2011 23:14:26 CEST</pubDate>
      <category><![CDATA[Inspiration]]></category>
      <guid isPermaLink="true">http://www.codeape.org/blog/2011/10/13/awesome-em-based-layout</guid>
      <description>Awesome EM Based Layout</description>
      <content:encoded><![CDATA[<p>
Today I updated the design of my little blog. Usually it is meaningless to 
mention that, but in this case I need to give some credit to a good source of 
inspiration.
</p>

<p>
I stared out playing around with matching colors and got very bored. I have done
this many times and it never end up well  So i started over and decided to look
for some inspiration by searching for words like: cool web design  I found a lot
of good looking black and white home pages. The color problem was now solved!
</p>

<p>
During my search for good looking black and white web pages I also found
<a href="http://mirificampress.com">Mirificam Press</a>. And started to read the
<a href="http://mirificampress.com/resources_and_study.php">Series and Study</a>
section. After some reading I ended up reading this nice article:
<a href="http://mirificampress.com/permalink/indestructable_website_em_based_layout">
Indestructible Website: How to Build an EM Based Layout that Won't Break
</a>. So I decided to use an EM based layout that won't break. Try it out! 
Zoom in and out on my home page with your browser and you will find that it will
scale gracefully.
</p>]]></content:encoded>
    </item>
    <item>
      <title>ValueError on Mac OS X caused by locale</title>
      <link>http://www.codeape.org/blog/2011/09/16/valueerror-on-mac-os-x-caused-by-locale</link>
      <pubDate>Fri, 16 Sep 2011 23:34:26 CEST</pubDate>
      <category><![CDATA[Blogofile]]></category>
      <guid isPermaLink="true">http://www.codeape.org/blog/2011/09/16/valueerror-on-mac-os-x-caused-by-locale</guid>
      <description>ValueError on Mac OS X caused by locale</description>
      <content:encoded><![CDATA[<p>I was lazy! Apparently I only needed to set my locales right in the terminal
and the error disappeared. I added this to my .bash_profile:</p>
<table class="pygments_nativetable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2</pre></div></td><td class="code"><div class="pygments_native"><pre><span class="nb">export </span><span class="nv">LC_ALL</span><span class="o">=</span>en_US.UTF-8
<span class="nb">export </span><span class="nv">LANG</span><span class="o">=</span>en_US.UTF-8
</pre></div>
</td></tr></table>]]></content:encoded>
    </item>
    <item>
      <title>Blogofile ValueError on Mac OS X</title>
      <link>http://www.codeape.org/blog/2011/09/14/blogofile-valueerror-on-mac-os-x</link>
      <pubDate>Wed, 14 Sep 2011 15:22:58 CEST</pubDate>
      <category><![CDATA[Blogofile]]></category>
      <guid isPermaLink="true">http://www.codeape.org/blog/2011/09/14/blogofile-valueerror-on-mac-os-x</guid>
      <description>Blogofile ValueError on Mac OS X</description>
      <content:encoded><![CDATA[<p>Today I found a nasty little bug in Blogofile: <a href="https://github.com/EnigmaCurry/blogofile/issues/112">https://github.com/EnigmaCurry/blogofile/issues/112</a></p>
<p>I get a ValueError from Blogofile on my Mac: This bug is problematic because I can not do a local build before I send new stuff over to the Linux server. </p>]]></content:encoded>
    </item>
    <item>
      <title>First post</title>
      <link>http://www.codeape.org/blog/2011/09/12/first-post</link>
      <pubDate>Mon, 12 Sep 2011 15:03:00 CEST</pubDate>
      <category><![CDATA[Ego]]></category>
      <guid isPermaLink="true">http://www.codeape.org/blog/2011/09/12/first-post</guid>
      <description>First post</description>
      <content:encoded><![CDATA[<p>This is the first post in my new blog. Why start over? Why not! The old one was
kind of boring and never got updated. I think the whole thing was about how the
work flow was in the old blog engine I used. I forgot to update it even if I 
had interesting stuff to write. It was not for me so I will try something else.</p>]]></content:encoded>
    </item>
  </channel>
</rss>

