<?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>vilimblog</title>
	<atom:link href="http://vilimpoc.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://vilimpoc.org/blog</link>
	<description>tech and food</description>
	<lastBuildDate>Sun, 01 Jan 2012 22:46:30 +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>SOPA/PROTECT-IP Blackout Simulator</title>
		<link>http://vilimpoc.org/blog/2012/01/02/sopaprotect-ip-blackout-simulator/</link>
		<comments>http://vilimpoc.org/blog/2012/01/02/sopaprotect-ip-blackout-simulator/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 22:46:30 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://vilimpoc.org/blog/?p=424</guid>
		<description><![CDATA[Ok, I've written a quick little client-side Javascript function that will simulate what a SOPA/PROTECT-IP Internet may look like. Feel free to link it into your website and help spread the word. Demonstration Page: here Code: Github Repository AmericanCensorship.org Infographic Electronic Frontier Foundation Campaign]]></description>
			<content:encoded><![CDATA[<div id="attachment_440" class="wp-caption aligncenter" style="width: 325px"><a href="http://vilimpoc.org/blog/wp-content/uploads/2012/01/were-sorry-sopa.png" rel="lightbox[424]" title="We&#039;re Sorry."><img src="http://vilimpoc.org/blog/wp-content/uploads/2012/01/were-sorry-sopa.png" alt="" title="We&#039;re Sorry." width="315" height="224" class="size-full wp-image-440" /></a><p class="wp-caption-text">This is what most of the Internet might look like, if SOPA passes.</p></div>
<p>Ok, I've written a quick little client-side Javascript function that will simulate what a SOPA/PROTECT-IP Internet may look like. Feel free to link it into your website and help spread the word.</p>
<p>Demonstration Page: <a href="http://vilimpoc.org/research/sopa-blackout-simulator/">here</a><br />
Code: <a href="https://github.com/nuket/SOPA-PROTECT-IP-Blackout-Simulator">Github Repository</a></p>
<p><a href="http://americancensorship.org/infographic.html">AmericanCensorship.org Infographic</a><br />
<a href="https://action.eff.org/o/9042/p/dia/action/public/?action_KEY=8173">Electronic Frontier Foundation Campaign</a></p>
]]></content:encoded>
			<wfw:commentRss>http://vilimpoc.org/blog/2012/01/02/sopaprotect-ip-blackout-simulator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Chrome With A Ramdisk on Ubuntu</title>
		<link>http://vilimpoc.org/blog/2011/11/26/google-chrome-with-a-ramdisk-on-ubuntu/</link>
		<comments>http://vilimpoc.org/blog/2011/11/26/google-chrome-with-a-ramdisk-on-ubuntu/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 02:08:51 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://vilimpoc.org/blog/?p=395</guid>
		<description><![CDATA[On Ubuntu 10.10, it looks something like this: /opt/google/chrome/google-chrome %U --disk-cache-dir="/dev/shm" Which is handy for not writing cache junk to your SSD.]]></description>
			<content:encoded><![CDATA[<p>On Ubuntu 10.10, it looks something like this:</p>
<blockquote><p>/opt/google/chrome/google-chrome %U --disk-cache-dir="/dev/shm"</p></blockquote>
<p>Which is handy for not writing cache junk to your SSD.</p>
]]></content:encoded>
			<wfw:commentRss>http://vilimpoc.org/blog/2011/11/26/google-chrome-with-a-ramdisk-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chrome Multiuser / Limited User Account Installation Annoyances</title>
		<link>http://vilimpoc.org/blog/2011/10/15/chrome-multiuser-limited-user-account-installation-annoyances/</link>
		<comments>http://vilimpoc.org/blog/2011/10/15/chrome-multiuser-limited-user-account-installation-annoyances/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 10:33:43 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://vilimpoc.org/blog/?p=356</guid>
		<description><![CDATA[To the Google Chrome installer builders: there are a few things that would be nice to have fixed. Limited User Account installations: On Windows XP x64 Edition (and probably other versions), trying to install the default Web Install package from here fails with the message "Google Update installation failed with error 0x80070003". Whatever that means. [...]]]></description>
			<content:encoded><![CDATA[<p>To the Google Chrome installer builders: there are a few things that would be nice to have fixed.</p>
<p>Limited User Account installations: On Windows XP x64 Edition (and probably other versions), trying to install the default Web Install package from <a href="http://www.google.com/chrome/">here</a> fails with the message "Google Update installation failed with error 0x80070003". Whatever that means. I have a hunch that on Windows Vista, and Windows 7, the User Account Control stuff might intercept that the installer wants privilege escalation and automatically pop up the right dialog for this.</p>
<div id="attachment_358" class="wp-caption aligncenter" style="width: 466px"><a href="http://vilimpoc.org/blog/wp-content/uploads/2011/10/chrome-install-02.png" rel="lightbox[356]" title="Chrome Install Error"><img src="http://vilimpoc.org/blog/wp-content/uploads/2011/10/chrome-install-02.png" alt="" title="Chrome Install Error" width="456" height="162" class="size-full wp-image-358" /></a><p class="wp-caption-text">What you see if you try to install the default Web Install package without running as Administrator.</p></div>
<p>If I click on the link "Show me help for this issue.", there's not much help there. Oddly enough, I was just reading Microsoft's <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa511258.aspx">"Windows User Experience Interaction Guidelines"</a>. The section on <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa511267.aspx#codes">"Error Messages / Error Codes"</a> applies here.</p>
<div id="attachment_359" class="wp-caption aligncenter" style="width: 310px"><a href="http://vilimpoc.org/blog/wp-content/uploads/2011/10/chrome-install-03.png" rel="lightbox[356]" title="Chrome Error &quot;Help&quot; Page"><img src="http://vilimpoc.org/blog/wp-content/uploads/2011/10/chrome-install-03-300x258.png" alt="" title="Chrome Error &quot;Help&quot; Page" width="300" height="258" class="size-medium wp-image-359" /></a><p class="wp-caption-text">That&#039;s useful.</p></div>
<p>I know what you're trying to say, Google Update is a system service, so it probably wants Administrator rights to my system. It would be nice if it didn't, maybe if it ran under the Limited User's profile only. I understand that's less secure, but ok, I try installing the package with the "Run As" option to escalate privileges to the installer.</p>
<div id="attachment_384" class="wp-caption aligncenter" style="width: 394px"><a href="http://vilimpoc.org/blog/wp-content/uploads/2011/10/chrome-install-05.png" rel="lightbox[356]" title="Run As"><img src="http://vilimpoc.org/blog/wp-content/uploads/2011/10/chrome-install-05.png" alt="" title="Run As" width="384" height="321" class="size-full wp-image-384" /></a><p class="wp-caption-text">Let&#039;s try it this way.</p></div>
<p>The installer completes, as the Administrator account. But wait, where's the icon in my Limited User Account? Oh no, the default Chrome installer package only installs to the account whose credentials were used to run it! e.g. Only the Administrator account has Chrome now.</p>
<p>Catch-22. So I uninstall you.</p>
<p>Then I see that there is an <a href="http://www.google.com/support/installer/bin/answer.py?answer=126299">"Alternate (offline) Google Chrome installer (Windows)"</a>, which allows me to download one version of the installer that installs Chrome "for your own user account only" or a version that installs Chrome "for all user accounts on your computer".</p>
<p>The first package doesn't work, for the same reasons the Web Install package doesn't work.</p>
<p>The second package works, when installed as Administrator, which makes sense. However, when the Installer starts the Chrome Browser for the first time right after installation, it runs the Browser instances as the Administrator account, not as the Limited User Account. </p>
<p>When I go to start it with the Limited User Account, I get two errors. First, "Failed To Create Data Directory, Google Chrome cannot read and write to its data directory." Second, "Your preferences can not be read. Some features may be unavailable and changes to preferences won't be saved."</p>
<div id="attachment_362" class="wp-caption aligncenter" style="width: 468px"><a href="http://vilimpoc.org/blog/wp-content/uploads/2011/10/chrome-install-06.png" rel="lightbox[356]" title="User Data Error"><img src="http://vilimpoc.org/blog/wp-content/uploads/2011/10/chrome-install-06.png" alt="" title="User Data Error" width="458" height="133" class="size-full wp-image-362" /></a><p class="wp-caption-text">Profiles missing for accounts not used during the install.</p></div>
<p>I select a different directory for my preferences, using the directory chooser.</p>
<p>When I close and restart Chrome, I get the same error, because the --user-data-dir in the Google Chrome shortcut in my Limited User Account somehow gets reset.</p>
<div id="attachment_364" class="wp-caption aligncenter" style="width: 377px"><a href="http://vilimpoc.org/blog/wp-content/uploads/2011/10/chrome-install-08.png" rel="lightbox[356]" title="Changing The Shortcut"><img src="http://vilimpoc.org/blog/wp-content/uploads/2011/10/chrome-install-08.png" alt="" title="Changing The Shortcut" width="367" height="509" class="size-full wp-image-364" /></a><p class="wp-caption-text">Adding --user-data-dir=(somewhere) to the shortcut allows Chrome to work in a Limited User Account.</p></div>
<p>If I add --user-data-dir to the Quick Start shortcut, it somehow/sometimes gets reset to something without the --user-data-dir flag the next time Chrome is started, but after that it doesn't get reset. (I'm not going to debug why this is so.)</p>
<p>If I add --user-data-dir to the shortcut located on my Desktop, it doesn't get reset.</p>
<p>I have a hunch here that the multiuser installation will work under Windows Vista and Windows 7 because of that weird profile virtualization stuff Microsoft built into them (<em>and which annoys the heck out of software developers, because we never know where a profile's files are actually stored</em>).</p>
<p>In any case, after all of that, the browser does work fine, but the taste of a bad install experience does not cast a good first impression.</p>
]]></content:encoded>
			<wfw:commentRss>http://vilimpoc.org/blog/2011/10/15/chrome-multiuser-limited-user-account-installation-annoyances/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oddly Good Chinese Food In Madrid</title>
		<link>http://vilimpoc.org/blog/2011/04/02/oddly-good-chinese-food-in-madrid/</link>
		<comments>http://vilimpoc.org/blog/2011/04/02/oddly-good-chinese-food-in-madrid/#comments</comments>
		<pubDate>Sat, 02 Apr 2011 16:03:57 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Food]]></category>

		<guid isPermaLink="false">http://vilimpoc.org/blog/?p=328</guid>
		<description><![CDATA[After a few days of eating local in Madrid, the diet of mostly meat, cheese, rice, seafood, olives, and bread can start to get a bit exhausting. One begins to crave vegetables of the leafy green variety, especially when one has Asian parents. Somehow in searching these out, my father and I managed to stumble [...]]]></description>
			<content:encoded><![CDATA[<p>After a few days of eating local in Madrid, the diet of mostly meat, cheese, rice, seafood, olives, and bread can start to get a bit exhausting. One begins to crave vegetables of the leafy green variety, especially when one has Asian parents. Somehow in searching these out, my father and I managed to stumble into two fantastic Chinese restaurants on the same street: Calle de Isabel 'La Catolica' by the Plaza de España. It may be a bit cheesy going to Spain to eat Chinese food, but sometimes your intestines just demand it.</p>
<p>Here's the Google Street View of the places.</p>
<p><iframe width="550" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.es/maps?f=q&amp;source=embed&amp;hl=es&amp;geocode=&amp;q=madrid&amp;sll=40.396764,-3.713379&amp;sspn=9.702386,19.753418&amp;ie=UTF8&amp;hq=&amp;hnear=Madrid,+Comunidad+de+Madrid&amp;ll=40.416691,-3.700345&amp;spn=0.004484,0.013733&amp;z=14&amp;layer=c&amp;cbll=40.421426,-3.70919&amp;panoid=zkPLZxbSzy2Z7Bwh3kXKQw&amp;cbp=12,293.69,,0,13.21&amp;output=svembed"></iframe><br /><small><a href="http://maps.google.es/maps?f=q&amp;source=embed&amp;hl=es&amp;geocode=&amp;q=madrid&amp;sll=40.396764,-3.713379&amp;sspn=9.702386,19.753418&amp;ie=UTF8&amp;hq=&amp;hnear=Madrid,+Comunidad+de+Madrid&amp;ll=40.416691,-3.700345&amp;spn=0.004484,0.013733&amp;z=14&amp;layer=c&amp;cbll=40.421426,-3.70919&amp;panoid=zkPLZxbSzy2Z7Bwh3kXKQw&amp;cbp=12,293.69,,0,13.21" style="color:#0000FF;text-align:left">[click to open in a new window]</a></small></p>
<p>In the first restaurant, we ordered fresh steamed fish in soy sauce with green onions, fried salt and pepper prawns, and some bamboo with shiitake mushrooms (by mistake). In the second restaurant, we ordered pork blood with pig intestines (a rarity almost everywhere outside of Thailand or Taiwan), ma poa tofu, and fried <a href="http://en.wikipedia.org/wiki/Ipomoea_aquatica">water spinach</a> (also a rarity). I'll let the pictures speak for themselves.</p>

<a href='http://vilimpoc.org/blog/2011/04/02/oddly-good-chinese-food-in-madrid/img_0344/' title='IMG_0344'><img width="150" height="150" src="http://vilimpoc.org/blog/wp-content/uploads/2011/04/IMG_0344-150x150.jpg" class="attachment-thumbnail" alt="IMG_0344" title="IMG_0344" /></a>
<a href='http://vilimpoc.org/blog/2011/04/02/oddly-good-chinese-food-in-madrid/img_20110330_174921/' title='IMG_20110330_174921'><img width="150" height="150" src="http://vilimpoc.org/blog/wp-content/uploads/2011/04/IMG_20110330_174921-150x150.jpg" class="attachment-thumbnail" alt="IMG_20110330_174921" title="IMG_20110330_174921" /></a>
<a href='http://vilimpoc.org/blog/2011/04/02/oddly-good-chinese-food-in-madrid/img_20110330_174939/' title='IMG_20110330_174939'><img width="150" height="150" src="http://vilimpoc.org/blog/wp-content/uploads/2011/04/IMG_20110330_174939-150x150.jpg" class="attachment-thumbnail" alt="IMG_20110330_174939" title="IMG_20110330_174939" /></a>
<a href='http://vilimpoc.org/blog/2011/04/02/oddly-good-chinese-food-in-madrid/img_20110330_174944/' title='IMG_20110330_174944'><img width="150" height="150" src="http://vilimpoc.org/blog/wp-content/uploads/2011/04/IMG_20110330_174944-150x150.jpg" class="attachment-thumbnail" alt="IMG_20110330_174944" title="IMG_20110330_174944" /></a>
<a href='http://vilimpoc.org/blog/2011/04/02/oddly-good-chinese-food-in-madrid/img_20110330_174948/' title='IMG_20110330_174948'><img width="150" height="150" src="http://vilimpoc.org/blog/wp-content/uploads/2011/04/IMG_20110330_174948-150x150.jpg" class="attachment-thumbnail" alt="IMG_20110330_174948" title="IMG_20110330_174948" /></a>

]]></content:encoded>
			<wfw:commentRss>http://vilimpoc.org/blog/2011/04/02/oddly-good-chinese-food-in-madrid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vertical Sync and Ubuntu 10.10</title>
		<link>http://vilimpoc.org/blog/2011/02/18/vertical-sync-and-ubuntu-10-10/</link>
		<comments>http://vilimpoc.org/blog/2011/02/18/vertical-sync-and-ubuntu-10-10/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 20:10:13 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://vilimpoc.org/blog/?p=317</guid>
		<description><![CDATA[Ubuntu 10.10, with the Compiz desktop effects enabled, is a formidable user interface. One minor issue is that the graphics refresh ignores the vertical sync by default, leading to some tearing and visual ugliness. There are three settings that I used to fix this up, with a marked improvement in visual quality. Note: With vertical [...]]]></description>
			<content:encoded><![CDATA[<p>Ubuntu 10.10, with the Compiz desktop effects enabled, is a formidable user interface. One minor issue is that the graphics refresh ignores the vertical sync by default, leading to some tearing and visual ugliness.</p>
<p>There are three settings that I used to fix this up, with a marked improvement in visual quality. Note: With vertical sync enabled, the UI might feel just a few milliseconds more sluggish than before, because it will wait slightly until the next sync pulse to refresh. This takes a little getting used to, but the overall improvement in the feel of the UI can be worth it. e.g. No more flickering!</p>
<p>Setting 1 is the "Sync To VBlank" item in the CompizConfig Settings Manager: </p>
<p><a href="http://vilimpoc.org/blog/wp-content/uploads/2011/02/ccsm-1.png" rel="lightbox[317]" title="CompizConfig Settings Manager"><img src="http://vilimpoc.org/blog/wp-content/uploads/2011/02/ccsm-1-300x200.png" alt="" title="CompizConfig Settings Manager" width="300" height="200" class="aligncenter size-medium wp-image-320" /></a></p>
<p>Setting 2 is in the "X Server XVideo Settings" panel of the NVIDIA X Server Settings control panel.</p>
<p><a href="http://vilimpoc.org/blog/wp-content/uploads/2011/02/nxss-1.png" rel="lightbox[317]" title="NVIDIA X Server Settings 1"><img src="http://vilimpoc.org/blog/wp-content/uploads/2011/02/nxss-1-300x226.png" alt="" title="NVIDIA X Server Settings 1" width="300" height="226" class="aligncenter size-medium wp-image-323" /></a></p>
<p>Setting 3 is in the "OpenGL Settings" panel of the NVIDIA X Server Settings control panel.</p>
<p><a href="http://vilimpoc.org/blog/wp-content/uploads/2011/02/nxss-2.png" rel="lightbox[317]" title="NVIDIA X Server Settings 2"><img src="http://vilimpoc.org/blog/wp-content/uploads/2011/02/nxss-2-300x226.png" alt="" title="NVIDIA X Server Settings 2" width="300" height="226" class="aligncenter size-medium wp-image-324" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://vilimpoc.org/blog/2011/02/18/vertical-sync-and-ubuntu-10-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing REST API with LearnBoost&#8217;s Tobi + Vows.js</title>
		<link>http://vilimpoc.org/blog/2011/01/19/testing-rest-api-with-learnboosts-tobi-vows-js/</link>
		<comments>http://vilimpoc.org/blog/2011/01/19/testing-rest-api-with-learnboosts-tobi-vows-js/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 00:11:28 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://vilimpoc.org/blog/?p=311</guid>
		<description><![CDATA[I've been looking for a clean, framework-independent way of doing white-box API testing using Node.js. For a long while, the things that popped up when doing a quick scan of the Node Package Manager package lists weren't ticking all of the right boxes: zombie.js is going for a full browser simulation but doesn't provide a [...]]]></description>
			<content:encoded><![CDATA[I've been looking for a clean, framework-independent way of doing white-box API testing using <a href="http://nodejs.org/">Node.js</a>. For a long while, the things that popped up when doing a quick scan of the Node Package Manager package lists weren't ticking all of the right boxes: <a href="http://zombie.labnotes.org/">zombie.js</a> is going for a full browser simulation but doesn't provide a simple Browser.post() method (you have to use selectors to find the form.submit button and then fire a click() on it), Node's native http.Client is too low-level and doesn't do cookies, and various other http request wrappers weren't quite cutting it either.

I think I've found a solution for this particular version of the problem:

LearnBoost's <a href="https://github.com/LearnBoost/tobi">Tobi</a> combined with <a href="http://vowsjs.org/">Vows.js</a> is letting me do clean REST API testing, with a minimum of hassle, and all the built-in sugar-coated goodness of <a href="https://github.com/visionmedia/should.js">should.js</a> fluent assertions.

For example:

<pre class="brush:js">
var HOST  = 'localhost';
var PORT  = 80;
var API   = "/api/user/create";

var tobi   = require('tobi'),
    vows   = require('vows'),
    assert = require('assert');

var newbie = function() { return tobi.createBrowser(PORT, HOST) };

// -------------------------------------------------------------
// Macros.
// -------------------------------------------------------------

var macroPostOnlyApiChecks = function(url) {
	return {
		'GET': {
			topic: function() {
				var browser = newbie();
				browser.get(url, this.callback);
			},
			'should fail.': function(res, $) {
				res.should.not.have.status(200);
			}
		},
		'Empty POST': {
			topic: function() {
				var browser = newbie();
				browser.post(url, this.callback);
			},
			'should fail.': function(res, $) {
				res.should.not.have.status(200);
			}
		}
	};
};

var macroCreateUserOk = function(suite) {
	return {
		'Create user': {
			topic: function() {
				var browser = newbie();
				var data = { signupUsername: '', };
				
				data = JSON.stringify(data);
				browser.post('/api/user/create', data, this.callback);
			},
			'should succeed.': function(res, $) {
				res.should.have.status(200);
				console.log(res);
				
				// Pass created user credentials back to
				// the calling suite for later use.
				if (suite) {
				}
			}
		}
	};
};

// -------------------------------------------------------------
// User API Test Suite
//
// Run me with: vows api.user.create.vows.js --spec
// -------------------------------------------------------------

var suite = vows.describe('User API Test Suite');

// Batches  are executed sequentially.
// Contexts are executed in parallel.

suite.addBatch(macroPostOnlyApiChecks(API));
suite.addBatch(macroCreateUserOk());

suite.export(module);
</pre>

Future steps then include using the macros to help set up other tests that require a valid user, etc. Overall, this is the most straightforward solution I've yet found for the problem of testing a REST API while also faking a session.]]></content:encoded>
			<wfw:commentRss>http://vilimpoc.org/blog/2011/01/19/testing-rest-api-with-learnboosts-tobi-vows-js/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Decorators In C</title>
		<link>http://vilimpoc.org/blog/2010/12/24/decorators-in-c/</link>
		<comments>http://vilimpoc.org/blog/2010/12/24/decorators-in-c/#comments</comments>
		<pubDate>Fri, 24 Dec 2010 15:27:12 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://vilimpoc.org/blog/?p=296</guid>
		<description><![CDATA[Turns out you can also do decorators in C, this came in handy for something else I had to work on recently. It's not quite as nice, because functions aren't first-class, but handy nonetheless. Here's what that looks like: #include typedef int (* const decorableFnType)(int paramOne, int paramTwo); int functionOne(int paramOne, int paramTwo) { printf("functionOne: [...]]]></description>
			<content:encoded><![CDATA[<p>Turns out you can also do decorators in C, this came in handy for something else I had to work on recently. It's not quite as nice, because functions aren't first-class, but handy nonetheless.</p>
<p>Here's what that looks like:</p>
<pre class="brush:c">
#include <stdio.h>

typedef int (* const decorableFnType)(int paramOne, int paramTwo);

int functionOne(int paramOne, int paramTwo)
{
	printf("functionOne: %d, %d\n", paramOne, paramTwo);
	return 0;
}

int functionTwo(int paramOne, int paramTwo)
{
	printf("functionTwo: %d, %d\n", paramOne, paramTwo);
	return 0;
}

int functionThree(int paramOne, int paramTwo)
{
	printf("functionThree: %d, %d\n", paramOne, paramTwo);
	return 0;
}

int decorator(int paramOne, int paramTwo, decorableFnType originalFn)
{
	printf("decorator precondition!\n");
	originalFn(paramOne, paramTwo);
	return 0;
}

int main(int argc, char **argv)
{
	printf("hello, C decorators!\n");

	functionOne(1, 2);

	decorator(1, 2, functionOne);
	decorator(1, 2, functionTwo);
	decorator(1, 2, functionThree);

	return 0;
}
</pre>
<p>The output of which is:</p>
<blockquote><p>
vilimpoc@funky:~$ ./c-decorators<br />
hello, C decorators!<br />
functionOne: 1, 2<br />
decorator precondition!<br />
functionOne: 1, 2<br />
decorator precondition!<br />
functionTwo: 1, 2<br />
decorator precondition!<br />
functionThree: 1, 2<br />
vilimpoc@funky:~$
</p></blockquote>
<p>This might be a bit simplistic, in reality, you'd probably want to decorate a function with a signature like the following, so that you can just change the structure and not bother w/a bajillion function declarations:</p>
<pre class="brush:c">
typedef int (* const decorableFnType)(SomeStruct * data);
</pre>
<p>Again, not super elegant, but handy.</p>
]]></content:encoded>
			<wfw:commentRss>http://vilimpoc.org/blog/2010/12/24/decorators-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Decorators</title>
		<link>http://vilimpoc.org/blog/2010/12/17/javascript-decorators/</link>
		<comments>http://vilimpoc.org/blog/2010/12/17/javascript-decorators/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 22:57:09 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://vilimpoc.org/blog/?p=284</guid>
		<description><![CDATA[One reason why Javascript rocks: As a use case, imagine you want to restrict a certain set of functions to only run if you are logged in. Doing stuff like this is ridiculously easy with first-class functions. Here's a generic decoration example: (function() { var original = function(paramOne, paramTwo) { console.log('original: ' + paramOne + [...]]]></description>
			<content:encoded><![CDATA[<p>One reason why Javascript rocks:</p>
<p>As a use case, imagine you want to restrict a certain set of functions to only run if you are logged in. Doing stuff like this is ridiculously easy with first-class functions.</p>
<p>Here's a generic decoration example:</p>
<pre class="brush:jscript">
(function()
{
	var original = function(paramOne, paramTwo) {
		console.log('original: ' + paramOne + ' ' + paramTwo);
	};

	var decorator = function(originalFn) {
		return function(paramOne, paramTwo) {
			console.log('decorator: ' + paramOne + ' ' + paramTwo);
			originalFn(paramOne, paramTwo);
		};
	};

	var fnTable = {};
	var registerCallback = function(url, callback) {
		fnTable[url] = callback;
	};

	registerCallback('/abc', original);
	registerCallback('/def', decorator(original));

	fnTable['/abc']('one', 'two');
	fnTable['/def']('three', 'four');
})();
</pre>
<p>Update: Here's the specific way you'd do this with node.js/Express:</p>
<p>Since all of the URL handlers you register have the same signature, it's easy to add precondition checks to the handlers via decorators.</p>
<pre class="brush:jscript">
var decorator = function(originalFn) {
    return function(req, res) {
        if (req.session.userLoggedIn) {
            originalFn(req, res);
        } else {
            redirectSomewhere(res);
        }
    }
}

app.get('/url', decorator(original));
app.post('/other', decorator(original));
</pre>
<p>You get preconditions essentially for free, which is a damn sight better than adding the if() block to each and every handler function. Also, if you need more preconditions in the future, you can just stack them.</p>
]]></content:encoded>
			<wfw:commentRss>http://vilimpoc.org/blog/2010/12/17/javascript-decorators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starting Copies of Firefox with Different Profiles on Ubuntu</title>
		<link>http://vilimpoc.org/blog/2010/11/16/starting-copies-of-firefox-with-different-profiles-on-ubuntu/</link>
		<comments>http://vilimpoc.org/blog/2010/11/16/starting-copies-of-firefox-with-different-profiles-on-ubuntu/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 19:16:29 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://vilimpoc.org/blog/?p=275</guid>
		<description><![CDATA[Just a quick note to self, how to setup Firefox to a) start separate instances of itself, b) load a different profile, c) use a particular locale. Useful when developing localized web apps.]]></description>
			<content:encoded><![CDATA[<p>Just a quick note to self, how to setup Firefox to a) start separate instances of itself, b) load a different profile, c) use a particular locale.</p>
<p><a href="http://vilimpoc.org/blog/wp-content/uploads/2010/11/Screenshot-Launcher-Properties.png" rel="lightbox[275]" title="Screenshot-Launcher-Properties"><img src="http://vilimpoc.org/blog/wp-content/uploads/2010/11/Screenshot-Launcher-Properties.png" alt="" title="Screenshot-Launcher-Properties" width="619" height="197" class="aligncenter size-full wp-image-276" /></a></p>
<p>Useful when developing localized web apps.</p>
]]></content:encoded>
			<wfw:commentRss>http://vilimpoc.org/blog/2010/11/16/starting-copies-of-firefox-with-different-profiles-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Repke Spaetzlerei: A Great Lunch Place</title>
		<link>http://vilimpoc.org/blog/2010/10/06/repke-spaetzlerei/</link>
		<comments>http://vilimpoc.org/blog/2010/10/06/repke-spaetzlerei/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 20:01:50 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Food]]></category>
		<category><![CDATA[charlottenburg]]></category>
		<category><![CDATA[german]]></category>
		<category><![CDATA[mittagstisch]]></category>
		<category><![CDATA[schwäbisch]]></category>

		<guid isPermaLink="false">http://vilimpoc.org/blog/?p=162</guid>
		<description><![CDATA[Stopped by one of my favorite spots for lunch today: Repke Spätzlerei, a cozy, cafeteria-style restaurant by Savignyplatz in Berlin. It's pretty busy at lunch time, as they have good deals for comfort foods like Spätzle, Schnitzel, meatloaf (Hacksteak), and Königsburger Klopse (€6,90!). The portions are a good size, but aren't so large that they'll [...]]]></description>
			<content:encoded><![CDATA[<p>Stopped by one of my favorite spots for lunch today: Repke Spätzlerei, a cozy, cafeteria-style restaurant by Savignyplatz in Berlin. </p>
<p>It's pretty busy at lunch time, as they have good deals for comfort foods like Spätzle, Schnitzel, meatloaf (Hacksteak), and Königsburger Klopse (€6,90!). The portions are a good size, but aren't so large that they'll put you to sleep at your next meeting. There's always a good selection of freshly made salad sides such as: mixed bean salad, fennel and cabbage salad, or potato salad. Additionally, each of the lunch menu items usually comes with a mixed salad of some sort, with your choice of vinaigrette or yogurt dressing.</p>

<a href='http://vilimpoc.org/blog/2010/10/06/repke-spaetzlerei/repke-spaetzle-02/' title='repke-spaetzle-02'><img width="150" height="150" src="http://vilimpoc.org/blog/wp-content/uploads/2010/10/repke-spaetzle-02-150x150.jpg" class="attachment-thumbnail" alt="repke-spaetzle-02" title="repke-spaetzle-02" /></a>
<a href='http://vilimpoc.org/blog/2010/10/06/repke-spaetzlerei/repke-spaetzle-03/' title='repke-spaetzle-03'><img width="150" height="150" src="http://vilimpoc.org/blog/wp-content/uploads/2010/10/repke-spaetzle-03-150x150.jpg" class="attachment-thumbnail" alt="repke-spaetzle-03" title="repke-spaetzle-03" /></a>
<a href='http://vilimpoc.org/blog/2010/10/06/repke-spaetzlerei/repke-spaetzle-04a/' title='repke-spaetzle-04a'><img width="150" height="150" src="http://vilimpoc.org/blog/wp-content/uploads/2010/10/repke-spaetzle-04a-150x150.jpg" class="attachment-thumbnail" alt="repke-spaetzle-04a" title="repke-spaetzle-04a" /></a>
<a href='http://vilimpoc.org/blog/2010/10/06/repke-spaetzlerei/repke-spaetzle-04b/' title='repke-spaetzle-04b'><img width="150" height="150" src="http://vilimpoc.org/blog/wp-content/uploads/2010/10/repke-spaetzle-04b-150x150.jpg" class="attachment-thumbnail" alt="repke-spaetzle-04b" title="repke-spaetzle-04b" /></a>
<a href='http://vilimpoc.org/blog/2010/10/06/repke-spaetzlerei/repke-spaetzle-04c/' title='repke-spaetzle-04c'><img width="150" height="150" src="http://vilimpoc.org/blog/wp-content/uploads/2010/10/repke-spaetzle-04c-150x150.jpg" class="attachment-thumbnail" alt="repke-spaetzle-04c" title="repke-spaetzle-04c" /></a>
<a href='http://vilimpoc.org/blog/2010/10/06/repke-spaetzlerei/repke-spaetzle-06/' title='repke-spaetzle-06'><img width="150" height="150" src="http://vilimpoc.org/blog/wp-content/uploads/2010/10/repke-spaetzle-06-150x150.jpg" class="attachment-thumbnail" alt="repke-spaetzle-06" title="repke-spaetzle-06" /></a>
<a href='http://vilimpoc.org/blog/2010/10/06/repke-spaetzlerei/repke-spaetzle-07/' title='repke-spaetzle-07'><img width="150" height="150" src="http://vilimpoc.org/blog/wp-content/uploads/2010/10/repke-spaetzle-07-150x150.jpg" class="attachment-thumbnail" alt="repke-spaetzle-07" title="repke-spaetzle-07" /></a>
<a href='http://vilimpoc.org/blog/2010/10/06/repke-spaetzlerei/repke-spaetzle-08/' title='repke-spaetzle-08'><img width="150" height="150" src="http://vilimpoc.org/blog/wp-content/uploads/2010/10/repke-spaetzle-08-150x150.jpg" class="attachment-thumbnail" alt="repke-spaetzle-08" title="repke-spaetzle-08" /></a>
<a href='http://vilimpoc.org/blog/2010/10/06/repke-spaetzlerei/repke-spaetzle-09/' title='repke-spaetzle-09'><img width="150" height="150" src="http://vilimpoc.org/blog/wp-content/uploads/2010/10/repke-spaetzle-09-150x150.jpg" class="attachment-thumbnail" alt="repke-spaetzle-09" title="repke-spaetzle-09" /></a>

<p>p.s. Don't mind the crappy photos, that's what I get for using a Motorola Milestone to take them.</p>
<h3>Directions</h3>
<p><a href="http://www.repke-suppen.de/">Repke Spätzlerei</a><br />
Bleibtreustrasse 46<br />
10623 Berlin</p>

<h3>Opening Hours</h3>
<p>Daily from 11:30h</p>
]]></content:encoded>
			<wfw:commentRss>http://vilimpoc.org/blog/2010/10/06/repke-spaetzlerei/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

