<?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>Pierre-Luc Bacon</title>
	<atom:link href="http://pierrelucbacon.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://pierrelucbacon.com</link>
	<description></description>
	<lastBuildDate>Sat, 19 Nov 2011 19:59:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Asynchronous timer expiry notification or “how awesome timerfd and epoll are”</title>
		<link>http://pierrelucbacon.com/2011/11/19/asynchronous-timer-expiry-notification-or-how-awesome-timerfd-and-epoll-are/</link>
		<comments>http://pierrelucbacon.com/2011/11/19/asynchronous-timer-expiry-notification-or-how-awesome-timerfd-and-epoll-are/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 19:47:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pierrelucbacon.com/?p=324</guid>
		<description><![CDATA[In some recent TCP experiment that I carried in the user space, I faced the problem of generating relatively precise timer events in an asynchronous way. Furthermore, multiple timers had to be maintained simultaneously. The timerfd mechanism in Linux (man timerfd_create(2)) allows one to create different types of timers that communicate expiry events through a file [...]]]></description>
			<content:encoded><![CDATA[<p>In some recent TCP experiment that I carried in the user space, I faced the problem of generating relatively precise timer events in an asynchronous way. Furthermore, multiple timers had to be maintained simultaneously.</p>
<p>The timerfd mechanism in Linux (<a href="http://kernel.org/doc/man-pages/online/pages/man2/timerfd_create.2.html">man timerfd_create(2)</a>) allows one to create different types of timers that communicate expiry events through a file descriptor. The standard <strong>read()</strong>, <strong>select()</strong>, <strong>poll()</strong> functions can then be used to detect and process the expiration notifications. As for the clock granularity, with CLOCK_REALTIME and with High Resolution Timer (HRT) support, I get very respectable 1.000000e-09 seconds on my system. To see this, you can compile (using the <strong>–lrt</strong> flag) and run the following :</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include </span>
<span style="color: #339933;">#include </span>
<span style="color: #339933;">#include </span>
&nbsp;
<span style="color: #993333;">int</span> main<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: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;System Clock Granularity %ld<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> sysconf<span style="color: #009900;">&#40;</span>_SC_CLK_TCK<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #993333;">struct</span> timespec gran<span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>clock_getres<span style="color: #009900;">&#40;</span>CLOCK_MONOTONIC<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>gran<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        perror<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;clock_getres()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;CLOCK_MONOTONIC granularity %ld %ld<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> gran.<span style="color: #202020;">tv_sec</span><span style="color: #339933;">,</span> gran.<span style="color: #202020;">tv_nsec</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Both periodic and non-periodic timers can be created a timer obtained through <a href="http://kernel.org/doc/man-pages/online/pages/man2/timerfd_create.2.html">timerfd_create()</a>. This behavior is configurable via the itermerspec structure passed as an argument to the <a href="http://kernel.org/doc/man-pages/online/pages/man2/timer_settime.2.html">timerfd_settime()</a> function:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">    <span style="color: #993333;">struct</span> itimerspec timerSpec<span style="color: #339933;">;</span>
    memset<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>timerSpec<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>timerSpec<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    timerSpec.<span style="color: #202020;">it_value</span>.<span style="color: #202020;">tv_sec</span> <span style="color: #339933;">=</span> sec<span style="color: #339933;">;</span>
    timerSpec.<span style="color: #202020;">it_value</span>.<span style="color: #202020;">tv_nsec</span> <span style="color: #339933;">=</span> nsec<span style="color: #339933;">;</span>
&nbsp;
    timerSpec.<span style="color: #202020;">it_interval</span>.<span style="color: #202020;">tv_sec</span> <span style="color: #339933;">=</span> intsec<span style="color: #339933;">;</span>
    timerSpec.<span style="color: #202020;">it_interval</span>.<span style="color: #202020;">tv_nsec</span> <span style="color: #339933;">=</span> intnsec<span style="color: #339933;">;</span></pre></div></div>

<p>Whenever the it_value field has both its <em>tv_sec</em> and <em>tv_nsec</em> fields set to 0, the timer is effectively disarmed and no future timer expiry events should take place.</p>
<p>Once a timer has been set, <a href="http://kernel.org/doc/man-pages/online/pages/man2/read.2.html">read()</a> will report the number of timer expirations events that have occurred since the last call.</p>
<h2>Epoll</h2>
<p>Having the ability to generate timer events, wouldn’t be nice if we could only register a callback function that would get call automatically from the <em>outside</em> to handle any processing that would have to be done ?</p>
<p>Linux provides the <a href="http://kernel.org/doc/man-pages/online/pages/man7/epoll.7.html">epoll</a> functionality which appears much more elegant and easy to use that its traditional select() counterpart. Even better maybe, it is said to be O(1) versus O(n) : this claim is reported <a href="http://kovyrin.net/2006/04/13/epoll-asynchronous-network-programming/">here</a> then taken to <a href="http://en.wikipedia.org/wiki/Epoll#cite_note-1">Wikipedia</a> and discussed on <a href="http://stackoverflow.com/questions/6474602/does-epoll-do-its-job-in-o1">Stackoverflow</a>. </p>
<p>One cool thing for sure is its ability to deliver event notifications on the set of file descriptors that it watches under either <em>edge</em> or <em>level-triggered</em> modes. In the first case, <a href="http://kernel.org/doc/man-pages/online/pages/man2/epoll_wait.2.html">epoll_wait()</a> (normally a blocking call that you would place in a mainloop) will return as long as there is remaining data on one of its file descriptor. By contrast, when one sets the <strong>EPOLLONESHOT</strong> flag, epoll_wait() will generate only one event after which the associated file descriptor will be disabled.</p>
<h2>Cooking up the final solution</h2>
<p>Before going any further : yes <a href="http://libevent.org/">libevent</a> exists and also uses epoll. The point here is not to use it.</p>
<p>Back to the initial goal of generating timer expiry notifications asynchronously via callbacks, we only have to register the file descriptor associated with our instantiated timerfd elements to epoll with <a href="http://kernel.org/doc/man-pages/online/pages/man2/epoll_ctl.2.html">epoll_ctl()</a> and the <strong>EPOLL_CTL_ADD</strong> flag. Then run the <strong>epoll_wait()</strong> in a loop and you almost have a complete solution. </p>
<p>Two problems then remain : how do you keep track of which callback function (together with the arguments to pass) goes with a given timer, and finally how do you avoid blocking you application on epoll_wait() ? The latter can be easily solved by wrapping our mainloop in a thread (with the necessary thread-safety precautions): DONE. For the former, epoll_ctl() delights us with its epoll_data_t union member of the epoll_event structure.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">    <span style="color: #993333;">typedef</span> <span style="color: #993333;">union</span> epoll_data <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">void</span>        <span style="color: #339933;">*</span>ptr<span style="color: #339933;">;</span>
        <span style="color: #993333;">int</span>          fd<span style="color: #339933;">;</span>
        <span style="color: #993333;">uint32_t</span>     u32<span style="color: #339933;">;</span>
        <span style="color: #993333;">uint64_t</span>     u64<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> epoll_data_t<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #993333;">struct</span> epoll_event <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">uint32_t</span>     events<span style="color: #339933;">;</span>      <span style="color: #808080; font-style: italic;">/* Epoll events */</span>
        epoll_data_t data<span style="color: #339933;">;</span>        <span style="color: #808080; font-style: italic;">/* User data variable */</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>“<strong>void *ptr</strong>” you said ? Yep that’s it : here’s our function pointer. Since epoll_data is a union, we will probably want to record more than one element under ptr. To do so, we can wrap all the information we need under a structure such as :</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">typedef</span> <span style="color: #993333;">struct</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">int</span> tfd<span style="color: #339933;">;</span>
    <span style="color: #993333;">void</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>timed_action_handler<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">void</span><span style="color: #339933;">*</span> arg<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> timed_action_t<span style="color: #339933;">;</span></pre></div></div>

<p>Now when epoll_wait() unblocks we will be able to get access to the associated epoll_event and execute the callback passing its <em>arg</em> argument from the <strong>timed_action_t</strong> structure.</p>
<h2>GitHub</h2>
<p>You can checkout a sketch of the approach explained above at <a href="https://github.com/pierrelux/timedaction">https://github.com/pierrelux/timedaction</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pierrelucbacon.com/2011/11/19/asynchronous-timer-expiry-notification-or-how-awesome-timerfd-and-epoll-are/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Applying a function to every row or column of a matrix in Matlab</title>
		<link>http://pierrelucbacon.com/2011/10/12/applying-a-function-to-every-row-or-column-of-a-matrix-in-matlab/</link>
		<comments>http://pierrelucbacon.com/2011/10/12/applying-a-function-to-every-row-or-column-of-a-matrix-in-matlab/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 00:46:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pierrelucbacon.com/?p=305</guid>
		<description><![CDATA[Sure we have arrayfun, but it applies a function every element of a matrix. What if we want to compute the sum over each row or column for example ? The trick that I’m presenting here lies in the use of the num2cell function. In the example below, we add a 1x4 vector to every [...]]]></description>
			<content:encoded><![CDATA[<p>Sure we have arrayfun, but it applies a function every element of a matrix. What if we want to compute the sum over each row or column for example ?</p>
<p>The trick that I’m presenting here lies in the use of the num2cell function.</p>
<p>In the example below, we add a 1x4 vector to every row of a matrix A.</p>

<div class="wp_syntax"><div class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; A = <span style="color: #0000FF;">magic</span><span style="color: #080;">&#40;</span><span style="color: #33f;">4</span><span style="color: #080;">&#41;</span>
A =
&nbsp;
    <span style="color: #33f;">16</span>     <span style="color: #33f;">2</span>     <span style="color: #33f;">3</span>    <span style="color: #33f;">13</span>
     <span style="color: #33f;">5</span>    <span style="color: #33f;">11</span>    <span style="color: #33f;">10</span>     <span style="color: #33f;">8</span>
     <span style="color: #33f;">9</span>     <span style="color: #33f;">7</span>     <span style="color: #33f;">6</span>    <span style="color: #33f;">12</span>
     <span style="color: #33f;">4</span>    <span style="color: #33f;">14</span>    <span style="color: #33f;">15</span>     <span style="color: #33f;">1</span>
&nbsp;
&gt;&gt; y = <span style="color: #080;">&#91;</span><span style="color: #33f;">1</span> <span style="color: #33f;">2</span> <span style="color: #33f;">3</span> <span style="color: #33f;">4</span><span style="color: #080;">&#93;</span>;
&gt;&gt; B = <span style="color: #0000FF;">cellfun</span><span style="color: #080;">&#40;</span>@<span style="color: #080;">&#40;</span>x<span style="color: #080;">&#41;</span><span style="color: #080;">&#40;</span>x + y<span style="color: #080;">&#41;</span>, <span style="color: #0000FF;">num2cell</span><span style="color: #080;">&#40;</span>A, <span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>, ‘Uni­<span style="color: #0000FF;">for</span>­mOut­put’, false<span style="color: #080;">&#41;</span>
&nbsp;
B = 
&nbsp;
    <span style="color: #080;">&#91;</span>1x4 <span style="color: #0000FF;">double</span><span style="color: #080;">&#93;</span>
    <span style="color: #080;">&#91;</span>1x4 <span style="color: #0000FF;">double</span><span style="color: #080;">&#93;</span>
    <span style="color: #080;">&#91;</span>1x4 <span style="color: #0000FF;">double</span><span style="color: #080;">&#93;</span>
    <span style="color: #080;">&#91;</span>1x4 <span style="color: #0000FF;">double</span><span style="color: #080;">&#93;</span>
&nbsp;
&gt;&gt; cell2mat<span style="color: #080;">&#40;</span>B<span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #0000FF;">ans</span> =
&nbsp;
    <span style="color: #33f;">17</span>     <span style="color: #33f;">4</span>     <span style="color: #33f;">6</span>    <span style="color: #33f;">17</span>
     <span style="color: #33f;">6</span>    <span style="color: #33f;">13</span>    <span style="color: #33f;">13</span>    <span style="color: #33f;">12</span>
    <span style="color: #33f;">10</span>     <span style="color: #33f;">9</span>     <span style="color: #33f;">9</span>    <span style="color: #33f;">16</span>
     <span style="color: #33f;">5</span>    <span style="color: #33f;">16</span>    <span style="color: #33f;">18</span>     <span style="color: #33f;">5</span></pre></div></div>

<p>If we wanted to do a similar operation but this time over the columns, we would write num2cell(A, 1) : “1” instead of “2”. </p>
]]></content:encoded>
			<wfw:commentRss>http://pierrelucbacon.com/2011/10/12/applying-a-function-to-every-row-or-column-of-a-matrix-in-matlab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Indexing Diagonal Matrix Elements  in Matlab</title>
		<link>http://pierrelucbacon.com/2011/09/28/indexing-diagonal-matrix-elements-in-matlab/</link>
		<comments>http://pierrelucbacon.com/2011/09/28/indexing-diagonal-matrix-elements-in-matlab/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 02:46:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pierrelucbacon.com/?p=273</guid>
		<description><![CDATA[I have came across this problem very often, but always ended up solving it in a different way each time. Here is what looks to me to be the most concise way of doing it. Indexing the diagonal &#38;gt;&#38;gt; A = magic&#40;4&#41; A = 16 2 3 13 5 11 10 8 9 7 6 [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;">
<p>I have came across this problem very often, but always ended up solving it in a different way each time. Here is what looks to me to be the most concise way of doing it.</p>
<h4>Indexing the diagonal</h4>

<div class="wp_syntax"><div class="code"><pre class="matlab" style="font-family:monospace;">&amp;gt;&amp;gt; A = <span style="color: #0000FF;">magic</span><span style="color: #080;">&#40;</span><span style="color: #33f;">4</span><span style="color: #080;">&#41;</span>
A =
    <span style="color: #33f;">16</span>     <span style="color: #33f;">2</span>     <span style="color: #33f;">3</span>    <span style="color: #33f;">13</span>
     <span style="color: #33f;">5</span>    <span style="color: #33f;">11</span>    <span style="color: #33f;">10</span>     <span style="color: #33f;">8</span>
     <span style="color: #33f;">9</span>     <span style="color: #33f;">7</span>     <span style="color: #33f;">6</span>    <span style="color: #33f;">12</span>
     <span style="color: #33f;">4</span>    <span style="color: #33f;">14</span>    <span style="color: #33f;">15</span>     <span style="color: #33f;">1</span>
&nbsp;
&amp;gt;&amp;gt; A<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:<span style="color: #0000FF;">length</span><span style="color: #080;">&#40;</span>A<span style="color: #080;">&#41;</span>+<span style="color: #33f;">1</span>:numel<span style="color: #080;">&#40;</span>A<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">ans</span> =
    <span style="color: #33f;">16</span>    <span style="color: #33f;">11</span>     <span style="color: #33f;">6</span>     <span style="color: #33f;">1</span>
&nbsp;
&amp;gt;&amp;gt; A<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:<span style="color: #0000FF;">length</span><span style="color: #080;">&#40;</span>A<span style="color: #080;">&#41;</span>+<span style="color: #33f;">1</span>:numel<span style="color: #080;">&#40;</span>A<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> = <span style="color: #33f;">1</span>
A =
     <span style="color: #33f;">1</span>     <span style="color: #33f;">2</span>     <span style="color: #33f;">3</span>    <span style="color: #33f;">13</span>
     <span style="color: #33f;">5</span>     <span style="color: #33f;">1</span>    <span style="color: #33f;">10</span>     <span style="color: #33f;">8</span>
     <span style="color: #33f;">9</span>     <span style="color: #33f;">7</span>     <span style="color: #33f;">1</span>    <span style="color: #33f;">12</span>
     <span style="color: #33f;">4</span>    <span style="color: #33f;">14</span>    <span style="color: #33f;">15</span>     <span style="color: #33f;">1</span></pre></div></div>

<h4>Selecting off-diagonal entries</h4>

<div class="wp_syntax"><div class="code"><pre class="matlab" style="font-family:monospace;">&amp;gt;&amp;gt; A = <span style="color: #0000FF;">magic</span><span style="color: #080;">&#40;</span><span style="color: #33f;">4</span><span style="color: #080;">&#41;</span>
A =
    <span style="color: #33f;">16</span>     <span style="color: #33f;">2</span>     <span style="color: #33f;">3</span>    <span style="color: #33f;">13</span>
     <span style="color: #33f;">5</span>    <span style="color: #33f;">11</span>    <span style="color: #33f;">10</span>     <span style="color: #33f;">8</span>
     <span style="color: #33f;">9</span>     <span style="color: #33f;">7</span>     <span style="color: #33f;">6</span>    <span style="color: #33f;">12</span>
     <span style="color: #33f;">4</span>    <span style="color: #33f;">14</span>    <span style="color: #33f;">15</span>     <span style="color: #33f;">1</span>
&nbsp;
&amp;gt;&amp;gt; A<span style="color: #080;">&#40;</span><span style="color: #0000FF;">setdiff</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span>:numel<span style="color: #080;">&#40;</span>A<span style="color: #080;">&#41;</span>, <span style="color: #33f;">1</span>:<span style="color: #0000FF;">length</span><span style="color: #080;">&#40;</span>A<span style="color: #080;">&#41;</span>+<span style="color: #33f;">1</span>:numel<span style="color: #080;">&#40;</span>A<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> = <span style="color: #33f;">0</span>
A =
    <span style="color: #33f;">16</span>     <span style="color: #33f;">0</span>     <span style="color: #33f;">0</span>     <span style="color: #33f;">0</span>
     <span style="color: #33f;">0</span>    <span style="color: #33f;">11</span>     <span style="color: #33f;">0</span>     <span style="color: #33f;">0</span>
     <span style="color: #33f;">0</span>     <span style="color: #33f;">0</span>     <span style="color: #33f;">6</span>     <span style="color: #33f;">0</span>
     <span style="color: #33f;">0</span>     <span style="color: #33f;">0</span>     <span style="color: #33f;">0</span>     <span style="color: #33f;">1</span>
&amp;gt;&amp;gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://pierrelucbacon.com/2011/09/28/indexing-diagonal-matrix-elements-in-matlab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Latex your instant messaging</title>
		<link>http://pierrelucbacon.com/2009/12/16/latex-your-instant-messaging/</link>
		<comments>http://pierrelucbacon.com/2009/12/16/latex-your-instant-messaging/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 18:12:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pierrelucbacon.com/?p=267</guid>
		<description><![CDATA[Probably one of the most useful thing that I’ve discovered this month: http://sourceforge.net/projects/pidgin-latex/ Pidgin-latex lets you write Latex code normally in your chat conversation and renders the result in real time. For both parties to be able to see the result, they will have to install this plugin or any other one that is handling [...]]]></description>
			<content:encoded><![CDATA[<p>Probably one of the most useful thing that I’ve discovered this month:</p>
<p><a title="Pidgin Latex" href="http://sourceforge.net/projects/pidgin-latex/  ">http://sourceforge.net/projects/pidgin-latex/</a></p>
<p>Pidgin-latex lets you write Latex code normally in your chat conversation and renders the result in real time.</p>
<p>For both parties to be able to see the result, they will have to install this plugin or any other one that is handling the mime type latex.</p>
<p>To switch to math mode, it suffices to enclose the content between “$$” symbols.</p>
<p><img class="size-full wp-image-268 alignnone" title="latex-pidgin" src="http://pierrelucbacon.com/wp-content/uploads/2009/12/latex-pidgin.png" alt="latex-pidgin" width="333" height="354" /></p>
<p>The install process is straightforward. No trick needed. Just follow the one line instruction from the README.</p>
]]></content:encoded>
			<wfw:commentRss>http://pierrelucbacon.com/2009/12/16/latex-your-instant-messaging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tilda: The ubiquitous drop-down terminal</title>
		<link>http://pierrelucbacon.com/2009/10/24/tilda-the-ubiquitous-drop-down-terminal/</link>
		<comments>http://pierrelucbacon.com/2009/10/24/tilda-the-ubiquitous-drop-down-terminal/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 06:19:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pierrelucbacon.com/?p=265</guid>
		<description><![CDATA[I was commenting on Guake in http://pierrelucbacon.com/2008/09/19/3-useful-applications/ but found that it was slightly buggy and polluting the tray in the top panel under gnome with its icon. A few weeks ago, I stumbled upon Tilda which turned out to be at least equally, and so far, much more usable and interesting to use than Guake. My [...]]]></description>
			<content:encoded><![CDATA[<p>I was commenting on Guake in <a href="http://">http://pierrelucbacon.com/2008/09/19/3-useful-applications/</a> but found that it was slightly buggy and polluting the tray in the top panel under gnome with its icon.</p>
<p>A few weeks ago, I stumbled upon <a href="http://tilda.sourceforge.net/wiki/index.php/Main_Page">Tilda</a> which turned out to be at least equally, and so far, much more usable and interesting to use than Guake. My point behind this is that I loved the fact that the GUI is kept just as clean as I like it: a black border-less window.</p>
<p>Currently on my system, Tilda is launched at startup (System-&gt;Preferences-&gt;Startup Applications) and is invoked with SUPER-A on the keyboard.</p>
<p>It’s good to have an unobtrusive terminal at the tip of our fingers anytime you need it.</p>
<p>Here is a little screencast to give you  a sense of how it can interact on your desktop:</p>
<p><object width="425" height="350" data="http://www.youtube.com/v/6XDRU6nxP1M" type="application/x-shockwave-flash"><param name="src" value="http://www.youtube.com/v/6XDRU6nxP1M" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://pierrelucbacon.com/2009/10/24/tilda-the-ubiquitous-drop-down-terminal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PGF and Expected Value of the Poisson Distribution</title>
		<link>http://pierrelucbacon.com/2009/05/24/pgf-and-expected-value-of-the-poisson-distribution/</link>
		<comments>http://pierrelucbacon.com/2009/05/24/pgf-and-expected-value-of-the-poisson-distribution/#comments</comments>
		<pubDate>Sun, 24 May 2009 20:56:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pierrelucbacon.com/?p=231</guid>
		<description><![CDATA[Probability Generating Function for the Poisson Distribution Let p(y) be the probability generating function for Y. Expected Value of the Poisson Distribution]]></description>
			<content:encoded><![CDATA[<h3>Probability Generating Function for the Poisson Distribution</h3>
<p>Let p(y) be the probability generating function for Y.</p>
<img src='http://s.wordpress.com/latex.php?latex=%20%5Cbegin%7Baligned%7D%20p_y%28t%29%20%3D%20E%28t%5Ey%29%20%26%3D%20%7B%5Csum_%7By%3D0%7D%5E%7B%5Cinfty%7D%7D%20t%5Ey%20p%28y%29%20%5C%5C%20%26%3D%20%5Csum_%7By%3D0%7D%5E%7B%5Cinfty%7D%20t%5E%7By%7D%20%5Clambda%5E%7By%7De%5E%7B-%5Clambda%7D%20%5C%5C%20%26%3D%20e%5E%7B-%5Clambda%7D%5Csum_%7By%3D0%7D%5E%7B%5Cinfty%7D%20%7B%7Bt%5E%7By%7D%5Clambda%5E%7By%7D%7D%20%5Cover%20%7By%21%7D%7D%20%5C%5C%20%26%3D%20e%5E%7B-%5Clambda%7D%5Csum_%7By%3D0%7D%5E%7B%5Cinfty%7D%20%7B%28t%5Clambda%29%5E%7By%7D%20%5Cover%20%7By%21%7D%7D%20~~~~%5Cmbox%7BPower%20Series%7D%5C%5C%26%3D%20e%5E%7B-%5Clambda%7De%5E%7Bt%5Clambda%7D%20%5C%5C%26%3D%20e%5E%7Bt%5Clambda%20-%20%5Clambda%7D%20%5C%5C%26%3D%20e%5E%7B%5Clambda%28t-1%29%7D%5Cend%7Baligned%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt=' \begin{aligned} p_y(t) = E(t^y) &amp;= {\sum_{y=0}^{\infty}} t^y p(y) \\ &amp;= \sum_{y=0}^{\infty} t^{y} \lambda^{y}e^{-\lambda} \\ &amp;= e^{-\lambda}\sum_{y=0}^{\infty} {{t^{y}\lambda^{y}} \over {y!}} \\ &amp;= e^{-\lambda}\sum_{y=0}^{\infty} {(t\lambda)^{y} \over {y!}} ~~~~\mbox{Power Series}\\&amp;= e^{-\lambda}e^{t\lambda} \\&amp;= e^{t\lambda - \lambda} \\&amp;= e^{\lambda(t-1)}\end{aligned}' title=' \begin{aligned} p_y(t) = E(t^y) &amp;= {\sum_{y=0}^{\infty}} t^y p(y) \\ &amp;= \sum_{y=0}^{\infty} t^{y} \lambda^{y}e^{-\lambda} \\ &amp;= e^{-\lambda}\sum_{y=0}^{\infty} {{t^{y}\lambda^{y}} \over {y!}} \\ &amp;= e^{-\lambda}\sum_{y=0}^{\infty} {(t\lambda)^{y} \over {y!}} ~~~~\mbox{Power Series}\\&amp;= e^{-\lambda}e^{t\lambda} \\&amp;= e^{t\lambda - \lambda} \\&amp;= e^{\lambda(t-1)}\end{aligned}' class='latex' />
<h3>Expected Value of the Poisson Distribution</h3>
<img src='http://s.wordpress.com/latex.php?latex=%20%5Cbegin%7Baligned%7DE%28Y%29%20%3D%20%5Cmu_%7B%5B1%5D%7D%20%26%3D%20%7B%5Cfrac%7Bd%28P_%7By%7D%28t%29%7D%7Bdt%7D%7D%5Cleft.%7B%5C%21%5C%21%5Cfrac%7B%7D%7B%7D%7D%5Cright%7C_%7Bt%3D1%7D%5C%5C%26%3D%20%7B%5Cfrac%7Bd%28e%5E%7B%5Clambda%28t-1%29%7D%29%7D%7Bdt%7D%7D%5Cleft.%7B%5C%21%5C%21%5Cfrac%7B%7D%7B%7D%7D%5Cright%7C_%7Bt%3D1%7D%5C%5C%26%3D%20%7Be%5E%7B%5Clambda%28t-1%29%7D%20%5Ccdot%20%5Clambda%7D%5Cleft.%7B%5C%21%5C%21%5Cfrac%7B%7D%7B%7D%7D%5Cright%7C_%7Bt%3D1%7D%5C%5C%26%3D%20%5Clambda%5Cend%7Baligned%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt=' \begin{aligned}E(Y) = \mu_{[1]} &amp;= {\frac{d(P_{y}(t)}{dt}}\left.{\!\!\frac{}{}}\right|_{t=1}\\&amp;= {\frac{d(e^{\lambda(t-1)})}{dt}}\left.{\!\!\frac{}{}}\right|_{t=1}\\&amp;= {e^{\lambda(t-1)} \cdot \lambda}\left.{\!\!\frac{}{}}\right|_{t=1}\\&amp;= \lambda\end{aligned}' title=' \begin{aligned}E(Y) = \mu_{[1]} &amp;= {\frac{d(P_{y}(t)}{dt}}\left.{\!\!\frac{}{}}\right|_{t=1}\\&amp;= {\frac{d(e^{\lambda(t-1)})}{dt}}\left.{\!\!\frac{}{}}\right|_{t=1}\\&amp;= {e^{\lambda(t-1)} \cdot \lambda}\left.{\!\!\frac{}{}}\right|_{t=1}\\&amp;= \lambda\end{aligned}' class='latex' />
]]></content:encoded>
			<wfw:commentRss>http://pierrelucbacon.com/2009/05/24/pgf-and-expected-value-of-the-poisson-distribution/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Merging pdf files together</title>
		<link>http://pierrelucbacon.com/2009/04/22/merging-pdf-files-together/</link>
		<comments>http://pierrelucbacon.com/2009/04/22/merging-pdf-files-together/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 17:20:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pierrelucbacon.com/?p=229</guid>
		<description><![CDATA[From the gs package in Ubuntu: gs –dBATCH –dNOPAUSE –q –sDEVICE=pdfwrite –sOutputFile=outputMerged.pdf file1.pdf file2.pdf jPdf Tweak, the “Swiss Army Knife for PDF files”, is also a great tool and run out of the box with Java but it might be faster just using the above command rather than browsing through jpdftweak’s GUI.]]></description>
			<content:encoded><![CDATA[<p>From the gs package in Ubuntu:</p>
<p>gs –dBATCH –dNOPAUSE –q –sDEVICE=pdfwrite –sOutputFile=outputMerged.pdf file1.pdf file2.pdf</p>
<p><a title="Jpdf Tweak" href="http://jpdftweak.sourceforge.net/">jPdf Tweak</a>, the “Swiss Army Knife for PDF files”, is also a great tool and run out of the box with Java but it might be faster just using the above command rather than browsing through jpdftweak’s GUI.</p>
]]></content:encoded>
			<wfw:commentRss>http://pierrelucbacon.com/2009/04/22/merging-pdf-files-together/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing a LaTeX package under Ubuntu</title>
		<link>http://pierrelucbacon.com/2009/04/20/installing-a-latex-package-under-ubuntu/</link>
		<comments>http://pierrelucbacon.com/2009/04/20/installing-a-latex-package-under-ubuntu/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 21:06:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pierrelucbacon.com/?p=226</guid>
		<description><![CDATA[In two easy steps: Download, extract and create a directory under /usr/share/texmf-texlive/tex/latex/ if necessary. Copy the entire directory, or the single .sty file to that location. (You need to be root) Run “sudo mktexlsr” From the man pages: mktexlsr is used to generate the ls-R databases used by the kpathsea library.  Kpathsea: A library for [...]]]></description>
			<content:encoded><![CDATA[<p>In two easy steps:</p>
<ol>
<li>Download, extract and create a directory under <strong>/usr/share/texmf-texlive/tex/latex/</strong> if necessary. Copy the entire directory, or the single .sty file to that location. (You need to be root)</li>
<li>Run “<strong>sudo mktexlsr</strong>”</li>
</ol>
<p>From the man pages:</p>
<blockquote><p>mktexlsr  is  used  to generate the ls-R databases used by the kpathsea library.  Kpathsea: A library for path searching.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://pierrelucbacon.com/2009/04/20/installing-a-latex-package-under-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RDI en direct sous Linux</title>
		<link>http://pierrelucbacon.com/2009/01/29/rdi-en-direct-sous-linux/</link>
		<comments>http://pierrelucbacon.com/2009/01/29/rdi-en-direct-sous-linux/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 02:05:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[francais]]></category>
		<category><![CDATA[gossage]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://pierrelucbacon.com/?p=167</guid>
		<description><![CDATA[Depuis quelques temps, j’arrive à écouter sans problème le flux video de Radio-Canada sous Ubuntu Linux. Il en va pas de même avec tous les vidéos sur le site cependant. Je ne sais trop comment je suis abouti à la bonne configuration. Dans tout les cas, il faut se procurer les codecs appropriés dans les [...]]]></description>
			<content:encoded><![CDATA[<p>Depuis quelques temps, j’arrive à écouter sans problème le flux video de Radio-Canada sous Ubuntu Linux. Il en va pas de même avec tous les vidéos sur le site cependant.</p>
<p>Je ne sais trop comment je suis abouti à la bonne configuration. Dans tout les cas, il faut se procurer les codecs appropriés dans les bons canaux d’abord (restricted), et ensuite installer Mplayer et Mplayer-plugin.</p>
<p>Ensuite, on peut lancer Mplayer directement en ligne de commande, ou en créant un “lanceur” sur l’espace de bureau de Gnome. C’est ce que j’ai fini par faire puisque j’oubliais toujours l’adresse. Alors, la voilà, justement:</p>
<p><code>mplayer -playlist http://www.radio-canada.ca/util/endirect/rdidirect.asx</code></p>
<p>Un logo svg de Radio-Canada peut être trouvé ici <a href="http://upload.wikimedia.org/wikipedia/fr/thumb/9/92/Logo_Television_de_Radio-Canada.svg/617px-Logo_Television_de_Radio-Canada.svg.png">http://upload.wikimedia.org/wikipedia/fr/thumb/9/92/Logo_Television_de_Radio-Canada.svg/617px-Logo_Television_de_Radio-Canada.svg.png</a></p>
<p>pour servir d’icone au lanceur.</p>
<div id="attachment_168" class="wp-caption aligncenter" style="width: 580px"><a rel="attachment wp-att-168" href="http://pierrelucbacon.com/wp-content/uploads/2009/01/rdi3.png"><img class="size-medium wp-image-168" title="RDI en direct avec Mplayer" src="http://pierrelucbacon.com/wp-content/uploads/2009/01/rdi3-950x593.png" alt="RDI en direct avec Mplayer" width="570" height="356" /></a><p class="wp-caption-text">RDI en direct avec Mplayer</p></div>
]]></content:encoded>
			<wfw:commentRss>http://pierrelucbacon.com/2009/01/29/rdi-en-direct-sous-linux/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
<enclosure url="http://www.radio-canada.ca/util/endirect/rdidirect.asx" length="528" type="video/x-ms-asf" />
		</item>
		<item>
		<title>Running Kamikaze with WRT54G under Client Mode</title>
		<link>http://pierrelucbacon.com/2009/01/15/running-kamikaze-with-wrt54g-under-client-mode/</link>
		<comments>http://pierrelucbacon.com/2009/01/15/running-kamikaze-with-wrt54g-under-client-mode/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 05:47:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hacking wifi opentwrt]]></category>
		<category><![CDATA[wifi]]></category>
		<category><![CDATA[wrt54g]]></category>

		<guid isPermaLink="false">http://pierrelucbacon.com/?p=157</guid>
		<description><![CDATA[Having the internet cable modem and the router in one place in the apartment, I needed a way to connect all my gadgets in my room/office without having to run a dozen of ethernet cables in the hallway. More specifically, I wanted to have my IP phone close to the bed and not to have [...]]]></description>
			<content:encoded><![CDATA[<p>Having the internet cable modem and the router in one place in the apartment, I needed a way to connect all my gadgets in my room/office without having to run a dozen of ethernet cables in the hallway. More specifically, I wanted to have my IP phone close to the bed and not to have to run a wire just for that purpose. The main router is an old TEW-432BRP from Trendnet and I had a also an unused WRT54G running Openwrt. Here is the setup I have at the moment and the configuration follows bellow:</p>
<div id="attachment_159" class="wp-caption aligncenter" style="width: 684px"><a rel="attachment wp-att-159" href="http://pierrelucbacon.com/wp-content/uploads/2009/01/networkappartment.png"><img class="size-medium wp-image-159" title="Network Overview" src="http://pierrelucbacon.com/wp-content/uploads/2009/01/networkappartment.png" alt="Network Overview" width="674" height="382" /></a><p class="wp-caption-text">Network Overview</p></div>
<p><strong>Open Network </strong></p>
<p>/etc/config/wireless</p>
<pre>config wifi-device  wl0
        option type     broadcom
        option channel  5
        option disabled '0'

config wifi-iface
        option device   wl0
        option network  lan
        option mode   "sta"
        option ssid openNetwork
        option network "lan"</pre>
<p><strong>Wep Encryption </strong><br />
/etc/config/wireless</p>
<pre>config wifi-device  wl0
        option type     broadcom
        option channel  5
        option disabled '0'

config wifi-iface
        option device   wl0
        option network  lan
        option mode   "sta"
        option ssid wepNetwork
        option network "lan"
        option encryption wep
        option key1 'mywepkeythatyouwontguess'</pre>
<p>My intent was at first to setup a WPA2 bridge, but I finally gave up because neither nas or wpa_supplicant (xsupplicant as well) did the job. nas, the proprietary tool for setting up the broadcom chipset, is also a nightmare to debug with its cryptic error messages (or should I say its absence of any error message ?). The configuration file that is shown above is pretty much self-explanatory. Using Wep 128 is a pretty good compromise on security that I would have better avoided, but I think it worth it considering that MAC filtering can be done and that I always have access to a VPN server.</p>
<p>An important thing that you should also not forget finally is to disable the DHCP server on the OpenWrt router because it might conflict with the other router since we are working in a bridged environment.</p>
]]></content:encoded>
			<wfw:commentRss>http://pierrelucbacon.com/2009/01/15/running-kamikaze-with-wrt54g-under-client-mode/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

