<?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>Yet Another [À Compléter]</title>
	<atom:link href="http://blog.neteril.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.neteril.org</link>
	<description>Random thoughts of Jérémie Laval</description>
	<lastBuildDate>Wed, 14 Mar 2012 13:08:50 +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>Celebrating Pi Day with a bit of math</title>
		<link>http://blog.neteril.org/2012/03/14/celebrating-pi-day-with-a-bit-of-math/</link>
		<comments>http://blog.neteril.org/2012/03/14/celebrating-pi-day-with-a-bit-of-math/#comments</comments>
		<pubDate>Wed, 14 Mar 2012 13:08:50 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[Non classé]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=1192</guid>
		<description><![CDATA[For those living under the scientist/math/geek/nerd radar, Pi Day is a celebration of the aforementioned famous constant that is hold on 14/03 every year (or as American would put it, 3/14 hence the catch). As always more information on the Wikipedia page. To celebrate a bit, I rewrote from memory the demonstration I was given [...]]]></description>
			<content:encoded><![CDATA[<p>For those living under the scientist/math/geek/nerd radar, Pi Day is a celebration of the aforementioned famous constant that is hold on 14/03 every year (or as American would put it, 3/14 hence the catch). As always more information on the <a href="http://en.wikipedia.org/wiki/Pi_Day">Wikipedia page</a>.</p>
<p>To celebrate a bit, I rewrote from memory the demonstration I was given once that use <a href="http://en.wikipedia.org/wiki/Modular_arithmetic">congruence</a> to demonstrate the well known division trick that says a number is divisible by 3 if the sum of its digit are also divisible by 3 (or vice versa).</p>
<p>So for instance, we know that 13905 is divisible by 3 because <img src='http://s.wordpress.com/latex.php?latex=1%20%2B%203%20%2B%209%20%2B%200%20%2B%205%20%3D%2018%20%3D%203%20%5Ctimes%206&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='1 + 3 + 9 + 0 + 5 = 18 = 3 \times 6' title='1 + 3 + 9 + 0 + 5 = 18 = 3 \times 6' class='latex' />. In modular arithmetic terms, we say that <img src='http://s.wordpress.com/latex.php?latex=13905%20%5Cequiv%200%20%5Cmod%203&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='13905 \equiv 0 \mod 3' title='13905 \equiv 0 \mod 3' class='latex' />.</p>
<p>Following is the demonstration in a obfuscated way for a sample 4 digits number (can be generalized to any digit number):<br />
<a href="http://blog.neteril.org/wp-content/uploads/2012/03/congruence.png"><img class="aligncenter size-full wp-image-1195" title="congruence" src="http://blog.neteril.org/wp-content/uploads/2012/03/congruence.png" alt="" width="769" height="389" /></a><br />
Some more explanations:</p>
<ol>
<li>The basis of the demonstration is to first say that any number is a sum of power of ten. If I take my previous number 13905, I can also say it&#8217;s <img src='http://s.wordpress.com/latex.php?latex=1%20%5Ctimes%2010%5E4%20%2B%203%20%5Ctimes%2010%5E3%20%2B%209%20%5Ctimes%2010%5E2%20%2B%200%20%5Ctimes%2010%5E1%20%2B%205%20%5Ctimes%2010%5E0&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='1 \times 10^4 + 3 \times 10^3 + 9 \times 10^2 + 0 \times 10^1 + 5 \times 10^0' title='1 \times 10^4 + 3 \times 10^3 + 9 \times 10^2 + 0 \times 10^1 + 5 \times 10^0' class='latex' />.</li>
<li>Then we start our equivalence chain by assuming we have a number n divisible by 3 and then walking our way by taking its power of ten sum representation</li>
<li>Due to the fact that 10 has a remainder of 1 when divided by 3 and using the properties of congruence, we reduce our initial expression to only use the initial number digits.</li>
<li>Then as the the initial number was divisible by 3, we come to the conclusion that the sum of its digit is also divisible by 3. Plus, since everything was made by equivalence, we know we can go the other way around too</li>
</ol>
<p>That&#8217;s it. You can have a similar reasoning for the other well know multiplication trick that says a number divisible by 5 always ends up with 0 or 5 (this time based on the fact that any power of ten with a power superior to 0 is divisible by 5 and thus has a remainder of 0).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2012/03/14/celebrating-pi-day-with-a-bit-of-math/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MacDoc: the interesting bits</title>
		<link>http://blog.neteril.org/2012/03/06/macdoc-the-interesting-bits/</link>
		<comments>http://blog.neteril.org/2012/03/06/macdoc-the-interesting-bits/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 22:45:39 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Mono]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=1162</guid>
		<description><![CDATA[Presentation Macdoc is the new Mono API documentation browser build entirely with MonoMac (Cocoa bindings for .NET). It has been recently shipped as part of the latest MonoDevelop beta for Mac users where it replace the excellent GTK+ version we use everywhere else. It was my first time hacking on any MonoMac app and along [...]]]></description>
			<content:encoded><![CDATA[<h2>Presentation</h2>
<p>Macdoc is the new Mono API documentation browser build entirely with <a href="https://github.com/mono/monomac/">MonoMac</a> (Cocoa bindings for .NET). It has been recently shipped as part of the latest MonoDevelop beta for Mac users where it replace the excellent GTK+ version we use everywhere else.</p>
<p>It was my first time hacking on any MonoMac app and along the way I came up with a couple of pieces of code that, I think, could be used as general recipes for MonoMac development.</p>
<p>Apple docs being severely lacking (or plainly useless) in some aspect of Mac development, some recipes also covers some general Mac constructs. MacDoc being a NSDocument-based application, recipes are given with respect to that style of Mac coding.</p>
<p>So, among the menu today we have:</p>
<ul>
<li>Answering Open URL commands</li>
<li>Escalating privileges</li>
<li>Uncompressing .xar archives</li>
<li>Fighting WebView or how to handle image requests yourself</li>
<li>Redirecting printing to a WebView in a NSDocument application</li>
</ul>
<h2>Answering Open URL commands</h2>
<p>Any Mac application after being started can receive an number of external signal called Apple events that are sent by other processes to ask the application to do something.</p>
<p>One of these Apple Events called <code>GURL</code> (the four chars code for &laquo;&nbsp;Get URL&nbsp;&raquo;) is a way for the application to receive URL request it can open from the outside world. So, for instance in MacDoc case, we respond to <code>mdoc://</code> and <code>monodoc://</code> that MonoDevelop send to update the documentation page we are showing to the user.</p>
<p>To answer these Apple events, there are a number of existing API. One of them is Carbon (part of the low level suite of Apple API) and an example of its usage can be seen in MonoDevelop and the GTK+ version of MonoDoc (e.g. <a href="https://github.com/mono/monodevelop/tree/master/main/src/addins/MacPlatform/MacInterop"">MacInterop folder</a> in MonoDevelop Mac addin). </p>
<p>But more interesting in the context of Cocoa application, there is a Objective-C wrapper called <code>NSAppleEventManager</code> around these C calls that is available as part of MonoMac master in the <code>Foundation</code> namespace.</p>
<p>If we return to our &laquo;&nbsp;Get URL&nbsp;&raquo; example, to let the system know that you can handle certain types of URL, you first need to set up some lines in your application <code>Info.plist</code> file. This will let tools like <code>open</code> (and more generally anything using the Launch Service API) automatically load your application when it&#8217;s used with an URL your are able to open. In MacDoc case, I paste below the relevant <code>Info.plist</code> lines for the two <code>mdoc://</code> and <code>monodoc://</code> URL schemes we support:</p>
<pre><code>&lt;key&gt;CFBundleURLTypes&lt;/key&gt;
&lt;array&gt;
    &lt;dict&gt;
        &lt;key&gt;CFBundleTypeRole&lt;/key&gt;
        &lt;string&gt;Viewer&lt;/string&gt;
        &lt;key&gt;CFBundleURLIconFile&lt;/key&gt;
        &lt;string&gt;monodoc&lt;/string&gt;
        &lt;key&gt;CFBundleURLName&lt;/key&gt;
        &lt;string&gt;com.xamarin.monodoc.url&lt;/string&gt;
        &lt;key&gt;CFBundleURLSchemes&lt;/key&gt;
        &lt;array&gt;
            &lt;string&gt;monodoc&lt;/string&gt;
            &lt;string&gt;mdoc&lt;/string&gt;
        &lt;/array&gt;
    &lt;/dict&gt;
&lt;/array&gt;
</code></pre>
<p>Pretty straightforward.</p>
<p>Now to catch an event, we decorate a callback method with the <code>[Export]</code> attribute and an Objective-C selector name. In MacDoc case we define the handler this way:</p>
<pre class="brush: csharp; title: ; notranslate">[Export (&quot;handleGetURLEvent:withReplyEvent:&quot;)]
public void HandleGetURLEvent (NSAppleEventDescriptor evt,
                               NSAppleEventDescriptor replyEvt)
</pre>
<p>I will show in a minute how you can process the arguments of this callback to extract the URLs. For now, let&#8217;s see how we register this callback with the event system via the <code>NSAppleEventManager</code> class:</p>
<pre class="brush: csharp; title: ; notranslate">public override void WillFinishLaunching (NSNotification notification)
{
    var selector = new MonoMac.ObjCRuntime.Selector (&quot;handleGetURLEvent:withReplyEvent:&quot;);
    NSAppleEventManager.SharedAppleEventManager.SetEventHandler (this,
                                                                 selector,
                                                                 AEEventClass.Internet,
                                                                 AEEventID.GetUrl);
}
</pre>
<p>As you can notice, the call to <code>NSAppleEventManager</code> is made inside the <code>NSApplicationDelegate.WillFinishLaunching</code> override. In the Cocoa application startup cycle, this method is called when all default handler have been setup but no event has been processed yet making it a good candidate to register our own event handler.</p>
<p>Now, let&#8217;s see how we can extract the received URLs from the event data. Apple events can have complex data attached them ranging from simple number/string to nested list of them.</p>
<p>For the &laquo;&nbsp;Get URL&nbsp;&raquo; event, the URLs are stored in a simple list of string which you can process in normal for loop:</p>
<pre class="brush: csharp; title: ; notranslate">[Export (&quot;handleGetURLEvent:withReplyEvent:&quot;)]
public void HandleGetURLEvent (NSAppleEventDescriptor evt, NSAppleEventDescriptor replyEvt)
{
	NSError error;

	// Received event is a list (1-based) of URL strings
	for (int i = 1; i &lt;= evt.NumberOfItems; i++) {
		var innerDesc = evt.DescriptorAtIndex (i);
		var url = new NSUrl (innerDesc.StringValue);
		// Do something with URL
	}
}
</pre>
<p>As you may have noticed, elements index inside a list are 1-based and not 0-based like we are used to.</p>
<h2>Escalating privileges</h2>
<p>Mac OS X being a UNIX operating system, it has a clear separation of privileges based on the traditional user mode system where <code>root</code> is the only account that can do anything on the system.</p>
<p>Although most applications are just fine running under a normal user, you may sometimes need to escalate privileges if at some point you want to, for instance, write files to a protected system directory.</p>
<p>There are two ways to do so, either upgrade the running process to a better user or launch an external process with better privileges than the calling one. Apple preferred way seems to be the second option (although they won&#8217;t really like an app that needs to be fully run as <code>root</code> in their Store anyway).</p>
<p>For Linux users, this is akin to using a <code>sudo</code> GUI (e.g. <code>gksudo</code>). Apple provides its own way to do the same thing with a C API of their own called SecurityFramework (and it&#8217;s Objective-C brother Security Foundation).</p>
<p>SecurityFramework, is a very much stupid low-level C API and although there is an Objective-C wrapper, it&#8217;s just an excuse for &laquo;&nbsp;Sorry we can&#8217;t do any better&nbsp;&raquo;.</p>
<p>Thankfully, we have the <code>AuthorizationExecuteWithPrivileges</code> shortcut call that make launching an external root process a bit easier. Be careful though because it was deprecated in Lion.</p>
<p>The following class and its <code>LaunchExternalTool</code> method let you start an external application as if run by the root user:</p>
<pre class="brush: csharp; title: ; notranslate">public static class RootLauncher
{
	const string SecurityFramework = &quot;/System/Library/Frameworks/Security.framework/Versions/Current/Security&quot;;

	public static bool LaunchExternalTool (string toolPath)
	{
		IntPtr authReference = IntPtr.Zero;
		int result = AuthorizationCreate (IntPtr.Zero, IntPtr.Zero, 0, out authReference);
		if (result != 0) {
			Console.WriteLine (&quot;Error while creating Auth Reference: {0}&quot;, result);
			return false;
		}
		AuthorizationExecuteWithPrivileges (authReference, toolPath, 0, new string[] { null }, IntPtr.Zero);
		return true;
	}

	[DllImport (SecurityFramework)]
	extern static int AuthorizationCreate (IntPtr autorizationRights,
	                                       IntPtr environment,
	                                       int authFlags,
	                                       out IntPtr authRef);

	[DllImport (SecurityFramework)]
	extern static int AuthorizationExecuteWithPrivileges (IntPtr authRef,
	                                                      string pathToTool,
	                                                      int authFlags,
	                                                      string[] args,
	                                                      IntPtr pipe);
}
</pre>
<h2>Uncompressing .xar archives</h2>
<p>Xar is an extensible archive format using an XML document to keep its inner filesystem information. It&#8217;s used by a lot of stuff distributed by Apple like, in MacDoc case, all their documentation bundles.</p>
<p>Xar is available by default on every Mac OS X installation and it has a very simple and straightforward API available in the libxar library making it really easy to bind.</p>
<p>In our case, we just needed to be able to decompress a Xar archive where we wanted which is easily achieved with the following class and its <code>Extract</code> method:</p>
<pre class="brush: csharp; title: ; notranslate">class XarApi
{
    public static bool Extract (string filename,
                                string outputDirectory,
                                CancellationToken token,
                                Action&lt;string&gt; pathCallback)
    {
        var cwdSave = Directory.GetCurrentDirectory ();
        Directory.SetCurrentDirectory (outputDirectory);
        IntPtr xart = IntPtr.Zero;
        IntPtr iter = IntPtr.Zero;

        try {
            xart = xar_open (filename, 0);
            iter = xar_iter_new ();

            IntPtr file = xar_file_first (xart, iter);
            while (file != IntPtr.Zero) {
                if (token.IsCancellationRequested)
                    return false;
                if (pathCallback != null)
                    pathCallback (xar_get_path (file));
                if (xar_extract (xart, file) &amp;lt; 0)
                    return false;
                file = xar_file_next (iter);
            }
        } finally {
            if (iter != IntPtr.Zero)
                xar_iter_free (iter);
            if (xart != IntPtr.Zero)
                xar_close (xart);
            Directory.SetCurrentDirectory (cwdSave);
        }

        return true;
    }

    [DllImport (&quot;xar&quot;)]
    extern static IntPtr xar_open (string filename, int mode); // 0 for READ, 1 for READWRITE

    [DllImport (&quot;xar&quot;)]
    extern static IntPtr xar_close (IntPtr xart);

    [DllImport (&quot;xar&quot;)]
    extern static IntPtr xar_iter_new ();

    [DllImport (&quot;xar&quot;)]
    extern static void xar_iter_free (IntPtr iter);

    [DllImport (&quot;xar&quot;)]
    extern static IntPtr xar_file_first (IntPtr xart, IntPtr iter);

    [DllImport (&quot;xar&quot;)]
    extern static IntPtr xar_file_next (IntPtr iter);

    [DllImport (&quot;xar&quot;)]
    extern static int xar_extract (IntPtr xart, IntPtr filet);

    [DllImport (&quot;xar&quot;)]
    extern static string xar_get_path (IntPtr file);
}
</pre>
<p>Process is pretty simple really, the only catch being that xar extract archive filesystem based on the current working directory which is why we adapt this setting to the given parameter. You thus need to be careful if for some reason you want to execute more than one call concurrently.</p>
<h2>Fighting WebView or how to handle image requests yourself</h2>
<p>WebView is the widget which can display any kind of rich HTML using Webkit. It has some integration with the embedder, letting it decide how the WebKit engine should handle some operation (e.g. link navigation). What it doesn&#8217;t let you do though is handle linked content request yourself i.e. any resource that needs to be downloaded separately (images, external scripts,
<link />, &#8230;).</p>
<p>In our case, we try as much as possible to display inlined HTML (including the CSS and our small bit of Javascript) inside the widget for our documentation and for default images we could certainly well extract them in a known place on disk and point the browser to it.</p>
<p>What we couldn&#8217;t act on however were the internal images referenced from documentation as WebView doesn&#8217;t let you catch Web request and feed on your own data. Thus we needed a way to trick the system to let us inject our own bytes at some point.</p>
<p>As I said earlier, for convenience we try to inline as much stuff as possible, so taking that reasoning to images, we needed to do the same thing for them. Enter the <a href="http://en.wikipedia.org/wiki/Data_URI_scheme">Data URI scheme</a> which let you embed raw data (or well, base64 encoded data) directly as content.</p>
<p>What we can thus do with our WebView is to hack on the DOM when the page has loaded to detect places where a <code>&lt;img /&gt;</code> tag referencing an internal image resource is used and fill that tag with raw data taken from our store.</p>
<p>If we want to manipulate the DOM, we need it to be properly initialized. A way to do that is to hookup our method to the <code>FinishedLoad</code> event which tells when the DOM is ready for consumption for the currently loading document (remember that loading a page is asynchronous in a WebView).</p>
<p>The method itself which fetch image tags and fill them with our data is given below:</p>
<pre class="brush: csharp; title: ; notranslate">var dom = e.ForFrame.DomDocument;

var imgs = dom.GetElementsByTagName (&quot;img&quot;)
              .Where (n =&gt; n.Attributes[&quot;src&quot;].Value.StartsWith (&quot;source-id&quot;));
byte[] buffer = new byte[4096];

foreach (var img in imgs) {
    var src = img.Attributes[&quot;src&quot;].Value;
    // Our specific call to get an embedded image stream
    var imgStream = AppDelegate.Root.GetImage (src);
    if (imgStream == null)
        continue;
    var length = imgStream.Read (buffer, 0, buffer.Length);
    var read = length;
    while (read != 0) {
        if (length == buffer.Length) {
            var oldBuffer = buffer;
            buffer = new byte[oldBuffer.Length * 2];
            Buffer.BlockCopy (oldBuffer, 0, buffer, 0, oldBuffer.Length);
        }
        length += read = imgStream.Read (buffer, length, buffer.Length - length);
    }

    var data = Convert.ToBase64String (buffer, 0, length, Base64FormattingOptions.None);
    var uri = &quot;data:image/&quot; + src.Substring (src.LastIndexOf ('.')) + &quot;;base64,&quot; + data;
    ((DomElement)img).SetAttribute (&quot;src&quot;, uri);
}
</pre>
<p>The two application-specific parts of this method are how we recognize a tag pointing to an embedded image (in our case their <code>src</code> attribute value is prefixed with &laquo;&nbsp;source-id&nbsp;&raquo;) and the call which get us a <code>Stream</code> for the image (here we get it from our documentation bundle). The rest is mostly stream reading boilerplate.</p>
<h2>Redirecting printing to a WebView in a NSDocument application</h2>
<p>Having a NSDocument-based application means a couple of standard operation are made easier for you to use. One of them is printing which simply require a couple of plumbing with most of the heavy lifting left to Cocoa.</p>
<p>What you may want to do however is to only print a part of your UI, generally the one that display the actual document content which is not something Cocoa can guess for you.</p>
<p>In MacDoc case, the <code>WebView</code> that show the API documentation is what we are interested in printing so let&#8217;s see how can redirect global print request to that specific part of the application.</p>
<p>First, we need to register an action on the Print menu item that points to our subclass of <code>NSApplicationDelegate</code>. In the action implementation, we will simply redirect the call to the currently activated document:</p>
<pre class="brush: csharp; title: ; notranslate">partial void HandlePrint (NSObject sender)
{
    NSDocumentController.SharedDocumentController.CurrentDocument.PrintDocument (sender);
}
</pre>
<p>Now by default, this will actually try to print the currently focused widget in your document UI which is most of time not something you want (feels weird to print a button).</p>
<p>As told earlier, most of the time what you rather want is to print a specific part of the UI. Fortunately, almost all widgets that display rich content also have an implementation of a print operation. <code>WebView</code> is no different and this the widget we are going to use as an example.</p>
<p>So, to redefine the printing behavior of a document, the first thing you need to do is to override the <code>PrintOperation</code> method in your <code>NSDocument</code> subclass.</p>
<p>Then, your simply fetch the current <code>FrameView</code> displayed by your <code>WebView</code> and proxy the print operation through it. This could be something like this:</p>
<pre class="brush: csharp; title: ; notranslate">public override NSPrintOperation PrintOperation (NSDictionary printSettings,
                                                 out NSError outError)
{
    outError = null;
    return webView.MainFrame.FrameView.GetPrintOperation (new NSPrintInfo (printSettings));
}</pre>
<p>The given <code>NSDictionary</code> parameter is a raw representation of a <code>NSPrintInfo</code> so it&#8217;s enough to simply instantiate the later with the former. The returned print operation will contains what&#8217;s necessary to print the rendered HTML shown by the <code>WebView</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2012/03/06/macdoc-the-interesting-bits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Next life steps</title>
		<link>http://blog.neteril.org/2012/02/28/next-life-steps/</link>
		<comments>http://blog.neteril.org/2012/02/28/next-life-steps/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 18:33:36 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=1150</guid>
		<description><![CDATA[A little more than a month ago, I had the last university exams of (hopefully) my whole life, closing a 5 years period of a fun student life. At the end of this week, I&#8217;ll be back in Dublin (Ireland), a town I left a year ago to finish my master degree, where I will [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_1158" class="wp-caption aligncenter" style="width: 650px"><a href="http://www.flickr.com/photos/eye_of_the_photograph/2991451329/"><img class="size-full wp-image-1158" title="2991451329_176b2034cc_z" src="http://blog.neteril.org/wp-content/uploads/2012/02/2991451329_176b2034cc_z.jpeg" alt="" width="640" height="426" /></a><p class="wp-caption-text">Belfort very own Lion</p></div>
<p>A little more than a month ago, I had the last university exams of (hopefully) my whole life, closing a 5 years period of a fun student life.</p>
<p>At the end of this week, I&#8217;ll be back in Dublin (Ireland), a town I left a year ago to finish my master degree, where I will be working together with a well acquainted Irish fellow.</p>
<p>As you may have guessed, that means I&#8217;m now a full-time <a href="http://www.xamarin.com">Xamarin</a> employee!</p>
<p>I&#8217;m also in the slow process of getting a VISA which should allow me to move to Boston in a (preferably) reasonable amount of years.</p>
<p>Interesting times ahead.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2012/02/28/next-life-steps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GSoC 2011 &#8211; TPL Dataflow</title>
		<link>http://blog.neteril.org/2011/08/24/gsoc-2011-tpl-dataflow/</link>
		<comments>http://blog.neteril.org/2011/08/24/gsoc-2011-tpl-dataflow/#comments</comments>
		<pubDate>Wed, 24 Aug 2011 11:31:54 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=1132</guid>
		<description><![CDATA[This summer I have been working again as a Google Summer of Code student for Mono. This time, I re-implemented another parallel-related library called TPL Dataflow. It&#8217;s still a research project at Microsoft and it has recently released a preview version of the framework which is designed to work well with the asynchronous features of [...]]]></description>
			<content:encoded><![CDATA[<p>This summer I have been working again as a <a href="http://code.google.com/soc/">Google Summer of Code</a> student for Mono. This time, I re-implemented another parallel-related library called <a href="http://msdn.microsoft.com/en-us/devlabs/gg585582">TPL Dataflow</a>.</p>
<p>It&#8217;s still a research project at Microsoft and it has recently released a preview version of the framework which is designed to work well with the asynchronous features of the latest .NET CTP.</p>
<p>The goal of the framework is similar to PLinq in the sense that you construct a pipeline composed of blocks expressing individual operation (action, transformation, join, fork, &#8230;) with the notable difference that the model is push-based instead of pull-based.</p>
<p>Push-based basically means that, in the same way than the <a href="http://msdn.microsoft.com/en-us/data/gg577609">Reactive Extensions</a>, you explicitly feed data to your pipeline instead of acquiring it from a source. Then the final data can be received or processed by a block at the other end of the chain.</p>
<p>All of that makes a nice model for asynchronicity that you can use both to send or receive data thanks to a number of extensions method in the framework (suffixed by <code>Async</code>) which returns a <code>Task</code> thus letting you setup continuations or use the new <code>await</code> keyword (also available in Mono master btw).</p>
<p>Under the hood the framework is built upon what ParallelFx provides like the concurrent collections and the task primitive meaning it&#8217;s also taking full advantage of the available parallelism on your machine.</p>
<p>The code is now available directly from Mono master and is built in the <code>System.Threading.Tasks.Dataflow</code> assembly with the 4.0 profile. While not totally complete, it&#8217;s still already usable.</p>
<p>MSDN doesn&#8217;t yet show the documentation so I <a href="http://neteril.org/~jeremie/mono/tpl-dataflow/">uploaded the copy</a> shipped with the preview. </p>
<p>You can also watch Stephen Toub <a href="http://channel9.msdn.com/posts/TPL-Dataflow-Tour">introductory video</a> for a tour of the framework (also embedded below).</p>
<div style="height:288px;width:512px;margin:auto"><iframe style="height:288px;width:512px;margin:auto;" src="http://channel9.msdn.com/posts/TPL-Dataflow-Tour/player?w=512&#038;h=288" frameBorder="0" scrolling="no" ></iframe></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2011/08/24/gsoc-2011-tpl-dataflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Going parallel on mobile devices</title>
		<link>http://blog.neteril.org/2011/07/25/going-parallel-on-mobile-devices/</link>
		<comments>http://blog.neteril.org/2011/07/25/going-parallel-on-mobile-devices/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 22:28:32 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=1116</guid>
		<description><![CDATA[It took around 20 years for CPU manufacturers to abandon the GHz war on the desktop and start going multicore. In the mobile space and only 3 years after the first Android smartphone, we are already seeing dual-cores phones (with quad-cores around the corner). Recent tablets are on the same boat. The brilliant thing is [...]]]></description>
			<content:encoded><![CDATA[<p align="center"><a href="http://blog.neteril.org/wp-content/uploads/2011/07/device-2011-07-19-175035.png"><img src="http://blog.neteril.org/wp-content/uploads/2011/07/device-2011-07-19-175035.png" alt="" title="device-2011-07-19-175035" width="240" height="400" class="aligncenter size-full wp-image-1117" /></a></p>
<p>It took around 20 years for CPU manufacturers to abandon the GHz war on the desktop and start going multicore. </p>
<p>In the mobile space and only 3 years after the first Android smartphone, we are already seeing dual-cores phones (with quad-cores around the corner). Recent tablets are on the same boat.</p>
<p>The brilliant thing is that with <a href="http://android.xamarin.com/">Monodroid</a> and <a href="http://ios.xamarin.com/">Monotouch</a>, we have the possibility to harness this new found processing power today using all the existing ParallelFx constructs since they are part of both distributions (i.e. Tasks, continuations, parallel loops, PLinq and friends).</p>
<p>To illustrate that, I ported the now classic raytracer code from the Parallel sample gallery to Android using Monodroid. Code is on <a href="https://github.com/garuma/raydroid">GitHub</a> if you want to give it a spin.</p>
<p>While the application itself is painfully slow since all rendering is in software, it does exhibit the same speed improvement when you ran in parallel mode as with the desktop version on my dual-core smartphone. For iDevices lovers, <a href="http://blog.sublimeintervention.com/">Geoff</a> also had a similar version running on an iPad 2.</p>
<p>If you are at Monospace and want to talk about that stuff (and ParallelFx in general), don&#8217;t hesitate to come and say hi. Anyhow, I&#8217;ll continue to post more examples of how you can use ParallelFx practically in your mobile apps.</p>
<p>PS: as you&#8217;ll see in the source, there are some hacks bundled because of a couple of Mono bugs but they will get fixed eventually.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2011/07/25/going-parallel-on-mobile-devices/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Say it with cows</title>
		<link>http://blog.neteril.org/2011/07/08/say-it-with-cows/</link>
		<comments>http://blog.neteril.org/2011/07/08/say-it-with-cows/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 20:29:37 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=1100</guid>
		<description><![CDATA[_________________________________ < All your moos are belong to us > --------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ &#124;&#124;----w &#124; &#124;&#124; &#124;&#124; Upon my latest Twitter question and getting no further answer, I carried out even more (useful) Manos world domination by writing Moo, an online cowsay generator (code on github under beer license). Cowsay is [...]]]></description>
			<content:encoded><![CDATA[<p>
<pre> _________________________________
< All your moos are belong to us  >
 ---------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
 </pre>
</p>
<p>Upon my latest Twitter <a href="https://twitter.com/#!/jeremie_laval/status/80777723458498560">question</a> and getting no further answer, I carried out even more (useful) <a href="http://manosdemono.com/">Manos</a> world domination by writing <a href="http://moo.neteril.org">Moo</a>, an online cowsay generator (<a href="https://github.com/garuma/moo">code</a> on github under <a href="http://en.wikipedia.org/wiki/Beerware">beer license</a>).</p>
<p><a href="http://en.wikipedia.org/wiki/Cowsay">Cowsay</a> is one of those obscure Perl thing from the dark hacker age that once plagued mails and terminals. </p>
<p>It basically consists of a variety of ASCII animals (not limited to cows actually) telling some text inside bubbles. Useless therefore essential.</p>
<p>All of that offering me the shameless plug of telling the world I&#8217;m attending
<p align="center"><a href="http://blog.neteril.org/wp-content/uploads/2011/07/monospace.png"><img src="http://blog.neteril.org/wp-content/uploads/2011/07/monospace.png" alt="" title="monospace" width="194" height="112" class="alignnone size-full wp-image-1101" /></a></p>
<p>See you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2011/07/08/say-it-with-cows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebMatrix.Data on Mono</title>
		<link>http://blog.neteril.org/2011/01/22/webmatrix-data-on-mono/</link>
		<comments>http://blog.neteril.org/2011/01/22/webmatrix-data-on-mono/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 13:28:00 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=1084</guid>
		<description><![CDATA[Initial reading on what is WebMatrix can be found on Scott Guthrie blog. After team WebMatrix was formed this week, I have reimplemented the Data part of WebMatrix, a cute layer on top of ADO.NET with support for the dynamic keyword (C# 4) so that you can directly call property equivalent to your column names. [...]]]></description>
			<content:encoded><![CDATA[<p>Initial reading on what is WebMatrix can be found on <a href=" http://weblogs.asp.net/scottgu/archive/2011/01/13/announcing-release-of-asp-net-mvc-3-iis-express-sql-ce-4-web-farm-framework-orchard-webmatrix.aspx">Scott Guthrie blog</a>.</p>
<p>After team WebMatrix was formed this week, I have reimplemented the Data part of WebMatrix, a cute layer on top of ADO.NET with support for the <code>dynamic</code> keyword (C# 4) so that you can directly call property equivalent to your column names.</p>
<p>Bonus point is that even though is has been shipped with a heavy slant towards SQL Server (and its new compact counterpart) since it&#8217;s implemented on top of stock System.Data.Common we can use any provider with it including the great old-fashioned SQlite provider.</p>
<p>Say I have the following SQlite database:</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-1085" title="Schema" src="http://blog.neteril.org/wp-content/uploads/2011/01/schema.png" alt="Schema" width="645" height="92" /></p>
<p>That is populated with these values:</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-1086" title="Data" src="http://blog.neteril.org/wp-content/uploads/2011/01/data.png" alt="Data" width="658" height="119" /></p>
<p>You can now write code like this to query the database:</p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using WebMatrix.Data;

class WebMatrixSample
{
	public static void Main ()
	{
		var db = Database.OpenConnectionString (&quot;Data Source=sqlite.db;Version=3;&quot;, &quot;Mono.Data.Sqlite&quot;);

		var result = db.Query (&quot;select * from Phonebook where Number glob '0*'&quot;);
		foreach (dynamic row in result)
			Console.WriteLine (&quot;({0:D2}) {1}: [{2}]&quot;, row.Id, row.Name, row.Number);

		var entry = db.QuerySingle (&quot;select * from Phonebook where Name = @0&quot;, &quot;Rupert&quot;);
		Console.WriteLine (&quot;Rupert number is {0} with id {1}&quot;, entry.Number, entry.Id);

		Console.WriteLine (&quot;but really his number is just {0}&quot;,
		                   db.QueryValue (&quot;select Number from Phonebook where Name = @0&quot;, &quot;Rupert&quot;));

		// And let's add my bank number
		db.Execute (&quot;insert into Phonebook(Name, Number) values (@0, @1)&quot;, &quot;Bank&quot;, &quot;01xxxxxxx&quot;);
	}
}
</pre>
<p>WebMatrix.Data assembly is now available when you compile Mono from Git master.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2011/01/22/webmatrix-data-on-mono/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Apachaï or playing around with Manos</title>
		<link>http://blog.neteril.org/2011/01/09/apachai-or-playing-around-with-manos/</link>
		<comments>http://blog.neteril.org/2011/01/09/apachai-or-playing-around-with-manos/#comments</comments>
		<pubDate>Sun, 09 Jan 2011 02:58:39 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=1060</guid>
		<description><![CDATA[Once upon a time As a lot of people I started doing programming during my HTML days when I needed to add a bit of interactivity with some layers of PHP. Realizing that what I was coding was both ugly and useless, I moved on to other stuff and distanced myself from web development altogether. [...]]]></description>
			<content:encoded><![CDATA[<p align="center"><img src="http://blog.neteril.org/wp-content/uploads/2011/01/apachai-header-300x112.png" alt="Apachaï logo" title="apachai-header" width="300" height="112" class="aligncenter size-medium wp-image-1075" /></p>
<h3>Once upon a time</h3>
<p>As a lot of people I started doing programming during my HTML days when I needed to add a bit of interactivity with some layers of PHP. Realizing that what I was coding was both ugly and useless, I moved on to other stuff and distanced myself from web development altogether.</p>
<p>Meanwhile, the Web became much more feature-full than what it was at the time and when I took another dive these past weeks I grasped how it had grew since with HTML 5, CSS3 or jQuery (yeah I know I was out of the wheel for a long time) to the point it was actually enjoyable.</p>
<p>But what really motivated me to come back was the recent release by my esteemed colleague <a href="http://jacksonh.tumblr.com/">Jackson</a> of his <a href="http://manosdemono.org/">Manos</a> web framework which, even though designed for cartels, was at long last <a href="http://jacksonh.tumblr.com/post/1159500924/manos-de-mono-the-manifesto">providing</a> a simple environment and simple interface to read and output valid HTTP headers in .NET/Mono.</p>
<h3>The use case</h3>
<p>Since I never really bothered signing-up for these Twitter image sharing website for the two or three pics I post per year and since I had no need of a special app for a badass smartphone I don&#8217;t have, I was leaning towards something FOSS and simple I could deploy on my own server which of course I didn&#8217;t find (if I was mistaken, replace that part with &laquo;&nbsp;I love reinventing the wheel&nbsp;&raquo;).</p>
<p>Thus <a href="http://apch.fr">Apachaï</a> was born (on <a href="https://github.com/garuma/apachai">GitHub</a>). It&#8217;s a KISS solution to a basic workflow: &laquo;&nbsp;let me post a pic quickly and write my twitter message at the same time&nbsp;&raquo;. </p>
<p>It does so by leveraging Twitter&#8217;s SSO using code borrowed from <a href="http://tirania.org/blog/">Miguel de Icaza</a>&#8216;s <a href="https://github.com/migueldeicaza/TweetStation">TrollStation</a>. It also have some nice goodies like simple image effects courtesy of <a href="https://github.com/jpobst/Pinta">Pinta</a> (yay for easy code reuse). </p>
<p>Data management is handled by <a href="http://redis.io/">Redis</a> because it wouldn&#8217;t have been wicked enough without some NoSQL sparkles (nice thing though). Plus Redis is so lightweight that it is not a big dependency really.</p>
<p>Oh and because eating your own soup is good, Apachaï uses ParallelFx&#8217;s Future and continuations to process long-running operations without blocking Manos itself so it&#8217;s an example of using ParallelFx in a web context. I also made a choice of not using any specific templating system, MVC or whatnot. The HTML is always served as a basic empty container and all specific elements are dynamically filled with Javascript and some JSON serialization routes (see why Manos and futures fit?).</p>
<div id="attachment_1070" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.neteril.org/wp-content/uploads/2011/01/apachai-screen.jpg"><img src="http://blog.neteril.org/wp-content/uploads/2011/01/apachai-screen-300x196.jpg" alt="Apachaï screenshot" title="apachai-screen" width="300" height="196" class="size-medium wp-image-1070" /></a><p class="wp-caption-text">Apachaï screenshot</p></div>
<h3>Finally</h3>
<p>So to summarize:</p>
<ul>
<li>Apachaï is a small and lightweight photo and picture sharing application (for services like Twitter) built on the Manos framework
</li>
<li>A public instance for your usage is available at <a href="http://apch.fr">apch.fr</a>
</li>
<li>Code is hosted on GitHub at <a href="https://github.com/garuma/apachai">https://github.com/garuma/apachai</a>
</li>
<li>I will be giving a talk about Manos during upcoming FOSDEM as <a href="http://weblog.savanne.be/">Ruben</a> once again secured a Mono room.
</li>
</ul>
<p><em>PS: the name comes from <a href="http://en.wikipedia.org/wiki/List_of_Kenichi:_The_Mightiest_Disciple_characters#Apachai_Hopachai">this character</a> because that was what I was reading at the time.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2011/01/09/apachai-or-playing-around-with-manos/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Porting, porting</title>
		<link>http://blog.neteril.org/2010/12/16/porting-porting/</link>
		<comments>http://blog.neteril.org/2010/12/16/porting-porting/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 16:36:05 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=1036</guid>
		<description><![CDATA[The past few weeks, I have given some cycles to test and ultimately make sure existing ParallelFx softwares from the .NET world could run on our Mono implementation. In the end, I selected three pieces of code that were using ParallelFx extensively: the Parallel Extensions sample gallery, Microsoft Biology Foundation and RavenDB (triggered by Rob [...]]]></description>
			<content:encoded><![CDATA[<p align="center"><a href="http://www.flickr.com/photos/migrainechick/4808597936/"><img src="http://blog.neteril.org/wp-content/uploads/2010/12/cat_penguin_doodle-300x184.png" alt="Cat thoughts by Deborah Leigh (Migraine Chick)" title="Cat thoughts by Deborah Leigh (Migraine Chick)" width="300" height="184" class="aligncenter size-medium wp-image-1037" /></a></p>
<p>The past few weeks, I have given some cycles to test and ultimately make sure existing ParallelFx softwares from the .NET world could run on our Mono implementation.</p>
<p>In the end, I selected three pieces of code that were using ParallelFx extensively: <a href="http://code.msdn.microsoft.com/ParExtSamples">the Parallel Extensions sample gallery</a>, <a href="http://research.microsoft.com/en-us/projects/bio/mbf.aspx">Microsoft Biology Foundation</a> and <a href="http://ravendb.net/">RavenDB</a> (triggered by Rob Ashton <a href="http://codeofrob.com/archive/2010/12/10/adventures-in-mono.aspx">work</a>).</p>
<p>As a result, I&#8217;m happy to say I was able to run most of the three of them and they were of a great help pinpointing some non obvious corner case of the API. Practical consequence is that to also run them you will need Mono from master.</p>
<p>Following is a bunch of notes specific to each of these projects:</p>
<h4>Parallel Extensions sample gallery</h4>
<p>This project actually also contains the parallel extras library which provides a bunch of new constructs and extensions to the classic ParallelFx API that you can reuse in your own project. </p>
<p>At the moment though, you should be aware that the license used doesn&#8217;t allow reusing the code on a platform different than Microsoft Windows but this will hopefully be changed in the near-future to use a wider free/open-source license.</p>
<p>In this gallery, I was only able to test the projects that didn&#8217;t specifically use non-supported library in Mono such as WPF. For the rest of them, using our xbuild tool does the trick of compiling the code.</p>
<p>If you happen to have a software that use one of those code path I hadn&#8217;t had a chance to test and if you can share the application with me I can also give it a spin.</p>
<h4>Microsoft Biology Foundation</h4>
<p>This project is a heavy user of almost everything in the framework ranging from concurrent collections to PLinq and is quite a hungry memory and CPU eater.</p>
<p>Since I couldn&#8217;t find a proper application leveraging this framework, I simply turned to the performance test suite bundled in the project which works fine although some test eats up quite a lot of memory (as always, running under sgen helps here).</p>
<p>The code actually requires a couple of extra tweaks if you want to run the performance test suite correctly but for compiling the core framework itself, again xbuild should be sufficient.</p>
<h4>RavenDB</h4>
<p>Last but not least, RavenDB is an engine part of the NoSQL and document database movement but with a slant towards .NET (with Linq integration for instance).</p>
<p>Rob Ashton decided to try to run the beast on Linux  and I gave him a hand to tackle the few incompatibilities between Mono and .NET result of which can be found in his GitHub repository: <a href="https://github.com/robashton/ravendb/tree/mono">https://github.com/robashton/ravendb/tree/mono</a></p>
<p>The test suite is running <a href="http://neteril.org/mono/raven.html">well enough</a> with a total of 531 tests passing out of 588. Some of the failure are perfectly normal (like the tests using Microsoft-only native librairies) and another good portion is probably casual portability mistake (like hardcoded path and such).</p>
<p>It would actually be much appreciated if those knowing how the framework work could help triage these failures and find what is Mono bugs and what is not so that we can fix them.</p>
<p>Some tests also depend on not implemented features in Mono so if you feel like it, you could also contribute these missing code pieces or provide a workaround in RavenDB.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2010/12/16/porting-porting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turning your MeeGo Lenovo S10-3t into a real slate</title>
		<link>http://blog.neteril.org/2010/11/19/turning-your-meego-lenovo-s10-3t-into-a-real-slate/</link>
		<comments>http://blog.neteril.org/2010/11/19/turning-your-meego-lenovo-s10-3t-into-a-real-slate/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 22:15:00 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=1004</guid>
		<description><![CDATA[Recently Dublin got busy with the first ever MeeGo conference being organized for developers. For 3 days, geeks invaded the shiny (and overly expensive) Aviva stadium for talks, fun and code. It was also a cool opportunity to meet up with some esteemed Novell colleagues. Among other goodness (hat off to the organizers for a [...]]]></description>
			<content:encoded><![CDATA[<p align="center"><a href="http://blog.neteril.org/wp-content/uploads/2010/11/meego-funny-guys.jpg"><img src="http://blog.neteril.org/wp-content/uploads/2010/11/meego-funny-guys.jpg" alt="" title="meego-funny-guys" width="514" height="172" class="aligncenter size-full wp-image-1008" /></a></p>
<p>Recently Dublin got busy with the first ever <a href="http://conference2010.meego.com//">MeeGo conference</a> being organized for developers. For 3 days, geeks invaded the shiny (and overly expensive) Aviva stadium for talks, fun and code. It was also a cool opportunity to meet up with <a href="http://blog.crozat.net/">some</a> <a href="http://twitter.com/#!/glunardi">esteemed</a> <a href="http://abock.org/">Novell</a> <a href="http://people.gnome.org/~michael/">colleagues</a>.</p>
<p>Among other goodness (hat off to the organizers for a truly top-notch event), Nokia and Intel in their great wisdom decided to hand out a free Lenovo S10-3t netbook/slate (pre)loaded with MeeGo to get our hand dirty with. I&#8217;ll probably discuss about MeeGo itself in another blog but for now I want to write here the couple of step I had to take to turn the Netbook edition into something suitable for the slate mode the Lenovo can adopt.</p>
<p>Basically by following this guide you will have: a working on-screen virtual keyboard and a tweaked Chromium understanding touch for scrolling.</p>
<p>The first step is to setup the keyboard. First of all, you have to enable the Handset repository to pull down some compatibility component (i.e. GTK+ immodule):</p>
<pre style="background-color: black; color: white; padding: 2ex; margin: 0 2ex 1em 2ex; overflow: auto;">$ cd /etc/zypp/repos.d/
$ sudo -s
$ cp netbook.repo handset.repo
$ sed 's/netbook/handset/' -i handset.repo
$ zypper refresh # at this point you will probably have a security alert, ignore it
$ zypper install meegotouch-inputmethodbridges meegotouch-inputmethodkeyboard meegotouch-theme meegotouch-theme-meego libmeegotouch-qtstyle meegotouch-systemui
</pre>
<p>To avoid a weird parsing bug, comment out line 715 in <code>/usr/share/themes/base/meegotouch/libmeegotouchcore/style/commonlayouts.css</code>.</p>
<p>Then, open up the file <code>/etc/xdg/autostart/meego-im-uiserver.desktop</code> and change the Exec line to<code> /usr/bin/meego-im-uiserver -target slate -bypass-wm-hint</code>. Finally, append <code>;X-MEEGO-NB</code> to the OnlyShowIn line (or remove it altogether), save, close up and restart your computer (all applications including MeeGo panel basically need to be relaunched to load up the new input engine so it&#8217;s the most straightforward way).</p>
<p>If everything went well (if not check that the process is alive and not choking), you should have a fair sized keyboard appearing at the bottom of the screen when a text field gets the focus. </p>
<p>Some comments here. The enter key on this keyboard is hidden behind the two modifier keys (bottom-left) and is only a <code>n</code> appender (read, it won&#8217;t fire any activated event). Thus when you need to validate something you have to either use your real Enter key or find a way around (&laquo;&nbsp;clicking&nbsp;&raquo; chrome first completion for an address, tweet/publish buttons, &#8230;). To make the keyboard go away (because it doesn&#8217;t resize any part of the UI it&#8217;s hiding) you have to use a ninja swipe to the bottom that precisely start at the top of the keyboard without touching a key (I did prepended ninja there).</p>
<p>On the web browser side (who use a slate for something else?), there is an <a href="https://chrome.google.com/extensions/detail/ncegfehgjifmmpnjaihnjpbpddjjebme">extension</a> that provide the scrolling gesture Android &#038; IPhone user will be familiar with. To get websites to take you as a slate you can resort to the good old user-agent trick and <a href="http://lifehacker.com/5508260/how-to-use-gmails-attractive-new-tablet+friendly-interface-on-your-regular-old-computer">make yourself look like an iPad</a> though, as far as I tried using it, special interface such as GMail one doesn&#8217;t work.</p>
<p>To get back the MeeGo panel on the top when you don&#8217;t have access to the Windows key, a really high touch-click on the screen will still get it to slide down for you.</p>
<p>EDIT: on the matter of having the keyboard hiding the UI beneath it, if you don&#8217;t use the keyboard in software mode (that is, no <code>-software</code> switch in your .desktop), you can make most of the keyboard transparent by opening <code>/usr/share/themes/base/meegotouch/svg/meegotouch-keyboard.svg</code> and adding an opacity value in the style attribute of the svg root node, something like (extra attributes stripped for readability):</p>
<pre class="brush: plain; title: ; notranslate">
&lt;svg version=&quot;1.1&quot;
  id=&quot;meegotouch-keyboard-layer&quot;
  viewBox=&quot;0 0 500 480&quot;
  style=&quot;enable-background:new 0 0 500 480; opacity:0.4&quot;
  xml:space=&quot;preserve&quot;&gt;
</pre>
<p>EDIT2: I updated the zypper install line with package that I thought were pulled down automatically but apparently weren&#8217;t.</p>
<p>If everything goes well you should get that result:</p>
<p align="center"><a href="http://blog.neteril.org/wp-content/uploads/2010/11/Screenshot.png"><img src="http://blog.neteril.org/wp-content/uploads/2010/11/Screenshot-300x175.png" alt="" title="Screenshot" width="300" height="175" class="aligncenter size-medium wp-image-1030" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2010/11/19/turning-your-meego-lenovo-s10-3t-into-a-real-slate/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 1.515 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-04-18 02:15:58 -->
<!-- Compression = gzip -->
