<?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>Pedro Larroy</title>
	<atom:link href="http://pedro.larroy.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://pedro.larroy.com/blog</link>
	<description>musings of a computer jockey and pilot</description>
	<lastBuildDate>Mon, 30 Apr 2012 11:30:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using boost on windows, quick</title>
		<link>http://pedro.larroy.com/blog/?p=533</link>
		<comments>http://pedro.larroy.com/blog/?p=533#comments</comments>
		<pubDate>Mon, 30 Apr 2012 11:30:53 +0000</pubDate>
		<dc:creator>piotr</dc:creator>
				<category><![CDATA[computers]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://pedro.larroy.com/blog/?p=533</guid>
		<description><![CDATA[Choose the list of libraries with: b2 --show-libraries You will need then to use a bat file or similar with the following actions, the important points are to set the visual studio variables with vcvarsall.bat and then building boost with the list of libraries you will need: ECHO Setting Visual Studio environment CALL "c:\Program Files [...]]]></description>
			<content:encoded><![CDATA[<p>Choose the list of libraries with:<br />
<code><br />
b2 --show-libraries<br />
</code><br />
You will need then to use a bat file or similar with the following actions, the important points are to set the visual studio variables with vcvarsall.bat and then building boost with the list of libraries you will need:</p>
<p><code><br />
ECHO Setting Visual Studio environment<br />
CALL "c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64<br />
set BASE=%CD%</p>
<p>cd 3rd-party\boost<br />
ECHO Bootstrapping boost<br />
CALL bootstrap.bat<br />
ECHO Building boost</p>
<p>set ZLIB_INCLUDE="%BASE%\3rd-party\zlib"<br />
set ZLIB_SOURCE="%BASE%\3rd-party\zlib"</p>
<p>set LIBDIR="%BASE%\lib"<br />
mkdir %LIBDIR%</p>
<p>ECHO %BASE%</p>
<p>REM http://www.boost.org/boost-build2/doc/html/bbv2/overview/builtins/features.html<br />
REM bjam --toolset=msvc --build-type=complete address-model=64 --without-python --without-mpi --with-serialization define=arch:SSE2 link=shared threading=multi<br />
--stagedir="%BASE%"<br />
b2 -j8 --toolset=msvc --build-type=complete address-model=64 --with-serialization --with-thread --with-date_time --with-program_options --with-graph --with-file<br />
system --with-iostreams --with-test define=arch:SSE2 link=static threading=multi --stagedir="%BASE%"</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://pedro.larroy.com/blog/?feed=rss2&#038;p=533</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Small utility to send a KDE knotify message</title>
		<link>http://pedro.larroy.com/blog/?p=530</link>
		<comments>http://pedro.larroy.com/blog/?p=530#comments</comments>
		<pubDate>Tue, 17 Apr 2012 11:30:09 +0000</pubDate>
		<dc:creator>piotr</dc:creator>
				<category><![CDATA[computers]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[knotify]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://pedro.larroy.com/blog/?p=530</guid>
		<description><![CDATA[#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys import subprocess import dbus import time def usage(): sys.stderr.write('Sends a knotify notification\nusage: {0} [title] [text]\n'.format(sys.argv[0])) def main(): if len(sys.argv) != 3: usage() return 1 knotify = dbus.SessionBus().get_object("org.kde.knotify", "/Notify") id = knotify.event("warning", "kde", [], sys.argv[1], sys.argv[2], [], [], 0, 0, dbus_interface="org.kde.KNotify") time.sleep(3) knotify.closeNotification(id) return 0 [...]]]></description>
			<content:encoded><![CDATA[<p><code><br />
#!/usr/bin/env python<br />
# -*- coding: utf-8 -*-<br />
import os<br />
import sys<br />
import subprocess<br />
import dbus<br />
import time</p>
<p>def usage():<br />
    sys.stderr.write('Sends a knotify notification\nusage: {0} [title] [text]\n'.format(sys.argv[0]))</p>
<p>def main():<br />
    if len(sys.argv) != 3:<br />
        usage()<br />
        return 1</p>
<p>    knotify = dbus.SessionBus().get_object("org.kde.knotify", "/Notify")<br />
    id = knotify.event("warning", "kde", [], sys.argv[1], sys.argv[2], [], [], 0, 0, dbus_interface="org.kde.KNotify")<br />
    time.sleep(3)<br />
    knotify.closeNotification(id)<br />
    return 0</p>
<p>if __name__ == '__main__':<br />
    sys.exit(main())<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://pedro.larroy.com/blog/?feed=rss2&#038;p=530</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Boost sqlite performance from python</title>
		<link>http://pedro.larroy.com/blog/?p=526</link>
		<comments>http://pedro.larroy.com/blog/?p=526#comments</comments>
		<pubDate>Mon, 16 Apr 2012 08:10:47 +0000</pubDate>
		<dc:creator>piotr</dc:creator>
				<category><![CDATA[computers]]></category>
		<category><![CDATA[fast]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://pedro.larroy.com/blog/?p=526</guid>
		<description><![CDATA[SQLite from python too slow? If you are moving data from or to sqlite in python, you will find these settings useful as they can increase the performance by an order of magnitude. Refer to the documentation to check what they are configuring. # configure for fast writes lite_cur = lite_con.cursor() lite_cur.execute('PRAGMA synchronous = 0') [...]]]></description>
			<content:encoded><![CDATA[<p>SQLite from python too slow? If you are moving data from or to sqlite in python, you will find these settings useful as they can increase the performance by an order of magnitude. Refer to the documentation to check what they are configuring.<br />
<code></p>
<p>    # configure for fast writes<br />
    lite_cur = lite_con.cursor()<br />
    lite_cur.execute('PRAGMA synchronous = 0')<br />
    lite_cur.execute('PRAGMA cache_size = 64000')<br />
    lite_cur.execute('PRAGMA fullfsync = 0')<br />
    lite_cur.execute('PRAGMA journal_mode = OFF')<br />
    lite_cur.arraysize = 30000<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://pedro.larroy.com/blog/?feed=rss2&#038;p=526</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coding to the stars!  mycelium 1.0 released</title>
		<link>http://pedro.larroy.com/blog/?p=519</link>
		<comments>http://pedro.larroy.com/blog/?p=519#comments</comments>
		<pubDate>Mon, 26 Mar 2012 19:53:06 +0000</pubDate>
		<dc:creator>piotr</dc:creator>
				<category><![CDATA[computers]]></category>
		<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://pedro.larroy.com/blog/?p=519</guid>
		<description><![CDATA[The fastest web crawler in the galaxy Get it from github.]]></description>
			<content:encoded><![CDATA[<p><a href="http://pedro.larroy.com/pics/12030023.jpg"><img src="http://pedro.larroy.com/pics/12030023_small.jpg" alt="to the stars" /></a></p>
<h2>The fastest web crawler in the galaxy</h2>
<p>
Get it <a href="https://github.com/larroy/mycelium">from github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://pedro.larroy.com/blog/?feed=rss2&#038;p=519</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A nasty bug!</title>
		<link>http://pedro.larroy.com/blog/?p=516</link>
		<comments>http://pedro.larroy.com/blog/?p=516#comments</comments>
		<pubDate>Sun, 25 Mar 2012 23:33:45 +0000</pubDate>
		<dc:creator>piotr</dc:creator>
				<category><![CDATA[computers]]></category>
		<category><![CDATA[bugs]]></category>

		<guid isPermaLink="false">http://pedro.larroy.com/blog/?p=516</guid>
		<description><![CDATA[Today I spent several hours hunting a very nasty bug which was corrupting a boost::ptr_map in an evented program. The symptoms where a late crash in glibc free, by double delete. Valgrind wasn&#8217;t helping much, in the end I was able to track down the bug to calling boos::ptr_map::erase(obj->key); which holded obj. erase takes the [...]]]></description>
			<content:encoded><![CDATA[<p>Today I spent several hours hunting a very nasty bug which was corrupting a boost::ptr_map in an evented program. The symptoms where a late crash in glibc free, by double delete. Valgrind wasn&#8217;t helping much, in the end I was able to track down the bug to calling boos::ptr_map::erase(obj->key); which holded obj. erase takes the key by reference, and it became invalid in the middle of the erase. I tracked down by installing a couple of sentinels around the ptr_map and monitoring them with gdb.</p>
]]></content:encoded>
			<wfw:commentRss>http://pedro.larroy.com/blog/?feed=rss2&#038;p=516</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run sqlite tests in debian</title>
		<link>http://pedro.larroy.com/blog/?p=506</link>
		<comments>http://pedro.larroy.com/blog/?p=506#comments</comments>
		<pubDate>Mon, 19 Mar 2012 15:14:56 +0000</pubDate>
		<dc:creator>piotr</dc:creator>
				<category><![CDATA[computers]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://pedro.larroy.com/blog/?p=506</guid>
		<description><![CDATA[apt-get install tcl8.5-dev # in sqlite source dir: ./configure --with-tcl=/usr/lib/tcl8.5/ make make test]]></description>
			<content:encoded><![CDATA[<p><code><br />
apt-get install tcl8.5-dev<br />
# in sqlite source dir:<br />
./configure --with-tcl=/usr/lib/tcl8.5/<br />
make<br />
make test<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://pedro.larroy.com/blog/?feed=rss2&#038;p=506</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My mercurial habits</title>
		<link>http://pedro.larroy.com/blog/?p=495</link>
		<comments>http://pedro.larroy.com/blog/?p=495#comments</comments>
		<pubDate>Fri, 16 Mar 2012 08:25:45 +0000</pubDate>
		<dc:creator>piotr</dc:creator>
				<category><![CDATA[computers]]></category>
		<category><![CDATA[mercurial]]></category>

		<guid isPermaLink="false">http://pedro.larroy.com/blog/?p=495</guid>
		<description><![CDATA[I just read Mark Dominus&#8217; Git habits post, and I can&#8217;t help to add a post about mercurial habits. For me, mercurial is much more user-friendly than git and the commands are much more reasonable and easier to remember. I usually work in the following way, the default branch is the trunk/master branch. Then we [...]]]></description>
			<content:encoded><![CDATA[<p>I just read <a href="http://blog.plover.com/prog/git-habits.html">Mark Dominus&#8217; Git habits</a> post, and I can&#8217;t help to add a post about mercurial habits. For me, mercurial is much more user-friendly than git and the commands are much more reasonable and easier to remember.</p>
<p>I usually work in the following way, the <strong>default</strong> branch is the trunk/master branch. Then we create named feature branches such as &#8216;feat_[featurename]&#8216;, release branches as &#8216;release_[version]&#8216; and also branches for tickets with the same name as the ticket name, the name inside braces is a placeholder. The named branches are not a problem in mercurial since as long as they are not needed we close them with <code>hg ci --close-branch</code>.</p>
<p>Most common development loop:<br />
<code><br />
hg branch feat_somenicething<br />
 ...hack...<br />
hg commit -m "hack"<br />
 ...good?... integrate into default<br />
hg up default<br />
hg merge feat_somenicething<br />
</code></p>
<p>To get the branching point from default:<br />
<code><br />
hg log -r 'ancestor(default,.)'<br />
</code></p>
<p>And to check the full patch of your feature against default:<br />
<code><br />
hg up feat_somenicething<br />
hg diff -r 'ancestor(default,.)'<br />
</code></p>
<p>Sometimes I rebase some changes (x) onto (y) to make the history more linear, when for example pulling brings (y) that has parent (z) and I commited (x) with parent (z):<br />
z&#8212;-y<br />
 \&#8212;x<br />
<code><br />
hg rebase -s x -d y<br />
</code><br />
z&#8212;-y&#8212;-x</p>
<p>Shelve does the same as git stash, &#8216;shelves&#8217; away your local changes. You can also use it to move the patch to another branch.<br />
<code><br />
hg shelve<br />
</code></p>
<p>To view the history graphicaly I use tortoise hg, there&#8217;s also hgview:<br />
<code><br />
thg<br />
</code></p>
<p>And that&#8217;s mostly it. It&#8217;s pretty straightforward and easy.</p>
]]></content:encoded>
			<wfw:commentRss>http://pedro.larroy.com/blog/?feed=rss2&#038;p=495</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title></title>
		<link>http://pedro.larroy.com/blog/?p=490</link>
		<comments>http://pedro.larroy.com/blog/?p=490#comments</comments>
		<pubDate>Thu, 15 Mar 2012 23:21:11 +0000</pubDate>
		<dc:creator>piotr</dc:creator>
				<category><![CDATA[computers]]></category>
		<category><![CDATA[hope]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://pedro.larroy.com/blog/?p=490</guid>
		<description><![CDATA[Some programming language archeology: While moving to the new Nokia building in Berlin I found an old book (1989): &#8220;Functional programming&#8221; which belonged to one of our current vice presidents. It seems to be nice an clear about concepts and is specific to Hope, a predecessor of Miranda and Haskell. Surprisingly, the syntax of Hope [...]]]></description>
			<content:encoded><![CDATA[<p>Some programming language archeology: While moving to the <a href="http://www.flickr.com/photos/bopuc/6922844693/">new Nokia building</a> in Berlin  I found an old book (1989): <a href="http://www.barnesandnoble.com/w/functional-programming-anthony-j-field/1000552009">&#8220;Functional programming&#8221;</a> which belonged to one of our current vice presidents. It seems to be nice an clear about concepts and is specific to <a href="http://en.wikipedia.org/wiki/Hope_(programming_language)">Hope</a>, a predecessor of Miranda and Haskell. Surprisingly, the syntax of <a href="http://www.soi.city.ac.uk/~ross/Hope/">Hope</a> is quite amenable and even &#8216;pythonic&#8217;&#8230;  I started reading just out of curiosity, and now I feel as I found a little trasure.</p>
]]></content:encoded>
			<wfw:commentRss>http://pedro.larroy.com/blog/?feed=rss2&#038;p=490</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuration of additional mouse buttons in Linux Xorg</title>
		<link>http://pedro.larroy.com/blog/?p=484</link>
		<comments>http://pedro.larroy.com/blog/?p=484#comments</comments>
		<pubDate>Sun, 04 Mar 2012 11:57:03 +0000</pubDate>
		<dc:creator>piotr</dc:creator>
				<category><![CDATA[computers]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[shortcuts]]></category>

		<guid isPermaLink="false">http://pedro.larroy.com/blog/?p=484</guid>
		<description><![CDATA[I got a nice Logitech MX performance mouse, which I&#8217;m liking a lot. The only &#8216;but&#8217; is that the utilities to change unifying bindings are not open source, except for this small snippet. I pimped up some shortcuts for pasting different buffers of klipper: sh -c 'c=`qdbus org.kde.klipper /klipper getClipboardHistoryItem 1`; echo -n $c&#124; xvkbd [...]]]></description>
			<content:encoded><![CDATA[<p>I got a nice Logitech MX performance mouse, which I&#8217;m liking a lot. The only &#8216;but&#8217; is that the utilities to change unifying bindings are not open source, except for this <a href="http://groups.google.com/group/linux.kernel/msg/36c53d79832fc3f5?pli=1">small snippet</a>. I pimped up some shortcuts for pasting different buffers of klipper:<br />
<code><br />
sh -c 'c=`qdbus org.kde.klipper /klipper getClipboardHistoryItem 1`; echo -n $c| xvkbd -xsendevent -file - 2>/dev/null'<br />
</code><br />
And added some bindingsto xbindkeys to use the other buttons for browsing:<br />
<code></p>
<p>cat .xbindkeysrc<br />
# Mouse Buttons:<br />
# next page<br />
"xvkbd -xsendevent -text "\[XF86Back]""<br />
m:0x0 + b:8<br />
# previous page<br />
"xvkbd -xsendevent -text "\[XF86Forward]""<br />
m:0x0 + b:9<br />
# Switch tab on thumb<br />
"xvkbd -xsendevent -text "\[Control_L]\[Tab]""<br />
b:10<br />
# Close tab on thumb<br />
"xvkbd -xsendevent -text "\[Control_L]w""<br />
b:13<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://pedro.larroy.com/blog/?feed=rss2&#038;p=484</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open source code review I: libuv</title>
		<link>http://pedro.larroy.com/blog/?p=475</link>
		<comments>http://pedro.larroy.com/blog/?p=475#comments</comments>
		<pubDate>Sat, 18 Feb 2012 00:36:46 +0000</pubDate>
		<dc:creator>piotr</dc:creator>
				<category><![CDATA[computers]]></category>
		<category><![CDATA[libuv]]></category>
		<category><![CDATA[nodejs]]></category>
		<category><![CDATA[nodenative]]></category>

		<guid isPermaLink="false">http://pedro.larroy.com/blog/?p=475</guid>
		<description><![CDATA[I&#8217;d like to make series of posts reviewing interesting open source projects. Maybe also doing constructive criticism about other not so good aspects. In this post I&#8217;d like to write about a very interesting piece of code which is libuv. Libuv is the library that abstracts platform IO and networking for node.js. You might agree [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d like to make series of posts reviewing interesting open source projects. Maybe also doing constructive criticism about other not so good aspects. In this post I&#8217;d like to write about a very interesting piece of code which is <a href="https://github.com/joyent/libuv" title="libuv">libuv</a>. Libuv is the library that abstracts platform IO and networking for <a href="http://nodejs.org/"><strong>node.js</strong></a>. You might agree or not with the node.js guys about if javascript is a good language for the server or not. Languagewise wars aside, I think there are very interesting ideas behind the node.js movement, the main one is non-blocking IO and events.</p>
<p><span id="more-475"></span></p>
<p>Libuv is claimed to work on Linux, MacOS, Windows (MinGW, VS) and Solaris. They have abstracted platform detail for event based IO not only for networking, but even for filesystem operations you can code callbacks to perform actions asynchronously when they finish. It&#8217;s being used also in other interesting projects such as <a href="https://github.com/d5/node.native"><strong>Node Native</strong></a>, which is similar to node.js in spirit but done instead in C++11.</p>
<p>Evented IO is good, it&#8217;s not difficult to program since usually you make small callbacks that responds to reading or writing a buffer, or to an event in a file or a socket. They are much better alternative to spawning threads just to let them block waiting for IO for the following reasons:</p>
<ul>
<li>It&#8217;s inefficient: thread creation is not so cheap</li>
<li>It <a href="http://www.kegel.com/c10k.html">doesn&#8217;t scale</a></li>
<li>It&#8217;s using the wrong tool for the job, threads should be used to exploit processing parallelism.</li>
<li>It exposes your program to potential concurrency pitfalls, which are very costly to debug.</li>
</ul>
<p><strong>Build system:</strong><br />
Libuv uses Makefiles and <a href="http://code.google.com/p/gyp/">GYP</a> as a meta-buildsystem to generate Makefiles, VS projects and XCode projects. The build system is on the small side of things, so although I&#8217;m not a big fan of Make,  I prefer better tooks like <a href="http://www.scons.org/">SCons</a>. But I wouldn&#8217;t say it&#8217;s a big deal for this project. Then supposedly, as per GYP you should be able to generate project files for the more clickety tools and OSes. So as per keeping the Makefiles simple and using a more modern tool such as GYP the balance on this point is positive.</p>
<p><strong>Code and capabilities:</strong><br />
The library is programmed in vanilla C. For this task I think it&#8217;s the right tool for the job, ensuring portability and easy mantainability. I&#8217;d say the quality of the code is in general good. <a href="https://github.com/joyent/libuv/blob/master/include/uv.h">The interface</a> is well abstracted and consistent. On unix variants it abstracts <a href="http://software.schmorp.de/pkg/libev.html">libev</a> for evented IO. And in Windows it abstracts <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa365198(v=vs.85).aspx">completion ports</a>. It also uses <a href="http://c-ares.haxx.se/">c-ares</a> library under the hood to do asynchronous DNS queries.</p>
<p>I find very interesting that the library takes the asynchronous paradigm fully radical up to the point that you can even create a directory asynchronously. You might not think that it&#8217;s so important to create a directory non-blocking, but if your IO system is under heavy load, just creating a dir might suspend the application for several seconds!</p>
<p>It also has a very basic interface for creating a joining threads:<br />
<code><br />
int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg);<br />
int uv_thread_join(uv_thread_t *tid);<br />
</code><br />
Also supports mutexes and locks.</p>
<p>It has also dynamic symbol loading capabilities.</p>
<p><strong>License:</strong><br />
The library is dual MIT / GPL,  and two clause BSD license for some parts.</p>
<p><strong>Valoration:</strong><br />
In all, a very nice, useful library which facilitates the right programming pattern for IO. Strongly recommended. Rating: 8.5/10</p>
]]></content:encoded>
			<wfw:commentRss>http://pedro.larroy.com/blog/?feed=rss2&#038;p=475</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

