<?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>HCoder.org &#187; javascript</title>
	<atom:link href="http://hcoder.org/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://hcoder.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 09 Feb 2012 22:15:38 +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>Pragmatic Thinking &amp; Learning, Wikis and Javascript</title>
		<link>http://hcoder.org/2011/10/24/pragmatic-thinking-learning-wikis-and-javascript/</link>
		<comments>http://hcoder.org/2011/10/24/pragmatic-thinking-learning-wikis-and-javascript/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 21:36:25 +0000</pubDate>
		<dc:creator>emanchado</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[pet]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[wikis]]></category>

		<guid isPermaLink="false">http://hcoder.org/?p=1207</guid>
		<description><![CDATA[After so much &#8220;slacking&#8221; (just posting book summaries) I&#8217;m trying to go back to regular blogging. Remember my summary of Pragmatic Thinking &#38; Learning? There are many exercises and pieces of advice in that book that I have been trying to practice. One of the things I decided to go for was having a personal [...]]]></description>
			<content:encoded><![CDATA[<p>After so much &#8220;slacking&#8221; (just posting book summaries) I&#8217;m trying to go back to regular blogging. Remember <a href="http://hcoder.org/2011/10/10/book-summary-pragmatic-thinking-learning/">my summary of Pragmatic Thinking &amp; Learning</a>? There are many exercises and pieces of advice in that book that I have been trying to practice. One of the things I decided to go for was having a <a href="http://en.wikipedia.org/wiki/Personal_wiki">personal wiki</a>. One of the reasons being, in all honesty, that I had always wanted to have one. Another reason being that my pet TODO application, <a href="https://bitbucket.org/emanchado/bubug/wiki/Home">Bubug</a>, had finally died after some Debian update (some retarded Ruby module broke compatibility with the version I was using, or something; couldn&#8217;t care to investigate). And yet another reason, well, to have a new small pet project and follow my obsession with learning Javascript, and especially <a href="http://nodejs.org/">Node</a>. And that I wanted to give <a href="https://no.de/">Joyent&#8217;s free Node service</a> a try!</p>
<p>But enough with the reasons. It&#8217;s starting to look like it was a pretty useful mini-project. Not just because I learned a bit more Javascript, the excellent <a href="http://expressjs.com/">express</a> web development framework and other things, but also because the result itself, even though it didn&#8217;t take long to develop (and it was pretty fun, even!), feels useful. It feels like a nice place to put all my notes, TODOs, random ideas for projects, etc. A similar feeling of freedom as when I started using my first <a href="http://en.wikipedia.org/wiki/Moleskine">Moleskine</a>. Not that I would ditch paper for computer-<em>anything</em>, but it&#8217;s useful and freeing in its own way, for specific purposes.</p>
<p>About the technology, I used the <a href="http://en.wikipedia.org/wiki/Markdown">Markdown</a> format for the pages thanks to the <a href="https://github.com/evilstreak/markdown-js">markdown-js library</a> (it&#8217;s really nice that the module has an intermediate tree format that you can parse to add your own stuff before converting to HTML, like e.g. wikipage links!), <a href="http://expressjs.com/">express</a> for the whole application structure and <a href="http://code.google.com/p/js-test-driver/">js-test-driver</a> + <a href="http://cjohansen.no/en/javascript/jstdutil_a_ruby_wrapper_over_jstestdriver">jsautotest</a> + a bit of syntax sugar from <a href="http://sinonjs.org/">Sinon.js</a> for the tests (but looking forward to trying out <a href="http://busterjs.org/">Buster.js</a> when it&#8217;s released!). The deployment to Joyent&#8217;s Node.js SmartMachine was reasonably easy. Actually, it was pretty easy once I figured the following:</p>
<ul>
<li>You must not forget to listen in the correct port, with <code class="syntax javascript">server.listen(process.env.PORT || 8001)</code></li>
<li>There are a couple of pretty useful <a href="http://wiki.joyent.com/display/node/Getting+Started+with+a+Node.js+SmartMachine#GettingStartedwithaNode.jsSmartMachine-SSHaccess">Node.js-related command-line utilities</a> to check logs, restart applications and so on</li>
<li>The configuration of the application can be done via <code class="syntax">npm config</code>, see <a href="http://wiki.joyent.com/display/node/npm+Integration">npm integration on Joyent&#8217;s Wiki</a></li>
</ul>
<p>If you&#8217;re curious to see the code, play with it or use it yourself, take a peek to the <a href="https://github.com/emanchado/Wiki-toki">Wiki-Toki repository</a> on GitHub. Happy hacking!</p>
 <p><a href="http://hcoder.org/?flattrss_redirect&amp;id=1207&amp;md5=666f11f6b9488a0fae815494decab83b" title="Flattr" target="_blank"><img src="http://hcoder.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://hcoder.org/2011/10/24/pragmatic-thinking-learning-wikis-and-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://hcoder.org/?flattrss_redirect&amp;id=1207&amp;md5=666f11f6b9488a0fae815494decab83b" type="text/html" />
	</item>
		<item>
		<title>Book review: Javascript Web Applications</title>
		<link>http://hcoder.org/2011/09/20/book-review-javascript-web-applications/</link>
		<comments>http://hcoder.org/2011/09/20/book-review-javascript-web-applications/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 20:42:17 +0000</pubDate>
		<dc:creator>emanchado</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://hcoder.org/?p=1168</guid>
		<description><![CDATA[This is my review of &#8220;Javascript Web Applications&#8221; by Alex MacCaw, part of the O&#8217;Reilly Blogger Review Program (in a nutshell: you can choose an ebook from a given selection, and you get it for free if you make a review and post it in any consumer site). It&#8217;s a book about using Javascript to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://oreilly.com/bloggers/"><img src="http://cdn.oreilly.com/bloggers/blogger-review-badge-200.png" alt="I review for the O'Reilly Blogger Review Program" width="200" height="150" align="right" border="0" /></a> This is my review of &#8220;<a href="http://shop.oreilly.com/product/0636920018421.do">Javascript Web Applications</a>&#8221; by <a href="http://alexmaccaw.co.uk/">Alex MacCaw</a>, part of the O&#8217;Reilly Blogger Review Program (in a nutshell: you can choose an ebook from a given selection, and you get it for free if you make a review and post it in any consumer site). It&#8217;s a book about using Javascript to write (mostly) client-side web applications. The book cover says &#8220;jQuery Developers&#8217; Guide to Moving State to the Client&#8221;, which is somewhat misleading: although most examples that could be written with jQuery <em>are</em> written with jQuery, it&#8217;s a book that anyone interested in Javascript can use, enjoy and learn from, regardless of their library of choice. It doesn&#8217;t even assume you know jQuery, and there&#8217;s a whole appendix dedicated to introducing the reader to the library, should she need it.</p>
<h2>Structure</h2>
<p>The book teaches how to write web applications using Javascript, always following the MVC pattern. It&#8217;s divided in four parts:</p>
<ol>
<li>The first two chapters serve as an introduction to both the MVC pattern and the Javascript language. Although this book is not aimed at total Javascript newbies, you don&#8217;t have to know that much to follow the book. For example, it explains prototypes and constructor functions.</li>
<li>Chapters 3 to 5 cover the implementation details of MVC in Javascript (one chapter for the Model, another for the Controller and the last one about the View).</li>
<li>Chapters 6 to 10 cover many practicalities of client-side web development, like dependency management, unit testing, debugging, interesting browser APIs and deployment tips.</li>
<li>The last three chapters cover Javascript libraries: Spine, Backbone and JavascriptMVC.</li>
</ol>
<p>Additionally, there are three appendices covering <a href="http://jquery.org">jQuery</a>, <a href="http://lesscss.org/">Less</a> and CSS3.</p>
<h2>Highlights and references</h2>
<ul>
<li>Chapter 10 (&#8220;Deploying&#8221;) is full of very good tips and information.</li>
<li>Both the Backbone and the JavascriptMVC chapters were brilliant, looking forward to use any of them soon.</li>
<li>All the <a href="https://github.com/maccman/book-assets">example code</a> is on GitHub.</li>
<li>Page 24: &#8220;The secret to making large Javascript applications is not make large Javascript applications&#8221;.</li>
<li><a href="http://plugins.jquery.com/project/HJS">HJS plugin</a> for jQuery for a nice syntax to create classes.</li>
<li><a href="https://github.com/kriskowal/es5-shim">ES5-shim</a> for browsers that don&#8217;t support Ecmascript 5 yet.</li>
<li>Chapter 2 was a very good introduction about events. removeEventListener (p. 41), stopPropagation/preventDefault (p. 43), list of properties (p. 44), load vs. DOMContentLoaded (p. 45), delegating events (p. 46) and custom events (p. 47-49), among others.</li>
<li>Reference to <a href="http://michaux.ca/articles/javascript-namespacing">blog post about namespacing</a>.</li>
<li>Object.create discussed on page 55.</li>
<li>Using URL hash for URLs on pages 82, 83.</li>
<li>Didn&#8217;t really understand the explanation for the HTML5 history API on p. 85. Alternatively, see the <a href="http://dev.opera.com/articles/view/introducing-the-html5-history-api/">HTML5 history API</a> on Dev Opera.</li>
<li>Very interesting file API on p. 103 and p. 111. Forget the drag-n-drop (<a href="http://www.quirksmode.org/blog/archives/2009/09/the_html5_drag.html">reason</a>) and the copy/paste.</li>
<li>Tips about when to load your Javascript on p. 156.</li>
<li>The JavascriptMVC chapter was brilliant, see p. 208-213 for the class syntax (nicer and more compact, supports this._super()), p. 210 for instrospection and namespaces, p. 211, 212 for model attributes and observables, and p. 213 for setters. Very cool server encapsulation on p. 215. Type conversion and CRUD events on p. 218. JMVC views on p. 219. Templated actions and final example on p. 226-228.</li>
</ul>
<p>Note that all page references are pages in the PDF file, not pages in the book!</p>
<h2>Wrapping up</h2>
<p>This book is packed with very practical information and <em>a lot</em> of code that will teach you how to write applications in Javascript. It builds up from relatively simple code to more advanced stuff, including tips, use of libraries, etc. It&#8217;s one of those books that makes you want to play with all the stuff you&#8217;re learning, and try it all in your next project.</p>
<p>However, sometimes the amount of code makes the book hard to read. Some parts (eg. beginning of the chapter about controllers) are a bit tiring as you have to read and understand so much code, esp. if you&#8217;re not that used to reading more-or-less advanced Javascript. It also lacks information about some important tools like <a href="http://www.opera.com/dragonfly/">Dragonfly</a> (it almost feels like there&#8217;s nothing for developing with Opera) or <a href="http://code.google.com/p/js-test-driver/">js-test-driver</a>.</p>
<p>In summary, this is the perfect book if you know <em>a bit</em> of Javascript and want to learn modern techniques and libraries that will get you started in <em>serious</em> client-side programming. <em>Especially</em> if you are one of those server-side programmers that don&#8217;t like Javascript but has to use it anyway (because despite all its warts, it&#8217;s a really nice language!). If you&#8217;re a Javascript wizard and you have been developing client-side code for years, this book may not be for you.</p>
 <p><a href="http://hcoder.org/?flattrss_redirect&amp;id=1168&amp;md5=083124645c164fd06570fbd5e5ccfc84" title="Flattr" target="_blank"><img src="http://hcoder.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://hcoder.org/2011/09/20/book-review-javascript-web-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://hcoder.org/?flattrss_redirect&amp;id=1168&amp;md5=083124645c164fd06570fbd5e5ccfc84" type="text/html" />
	</item>
		<item>
		<title>LeakFeed and &lt;angular/&gt;</title>
		<link>http://hcoder.org/2011/09/15/angular/</link>
		<comments>http://hcoder.org/2011/09/15/angular/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 20:37:35 +0000</pubDate>
		<dc:creator>emanchado</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Freedom]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[automated tests]]></category>
		<category><![CDATA[bootstrap]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[jasmine]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[tests]]></category>

		<guid isPermaLink="false">http://hcoder.org/?p=1128</guid>
		<description><![CDATA[A couple of week ago I discovered LeakFeed, an API to fetch cables from Wikileaks. I immediately thought it would be cool to play a bit with it and create some kind of application. After a couple of failed ideas that didn&#8217;t really take off, I decided to exploit my current enthusiasm for Javascript and [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of week ago I discovered <a href="http://www.leakfeed.com/">LeakFeed</a>, an API to fetch cables from <a href="http://www.wikileaks.org/">Wikileaks</a>. I immediately thought it would be cool to play a bit with it and create some kind of application. After a couple of failed ideas that didn&#8217;t really take off, I decided to exploit my current enthusiasm for Javascript and build something without a server. Other advantages were that I knew <a href="http://angularjs.org/">Angular</a>, an HTML &#8220;power up&#8221; written in Javascript (what else?), which I knew it would ease the whole process a lot, and I even got the chance to learn how to use Twitter&#8217;s excellent <a href="http://twitter.github.com/bootstrap/">Bootstrap</a> HTML and CSS toolkit.</p>
<p>What I decided to build is a very simple interface to search for leaked cables. I called it <a href="http://emanchado.github.com/leakyleaks.html">LeakyLeaks</a> (see the <a href="https://github.com/emanchado/LeakyLeaks">code on GitHub</a>). Unfortunately the LeakFeed API is quite limited, so I had to limit my original idea. However, I think the result is kind of neat, especially considering the little effort. To build it, I started writing support classes and functions using Test-Driven Development with <a href="http://pivotal.github.com/jasmine/">Jasmine</a>. Once I had that basic functionality up and running I started building the interface with Bootstrap and, at that point, integrating the data from LeakFeed with Angular was so easy it&#8217;s almost ridiculous. And as LeakFeed can return the data using JSONP, I didn&#8217;t even need a server: all my application is simply a <em>static</em> HTML file with some Javascript code.</p>
<p>All this get-data-from-somewhere-and-display-it is astonishingly simple in Angular. There&#8217;s this functionality (&#8220;<a href="http://docs.angularjs.org/#!/api/angular.service.$resource">resources</a>&#8220;) to declare sources of external data: you define the URLs and methods to get the data from those resources, and then simply call some methods to fetch the data. E.g.: you can get the list of all tags in LeakFeed from <a href="http://api.leakfeed.com/v1/cables/tags.json">http://api.leakfeed.com/v1/cables/tags.json</a> (adding a GET parameter <code>callback</code> with a function name if you want <a href="http://en.wikipedia.org/wiki/JSONP">JSONP</a>). Similarly, you can get the list of all offices in LeakFeed from <a href="http://api.leakfeed.com/v1/cables/offices.json">http://api.leakfeed.com/v1/cables/offices.json</a>. In Angular, you can declare a resource to get all this information like this:</p>
<pre class="syntax javascript">this.LeakFeedResourceProxy = $resource(
 'http://api.leakfeed.com/v1/cables/:id.json',
 { callback: 'JSON_CALLBACK' },
 { getTags:    {method: 'JSON', isArray: true, params: {id: 'tags'}},
   getOffices: {method: 'JSON', isArray: true, params: {id: 'offices'}}}
);</pre>
<p>Once you have declared it, using it is as simple as calling the appropriate method on the object. That is, you can get the tags by calling <code class="syntax javascript">this.LeakFeedResourceProxy.getTags()</code>, and the offices by calling <code class="syntax javascript">this.LeakFeedResourceProxy.getOffices()</code>. And when I say &#8220;get the tags&#8221;, I mean <em>get a list of Javascript objects</em>: no JSON, text or processing involved. If you assign the result of those functions to any property (say, <code class="syntax javascript">this.availableOffices</code>), you&#8217;ll be able to show that information like so (the <code class="syntax javascript">|officename</code> is a custom filter to show the office names with a special format):</p>
<pre class="syntax html">&lt;select id=&quot;office&quot; name=&quot;office&quot;&gt; \
  &lt;option value=&quot;{{o.name}}&quot;&gt;{{o.display_name|officename}} ({{o.cables}})&lt;/option&gt; \
&lt;/select&gt;</pre>
<p>The cool thing is, thanks to Angular&#8217;s data binding, anytime the value of that variable changes, the representation in the HTML changes, too. That is, if you assign another value to <code class="syntax javascript">this.availableOffices</code> the select box will be automatically updated to have the new set of options! But the data binding is two-way, so any changes you make in the UI also get reflected back in the Javascript variables. This further simplifies many tasks and makes programming with Angular a breeze.<br />
There are other nice things about Angular (and many nice things about Bootstrap and Jasmine of course!), but I think that&#8217;s enough for today :-)</p>
 <p><a href="http://hcoder.org/?flattrss_redirect&amp;id=1128&amp;md5=15fac2e864cbc672f9ea3fd3b8c15bc4" title="Flattr" target="_blank"><img src="http://hcoder.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://hcoder.org/2011/09/15/angular/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://hcoder.org/?flattrss_redirect&amp;id=1128&amp;md5=15fac2e864cbc672f9ea3fd3b8c15bc4" type="text/html" />
	</item>
		<item>
		<title>Facebook privacy scanner (ReclaimPrivacy)</title>
		<link>http://hcoder.org/2010/09/05/facebook-privacy-scanner-reclaimprivacy/</link>
		<comments>http://hcoder.org/2010/09/05/facebook-privacy-scanner-reclaimprivacy/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 12:52:48 +0000</pubDate>
		<dc:creator>emanchado</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Freedom]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[privacy]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[testability]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://hcoder.org/?p=486</guid>
		<description><![CDATA[Summary: there&#8217;s a simple tool that will tell you which Facebook sharing options are &#8220;too open&#8221; in your account. I&#8217;d like you to help me by trying it out and telling me what you think (if you had problems using it, if you would like extra/other information to be shown, if you found any bugs, [...]]]></description>
			<content:encoded><![CDATA[<p><em>Summary: there&#8217;s a simple tool that will tell you which Facebook sharing options are &#8220;too open&#8221; in your account. I&#8217;d like you to <strong>help me</strong> by trying it out and telling me what you think (if you had problems using it, if you would like extra/other information to be shown, if you found any bugs, etc.). Skip to &#8220;how to use it&#8221; below if you&#8217;re not interested in the details for developers. Thanks!</em></p>
<p>Some time ago I discovered a neat Javascript tool called <a href="http://www.reclaimprivacy.org/">ReclaimPrivacy</a>. It was a very simple program that scanned your Facebook privacy settings and told you if you had &#8220;too open&#8221; settings so you could review and fix them. I really liked the tool and thought it was a great idea, but after Facebook changed the layout of the privacy settings, the tool stopped working.</p>
<p>Weeks passed and the tool didn&#8217;t get any update, so I decided to step in and try to help the original programmer adapt the tool so it worked again. The <a href="http://github.com/mjpizz/reclaimprivacy">ReclaimPrivacy code</a> is in GitHub so it was pretty easy to make <a href="http://github.com/emanchado/reclaimprivacy">my own fork</a> and start hacking away. It didn&#8217;t take me long to adapt the first things to the new privacy settings layout, and after some more time I was much more comfortable with the code, had made more things work, added tests and even added new features. Now that it&#8217;s <em>starting</em> to get close to something we could release as the new official ReclaimPrivacy version, I&#8217;d like your feedback.</p>
<p><strong>How to use it</strong>: add a new bookmark for <a href="javascript:(function(){var%20script=document.createElement('script');script.src='http://hcoder.org/wp-content/uploads/2010/09/privacyscanner.js';document.getElementsByTagName('head')[0].appendChild(script);})()">this link</a>. You usually just have to drag and drop it to your browser toolbar, or alternatively add a new bookmark (typically you can do that by pressing Ctrl-D) and make sure the address is the above link. Go to the <a href="http://www.reclaimprivacy.org/help">ReclaimPrivacy help page</a> if you have trouble (but use my link, not the one provided there!). Once you have the bookmark, go to Facebook and click on the bookmark. It will show you some information about your Facebook privacy settings on top of the page. Just leave a comment here or drop me an e-mail with your opinion, thanks! You can skip the rest of the post if you are not interested in Javascript programming and/or software automated testing ;-)</p>
<p>During my hacking I made a lot of different changes: I split the source file into several different files, I made the code (more) testable, I added tests, and I added more features. I&#8217;m really into testing and testability, so one of the first things I did with the code was trying to decouple it from the network calls so I could write tests for it. As you may know, I think that code that doesn&#8217;t have tests is very hard to work with, and I even consider it&#8217;s not &#8220;<a href="http://hcoder.org/2010/08/10/from-pseudo-code-to-code/">true code</a>&#8220;. Now, <strong>I&#8217;m no Javascript expert</strong>, so some of my techniques might not be very&#8230; idiomatic. That said, some of the code change highlights you may be interested in:</p>
<ul>
<li> The <a href="http://github.com/mjpizz/reclaimprivacy/blob/master/javascripts/privacyscanner.js#LID7619">getInformationDropdownSettings</a> method, renamed to <a href="http://github.com/emanchado/reclaimprivacy/blob/advanced-settings/javascripts/scanning.js#LID204">getSettingInformation</a>, is now shorter, more readable, more testable and has more features. The changes are: (1) making it receive an object with the relevant part of the DOM, instead of a window object; (2) supporting, in principle, any kind of setting, not only dropdowns; (3) allowing each setting to have its own idea of what &#8220;too open&#8221; means (see <a href="http://github.com/emanchado/reclaimprivacy/blob/advanced-settings/javascripts/scanning.js#LID46">the settings array</a>); (4) allowing the caller of the method to specify its own list of recognised settings and acceptable privacy levels; (5) passing the number of open and total sections to the handler, instead of just a boolean stating whether or not there&#8217;s any &#8220;too open&#8221; setting.</li>
<li>I made the <a href="http://github.com/mjpizz/reclaimprivacy/blob/master/javascripts/privacyscanner.js#LID7425">old getUrlForV2Section</a> more testable by extracting the most <em>interesting</em> (read: likely to break or need maintenance) code to its own method, <a href="http://github.com/emanchado/reclaimprivacy/blob/master/javascripts/utils.js#LID26">_extractUrlsFromPrivacySettingsPage</a>, and making the <a href="http://github.com/emanchado/reclaimprivacy/blob/master/javascripts/utils.js#LID42">new getUrlForV2Section</a> work with both real URLs (checking Facebook with an Ajax call) and fake HTML dumps representing what those URLs would return.</li>
<li>I made the <a href="http://github.com/mjpizz/reclaimprivacy/blob/master/javascripts/privacyscanner.js#LID7387">old withFramedPageOnFacebook</a>, a very important method used in several places, more flexible by accepting not just URLs, but also functions or data structures (<a href="http://github.com/emanchado/reclaimprivacy/blob/advanced-settings/javascripts/utils.js#LID71">new withFramedPageOnFacebook</a>).</li>
<li>Now we have some <a href="http://github.com/emanchado/reclaimprivacy/blob/master/tests/unittest.html">basic tests</a> (with <a href="http://github.com/emanchado/reclaimprivacy/blob/master/tests/fixtures/privacy-pages.js">fixtures</a> even), without which doing some of these changes would have been such a pain, I wouldn&#8217;t have bothered making them in the first place.</li>
</ul>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 666px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">http://github.com/emanchado/reclaimprivacy/blob/master/javascripts/utils.js#LID42</div>
 <p><a href="http://hcoder.org/?flattrss_redirect&amp;id=486&amp;md5=b1a5ef4c1f236ebc1e8941e0fd781abd" title="Flattr" target="_blank"><img src="http://hcoder.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://hcoder.org/2010/09/05/facebook-privacy-scanner-reclaimprivacy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<atom:link rel="payment" href="http://hcoder.org/?flattrss_redirect&amp;id=486&amp;md5=b1a5ef4c1f236ebc1e8941e0fd781abd" type="text/html" />
	</item>
		<item>
		<title>Recent pet projects + Git + Github</title>
		<link>http://hcoder.org/2009/04/06/recent-pet-projects-git-github/</link>
		<comments>http://hcoder.org/2009/04/06/recent-pet-projects-git-github/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 22:21:00 +0000</pubDate>
		<dc:creator>emanchado</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[darcs]]></category>
		<category><![CDATA[demisus]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[kiva]]></category>
		<category><![CDATA[loanmeter]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[sudoku]]></category>
		<category><![CDATA[widget]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I had mentioned that I was learning Javascript to write a Kiva Opera widget. Some time ago I released the first version of my World Loanmeter widget, and I have uploaded two more since. Not much has happened between the first and the third release from the user POV, but a couple of things were [...]]]></description>
			<content:encoded><![CDATA[<p>I had mentioned that I was <a href="http://hcoder.org/2009/02/26/kiva-api-javascript-git-and-my-first-widget-oh-my">learning Javascript to write a Kiva Opera widget</a>. Some time ago I released the first version of my <a href="http://widgets.opera.com/widget/12102/">World Loanmeter</a> widget, and I have uploaded two more since. Not much has happened between the first and the third release from the user <span class="caps">POV</span>, but a couple of things were interesting when developing it:</p>
<ul>
<li>I learned <a href="http://docs.jquery.com/QUnit">QUnit</a>, which I used to write <a href="http://github.com/emanchado/world-loanmeter/blob/31d34707728a1f7d5813a57de4d3b8caf10750ce/test/unittest.html">some really useful unit tests</a>. It&#8217;s quite nice to be able to write Javascript unit tests easily.</li>
<li>I made some <a href="http://github.com/emanchado/world-loanmeter/commit/425a4a854bc074c825b6f15546235958977da1d5">heavy refactoring</a> (see above) which made me learn some more Javascript <em>and</em> made the code much more flexible, so now the widget is not limited to a single Kiva <span class="caps">API</span> page of results, but to as many pages as needed to fetch whatever number of loans the user wants. Not to mention that the data source need not be a <span class="caps">URL</span>.</li>
<li>Now the widget actually has some configuration. Namely, the number of loans to show in the map. It also stores it persistently using the <a href="http://dev.opera.com/articles/view/opera-widgets-preference-store/">preference store</a>, which is quite nice.</li>
</ul>
<p>As I said, I used Git for it. I don&#8217;t &#8220;hate&#8221; it anymore, but I still find some things annoying, like the horrible, confusing names some options have (I&#8217;m thinking about &#8220;git checkout <file>&#8221; to revert the local changes, or &#8220;git diff &#8212;cached&#8221; to see the contents of the index/staging area; seriously guys, W-T-F?). I used to be skeptical about the &#8220;git add&#8221; for changes and then &#8220;git commit&#8221;, but I actually find it quite nice: it&#8217;s easier to plan a commit that way, and if you don&#8217;t want to plan it, you can always just &#8220;git commit <file>&#8221; directly. Also &#8220;git add -p&#8221; is really nice to commit just <em>parts</em> of a file (at last, someone copies some of the good stuff <a href="http://darcs.net/">Darcs</a> had had for ages!). Apart from Git itself, it&#8217;s cool that there is <a href="http://github.com">GitHub</a>, so it&#8217;s easy to share your repositories without having to <code>rsync</code> to some web server or similar&#8230; not to mention that your project is much more visible that way.</p>
<p>But the World Loanmeter wasn&#8217;t the only pet project I was working on these past weeks: I also wrote a simple sudoku solver, <a href="http://wiki.github.com/emanchado/demisus">demisus</a>, in Ruby. The reason? Writing a prototype of a sudoku solver in a language I&#8217;m fluent with, to play with the design and get something interesting and easy to maintain&#8230; to rewrite it in Haskell. I have been trying to learn some functional language for some years now, but I never find a &#8220;project&#8221; that is interesting enough to write some &#8220;real world program&#8221; in the language and I end up not learning anything. After starting reading <a href="http://book.realworldhaskell.org/">Real World Haskell</a>, I really felt like trying to learn the language once and for all, and I figured that a sudoku solver was easy enough to write, something I know enough about, and something math-y enough to be reasonably easy to implement in Haskell.</p>
<p>So, if you&#8217;re interested in any of them, you can have a look in Github and even contribute ;-)</p>
 <p><a href="http://hcoder.org/?flattrss_redirect&amp;id=65&amp;md5=e6722f7dfe9cd27244931593fc4215ed" title="Flattr" target="_blank"><img src="http://hcoder.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://hcoder.org/2009/04/06/recent-pet-projects-git-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://hcoder.org/?flattrss_redirect&amp;id=65&amp;md5=e6722f7dfe9cd27244931593fc4215ed" type="text/html" />
	</item>
	</channel>
</rss>

