<?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>mFabrik - web and mobile development &#187; debugging</title>
	<atom:link href="http://blog.mfabrik.com/category/debugging/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mfabrik.com</link>
	<description>Freedom delivered.</description>
	<lastBuildDate>Thu, 02 Sep 2010 13:25:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>MooTools setOptions() nullifies object references</title>
		<link>http://blog.mfabrik.com/2008/08/19/mootools-setoptions-nullifies-object-references/</link>
		<comments>http://blog.mfabrik.com/2008/08/19/mootools-setoptions-nullifies-object-references/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 00:21:08 +0000</pubDate>
		<dc:creator>Tuukka Mustonen</dc:creator>
				<category><![CDATA[debugging]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[addressing]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[setOptions]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.redinnovation.com/?p=64</guid>
		<description><![CDATA[I bumped up into a problem where the object references where resolved as object copies when I passed them to class instances. That might sound easy to resolve, but unfortunately I was already deep in code and it was difficult to see this. Therefore, here&#8217;s a little explanation for those who are facing the same [...]]]></description>
			<content:encoded><![CDATA[<p>I bumped up into a problem where the object references where resolved as object copies when I passed them to class instances. That might sound easy to resolve, but unfortunately I was already deep in code and it was difficult to see this. Therefore, here&#8217;s a little explanation for those who are facing the same frustrating issue.</p>
<p>Say, you have variable &#8216;a&#8217; and you want to pass it to a MooTools class B instance during creation. In the easiest case you&#8217;d use new B({ myReference: a}) and trust on MooTools&#8217; Class.setOptions() to minify the need of code lines. This is what you should do&#8230; well at least that&#8217;s what I did and in this case it was a mistake.</p>
<p>It turns out that Class.setOptions() merges it&#8217;s arguments to this.options and then takes copy of them via $merge(). That means that any variable references you pass to setOptions() will get copied to this.options and.. well, that&#8217;s it. See lines 1170-1173 in uncompressed version of MooTools 1.2:</p>
<pre>var Options = new Class({
    setOptions: function(){
        this.options = $merge.run([this.options].extend(arguments));</pre>
<p>That effectively nullifies the benefits of Class.setOptions() if you want to pass in variable references..</p>
<p>Here&#8217;s a longer example to clarify (use Firebug):</p>
<pre>  // The most basic MooTools class that implements options
  // ref is a variable meant for pointing at given object
  // (won't do that, however)
  var B = new Class({
    Implements: Options,
    options: {
      ref: null
    },
    initialize: function(options) {
      this.setOptions(options);
    }
  });

  // Ok let's create an instance that we can pass to B
  // It's similar with all sorts of variables
  var A = new Class({
    initialize: function() {
      this.somevar = 'untouched';
    }
  });
  var a = new A();

  // Create an instance of B and give it somevar as reference
  var b = new B({ ref: a });

  // prints out "untouched" as should
  console.log(b.options.ref.somevar);

  // Let's change the variable (direct access, bad)
  a.somevar = "changed";

  // b's reference should still point to a, right?
  // In that case the following should print "changed",
  // but because our reference object was copied instead
  // of retaining reference to it, we just get "untouched"
  console.log(b.options.ref.somevar);</pre>
<p>I don&#8217;t know why MooTools wants to make a copy of arguments in setOptions() &#8211; propably for performance reasons.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2008/08/19/mootools-setoptions-nullifies-object-references/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Wrong swap UUID after hibernation in Feisty</title>
		<link>http://blog.mfabrik.com/2007/10/01/wrong-swap-uuid-after-hibernation-in-feisty/</link>
		<comments>http://blog.mfabrik.com/2007/10/01/wrong-swap-uuid-after-hibernation-in-feisty/#comments</comments>
		<pubDate>Mon, 01 Oct 2007 09:26:17 +0000</pubDate>
		<dc:creator>Tuukka Mustonen</dc:creator>
				<category><![CDATA[debugging]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.redinnovation.com/2007/10/01/wrong-swap-uuid-after-hibernation-in-feisty/</guid>
		<description><![CDATA[I&#8217;ve been using uswsusp for suspending/hibernating my Ubuntu Feisty laptop but suddenly it failed to resume from disk hibernation (blank screen with blinking cursor). I booted up in restoration mode and Ubuntu reported that it couldn&#8217;t restore the snapshot. After pressing enter to continue, the system booted up just fine, skipping the snapshot restoration as [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using <a href="http://suspend.sourceforge.net/">uswsusp</a> for suspending/hibernating my Ubuntu Feisty laptop but suddenly it failed to resume from disk hibernation (blank screen with blinking cursor). I booted up in restoration mode and Ubuntu reported that it couldn&#8217;t restore the snapshot. After pressing enter to continue, the system booted up just fine, skipping the snapshot restoration as supposed. The startup problem vanished, but it brought up a new one when trying to hibernate:</p>
<pre>&gt;&gt;&gt; sudo s2disk
Could not use the resume device (try swapon -a)</pre>
<p>Of course, swapon also gives a problem:</p>
<pre>&gt;&gt;&gt; sudo swapon -a
swapon: cannot stat
/dev/disk/by-uuid/4a815ae8-fa5b-4265-826c-d777a723e87b:
No such file or directory</pre>
<p>It seems that the UUID reference for swap is broken. Or is it the swap? At this point I did some Google research and it turned out the behaviour was because of an <a href="https://bugs.launchpad.net/ubuntu/+source/udev/+bug/105490">Ubuntu Feisty bug</a>, which causes the swap UUID change occasionally. It is closely related to hibernation, yet the cause remains unclear. To fix it, let&#8217;s do:</p>
<pre>&gt;&gt;&gt; free -m | grep -i swap
Swap:            0          0          0</pre>
<p>Which indicates that the system doesn&#8217;t find swap at all (because of wrong UUID). To find correct one:</p>
<pre>&gt;&gt;&gt; sudo fdisk -l | grep swap
/dev/sda6      10669   10917  2000061 82  Linux swap / Solaris</pre>
<p>Find your swap there and go for:</p>
<pre>&gt;&gt;&gt; sudo vol_id /dev/sda6
ID_FS_UUID=083d41f0-de57-48d4-92eb-aefde8fd6ec9</pre>
<p>Then you&#8217;ll just have to edit it in /etc/fstab and hibernation should work again. You could also try restoring the original snapshot by editing:</p>
<pre>&gt;&gt;&gt; sudo nano /etc/initramfs-tools/conf.d/resume</pre>
<p>and correcting the reference there also. I didn&#8217;t test this myself, however.</p>
<p>That should do it, but don&#8217;t get too excited: some report that the UUID keeps changing even after the fix, and it has to be manually changed over and over again. Luckily, I haven&#8217;t experienced such behaviour (yet!) and it&#8217;s quick to fix (though you might lose ability to hibernate, which is a really bad thing).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2007/10/01/wrong-swap-uuid-after-hibernation-in-feisty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
