<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
   <channel>
      <title>Nat!&apos;s Web Journal</title>
      <link>http://www.mulle-kybernetik.com/weblog/</link>
      <description></description>
      <language>en</language>
      <copyright>Copyright 2013</copyright>
      <lastBuildDate>Sat, 27 Apr 2013 12:52:29 +0100</lastBuildDate>
      <generator>http://www.sixapart.com/movabletype/</generator>
      <docs>http://blogs.law.harvard.edu/tech/rss</docs> 

      
      <item>
         <title>Changed Graphics Cards - Saved Money ?</title>
         <description><![CDATA[I switched graphic cards in my home machine from a 8800 GTS to a GTX 660. The difference was an astounding 70W (measured) during idle! With current energy prices, the new card pays for itself in about ... 5 years.  Which is about the usage time of the old card.
<p>In terms of the mathematics, was this now the optimal time to change cards, given the pricepoint and the wattage and availablity of this card at this point in time ?</p>
]]></description>
         <link>http://www.mulle-kybernetik.com/weblog/2013/04/changed_graphics_cards_-_saved.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2013/04/changed_graphics_cards_-_saved.html</guid>
        
        
         <pubDate>Sat, 27 Apr 2013 12:52:29 +0100</pubDate>
      </item>
      
      <item>
         <title>UIAppearance: Magic == Pain</title>
         <description><![CDATA[This shit is so obscure, that I needed to a lot of research to get a coherent view of what's happening in my head.
<h3>The problem with <tt>UIAppearance</tt> geometry values</h3>
<p>Let's assume that I have a property <strong>padding</strong> that defines the size of an inner border of my <tt>UIView</tt> subclass. It's merely a decorative element and has a default value of 2 pixels on each side.</p>
<pre>
-(void) initWithCoder:(NSCoder *) coder
{
   self = [super initWithCoder:coder];
   if( self)
      self-&gt;_padding = UIEdgeInsetsMake( 2, 2, 2, 2);
    return( self);
}
// and the same for initWithFrame:
</pre>
<p>I want this to be skinnable so I make it an UI_APPEARANCE_SELECTOR.</p>
<pre>
@property(nonatomic) UIEdgeInsets padding   UI_APPEARANCE_SELECTOR;
</pre>
<p>In my <tt>UIView</tt> subclass I want to host a <strong>contentView</strong> of some random size <i>(code not shown)</i>. How do I calculate the <tt>frame.size</tt> of my view ? I get the <tt>frame</tt> of the <strong>contentView</strong> and add the <b>padding</b>. Simple.</p>
<pre>   UIEdgeInsetsInsetRect   insets;
   
   insets        = [self padding];
   insets.top    = - insets.top;
   insets.left   = - insets.left;
   insets.bottom = - insets.bottom;
   insets.right  = - insets.right;
   frame         = UIEdgeInsetsInsetRect( [_contentView frame], 
                                          insets);
</pre>
<p>Will this work ? It depends. It depends on WHEN I call it.</p>
<p>Here's where the research comes in. This is the order in which a typical iOS program calls some of the key classes instance methods. This is not a stack trace, just the chronological order. The <font color="#F00"><tt>-[UIView setPadding:]</tt></font> call is the <tt>UIAppearance</tt> setting the value in the <tt>UIView</tt>:</p>
<pre>
-[UIWindow initWithFrame:]
-[UIViewController initWithNibName:]
-[UIWindow setRootViewController:]
-[UIWindow makeKeyAndVisible]
-[UIView initWithCoder:]
-[UIView awakeFromNib]
-[UIViewController viewDidLoad]
-[UIViewController viewWillAppear:]
-[UIView willMoveToWindow:]
+[UIView requiresConstraintBasedLayout]
<font color="#F00">-[UIView setPadding:]</font>
-[UIView didMoveToWindow]
-[UIView layoutSubviews]
-[UIView drawRect:]
-[UIViewController viewDidAppear:]
</pre>
It is important to notice, that the <tt>UIAppearance</tt> value is available only during and after <tt>-[UIView didMoveToWindow]</tt>. It is NOT available during <tt>-[UIViewController viewDidLoad]</tt> or <tt>-[UIViewController viewWillAppear:]</tt>. And <tt>-[UIViewController viewDidAppear:]</tt> is obviously too late. As the constraint code is running earlier, auto layout code would not help either.
<p>
<p><b>Rule #1: Do not access <tt>UI_APPEARANCE_SELECTOR</tt> properties if <tt>-[UIView window]</tt> returns nil</b><p>
<p>Now you may think: &quot;hey, do the code in <tt>-[UIView layoutSubviews]</tt>&quot;. But as the name indicates, that method should layout the <tt>subview</tt>s of my <tt>UIView</tt> and not change its own <tt>frame</tt>. That should have been set during the <tt>superview</tt>'s <tt>layoutSubviews</tt> method. Otherwise the <tt>superview</tt> could be surprised and misconfigured. In the end, it's really the job of the <tt>UIViewController</tt> to set my <tt>UIView</tt>'s <tt>frame</tt>.</p>
<p>But the <tt>UIViewController</tt> doesn't have a chance anymore to do this.</p>
<h3>The clever 90% Solution</h3>
<p>How can this be fixed ? Well it would be nice, if the <tt>UIView</tt> subclass offered a method like <b><tt>+frameForContentRect:</tt></b>, so the view's frame can be calculated in advance, during <tt>-[UIViewController viewDidLoad]</tt> given the frame of the future <b>contentView</b>:</p>
<pre>
+ (CGRect) frameForContentRect:(CGRect) rect
{
   id &lt;UIAppearance&gt;       appearance;
   UIEdgeInsetsInsetRect   insets;

   appearance    = [self appearance];
   insets        = [appearance padding];
   insets.top    = - insets.top;
   insets.left   = - insets.left;
   insets.bottom = - insets.bottom;
   insets.right  = - insets.right;
   return( UIEdgeInsetsInsetRect( rect, insets));
}
</pre>
Nice, but it doesn't work really well, if no one is setting the <tt>UIAppearance</tt> value, and we fall back to the default value of the instance.
<p>Solution ? Don't set the default value in the instance but instead preset the <tt>UIAppearance</tt> with it at <tt>+load</tt> time and delete the instance default value code from <tt>initWithCoder:</tt> (<i>and <tt>initWithFrame:</tt></i>)</p>
<pre>
+ (void) load
{
  [[self appearance] setPadding:UIEdgeInsetsMake( 2.0, 2.0, 2.0, 2.0)]);
}
</pre>
Nicey, but does it solve the problem ?
<p>
Not always, because the value of <b>padding</b> could also be set by user code on an individual instance. And then the <tt>UIAppearance</tt> value won't be used. Obviously there is no chance for knowing that in the custom <b><tt>+frameForContentRect:</tt></b> method, since it's a class method.
<p><b>Rule #2: Set <tt>UI_APPEARANCE_SELECTOR</tt>s default values in +load</b><p>
I think using <tt>+load</tt> to set default <tt>UIAppearance</tt> values is still a good and rather clean method, but for the problem at hand it's not the whole solution. It's pretty clean, because you can be sure that the default is set earlier than <tt>-[id &lt;UIApplicationDelegate&gt; application:didFinishLaunchingWithOptions:]</tt>, which one would expect the application coder to set his <tt>UIAppearance</tt> values.

<h3>The painful 100% Solution</h3>
The only good solution I have come up so far is this: Setup your view hierarchy like you just don't care, possibly in <tt>-[UIViewController viewDidLoad]</tt>. The real work has to be done delayed. For that you have to override your subclass <tt>-[UIView didMoveToWindow]</tt> method and call a custom method on the <tt>UIViewController</tt>.  Clumsy, but magic always comes with a price.
<p><b>Rule #3: Geometry <tt>UI_APPEARANCE_SELECTOR</tt>s need special attention</b><p>
]]></description>
         <link>http://www.mulle-kybernetik.com/weblog/2013/04/uiappearance_magic_pain.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2013/04/uiappearance_magic_pain.html</guid>
        
        
         <pubDate>Thu, 25 Apr 2013 22:44:39 +0100</pubDate>
      </item>
      
      <item>
         <title>-[UIButton tintColor] is just weird and non-conforming - or class clusters don&apos;t mix well with UIAppearance</title>
         <description><![CDATA[I figured, that I wanted to use <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAppearance_Protocol/Reference/Reference.html">UIAppearance</a> for my code, so that I can easily "skin" my iOS applications. What I wasn't really clear about is how to properly handle default values, because like most recent Apple code, it's just magic. I hate magic.
<p>
 To test the best way to handle default values for my <tt>UIViews</tt>, I wanted to test <tt>UIAppearance</tt> first with the most simple and minimal code possible and go from there. I didn't even make it...
<p>
Step 1: Create a new iOS application with a single view 
<p>
Step 2: Enter the following lines in the app delegate:

<pre>- (BOOL) application:(UIApplication *) application 
   didFinishLaunchingWithOptions:(NSDictionary *) launchOptions
{
   UIButton   *button;
   
   [[UIButton appearance] setTintColor:[UIColor orangeColor]];
   button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
   NSLog( @"%@", [button tintColor]);
 }
</pre>
<p>
Step 3:  Run and observe console. Notice that it doesn't work, <tt>tintColor</tt> returns <tt>nil</tt>. Which is surprising.
<p>
The documentation says:
<pre>tintColor
The tint color for the button.

@property(nonatomic, retain) UIColor *tintColor
Discussion
The default value is nil.

This property is not valid for all button types.
</pre>

Wasn't Apple's documentation somewhat better in previous times ? Why not write for what button types <tt>tintColor</tt> is valid ? Now came the most surprising part. I wrote a little loop to figure out, when <tt>tintColor</tt> is valid.

<pre>   UIButton   *button;
   NSUInteger   i;
   
   for( i = 0; i < 10; i++)
   {
      button = [UIButton buttonWithType:i];
      NSParameterAssert( button);
      [button setTintColor:[UIColor greenColor]];
      NSLog( @"%ld: %@", (long) i, [button tintColor]);
   }
</pre>
And as it turns out
<pre>2013-04-24 15:57:11.496 ApperanceTest[2732:c07] 0: (null)
2013-04-24 15:57:11.498 ApperanceTest[2732:c07] 1: UIDeviceRGBColorSpace 0 1 0 1
2013-04-24 15:57:11.499 ApperanceTest[2732:c07] 2: (null)
2013-04-24 15:57:11.499 ApperanceTest[2732:c07] 3: (null)
2013-04-24 15:57:11.500 ApperanceTest[2732:c07] 4: (null)
2013-04-24 15:57:11.500 ApperanceTest[2732:c07] 5: (null)
2013-04-24 15:57:11.500 ApperanceTest[2732:c07] 6: (null)
2013-04-24 15:57:11.501 ApperanceTest[2732:c07] 7: (null)
2013-04-24 15:57:11.501 ApperanceTest[2732:c07] 8: (null)
2013-04-24 15:57:11.502 ApperanceTest[2732:c07] 9: (null)
</pre>
the only valid value is ironically <b>1</b> which is  <tt>UIButtonTypeRoundedRect</tt>, the value I used in the first place.
<p>
So in the end although <b>tintColor</b> is advertised as being modifiable through <tt>UIAppearance</tt> in the header <tt>@property(nonatomic,retain)   UIColor     *tintColor NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR; // default is nil. only valid for some button types</tt>, it really seems not to be the case. 
<p>
I would on a hunch assume, that's because <tt>UIButton</tt> could be a class cluster and the subclasses implement their own <tt>tintColor</tt> accessors and the whole magic breaks down.
<hr>
<i>Addendum: I should add to my examples, that values from <tt>UIApperance</tt> only show up in the <tt>UIView</tt> when the window has been made visible. So the appearance setting should be done ahead of the NIB loading and the reading of values can only be done after <tt>[window makeKeyAndVisible]</tt>. More obscure magic.
<p>
As the button is indeed an instance of a class cluster subclass called <tt>UIRoundedRectButton</tt>, I tried <tt>   [[NSClassFromString(@"UIRoundedRectButton") appearance] setTintColor:[UIColor greenColor]];</tt> and then it worked as I'd expected it in the first place.</i>
<hr>
<i>Another Addendum: The problem is really with <tt>UIAppearance</tt> instead of <tt>UIButton</tt>:
<p>
Create an empty single view IOS project and create a <tt>UIView</tt> subclass:</i>

<p>
"MulleView.h"
<pre>#import &lt;UIKit/UIKit.h&gt;

@interface _MulleView : UIView &lt; UIAppearanceContainer&gt:
@end

@interface MulleView : _MulleView &lt; UIAppearanceContainer&gt;
@end
</pre>
<i>and</i>
<p>
"MulleView.m"
<pre>#import "MulleView.h"


@implementation _MulleView

+ (void) load
{
   [[self appearance] setXColor:[UIColor blueColor]];
}

- (void) setXColor:(UIColor *) color
{
   NSLog( @"%s", __PRETTY_FUNCTION__);
}

@end


@implementation MulleView

- (void) willMoveToWindow:(UIWindow *)newWindow
{
   NSLog( @"%s", __PRETTY_FUNCTION__);
}


- (void) setXColor:(UIColor *) color
{
   NSLog( @"%s", __PRETTY_FUNCTION__);
}

@end
</pre>

<i>Then set the class of the root view of your <b>xib</b> to <tt>MulleView</tt> instead of <tt>UIView</tt> and you will see this in the output when running:
</i>
<pre>-[MulleView willMoveToWindow:]
-[_MulleView setXColor:]</pre>
<i>
understandable but wrong for class clusters.
</i>

]]></description>
         <link>http://www.mulle-kybernetik.com/weblog/2013/04/-uibutton_tintcolor_is_just_we.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2013/04/-uibutton_tintcolor_is_just_we.html</guid>
        
        
         <pubDate>Wed, 24 Apr 2013 15:45:43 +0100</pubDate>
      </item>
      
      <item>
         <title>Neuer Slogan für die SPD</title>
         <description><![CDATA[<em>Mal was Politisches :)</em>
<p>Das neue Wahlkampfmotto der SPD &quot;Das Wir entscheidet&quot; steht ja unter <a href="http://www.spiegel.de/politik/deutschland/wahlkampf-leiharbeitsfirma-nutzt-seit-jahren-neuen-spd-slogan-a-893583.html">keinem guten Stern</a>, daher habe ich hier mal schnell einen schönen Ersatz geschaffen. Viel ehrlicher und nicht so verdruckst, als ob man keine Ahnung von nix hat.</p>
<p><a href="http://www.mulle-kybernetik.com/weblog/pix/spd-claim-alternativ.png"><img height="320" style="margin: 5px" width="437" alt="" src="http://www.mulle-kybernetik.com/weblog/spd-claim.png" alt="Alternativdesign? Klick!"/></a></p>
]]></description>
         <link>http://www.mulle-kybernetik.com/weblog/2013/04/neuer_slogan_fur_die_spd.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2013/04/neuer_slogan_fur_die_spd.html</guid>
        
        
         <pubDate>Wed, 10 Apr 2013 15:19:57 +0100</pubDate>
      </item>
      
      <item>
         <title>MP Navigator EX with CanoScan LIDE 90 scanner under OS X 10.8</title>
         <description><![CDATA[Here's how it works with the &quot;official&quot; Canon software.
<ol>
    <li>Download the scanner driver <a href="http://www.canon.de/Support/Consumer_Products/products/scanners/LiDE_series/CanoScan_LiDE_90.aspx?DLtcmuri=tcm:83-741076&amp;page=1&amp;type=download">lide90osx1391ej7.dmg</a></li>
    <li>Download the new Navigator EX 5.0.2 <a href="http://support-asia.canon-asia.com/contents/ASIA/EN/0200145902.html">mnve_5_0-mac-5_0_2-ea11.dmg</a></li>
</ol>
Install both.<br>Then (after reboot):
<ol>
    <li>Download the old Navigator EX 1.0 <a href="http://www.canon.de/Support/Consumer_Products/products/scanners/LiDE_series/CanoScan_LiDE_90.aspx?DLtcmuri=tcm:83-855325&amp;page=1&amp;type=download">mpnexosx105ej7.dmg</a></li>
</ol>
Open that DMG file. Copy the file <tt>PlugIns/Database/LIDE90.plist</tt> to <tt>/Applications/Canon\ Utilities/MP\ Navigator\ EX\ 5.0.app/Contents/PlugIns/Database</tt>.

]]></description>
         <link>http://www.mulle-kybernetik.com/weblog/2013/03/mp_navigator_ex_with_canoscan.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2013/03/mp_navigator_ex_with_canoscan.html</guid>
        
        
         <pubDate>Wed, 27 Mar 2013 12:16:28 +0100</pubDate>
      </item>
      
      <item>
         <title>TWIG-like Templates in Objective-C</title>
         <description><![CDATA[<font size=3>This is now an open source project called <a href="http://www.mulle-kybernetik.com/software/git/MulleScionTemplates"><i><tt>MulleScionTemplates</tt></i></a> on <a href="http://www.mulle-kybernetik.com/software">Mulle kybernetiK</a>.</font>
<hr>
When I installed and customized <a href="https://github.com/klaussilveira/gitlist"><strong>gitlist</strong></a> on Mulle, I really liked the PHP template engine they used called <a href="http://twig.sensiolabs.org/">TWIG.</a> I wanted something like this for myself but preferably in <strong>C</strong> or in <strong>Objective-C.</strong> But I didn't find anything, that was very TWIG like. Inspired by this anecdote of <a href="http://www.dadhacker.com/blog/?p=1911">Dadhacker,</a> I figured if that guy can write an assembler in four hours maybe I can write a template engine in four.... oh well days :)
<p>And that's what I did. The code fairly quickly was able to use a template like this:</p>
<blockquote>
    <p>&lt;html&gt;<br />&lt;!-- rendered by {{ [[NSProcessInfo processInfo] processName] }} on {{ [NSDate date]] }} --&gt;<br />&lt;body&gt;<br />{# render an old skool HTML table #}<br />{% MulleScionEven = &quot;#DDDDDD&quot; %}<br />{% MulleScionOdd = &quot;#FFFFFF&quot; %}<br />{% for item in [NSTimeZone knownTimeZoneNames] %}<br /> {% if item#.n %}<br /> {% if item#.isFirst %}<br />&lt;table&gt;<br /> &lt;tr&gt;&lt;th&gt;TimeZone&lt;/th&gt;&lt;/tr&gt;<br /> {% endif %}<br /> &lt;tr bgcolor=&quot;{{ item#.evenOdd }}&quot;&gt;&lt;td&gt;{{ item }}&lt;/td&gt;&lt;/tr&gt;<br /> {% if item#.isLast %}<br />&lt;/table&gt;<br /> {% endif %}<br /> {% else %}<br />Sorry, no timezone info available.<br /> {% endif %}<br />{% endfor %}<br />&lt;/body&gt;<br />&lt;/html&gt;<br /></p>
</blockquote>
to render HTML output like that:
<blockquote>
    <p>&lt;html&gt;<br />&lt;!-- rendered by mulle-scion on 2013-02-27 16:27:05 +0000 --&gt;<br />&lt;body&gt;<br />&lt;table&gt;<br /> &lt;tr&gt;&lt;th&gt;TimeZone&lt;/th&gt;&lt;/tr&gt;<br /> &lt;tr bgcolor=&quot;#DDDDDD&quot;&gt;&lt;td&gt;Africa/Abidjan&lt;/td&gt;&lt;/tr&gt;<br /> &lt;tr bgcolor=&quot;#FFFFFF&quot;&gt;&lt;td&gt;Africa/Accra&lt;/td&gt;&lt;/tr&gt;<br /> &lt;tr bgcolor=&quot;#DDDDDD&quot;&gt;&lt;td&gt;Africa/Addis_Ababa&lt;/td&gt;&lt;/tr&gt;<br /> &lt;tr bgcolor=&quot;#FFFFFF&quot;&gt;&lt;td&gt;Africa/Algiers&lt;/td&gt;&lt;/tr&gt;<br /> &lt;tr bgcolor=&quot;#DDDDDD&quot;&gt;&lt;td&gt;Africa/Asmara&lt;/td&gt;&lt;/tr&gt;<br /> &lt;tr bgcolor=&quot;#FFFFFF&quot;&gt;&lt;td&gt;Africa/Bamako&lt;/td&gt;&lt;/tr&gt;</p>
    <p><br /></p>
</blockquote>
Now it can do pretty much all that TWIG can, like extending and overriding blocks:
<blockquote>
    <p>{% extends &quot;base.scion&quot; %}<br /><br />This text is after extends, so it won't be printed.<br />It's a confusing way to comment...:)<br />All the blocks following are slurped up and remembered till the end of the<br />enveloping template. Then blocks are substituted.<br /><br />{% block header %}<br />this will be overridden shortly by the following block<br />{% endblock %}<br /><br />{% block header %}<br />replaced the whole header<br />{% endblock %}<br /><br />{% block body_extension %}<br />extended the body<br />{% endblock %}<br /><br />{% block footer_extension %}<br /> {% block footer_extension2 %}<br />default footer_extension2 text<br /> {% endblock %}<br />{% endblock %}<br /><br />{% block hackish_extension %}A bit of a mind bender{% endblock %}<br /><br />{% extends &quot;hackish.scion&quot; %}<br /></p>
</blockquote>
It's a fairly capable Objective-C interpreter with auto-boxing support. I can even write <tt>[string substringToIndex:NSMakeRange( 0, [string length] - 1]).length]</tt> into my template and it should work.

<p> Pretty nifty :)</p>
]]></description>
         <link>http://www.mulle-kybernetik.com/weblog/2013/02/twig-like_templates_in_objecti.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2013/02/twig-like_templates_in_objecti.html</guid>
        
        
         <pubDate>Wed, 27 Feb 2013 17:13:37 +0100</pubDate>
      </item>
      
      <item>
         <title>NAS upgrade: the honeymoon is over</title>
         <description><![CDATA[:)
<p>
Getting the <b>Synology DS213+ NAS</b> to sleep is trickier than anticipated. Judging from the <a href="http://www.synology-forum.de/showthread.html?32313-DS112-Kein-Ruhezustand-seit-DSM-Update">folklore</a> on the interwebs I am not alone.
<p>
The people's guess is, that it's an ARP request that wakes up the Synology. That sounds sensible and somewhat unavoidable. By my own observations, I'd say that ANY ARP request wakes up the Synology from deep sleep, not just the ones looking for the NAS ethernet address. ARPs are broadcast, but other broadcast traffic I observed didn't affect it. 
<p>
Case in point, when my "workstation" turns off or goes to sleep, my NAS magically awakes, presumably because my gateway is looking for the workstation again. (Speculation). Also when my "gateway" periodically awakens at night because of <a href="http://www.macworld.com/article/1153720/macpro_sleep.html">Wake on Demand</a>, then it will apparently also send out ARP packets.
<p>
The main and fixable problem seems to be, that, if the NAS has "accidentally" risen, it won't find sleep again soon. Instead it waits again for the configured period. (30 minutes in my case).
<p>
Another speculation is, that periodic awakenings from sleep mode have something to do with the <b>ntp</b> daemon, who's trying to contact a time server about every hour. I have now disabled <b>ntp</b> for testing, let's see how that works. On a hunch I would say, that this isn't the problem, as the <b>ntp</b> daemon shouldn't be running in sleep mode in the first place.
<hr>
<i>22.02: Last night my NAS did get a good nights sleep. So experimentally I am turning <b>ntp</b> back on.</i>
<hr>
<i>27.02:Predictably <b>ntp</b> had no averse side effect on sleep.</i>
]]></description>
         <link>http://www.mulle-kybernetik.com/weblog/2013/02/nas_upgrade_the_honeymoon_is_o.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2013/02/nas_upgrade_the_honeymoon_is_o.html</guid>
        
        
         <pubDate>Thu, 21 Feb 2013 14:37:53 +0100</pubDate>
      </item>
      
      <item>
         <title>NAS upgrade at home, DS213+ vs. MyBookLive</title>
         <description><![CDATA[Fuck off MyBookLive, welcome DS213+.
<p>From the technical specs alone I would have preferred the <a href="http://www.qnap.com/de/index.php?lang=de&amp;sn=375&amp;c=292&amp;sc=529&amp;t=538&amp;n=13449&amp;g=1">QNAP TS-269L</a>, but it doesn't have a good energy save mode and I really don't want my NAS to suck ~20W power 24/7. Otherwise the TS-269L from the benchmarks has significant horse power and the possibility to upgrade the RAM is also pretty nice. But it's also supposed to be quite noisey.</p>
<p><img height="192" width="192" alt="" src="http://wdc.com/global/images/products/models/img4/300/wdfMB_Live.jpg" /></p>
<p>I have to say, that I was never happy with the <a href="http://wdc.com/de/products/products.aspx?id=280">MyBookLive</a>. That NAS has only 256 MB of RAM, but with all services running, it is swapping very often, resulting in really bad performance. There are a lot of indexing scripts Western Digital uses, that are total crap and they are being run much too often (like for every file change). While it got a good review in c't magazine, I can't recommend it at all. Opening my MP3 collection in the Finder takes like 20s and sometimes much more. It will be relegated to it's only proper use, a Time Machine storage.</p>
<p><img alt="" src="http://www.synology.de/products/img/top/DS213+.jpg" /></p>
<p>The <a href="http://www.synology.de/products/spec.php?product_name=DS213%2B&lang=deu#p_submenu">Synology DS213+</a> main benefit is having a good sleep mode and a really, really excellent user interface. Like two generations ahead of what WD had to offer. From the way I read it, their <a href="http://www.synology.de/support/tutorials_show.php?lang=deu&amp;q_id=492">partitioned RAID-1 system</a> also sounds like a big advantage over plain RAID-1. 
<p>
Another plus, it's very quiet, if it's not doing anything. (Which it usually doesn't in my case).
</p>
<p>Everybody and their mother are putting <a href="http://www.wdc.com/de/products/products.aspx?id=810">Western Digital RED disks</a> in their NAS. But wait a minute, why would I care so much, when I am using RAID-1 ? I  saved 20% of my money and got a potentially much faster harddisk instead, a <a href="http://www.seagate.com/de/de/internal-hard-drives/desktop-hard-drives/desktop-hdd/?sku=ST3000DM001">Seagate ST3000DM001</a>  with 7200 RPM. I like to save energy, when I don't need the system. But otherwise I prefer fast over reliable :)</p>
<p>But it isn't quite as powerful as I would like. Copying files with <strong>Samba</strong>, is not a problem at all for the DS213+. But if you use <strong>rsync</strong>, which to my surprise, is <a href="http://lwn.net/Articles/400489/">quite the CPU hog</a>, you will probably not be able to saturate your harddisks. Opening my MP3 collection in the finder now only takes 3 seconds, which isn't great, but manageable.</p>
<p>I wouldn't buy anything less than a DS213+ for a home NAS now.</p>
]]></description>
         <link>http://www.mulle-kybernetik.com/weblog/2013/02/nas_upgrade_at_home_ds213_vs_m.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2013/02/nas_upgrade_at_home_ds213_vs_m.html</guid>
        
        
         <pubDate>Tue, 19 Feb 2013 18:03:16 +0100</pubDate>
      </item>
      
      <item>
         <title>Xcode4, quit messing with my .git</title>
         <description>Apparently there is no way to turn off the GIT integration in Xcode. And that&apos;s because you don&apos;t want to, since Apple knows best. And Xcode has no bugs.</description>
         <link>http://www.mulle-kybernetik.com/weblog/2013/02/xcode4_quit_messing_with_my_gi.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2013/02/xcode4_quit_messing_with_my_gi.html</guid>
        
        
         <pubDate>Thu, 07 Feb 2013 14:36:24 +0100</pubDate>
      </item>
      
      <item>
         <title>Obscure little EOModeler info</title>
         <description><![CDATA[In line #13 of the file <tt>Contents/Resources/English.lproj/iconColumn.dict</tt> there is a semicolon missing, which precludes the loading of this plist, as the Apple parser is (sigh) very pedantic about this.]]></description>
         <link>http://www.mulle-kybernetik.com/weblog/2013/02/obscure_little_eomodeler_info.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2013/02/obscure_little_eomodeler_info.html</guid>
        
        
         <pubDate>Mon, 04 Feb 2013 16:10:36 +0100</pubDate>
      </item>
      
      <item>
         <title>Bridging a wireless and an ethernet network with OS X 10.8, updated</title>
         <description><![CDATA[<i>I made a modification to the script, because the proxy_all sysctl isn't really needed in my setup.</i>

<p>Below in the drawing is my current home setup. My DSL router 192.168.<b>0.1</b> (&quot;fritz.box&quot;) creates a WIFI network 192.168.0.0/24. I then have another ethernet based network 192.168.1.0/24, with machines, that have no wireless capabilities.</p>
<p>This used to work fine, if one machine with an ethernet card (192.168.<b>1.2</b>) and a wireless card (192.168.<b>0.2</b>) running OS X, provided <a href="http://osxdaily.com/2012/01/05/enable-internet-sharing-mac-os-x/">internet sharing</a> for the wired net. But when I recently added a wireless only machine 192.168.<b>0.3</b> it became apparent, that this machine was not able to talk to the 192.168.1.0/24 network.</p>
<p>It took me quite a while to figure out how to do it, although the information is <a href="https://discussions.apple.com/thread/3537617?start=0&amp;tstart=0">available</a>, if you know which keywords to google for.</p>
<img height="543" style="margin: 5px" width="345" alt="" src="http://www.mulle-kybernetik.com/weblog/natnet.png" align="bottom" />

<p>First things first. Apple's "Internet Sharing" is doing NAT, which in this case is harmful. NAT and bridging can not be used reliably together (says the OpenBSD pf documentation). But I need to use &quot;real&quot; ethernet bridging, which can be done in OS X since 10.8 apparently.</p>
So "Internet Sharing" has to be turned off. <i>This could change the wired interface IP address!</i>

<h3>Create a permanent ethernet bridge on OS X</h3>


<p>
I put this shell script into <tt>/usr/local/sbin</tt> as <tt>mulle-ethernet-bridge.sh</tt>
<pre><font size="2">
#! /bin/sh
# ######################################
#  coded by Nat!
#  2013 Mulle kybernetiK
#  GPL

command=${1:-start}
shift
proxyarp=${1:-no}
shift

start()
{
	sysctl -w net.inet.ip.forwarding=1
	sysctl -w net.inet.ip.fw.enable=1
	if [ "$proxyarp" != "no" ]
	then
		sysctl -w net.link.ether.inet.proxyall=1
	fi

	ifconfig bridge0 create
	ifconfig bridge0 addm en0
	ifconfig bridge0 addm en1
	ifconfig bridge0 up
	if [ $? -eq 0 ]
	then
		syslog -s "Mulle Ethernet Bridge is up"
	else
		syslog -s "Mulle Ethernet Bridge failure"
	fi
}


stop()
{
	ifconfig bridge0 destroy

	sysctl -w net.inet.ip.forwarding=0
	sysctl -w net.inet.ip.fw.enable=0
	sysctl -w net.link.ether.inet.proxyall=0

	syslog -s "Mulle Ethernet Bridge is down"
}



case "$command" in
	start*)	start
		;;
	
	stop*)	stop
		;;
esac
</font></pre>
and configured it for executability
<pre><font size="2">chmod 755 /usr/local/sbin/mulle-ethernet-bridge.sh</font>
</pre>
Then I put the following <b>XML</b> into <tt>/Library/LaunchDaemons</tt> as <tt>com.mulle-kybernetik.admin.ethernet-bridge.plist</tt>
<pre><font size="2">
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;

&lt;plist version="1.0"&gt;
    &lt;dict&gt;
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;com.mulle-kybernetik.admin.ethernet-bridge&lt;/string&gt;
        &lt;key&gt;ProgramArguments&lt;/key&gt;
        &lt;array&gt;
            &lt;string&gt;/usr/local/sbin/mulle-ethernet-bridge.sh&lt;/string&gt;
        &lt;/array&gt;
        &lt;key&gt;UserName&lt;/key&gt;
        &lt;string&gt;root&lt;/string&gt;
        &lt;key&gt;GroupName&lt;/key&gt;
        &lt;string&gt;wheel&lt;/string&gt;
        &lt;key&gt;RunAtLoad&lt;/key&gt;
        &lt;true/&gt;
        &lt;key&gt;LaunchOnlyOnce&lt;/key&gt;
        &lt;true/&gt;   
    &lt;/dict&gt;
&lt;/plist&gt;
</font></pre>
and added it to <tt>launchd</tt> thusly
<pre><font size="2">
sudo chmod 644 /Library/LaunchDaemons/com.mulle-kybernetik.admin.ethernet-bridge.plist
sudo chown root:wheel /Library/LaunchDaemons/com.mulle-kybernetik.admin.ethernet-bridge.plist
sudo launchctl load /Library/LaunchDaemons/com.mulle-kybernetik.admin.ethernet-bridge.plist
</font></pre>

Check with <tt>ifconfig</tt> that the <tt>bridge0</tt> device has appeared now:
<pre><font size="2">bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	ether ac:dc:18:48:20:13 
	Configuration:
		priority 0 hellotime 0 fwddelay 0 maxage 0
		ipfilter disabled flags 0x2
	member: en0 flags=3<LEARNING,DISCOVER>
	         port 4 priority 0 path cost 0
	member: en1 flags=3<LEARNING,DISCOVER>
	         port 5 priority 0 path cost 0
</font></pre>

<H3>Adding routes to the wireless boxes</h3>

The wired boxes will be able to send pings to the wireless boxes, but the wireless boxes will send the return packets to the fritz.box, because NAT is disabled and any address 192.168.1.0/24 doesn't mean anything for them yet. Conceivably the fritz.box sends those replies then out to the interwebs, because it doesn't know the 192.168.1.0/24 network eiher and the interwebs are the default route.
<p>This information needs to be added to the static routing tables of the router. Thankfully the fritz box allows this in its expert settings. So I added:</p>
<table cellpadding=2>
    <tr bgcolor="#D0D0D0">
        <th>Network</th>
        <th>Netmask</th>
        <th>Gateway</th>
    </tr>
    <tr>
        <td>192.168.1.0</td>
        <td>255.255.255.0</td>
        <td>192.168.0.2</td>
    </tr>
</table>
<p></p>
With that the setup worked albeit not perfectly. I could now ping from the windows box 192.168.<b>0.3</b> to the debian box 192.168.<b>1.5</b>, but the packets would actually be running through both 192.168.<b>0.1</b> and 192.168.<b>0.2</b>: one hop too much. This is especially bad, since the extra hop is wireless.

Fortunately you can also add static routes in windows (using -p for a permanent route):

<pre>route -p add 192.168.1.0 mask 255.255.255.0 192.168.0.2 metric 1</pre>
]]></description>
         <link>http://www.mulle-kybernetik.com/weblog/2013/01/bridging_a_wireless_and_an_eth.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2013/01/bridging_a_wireless_and_an_eth.html</guid>
        
        
         <pubDate>Sun, 13 Jan 2013 19:11:21 +0100</pubDate>
      </item>
      
      <item>
         <title>Android, SVG and Java Rant</title>
         <description><![CDATA[I figured I could be spending the rest of my live in bliss, neither having to write in <strong>C#</strong> or <strong>Java</strong> ever again.
<p>WRONG!</p>
<p>Because of the cheapness of <strong>android</strong> tablets, I can now for the first time create small, simple programs and give them away for christmas to hapless children of my family complete with the hardware. All for EUR 80.</p>
<p><em>It would be really, really cool if those tablets would be conveniently rootable. They aren't though :( I hope RMS gets onto this.</em></p>
<p>But, <strong>android</strong> needs to be programmed in <strong>Java.</strong> Probably my pet-hated language, <strong>C++</strong> being a close second. Human memory being what it is, I thought that it wouldn't be cool, but that it probably would just work.</p>
<p>WRONG!</p>
<p>One of the things always touted about <strong>Java</strong> is, how convenient the garbage collection is and that one doesn't have to worry about memory management. Which even I remember, isn't true, because in the end most of the time in <strong>Java</strong> projects is spent hunting down leaks. So  explicit management of the object tree always was necessary. And I hated every second of it. I hated writing it and I hated debugging it. Oh god, the memories are coming back now...</p>
<p><em>As a little aside, I experimented loading <tt>Drawable</tt>s from <strong><a href="http://inkscape.org">inkscape</a></strong> generated SVG with <a href="http://code.google.com/p/svg-android/"><strong>svg-android</strong></a> and <a href="http://code.google.com/p/svg-android-2/"><strong>svg-android-2</strong>.</a> Forget about it. The parsing is javaesque snail paced and most of the time the inkscape SVG can't be parsed by these libraries anyway. I tried simplifying them with <a href="http://www.codedread.com/scour/"><strong>scour</strong></a> but that had some side-effects on the gradients, which I didn't like (maybe a precision thing). So I didn't go down that route further.</em></p>
<p>Anway. So of all the problems, that probably exist in <strong>android,</strong> I immediately run into this http://code.google.com/p/android/issues/detail?id=8488. I don't know how many other glaring bugs <strong>android</strong> has, but this is just the typical resource unaware <strong>Java</strong> lameness.  And this bug is most likely in there from the beginning of <strong>android.</strong></p>
<p>I especially love how the first mail is from a guy, who <a href="http://www.google.com/events/io/2009/sessions/TurboChargeUiAndroidFast.html">claims to have written parts</a> of the UI graphics code, who is totally oblivious to the fact, that a problem exists and then never shows up in the discussion afterwards. Bug Status ? Declined. There is no bug, because that's normal sucky <strong>Java</strong> behavior!</p>
<p>What is the folksy workaround ? Use some other crufty <strong>Java</strong> classes which allow manual management. The other idea, and I suspect a LOT of <strong>android</strong> is written this way: keep the <strong>Java</strong> as OS-glue and go native for the real action.</p>
]]></description>
         <link>http://www.mulle-kybernetik.com/weblog/2012/12/android_svg_and_java_rant.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2012/12/android_svg_and_java_rant.html</guid>
        
        
         <pubDate>Tue, 11 Dec 2012 17:06:08 +0100</pubDate>
      </item>
      
      <item>
         <title>Weihnachtsspam</title>
         <description><![CDATA[Das hier kam in meinem Briefkasten an.
<p><tt>spam.com</tt> ist deren Domäne, die ich allerdings geändert habe. <tt>rechner.firma.de</tt> ist mein Host/Domäne. Der Rest ist original.</p>
<pre>
Return-Path: Delivered-To: nat@rechner.firma.de
Received: from localhost (localhost [127.0.0.1])
    by rechner.firma.de (Postfix) with ESMTP id B8B232285BF
    for ; Fri,  7 Dec 2012 21:48:14 +0100 (CET)
X-Virus-Scanned: amavisd-new at firma.de
Received: from rechner.firma.de ([127.0.0.1])
    by localhost (rechner.firma.de [127.0.0.1]) (amavisd-new, port 10024)
    with ESMTP id uzkiaWIfZGHK for ;
    Fri,  7 Dec 2012 21:48:09 +0100 (CET)
Received: from spam.com (spam.com [91.240.71.205])
    by rechner.firma.de (Postfix) with ESMTP id 97E2E2285B9
    for ; Fri,  7 Dec 2012 21:48:08 +0100 (CET)
Received: from localhost (localhost [127.0.0.1])
    by spam.com (Postfix) with ESMTP id 1BCCA31128
    for ; Fri,  7 Dec 2012 21:39:00 +0100 (CET)
Date: Fri, 7 Dec 2012 21:39:00 +0100
To: info@firma.de
From: Fickt-Euch Sell Subject: =?iso-8859-1?Q?Nikolausgeschenk_f=FCr_firma_GmbH?=
Message-ID: X-Priority: 3
Importance: 
X-Mailer:  Microsoft Outlook 6.00.692277
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="iso-8859-1"
Guten Tag,
Weihnachten naht - und damit unsere Top-Angebote:
++ Kunst-Weihnachtsbaum: Nordmann-Tanne, NADELT NICHT: statt 199,- Euro* nur 79,- Euro
++ Das perfekte Geschenk für den Hausmann: Set aus Akkuschrauber und Akkubohrer: statt 399,- Euro* nur 89,- Euro
++ Superstarke 3,1 PS-Kettensäge: statt 399,- Euro* nur 139 Euro
Hier sofort bestellen:
http://spam.com/
Denken Sie praktisch - und verschenken Sie eine der nützlichen Produkte aus unserem Online-Shop. Bestellen Sie jetzt und profitieren Sie von den allergrößten Rabatten.
Vorweihnachtliche Grüße
Fickt-Euch Sell
Newsletter Abmelden: http://spam.com/abmelden
* Zu diesen und ähnlichen Preise im Handel gesehen
</pre>
]]></description>
         <link>http://www.mulle-kybernetik.com/weblog/2012/12/weihnachtsspam.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2012/12/weihnachtsspam.html</guid>
        
        
         <pubDate>Sat, 08 Dec 2012 15:28:20 +0100</pubDate>
      </item>
      
      <item>
         <title>Sorting and Beautifying Code in Xcode</title>
         <description><![CDATA[Thanks to Automator it's very easy to create a Service using Applescript and unix commands. Here's an example how to sort lines in Xcode with the context menu.
<p>In Automator create a new Service (Dienst)</p>
<p><img height="336" style="margin: 5px" width="400" alt="Automator Open Dialog" title="Automator" src="http://www.mulle-kybernetik.com/weblog/align-screeny-1.jpg" align="bottom" /></p>
<p>Then add a shell script to the Service (red). Be sure to check the box (yellow) and change the command to sort (green), Finally save the script. The name you give to your script, will be the name that appears in the Services menu. I chose &quot;Zeilen sortieren&quot;.</p>
<p><img height="185" style="margin: 5px" width="480" alt='Add "Run a Shell Sript" and check "replace input text"' title="Creating the AppleScript" src="http://www.mulle-kybernetik.com/weblog/align-screeny-2.jpg" align="bottom" /></p>
<p>Now in 10.8.1 everything works fine. But I remember that in former times, it may have been necessary to do some magic to get the service going (login/logut). But maybe I am confusing this with Colorsync or Finder plugins.</p>
<p>Anyway... In Xcode select some lines and run your &quot;Service&quot; on it. If you don't have many services, you might be lucky, and the services will appear directly in the top menu.</p>
<p><img height="428" style="margin: 5px" width="480" alt="Doing the magic in Xcode" src="http://www.mulle-kybernetik.com/weblog/align-screeny-3.jpg" align="bottom" /></p>
<p>Now with these preliminaries out of the way, I have created a small <a href="http://github.com/mulle-nat/mulle-c-code-align">unix tool</a>, that aligns variables (and as a bonus also can align assignment statements).  So this:</p>
<pre>
   int    foo;
   static char  *x;
   auto volatile int  foo[ 126];
</pre>
<p>becomes</p>
<pre>
   int                 foo;
   static char         *x;
   auto volatile int   foo[ 126];
</pre>
<p>and</p>
<pre>
   x = foo
    // bla
      y[x] = bar
</pre>
<p>becomes</p>
<pre>
   x     = foo
    // bla
   y[x]  = bar
</pre>
]]></description>
         <link>http://www.mulle-kybernetik.com/weblog/2012/09/sorting_and_beautifying_code_i.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2012/09/sorting_and_beautifying_code_i.html</guid>
        
        
         <pubDate>Wed, 26 Sep 2012 00:23:49 +0100</pubDate>
      </item>
      
      <item>
         <title>Oops I did it again</title>
         <description><![CDATA[<img height="522" style="margin: 5px" width="567" alt="" src="http://www.mulle-kybernetik.com/weblog/oops-i-did-it-again.png" />
<p>Not so easy this time because Cocoa.framework is missing some symbols.</p>

]]></description>
         <link>http://www.mulle-kybernetik.com/weblog/2012/08/oops_i_did_it_again.html</link>
         <guid>http://www.mulle-kybernetik.com/weblog/2012/08/oops_i_did_it_again.html</guid>
        
        
         <pubDate>Mon, 27 Aug 2012 18:01:04 +0100</pubDate>
      </item>
      
   </channel>
</rss>
