Sergi Mansillahttps://sergimansilla.com/icon.png2022-11-10T21:27:22.992Zhttps://sergimansilla.com/Sergi MansillaHexoRefactoring in Go: Using reflectionhttps://sergimansilla.com/blog/refactoring-in-go-using-reflection/2018-08-24T14:51:23.000Z2022-11-10T21:27:22.992Z<p>Go’s reflection API is quite the unknown for many developers. In this article, I’ll use it in a familiar scenario to show that it can help you in your day to day coding.</p>Refactoring in Go: goroutine concurrencyhttps://sergimansilla.com/blog/refactoring-in-go-goroutine-concurrency/2018-08-09T19:18:18.000Z2022-11-10T21:27:22.992Z<p>Surprise! I write Go these days.</p>
<p>Lately I’ve been finding some code out in the wild that uses naive solutions for concurrency. Given the times I’ve seen similar patterns, my theory is that it is probably inspired by basic goroutines example code out there.</p>React patterns: Privileged Contenthttps://sergimansilla.com/blog/react-patterns-privileged-content/2018-04-10T12:00:54.000Z2022-11-10T21:27:22.992Z<p>In the last project I worked on, some parts in the page should only be shown to privileged users. As easy as it would be to just add that bit of logic in a <code>render</code> method, it would not be idiomatic React, and it would also get cumbersome when the validation logic becomes more complex, besides the fact that we would have to add similar logic in many places in the code. DRY, as they say.</p>Real World Observableshttps://sergimansilla.com/blog/real-world-observables/2016-05-03T16:33:21.000Z2022-11-10T21:27:22.992Z<p>Reactive code examples can be mind-blowing. Powerful, succint, robust…they seem to handle many concurrency scenarios without breaking a sweat. But let’s be honest, examples from 30-minute conference talks and short blog posts rarely reflect the messy real world™.</p>
<p>In any case, developers get all pumped up about reactive goodness and want to use it in their projects. Alas, they quickly find out that it’s not all reactive unicorns and rainbows, and that thinking of state in traditional programs as a sequence of events is not trivial.</p>
<p>I will attempt to shed some light on how to do that by writing a real world example in a few lines of RxJS: An FTP client.</p>Firefox disabled my extensionshttps://sergimansilla.com/blog/firefox-disabled-my-extensions/2015-08-13T18:25:48.000Z2022-11-10T21:27:22.988Z<p>Firefox—my browser of choice—just updated to version 41 beta. It turns out that from this version on, <a href="https://support.mozilla.org/en-US/kb/add-on-signing-in-firefox?as=u&utm_source=inproduct">any extension that hasn’t been signed by Mozilla is disabled automatically</a>. Firefox didn’t warn me about that. I had to go to the Add-ons panel to check why some of my extensions were not working, only to find that they were disabled. And I can’t seem to find a place in the UI to opt out and allow unsigned extensions in my browser. And, you know, it’s not that I use obscure extensions made by shady developers that don’t care about security. The disabled extensions are:</p>
<ul>
<li> <a href="https://agilebits.com/onepassword">1password (Agilebits)</a></li>
<li> <a href="https://www.eff.org/Https-Everywhere">HTTPS Everywhere (EFF)</a></li>
<li> <a href="https://www.eff.org/privacybadger">Privacy Badger (EFF)</a></li>
<li> <a href="http://facebook.github.io/react/blog/2015/08/03/new-react-devtools-beta.html">React Devtools (Facebook)</a></li>
</ul>Making geolocation work on Geeksphone deviceshttps://sergimansilla.com/blog/making-geolocation-work-on-geeksphone-devices/2014-05-01T05:28:11.000Z2022-11-10T21:27:22.988Z<p><em>This post is written for my own reference, in order to document the steps for getting geolocation working on GeeksphoneExtending JavaScript with inline unit testshttps://sergimansilla.com/blog/extending-js-inline-unit-tests/2013-11-09T20:56:57.000Z2022-11-10T21:27:22.988Z<p>I’ve been checking out <a href="http://www.pyret.org/">Pyret</a>, the new language from the same guys that made <aAdd code coverage to your Node.js projectshttps://sergimansilla.com/blog/test-coverage-node/2013-06-19T19:13:00.000Z2022-11-10T21:27:22.992Z<p><strong>Note: This blog post is inspired on <a href="http://xseignard.github.io/2013/04/25/quality-analysis-on-node.js-projects-with-mocha-istanbul-and-sonar/">Xavier Seignard’s blog post</a>. He gives a longer introduction on it, and integrates it together with <a href="http://www.sonarqube.org/">Sonar</a>. You should check it out.</strong></p>
<p>Code coverage is convenient to get an overview of how well-tested your program is. I’m going to show you how to set up code coverage using <a href="http://visionmedia.github.io/mocha/">Mocha</a>, <a href="https://github.com/gotwarlost/istanbul">Istanbul</a> and <a href="http://ltp.sourceforge.net/coverage/lcov.php">LCOV</a> in two easy steps.</p>Virtual list in vanilla JavaScripthttps://sergimansilla.com/blog/virtual-scrolling/2013-05-12T19:20:28.000Z2022-11-10T21:27:22.992Z<p>Let’s say you need to show a scrolling list with millions of rows, or even a reasonably big list with visually complex rows, each one composed by several DOM elements or CSS3 effects.</p>
<p>If you try to render this the naive way, for example by appending rows into a DOM container with the CSS <code>overflow</code> property set to <code>scroll</code> (or <code>auto</code>), you will most likely run into performance issues. This is because all the items in the list are cached, thus your memory consumption will certainly go up, and since all the DOM nodes composing the rows of the list are appended in the document, the browser is trying to properly render them all making your CPU pretty busy as you scroll. If these rows change any style say, on hover, you will trigger a <a href="http://www-archive.mozilla.org/newlayout/doc/reflow.html">reflow</a> and the experience will be even more sluggish.</p>Implement cursor-swiping in half an afternoonhttps://sergimansilla.com/blog/swipeselection-in-an-afternoon/2013-02-21T13:21:20.000Z2022-11-10T21:27:22.992Z<p>If you haven’t seen it yet, I suggest that you take a look at this concept video that made the rounds on the internet some monthsThe promise of Firefox OShttps://sergimansilla.com/blog/promise-of-ffos/2013-02-09T18:57:30.000Z2022-11-10T21:27:22.988Z<blockquote>
<p>“But <em>how</em> is it going to beat Android or iOS?”</p>
</blockquote>
<p>That’s the reaction many people have when I tell them that I am working on <a href="http://www.mozilla.org/en-US/firefoxos/">Firefox OS</a>, the new mobile operating system from <a href="http://www.mozilla.org/en-US/">Mozilla</a>. It is a logical reaction. After all, we live in times where every major software company and its mother is releasing a mobile platform, struggling to lure developers into their new proprietary environment, APIs, libraries, etc. And indeed, many of these companies <a href="http://global.blackberry.com/sites.html">barely make it</a> or <a href="http://www.hpwebos.com/us/">don’t make it at all</a>.</p>
<p>But Firefox OS will not be directly battling against other mobile platforms. Its main objective is to change the way the world develops mobile apps, and even in the unlikely event that Firefox OS itself disappears in the process, if web-apps become mainstream, it will have succeeded.</p>Moving onhttps://sergimansilla.com/blog/moving-on/2013-01-29T19:04:18.000Z2022-11-10T21:27:22.988Z<p>A little bit more than two years ago I was sitting on a meeting room, listening to Ruben Daniels and Rik Arends, the two founders of the company I was considering to join, <a href="http://c9.io/">Cloud9 IDE</a>. These were two of the smartest, most inspiring people I’ve met, and they were working hard on a ground-breaking concept: a full-fledged development environment that run in the browser, and in the cloud. At the time, that sounded wildly adventurous, to say the least. But the challenges were so many, the concept so revolutionary and the people so inspiring that I joined the company two weeks after that conversation. </p>Nodejsconf in Italyhttps://sergimansilla.com/blog/nodejs-conference-italy-2012/2012-11-12T19:08:36.000Z2022-11-10T21:27:22.988Z<p>Last weekend I was at the <a href="http://nodejsconf.it/">Node.js conference</a> in Brescia, Italy. Like every year the organizersMy talk at DynCon 2011https://sergimansilla.com/blog/my-talk-at-dyncon-2011/2011-04-04T17:09:04.000Z2022-11-10T21:27:22.988Z<p>The video with my talk about <a href="http://c9.io/">Cloud9 IDE</a> at <a href="http://swdc-central.com/dyncon2011/">DynCon 2011</a> isDynamically generating MIDI in JavaScripthttps://sergimansilla.com/blog/dynamically-generating-midi-in-javascript/2010-11-08T21:09:38.000Z2022-11-10T21:27:22.988Z<p>Last weekend I open-sourced a <a href="https://github.com/sergi/jsmidi">small side project</a> consisting of a JavaScript library thatWriting a JavaScript interpreter for DBN using PEG.js and canvas (Part II)https://sergimansilla.com/blog/writing-a-javascript-interpreter-for-dbn-using-canvas-ii/2010-08-20T19:32:04.000Z2022-11-10T21:27:22.992Z<p><strong>In this article I build an interpreter for the DBN language from the parsed AST generated by the grammar we defined <aWriting a JavaScript interpreter for DBN using PEG.js and canvas (Part I)https://sergimansilla.com/blog/writing-a-javascript-interpreter-for-dbn-using-canvas-i/2010-08-03T06:03:43.000Z2022-11-10T21:27:22.992Z<p><strong><em>In this first part of the article, I will define a grammar for DBN (Design By Numbers) and generate a parser for it thatGitHub in Catalanhttps://sergimansilla.com/blog/github-in-catalan/2010-07-28T19:34:19.000Z2022-11-10T21:27:22.988Z<p>This is awesome. From now on, Catalan users of GitHub can use the website in their native language. Thanks to the Github team initiativeBlog running on Jekyll nowhttps://sergimansilla.com/blog/blog-running-on-jekyll-now/2010-04-13T19:35:50.000Z2022-11-10T21:27:22.988Z<p>That’s right, I couldn’t resist switching to <a href="http://github.com/mojombo/jekyll">Jekyll</a>. I feel so free now! For those whoABN Amro to Wesabe scripthttps://sergimansilla.com/blog/abn-amro-to-wesabe-script/2009-02-25T21:37:40.000Z2022-11-10T21:27:22.988Z<p><a href="http://www.wesabe.com/">Wesabe</a> is a great service. And a very big part of its greatness resides in the fact that itYQL mashup with GWThttps://sergimansilla.com/blog/yql-mashup-with-gwt/2008-11-16T21:40:04.000Z2022-11-10T21:27:22.992Z<p>Yahoo came up with YQL a few weeks ago, and I think it is a very interesting idea. It is basically a SQL-like language that allows developers to retrieve structured data from multiple Yahoo web services without having to deal with each service particularities; developers can query any service in a generic way, just like they would do retrieving rows and columns from a SQL database.</p>Solitaire Encryption Algorithm implementation in F#https://sergimansilla.com/blog/solitaire-encryption-algorithm-implementation-in-f/2008-10-13T19:45:48.000Z2022-11-10T21:27:22.992Z<p>I first read about the <a href="http://www.schneier.com/solitaire.html">Solitaire algorithm</a> in the novel <a href="http://en.wikipedia.org/wiki/Cryptonomicon">Cryptonomicon</a>, by Neal Stephenson. Being a geeky kid fascinated by computers I thought that it was a brilliant idea, but my curiosity didn’t go so far as to make me write an implementation of it (you can find a perl version in the book, which by the way I consider to be another great way to encrypt information).</p>
<p>Solitaire is a <a href="http://en.wikipedia.org/wiki/Stream_cipher">Stream Cipher</a> created by <a href="http://www.schneier.com/">Bruce Schneier</a> and designed to be used with only a deck of cards. No electronic devices are needed and its security is intended to be of military-strength; that means that even if the way to generate/decipher messages is manual and might look a bit rudimentary, ideally not even the most powerful government could ever decipher a message generated with Solitaire (although some potential flaws have been <a href="http://www.ciphergoth.org/crypto/solitaire">reported</a>).</p>
<p>So after playing with <a href="http://research.microsoft.com/fsharp/fsharp.aspx">F#</a> lately, I decided to write some non-trivial code in order to see how it suits my coding style and habits, and yet another naive implementation of this curious crypto-algorithm was born.</p>Nth attempthttps://sergimansilla.com/blog/nth-attempt/2008-10-08T19:50:36.000Z2022-11-10T21:27:22.988Z<p>Yes, I am blogging again. But this time I have a plan. My last blog tried to cover too many things, from my life abroad, to ramblings on