<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Technically Unnecessary</title>
    <link rel="alternate" type="text/html" href="http://tu.wesolek.net/" />
    <link rel="self" type="application/atom+xml" href="http://tu.wesolek.net/atom.xml" />
    <id>tag:tu.wesolek.net,2009-08-20://2</id>
    <updated>2010-07-27T07:45:15Z</updated>
    
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.261</generator>

<entry>
    <title>Per-tags feeds in MovableType</title>
    <link rel="alternate" type="text/html" href="http://tu.wesolek.net/2009/11/per-tags-feeds-in-movabletype.html" />
    <id>tag:tu.wesolek.net,2009://2.7</id>

    <published>2009-11-21T19:54:01Z</published>
    <updated>2010-07-27T07:45:15Z</updated>

    <summary>In Movable Type it is possible to generate a feed for entries matching a given tag only. For this to happen, just select some tag, e.g. from tags cloud and take a look at link named &#8220;Feed of results tagged...</summary>
    <author>
        <name>Przemek Wesołek</name>
        
    </author>
    
        <category term="Movable Type" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="ironman" label="Ironman" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="movabletype" label="Movable Type" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ubuntu" label="Ubuntu" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://tu.wesolek.net/">
        <![CDATA[<p>In Movable Type it is possible to generate a feed for entries matching a given tag only. For this to happen, just select some tag, e.g. from tags cloud and take a look at link named &#8220;Feed of results tagged &#8230;&#8221;. For example, for this blog&#8217;s Perl tag, the link looks like:</p>

<p><code>
http://tu.wesolek.net/cgi-bin/mt/mt-search.cgi?tag=Perl&amp;Template=feed&amp;IncludeBlogs=2&amp;limit=20
</code></p>

<p>and you can use this URL as a feed, e.g. for <a href="http://www.enlightenedperl.org/ironman.html">Ironman challenge</a>.</p>

<p>There is a problem with Ubuntu package, however (Karmic at least). Packaged MT is missing <code>search_templates</code> link in <code>/usr/lib/cgi-bin/movabletype</code>. I <a href="https://bugs.launchpad.net/ubuntu/+source/movabletype-opensource/+bug/486402">reported this bug</a>, and you can apply the simple solution on your own.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Perlmonks on giving ready solutions</title>
    <link rel="alternate" type="text/html" href="http://tu.wesolek.net/2009/11/perlmonks-on-giving-ready-solutions.html" />
    <id>tag:tu.wesolek.net,2009://1.6</id>

    <published>2009-11-18T12:52:54Z</published>
    <updated>2009-11-21T20:29:10Z</updated>

    <summary>I read Perlmonks irregularly, sometimes I even post something. I give hints, thoughts or bigger chunks of code. But for the first time I got as much as 40% of downvotes on an entry that I think is rather neutral....</summary>
    <author>
        <name>Przemek Wesołek</name>
        
    </author>
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perlmonks" label="PerlMonks" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://tu.wesolek.net/">
        <![CDATA[<p>I read <a href="http://perlmonks.org">Perlmonks</a> irregularly, sometimes I even post something. I give hints, thoughts or bigger chunks of code. But for the first time I got as much as 40% of <a href="http://perlmonks.org/?node_id=5938">downvotes</a> on an <a href="http://perlmonks.org/?node_id=807809">entry that I think is rather neutral</a>.</p>

<p>I understand that some people don&#8217;t like to give others ready solutions, they prefer &#8220;to teach others to fish than to give them a fish&#8221;. But is it really something that bothers them so much to give thumbs down to the ones who don&#8217;t mind? No feelings hurt, I&#8217;m just curious&#8230;</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Compiling Perl 5.10.1 under Ubuntu</title>
    <link rel="alternate" type="text/html" href="http://tu.wesolek.net/2009/10/compiling-perl-5101-under-ubuntu.html" />
    <id>tag:tu.wesolek.net,2009://1.5</id>

    <published>2009-10-11T19:03:52Z</published>
    <updated>2009-11-21T20:28:37Z</updated>

    <summary> Note: Since 5.10.1 is not upstream, there might be changes in packages versions, so downloading patches as described below might not work. I&#8217;ll try to update this entry to reflect the correct links, but in case of problems just...</summary>
    <author>
        <name>Przemek Wesołek</name>
        
    </author>
    
        <category term="Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="debian" label="Debian" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ubuntu" label="Ubuntu" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://tu.wesolek.net/">
        <![CDATA[<hr />

<p><strong>Note:</strong> Since 5.10.1 is not upstream, there might be changes in packages versions, so downloading patches as described below might not work. I&#8217;ll try to update this entry to reflect the correct links, but in case of problems just go to <a href="http://patch-tracker.debian.org/package/perl">http://patch-tracker.debian.org/package/perl</a>, select the current version of Perl 5.10.1 and download <code>mod_paths.diff</code> manually.</p>

<hr />

<p>After reading encouragingly simple <a href="http://oylenshpeegul.vox.com/library/post/perl-5101.html">instructions on compiling Perl 5.10.1</a>, I decided to compile Perl &#8212; for the first time &#8212; on my own.</p>

<p>Everything went fine, but after installation it occurred that the order of directories on <code>@INC</code> is &#8220;core, vendor, site&#8221;, where the expected &#8212; after using Debian&#8217;s Perl for years &#8212; was &#8220;site, vendor, core&#8221;. Apparently a bug (for most), with no chance to be corrected due to backward compatibility.</p>

<p>So, I applied <a href="http://patch-tracker.debian.org/patch/series/dl/perl/5.10.1-7/debian/mod_paths.diff">a patch from Debian</a>, which corrects the order. Note, that besides correcting the order, the patch adds <code>/etc/perl</code> at the beginning of <code>@INC</code> and <code>/usr/local/lib/site_perl</code> at the end. This is fine with me, but you can remove it from the code if you wish.</p>

<p><code>mod_paths.diff</code>:</p>

<pre class='brush: diff'>
Subject: Tweak @INC so that the ordering is:

    etc (for config files)
    site (5.8.1)
    vendor (all)
    core (5.8.1)
    site (version-indep)
    site (pre-5.8.1)

The rationale being that an admin (via site), or module packager
(vendor) can chose to shadow core modules when there is a newer
version than is included in core.


---
 perl.c |   62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/perl.c b/perl.c
index 94f2b13..5a6744a 100644
--- a/perl.c
+++ b/perl.c
@@ -4879,9 +4879,14 @@ S_init_perllib(pTHX)
     incpush(APPLLIB_EXP, TRUE, TRUE, TRUE, TRUE);
 #endif

+#ifdef DEBIAN
+    /* for configuration where /usr is mounted ro (CPAN::Config, Net::Config) */
+    incpush(&quot;/etc/perl&quot;, FALSE, FALSE, FALSE, FALSE);
+#else
 #ifdef ARCHLIB_EXP
     incpush(ARCHLIB_EXP, FALSE, FALSE, TRUE, TRUE);
 #endif
+#endif
 #ifdef MACOS_TRADITIONAL
     {
    Stat_t tmpstatbuf;
@@ -4906,11 +4911,13 @@ S_init_perllib(pTHX)
 #ifndef PRIVLIB_EXP
 #  define PRIVLIB_EXP &quot;/usr/local/lib/perl5:/usr/local/lib/perl&quot;
 #endif
+#ifndef DEBIAN
 #if defined(WIN32)
     incpush(PRIVLIB_EXP, TRUE, FALSE, TRUE, TRUE);
 #else
     incpush(PRIVLIB_EXP, FALSE, FALSE, TRUE, TRUE);
 #endif
+#endif

 #ifdef SITEARCH_EXP
     /* sitearch is always relative to sitelib on Windows for
@@ -4954,6 +4961,61 @@ S_init_perllib(pTHX)
     incpush(PERL_VENDORLIB_STEM, FALSE, TRUE, TRUE, TRUE);
 #endif

+#ifdef DEBIAN
+    incpush(ARCHLIB_EXP, FALSE, FALSE, TRUE, FALSE);
+    incpush(PRIVLIB_EXP, FALSE, FALSE, TRUE, FALSE);
+
+    /* Non-versioned site directory for local modules and for
+       compatability with the previous packages' site dirs */
+    incpush(&quot;/usr/local/lib/site_perl&quot;, TRUE, FALSE, FALSE, FALSE);
+
+#ifdef PERL_INC_VERSION_LIST
+    {
+   struct stat s;
+
+   /* add small buffer in case old versions are longer than the
+      current version */
+   char sitearch[sizeof(SITEARCH_EXP)+16] = SITEARCH_EXP;
+   char sitelib[sizeof(SITELIB_EXP)+16] = SITELIB_EXP;
+   char const *vers[] = { PERL_INC_VERSION_LIST };
+   char const **p;
+
+   char *arch_vers = strrchr(sitearch, '/');
+   char *lib_vers = strrchr(sitelib, '/');
+
+   if (arch_vers &amp;&amp; isdigit(*++arch_vers))
+       *arch_vers = 0;
+   else
+       arch_vers = 0;
+
+   if (lib_vers &amp;&amp; isdigit(*++lib_vers))
+       *lib_vers = 0;
+   else
+       lib_vers = 0;
+
+   /* there is some duplication here as incpush does something
+      similar internally, but required as sitearch is not a
+      subdirectory of sitelib */
+   for (p = vers; *p; p++)
+   {
+       if (arch_vers)
+       {
+       strcpy(arch_vers, *p);
+       if (PerlLIO_stat(sitearch, &amp;s) &gt;= 0 &amp;&amp; S_ISDIR(s.st_mode))
+           incpush(sitearch, FALSE, FALSE, FALSE, FALSE);
+       }
+
+       if (lib_vers)
+       {
+       strcpy(lib_vers, *p);
+       if (PerlLIO_stat(sitelib, &amp;s) &gt;= 0 &amp;&amp; S_ISDIR(s.st_mode))
+           incpush(sitelib, FALSE, FALSE, FALSE, FALSE);
+       }
+   }
+    }
+#endif
+#endif
+
 #ifdef PERL_OTHERLIBDIRS
     incpush(PERL_OTHERLIBDIRS, TRUE, TRUE, TRUE, TRUE);
 #endif
-- 
tg: (daf8b46..) debian/mod_paths (depends on: upstream)
</pre>

<p>So, my modified compilation instructions with Ubuntu&#8217;s &#8220;taste&#8221; look like:</p>

<pre class='brush: plain'>
wget http://www.cpan.org/modules/by-authors/id/D/DA/DAPM/perl-5.10.1.tar.bz2
wget http://patch-tracker.debian.org/patch/series/dl/perl/5.10.1-7/debian/mod_paths.diff
tar xjf perl-5.10.1.tar.bz2
cd perl-5.10.1
patch -b -p1 &lt;../mod_paths.diff
perl Configure -de -Dprefix=${HOME}/local -Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i486-linux-gnu -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Ud_ualarm -Uusesfio -Doptimize=-O2
make
make test
make install
</pre>
]]>
        

    </content>
</entry>

<entry>
    <title>Perl test in MT</title>
    <link rel="alternate" type="text/html" href="http://tu.wesolek.net/2009/09/perl-test-in-mt.html" />
    <id>tag:tu.wesolek.net,2009://1.4</id>

    <published>2009-09-07T10:21:15Z</published>
    <updated>2009-09-07T10:28:59Z</updated>

    <summary><![CDATA[Here&#8217;s a little test of Perl formatting with SyntaxHighlighter. #!/usr/bin/perl use strict; print &quot;Hello there!&quot;; I&#8217;ll write a bit more on my Movable Type config soon, as there are some interesting quirks....]]></summary>
    <author>
        <name>Przemek Wesołek</name>
        
    </author>
    
    <category term="movabletype" label="Movable Type" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://tu.wesolek.net/">
        <![CDATA[<p>Here&#8217;s a little test of Perl formatting with SyntaxHighlighter.</p>

<pre class='brush: perl'>
#!/usr/bin/perl

use strict;

print &quot;Hello there!&quot;;
</pre>

<p>I&#8217;ll write a bit more on my Movable Type config soon, as there are some interesting quirks.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Compiling with distcc and ccache</title>
    <link rel="alternate" type="text/html" href="http://tu.wesolek.net/2009/09/compiling-with-distcc-and-ccache.html" />
    <id>tag:tu.wesolek.net,2009://1.3</id>

    <published>2009-09-04T14:15:32Z</published>
    <updated>2009-10-11T19:00:34Z</updated>

    <summary>In my working environment a firewall is set up that prevents connecting with remote server do do distributed computing with distcc. Here&#8217;s a short note on how I work around it and generally, how my compilation chain is constructed. First,...</summary>
    <author>
        <name>Przemek Wesołek</name>
        
    </author>
    
    <category term="c" label="C" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="c" label="C++" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ccache" label="ccache" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="distcc" label="distcc" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://tu.wesolek.net/">
        <![CDATA[<p>In my working environment a firewall is set up that prevents connecting with remote server do do distributed computing with <code>distcc</code>. Here&#8217;s a short note on how I work around it and generally, how my compilation chain is constructed.</p>

<p>First, I setup SSH tunnel to avoid firewall restrictions:</p>

<pre class='brush: bash'>
ssh SERVER -L 3633:localhost:3632
</pre>

<p>and run a build on the local machine</p>

<pre class='brush: bash'>
DISTCC_HOSTS='localhost:3633' CCACHE_PREFIX='distcc' CXX='ccache g++' make -j8
</pre>

<p>The compilation chain is as follow:</p>

<ol>
<li><code>ccache</code> is run instead of <code>g++</code>.</li>
<li><code>ccache</code> checks if it has a locally (on the client) cached version of compilation result. If so, the result is returned.</li>
<li>If not, <code>distcc</code> is called and performs compilation on the <code>SERVER</code>.</li>
<li>Compilation result is stored in <code>ccache</code>&#8217;s cache and &#8220;returned back&#8221;.</li>
</ol>
]]>
        

    </content>
</entry>

<entry>
    <title>Auto-connecting signal handlers in glademm</title>
    <link rel="alternate" type="text/html" href="http://tu.wesolek.net/2009/08/auto-connecting-signal-handlers-in-glademm.html" />
    <id>tag:tu.wesolek.net,2009://1.2</id>

    <published>2009-08-20T13:24:16Z</published>
    <updated>2009-10-11T19:01:45Z</updated>

    <summary>libglade has the possibility to automatically connect all signal handlers specified in a Glade XML file. However, it is not directly possible in libglademm (C++). Although you find some results when you search the Net for &#8220;libglademm autoconnect&#8221;, either no...</summary>
    <author>
        <name>Przemek Wesołek</name>
        
    </author>
    
    <category term="c" label="C" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="c" label="C++" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="gtk" label="GTK+" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://tu.wesolek.net/">
        <![CDATA[<p>libglade has the possibility to automatically connect all signal handlers specified in a Glade XML file. However, it is not directly possible in libglademm (C++).</p>

<p>Although you find some results when you search the Net for &#8220;libglademm autoconnect&#8221;, either no solution is given, or the posters mention that &#8220;wrapping functions with extern works for them&#8221;. No code. So here is a simple example working for me.</p>

<p><code>minimal.cc</code>:</p>

<pre class='brush: cpp'>
#include &lt;gtkmm.h&gt;
#include &lt;libglademm.h&gt;
#include &lt;iostream&gt;
#include &lt;glade/glade-xml.h&gt;

extern &quot;C&quot; {
    void on_button1_clicked() {
        std::cout &lt;&lt; &quot;Clicked&quot; &lt;&lt; std::endl;
    }
}

int main(int argc, char *argv[]) {
    Gtk::Main kit(argc, argv);

    Glib::RefPtr&lt;Gnome::Glade::Xml&gt; refXml = Gnome::Glade::Xml::create(&quot;minimal.glade&quot;);
    glade_xml_signal_autoconnect(refXml-&gt;gobj());

    Gtk::Window *mainWnd = 0;
    refXml-&gt;get_widget(&quot;window1&quot;, mainWnd);
    Gtk::Main::run(*mainWnd);

    return 0;
}
</pre>

<p><code>minimal.glade</code>:</p>

<pre class='brush: xml'>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;
&lt;!DOCTYPE glade-interface SYSTEM &quot;glade-2.0.dtd&quot;&gt;
&lt;!--Generated with glade3 3.4.5 on Thu Aug 20 15:37:26 2009 --&gt;
&lt;glade-interface&gt;
  &lt;widget class=&quot;GtkWindow&quot; id=&quot;window1&quot;&gt;
    &lt;child&gt;
      &lt;widget class=&quot;GtkButton&quot; id=&quot;button1&quot;&gt;
        &lt;property name=&quot;visible&quot;&gt;True&lt;/property&gt;
        &lt;property name=&quot;can_focus&quot;&gt;True&lt;/property&gt;
        &lt;property name=&quot;receives_default&quot;&gt;True&lt;/property&gt;
        &lt;property name=&quot;label&quot; translatable=&quot;yes&quot;&gt;click me&lt;/property&gt;
        &lt;property name=&quot;response_id&quot;&gt;0&lt;/property&gt;
        &lt;signal name=&quot;clicked&quot; handler=&quot;on_button1_clicked&quot;/&gt;
      &lt;/widget&gt;
    &lt;/child&gt;
  &lt;/widget&gt;
&lt;/glade-interface&gt;
</pre>

<p><code>Makefile</code>:</p>

<pre class='brush: plain'>
CXXFLAGS = $(shell pkg-config gtkmm-2.4 libglademm-2.4 --cflags)
LDLIBS = $(shell pkg-config gtkmm-2.4 libglademm-2.4 --libs)
LDFLAGS = -export-dynamic

minimal: minimal.o

clean:
    rm minimal minimal.o
</pre>

<p>And then</p>

<pre class='brush: bash'>
make minimal
</pre>

<p>produces something like</p>

<pre class='brush: bash'>
g++ -D_REENTRANT -I/usr/include/gtkmm-2.4 -I/usr/lib/gtkmm-2.4/include -I/usr/include/glibmm-2.4 -I/usr/lib/glibmm-2.4/include -I/usr/include/giomm-2.4 -I/usr/lib/giomm-2.4/include -I/usr/include/gdkmm-2.4 -I/usr/lib/gdkmm-2.4/include -I/usr/include/pangomm-1.4 -I/usr/include/atkmm-1.6 -I/usr/include/gtk-2.0 -I/usr/include/sigc++-2.0 -I/usr/lib/sigc++-2.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I/usr/include/cairomm-1.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12 -I/usr/include/atk-1.0 -I/usr/include/libglademm-2.4 -I/usr/lib/libglademm-2.4/include -I/usr/include/libglade-2.0 -I/usr/include/libxml2     -c -o minimal.o minimal.cc
cc -export-dynamic  minimal.o  -lglademm-2.4 -lgtkmm-2.4 -lglade-2.0 -lgiomm-2.4 -lgdkmm-2.4 -latkmm-1.6 -lpangomm-1.4 -lcairomm-1.0 -lglibmm-2.4 -lsigc-2.0 -lgtk-x11-2.0 -lxml2 -lgdk-x11-2.0 -latk-1.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lgio-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0   -o minimal
</pre>

<p>Running the <code>minimal</code> program and clicking the &#8220;click me&#8221; button should produce a message on stdout.</p>
]]>
        

    </content>
</entry>

</feed>
