<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    
    <title>Lunesu</title>
    <link>http://lunesu.com/</link>
    <description>Random Notes</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.6 - http://www.s9y.org/</generator>
    
    

<item>
    <title>Show current GIT branch in TCC</title>
    <link>http://lunesu.com/index.php?/archives/133-Show-current-GIT-branch-in-TCC.html</link>
            <category>Knowledge Base</category>
    
    <comments>http://lunesu.com/index.php?/archives/133-Show-current-GIT-branch-in-TCC.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=133</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=133</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    I&#039;m getting more and more familiar with the GIT workflow, which goes kinda like this:&lt;blockquote&gt;git checkout -b topicbranchX&lt;br /&gt;
git add somefile&lt;br /&gt;
git commit -m&quot;commit message&quot;&lt;br /&gt;
git pull&lt;br /&gt;
git rebase master&lt;br /&gt;
git push&lt;/blockquote&gt;&lt;br /&gt;
Unfortunately this means that you&#039;ll end up with a bunch of branches (which you can delete once they get pulled into origin/master) but I keep forgetting what branch I currently have checked out. I&#039;ve seen bash prompts that show the current branch and I decided to do something similar for &lt;a href=&quot;http://jpsoft.com&quot; title=&quot;JP Software&quot;&gt;TCC/LE&lt;/a&gt;.&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;c&quot;&gt;/&amp;#42;
@cl &quot;/Tp%~f0&quot; /nologo /GS- /link /SUBSYSTEM:console /nodefaultlib /entry:_main kernel32.lib
@goto :EOF
*/
#define WIN32_LEAN_AND_MEAN
#include &amp;lt;windows.h&gt;
const WCHAR root[] = L&quot;..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\.git\\HEAD&quot;;
int __stdcall _main() {
  int offset = sizeof(root)/2 - 10;
  while (offset &gt;= 0) {
    HANDLE h = CreateFileW(root + offset, GENERIC_READ, FILE_SHARE_READ, NULL, 
      OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if (h != INVALID_HANDLE_VALUE) {
      char buf[64];
      DWORD read = 0;
      if (ReadFile(h, buf, sizeof(buf), &amp;read, NULL) &amp;&amp;amp; read &gt; 16) {
        DWORD off = 0;
        DWORD len = 7;            // show 7 hex digits
        if ((int&amp;)buf[0] == &#039;:fer&#039;) {
          off = 16;               // skip ref: refs/heads/
          len = read - off ;     // keep LF
        }
        WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), buf + off, len, NULL, NULL);
      }
      return 13 - offset / 3;
    }
    offset -= 3;
  }
  return 0;
}&lt;/pre&gt;&lt;br /&gt;
What&#039;s fun about this file is that you can save it as &quot;gb.cmd&quot;. When you then enter &quot;gb&quot; on the command line, it will actually invoke the C compiler (remember to run vcvars32) to generate the gb.exe. Next time, the exe will be invoked instead.&lt;br /&gt;
&lt;br /&gt;
This is the final prompt:&lt;br /&gt;
&lt;blockquote&gt;prompt %%@exec[@gb.exe]$e[1m$P$e[0m$_$+$g&lt;/blockquote&gt; 
    </content:encoded>

    <pubDate>Fri, 03 May 2013 07:02:39 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/133-guid.html</guid>
    
</item>
<item>
    <title>Interview with Shanghai TV</title>
    <link>http://lunesu.com/index.php?/archives/132-Interview-with-Shanghai-TV.html</link>
            <category>China</category>
    
    <comments>http://lunesu.com/index.php?/archives/132-Interview-with-Shanghai-TV.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=132</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=132</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    A few weeks ago I got interviewed by &lt;a href=&quot;http://www.stv.sh.cn/&quot; title=&quot;SMG&quot;&gt;Shanghai TV&lt;/a&gt; about the Shanghai hackerspace &lt;a href=&quot;http://xinchejian.com&quot; title=&quot;XinCheJian hackerspace&quot;&gt;新车间 (XinCheJian)&lt;/a&gt; that I&#039;m part of. In the interview I demonstrate one of the hacks I did, using a TP-Link router to open the machine room.&lt;br /&gt;
&lt;iframe height=498 width=510 frameborder=0 src=&quot;http://player.youku.com/embed/XNTE0NTg1ODY4&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;br /&gt;
(No, that&#039;s not actually the password for our machine room.)&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://twitter.com/gblock&quot; title=&quot;Glenn Block on Twitter&quot;&gt;@GBlock&lt;/a&gt; also has a &lt;a href=&quot;http://vimeo.com/46292601&quot; title=&quot;Wireless Door Lock&quot;&gt;video&lt;/a&gt; on the hack on &lt;a href=&quot;http://vimeo.com/user6775216&quot; title=&quot;Glenn Block&#039;s Vimeo page&quot;&gt;his Vimeo page&lt;/a&gt;. 
    </content:encoded>

    <pubDate>Tue, 19 Feb 2013 02:51:12 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/132-guid.html</guid>
    
</item>
<item>
    <title>Set IE10 InPrivate as default</title>
    <link>http://lunesu.com/index.php?/archives/131-Set-IE10-InPrivate-as-default.html</link>
    
    <comments>http://lunesu.com/index.php?/archives/131-Set-IE10-InPrivate-as-default.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=131</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=131</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    Do this by adding &quot;-private&quot; to the shortcut in the taskbar. Right-click on the IE logo in the taskbar. Then, right-click on &quot;Internet Explorer&quot; and click &quot;Properties&quot;. In the properties dialog, add a space and then &lt;strong&gt;-private&lt;/strong&gt; to the end of the &lt;strong&gt;Target&lt;/strong&gt;. OK.&lt;br /&gt;
&lt;br /&gt;
If IE is not currently running, right-clicking the IE logo in the task bar and selecting &quot;Open new tab&quot; opens a new, non-InPrivate, tab.&lt;br /&gt;
&lt;br /&gt;
&lt;!-- s9ymdb:149 --&gt;&lt;img class=&quot;serendipity_image_left&quot; width=&quot;332&quot; height=&quot;309&quot;  src=&quot;http://lunesu.com/uploads/ie10inprivate.png&quot; title=&quot;ie10inprivate.png&quot; alt=&quot;Set IE10 InPrivate as default&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;!-- s9ymdb:150 --&gt;&lt;img class=&quot;serendipity_image_left&quot; width=&quot;377&quot; height=&quot;516&quot;  src=&quot;http://lunesu.com/uploads/ie10inprivate2.png&quot;  alt=&quot;IE10 properties&quot; /&gt; 
    </content:encoded>

    <pubDate>Wed, 02 Jan 2013 09:11:54 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/131-guid.html</guid>
    
</item>
<item>
    <title>Google sabotaging Windows Phone clients?</title>
    <link>http://lunesu.com/index.php?/archives/129-Google-sabotaging-Windows-Phone-clients.html</link>
    
    <comments>http://lunesu.com/index.php?/archives/129-Google-sabotaging-Windows-Phone-clients.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=129</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=129</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    (Disclaimer: I&#039;m a Software Engineer for Microsoft China. In this blog I express my personal opinion and none of this constitutes the official nor unofficial opinion of Microsoft.)&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;UPDATE:&lt;/strong&gt; this issue also hit &lt;a href=&quot;http://www.theverge.com/2013/1/4/3836510/windows-phone-8-users-unable-to-access-google-maps&quot;&gt;The Verge&lt;/a&gt;. The information in &lt;a href=&quot;http://www.theverge.com/2013/1/4/3834960/google-maps-disabled-on-wp8&quot;&gt;this thread&lt;/a&gt; also confirms that Google tests for &quot;Windows Phone&quot;, as opposed to testing for specific browser capabilities. &lt;a href=&quot;http://gizmodo.com/5973295/google-maps-has-never-been-accessible-on-mobile-internet-explorer&quot;&gt;Gizmodo&lt;/a&gt; also posted the story.&lt;br /&gt;
&lt;br /&gt;
I make no secret of the fact that, while I like my (Microsoft sponsored) Windows Phone, I miss Google Maps. For me, Google Maps was the killer app for Android. And the experience is great, even in China, with vector maps, buildings, public transport, subway exits, real-time traffic, latitude.&lt;br /&gt;
&lt;br /&gt;
But Google Maps wasn&#039;t enough to keep me on Android. I thought the Windows Phone experience was better overall and I ended up using by &lt;strong&gt;Nokia Lumia 800&lt;/strong&gt; over my &lt;strong&gt;HTC Desire S&lt;/strong&gt;. For maps, I keep switching between Nokia Maps and &lt;a href=&quot;http://www.windowsphone.com/en-us/store/app/gmaps-pro/5fad1b41-f8db-4397-b584-4a0da12fe233&quot; title=&quot;GMaps Pro&quot;&gt;GMaps Pro&lt;/a&gt;, an unofficial Google Maps client for WP. And occasionally I&#039;d simply go to &lt;a href=&quot;http://maps.google.com&quot; title=&quot;Google Maps&quot;&gt;maps.google.com&lt;/a&gt; with IE. Well, I used to, anyway.&lt;br /&gt;
&lt;br /&gt;
Lately (as of a few months ago) opening maps.google.com on my WinPhone simply redirects me to Google Search. Even the Chinese site, &lt;a href=&quot;http://ditu.google.com&quot; title=&quot;谷歌地图&quot;&gt;ditu.google.com&lt;/a&gt;, no longer opens on my WinPhone. Switching IE from Mobile to Desktop mode also doesn&#039;t fix the issue, and I keep getting redirected to a regular search page (under the maps.google.com domain, but it&#039;s still regular search, without maps.)&lt;br /&gt;
&lt;br /&gt;
My first thought was that the IE browser on WP7.5 &quot;Mango&quot; was simply not supported by Google. So I fired up the WP8 emulator to check whether Google Maps would open on the mobile version of IE10. Sure enough, it didn&#039;t. However, this time switching IE to Desktop mode did solve the problem and I got the regular desktop experience, albeit on a small screen. &lt;br /&gt;
&lt;br /&gt;
That&#039;s suspicious, I thought, since the browser is exactly the same, whether I use mobile mode or desktop mode. I figure I&#039;d manually try the different &lt;a href=&quot;http://en.wikipedia.org/wiki/User_agent&quot; title=&quot;User Agent on Wikipedia&quot;&gt;User-Agents&lt;/a&gt; to see what would happen:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;WP7 - Mobile Version&lt;br /&gt;
Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; NOKIA; Nokia 800)&lt;br /&gt;
&lt;blockquote&gt;HTTP/1.1 302 Found&lt;br /&gt;
Location: http://maps.google.com/m/local&lt;/blockquote&gt;&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;WP7 - Desktop Version&lt;br /&gt;
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; XBLWP7; ZuneWP7)&lt;br /&gt;
&lt;blockquote&gt;HTTP/1.1 302 Found&lt;br /&gt;
Location: http://maps.google.com/m/local&lt;/blockquote&gt;&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;WP8 - Mobile Version&lt;br /&gt;
Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; Microsoft; Virtual)&lt;br /&gt;
&lt;blockquote&gt;HTTP/1.1 302 Found&lt;br /&gt;
Location: http://maps.google.com/m/local&lt;/blockquote&gt;&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;WP8 - Desktop Version&lt;br /&gt;
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; ARM; Touch; WPDesktop)&lt;br /&gt;
&lt;blockquote&gt;HTTP/1.1 200 OK&lt;/blockquote&gt;&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Win8 - Desktop Browser&lt;br /&gt;
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)&lt;br /&gt;
&lt;blockquote&gt;HTTP/1.1 200 OK&lt;/blockquote&gt;&lt;br /&gt;
&lt;/li&gt;&lt;li&gt;Win8 - &quot;Metro&quot; Modern Browser&lt;br /&gt;
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)&lt;br /&gt;
&lt;blockquote&gt;HTTP/1.1 200 OK&lt;/blockquote&gt;&lt;br /&gt;
&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;
Interestingly, as soon as a device identifies itself as a Windows Phone (or WP7) it gets redirected. In other cases it gets the actual Google Maps page. As a test I wanted to replace the User-Agent from my WP7 device with the one from an Android device. Here&#039;s how:&lt;br /&gt;
&lt;blockquote&gt;sudo apt-get privoxy&lt;br /&gt;
sudo vi /etc/privoxy/default.actions&lt;/blockquote&gt;Add this to the end:&lt;blockquote&gt;{+hide-user-agent{Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus One Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1)}}&lt;br /&gt;
.google.&lt;/blockquote&gt;Change &lt;strong&gt;listen-address &lt;/strong&gt;to listen on a public IP:&lt;blockquote&gt;sudo vi /etc/privoxy/config&lt;br /&gt;
sudo /etc/init.d/privoxy restart&lt;/blockquote&gt;On the WP device, change the proxy for your current WLAN profile to point to your instance of &lt;a href=&quot;http://www.privoxy.org/&quot; title=&quot;Privoxy HTTP proxy&quot;&gt;Privoxy&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Et voilà, you got Google Maps on WP7, albeit a little flaky. It might be that Google preferred WP user to have no experience to them having a flaky one, but that still doesn&#039;t explain why it&#039;s redirecting WP8 IE when in Mobile mode.&lt;br /&gt;
&lt;br /&gt;
Now here&#039;s what&#039;s interesting. As soon as I add &quot;Windows Phone&quot; to the User-Agent, the page no longer loads and I get redirected again. Clearly there&#039;s some regex magic at work on Google&#039;s end.&lt;br /&gt;
&lt;br /&gt;
As much as I agree with &lt;a href=&quot;http://en.wikipedia.org/wiki/Hanlon%27s_razor&quot; title=&quot;Hanlon&#039;s razor on Wikipedia&quot;&gt;Hanlon&#039;s razor&lt;/a&gt; &quot;Never attribute to malice that which is adequately explained by stupidity,&quot; this does reek of Google being disingenuous and blocking the competition from their platform&#039;s killing app.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lunesu.com/index.php?/archives/130-Do-no-evil.html&quot; title=&quot;&quot;Do no evil&quot;&quot;&gt;And it&#039;s not as-if they haven&#039;t done shit like this before.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Oh, and Happy New Year! 
    </content:encoded>

    <pubDate>Tue, 01 Jan 2013 08:05:00 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/129-guid.html</guid>
    
</item>
<item>
    <title>&quot;Do no evil&quot;</title>
    <link>http://lunesu.com/index.php?/archives/130-Do-no-evil.html</link>
    
    <comments>http://lunesu.com/index.php?/archives/130-Do-no-evil.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=130</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=130</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    (Cross-posted from my Facebook profile)&lt;br /&gt;
&lt;br /&gt;
Smart, but disingenuous, ad served by Google. Mentions other browsers but links to the Chrome homepage. The site this ad got served on worked just fine in IE. Dirty trick.&lt;br /&gt;
&lt;!-- s9ymdb:148 --&gt;&lt;img class=&quot;serendipity_image_center&quot; width=&quot;300&quot; height=&quot;250&quot;  src=&quot;http://lunesu.com/uploads/scroogled.png&quot; title=&quot;scroogled.png&quot; alt=&quot;&quot; /&gt; 
    </content:encoded>

    <pubDate>Sat, 11 Aug 2012 09:05:00 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/130-guid.html</guid>
    
</item>
<item>
    <title>Finally: unbound + dnsmasq</title>
    <link>http://lunesu.com/index.php?/archives/128-Finally-unbound-+-dnsmasq.html</link>
            <category>Knowledge Base</category>
    
    <comments>http://lunesu.com/index.php?/archives/128-Finally-unbound-+-dnsmasq.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=128</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=128</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    I&#039;ve been using &lt;a href=&quot;http://unbound.net/&quot; title=&quot;Unbound&quot;&gt;unbound&lt;/a&gt; as my only DNS server for over a year now. It&#039;s a recursive and caching DNS server with DNSSEC (a.o.) support. &lt;br /&gt;
&lt;br /&gt;
This is particularly interesting for people living in China: the GFW&#039;s first line of defense (if you can call it that) is spoofing DNS. If you use the DNS server provided by any of the Chinese ISPs, you&#039;re unlikely to get any meaningful IP for domain such as facebook or twitter. But if you go through the whole recursive query yourself (ie. ask the root-servers for &quot;com&quot;, ask the .com servers for &quot;facebook&quot; and ask the facebook servers for &quot;www&quot;) then you will get an IP, which you can potentially verify using DNSSEC. Because facebook and others constantly add new servers to their datacenters, with new IPs, it&#039;s likely that once you get the right IP, you can actually connect to the server, without the need for VPN.&lt;br /&gt;
&lt;br /&gt;
Unbound is easy to setup. For me, &quot;opkg install unbound&quot; was half the battle. The other half involved editing /etc/unbound/unbound.conf. For a detailed walk through, check &lt;a href=&quot;https://calomel.org/unbound_dns.html&quot; title=&quot;Calomel&quot;&gt;this &lt;/a&gt;great site [calomel.org]. Here&#039;s my current unbound.conf:&lt;blockquote&gt;server:&lt;br /&gt;
        neg-cache-size: 0&lt;br /&gt;
        use-caps-for-id: yes&lt;br /&gt;
        prefetch: yes&lt;br /&gt;
        port: 533&lt;br /&gt;
        do-udp: yes&lt;br /&gt;
        do-tcp: yes&lt;br /&gt;
        interface: 0.0.0.0&lt;br /&gt;
        #interface: ::0&lt;br /&gt;
        #do-ip6: no&lt;br /&gt;
        val-clean-additional: yes&lt;br /&gt;
        harden-glue: yes&lt;br /&gt;
        harden-dnssec-stripped: yes&lt;br /&gt;
        rrset-cache-size: 1m&lt;br /&gt;
        rrset-cache-slabs: 2&lt;br /&gt;
        root-hints: &quot;named.cache&quot;&lt;br /&gt;
        auto-trust-anchor-file: &quot;root.autokey&quot;&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
All this was working fine, but the problem was that local names in my LAN no longer got resolved. Unbound doesn&#039;t no anything about DHCP and it won&#039;t accept DNS registrations from local machines. Dnsmasq does know about local names, since it&#039;s the one handing out the IPs in the first place. Ideally, I use both DNS servers: unbound for external queries and dnsmasq for internal (and internal only!) queries.&lt;br /&gt;
&lt;br /&gt;
Most of the time I query external names, so I&#039;d tried to get Unbound to forward local queries to Dnsmasq. I configured Unbound to use port 53 and Dnsmasq to use port 533. Then, I added a forward-zone to unbound.conf:&lt;blockquote&gt;    forward-zone:&lt;br /&gt;
       name: &quot;lan&quot;&lt;br /&gt;
       forward-addr: 127.0.0.1@533&lt;/blockquote&gt;&lt;br /&gt;
This was supposed to forward all queries in the &quot;lan&quot; domain (the local domain, as configured in dnsmasq/dhcp) to the dnsmasq server listening on port 533. Unfortunately, this didn&#039;t work. No queries got forwarded, even though a lookup for a local name did get suffixed with &quot;.lan&quot; by the clients.&lt;br /&gt;
&lt;br /&gt;
So I flipped it around: dnsmasq on port 53, unbound on 533. Add the following to /etc/config/dhcp:&lt;blockquote&gt;        option &#039;nonegcache&#039; &#039;1&#039;&lt;br /&gt;
        list &#039;server&#039; &#039;127.0.0.1#533&#039;&lt;br /&gt;
        option &#039;port&#039; &#039;53&#039;&lt;br /&gt;
        option &#039;noresolv&#039; &#039;1&#039;&lt;br /&gt;
&lt;/blockquote&gt;This works: I can successfully ping my local computers and NAS, while still having other queries resolved (recursively) by unbound. I used &lt;a href=&quot;https://calomel.org/dns_verify.html&quot; title=&quot;DNS verification script&quot;&gt;dns_verify.sh&lt;/a&gt; to check my setup:&lt;blockquote&gt;root@OpenWrt:~# ./dns_verify.sh&lt;br /&gt;
&lt;br /&gt;
        ip        -&gt;     hostname      -&gt; ip&lt;br /&gt;
--------------------------------------------------------&lt;br /&gt;
ok      192.168.2.1 -&gt; OpenWrt.lan. -&gt; 192.168.2.1&lt;br /&gt;
ok      192.168.2.2 -&gt; DaWang.lan. -&gt; 192.168.2.2&lt;br /&gt;
&lt;br /&gt;
DONE.&lt;/blockquote&gt;By the way, the script needs &lt;strong&gt;dig&lt;/strong&gt;, which you can get by doing &quot;opkg install bind-dig&quot;. 
    </content:encoded>

    <pubDate>Mon, 25 Jun 2012 13:33:57 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/128-guid.html</guid>
    
</item>
<item>
    <title>Real life example</title>
    <link>http://lunesu.com/index.php?/archives/127-Real-life-example.html</link>
            <category>Knowledge Base</category>
    
    <comments>http://lunesu.com/index.php?/archives/127-Real-life-example.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=127</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=127</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    I never found the need to study those common unix utilities like &lt;strong&gt;sed&lt;/strong&gt;, &lt;strong&gt;awk&lt;/strong&gt;, &lt;strong&gt;xargs&lt;/strong&gt;. Even my knowledge of grep didn&#039;t go further than &lt;strong&gt;blah | grep foo&lt;/strong&gt;. Until yesterday, when I needed to accomplish a task that just happened to involve all of these utilities:&lt;blockquote&gt;grep ppp /proc/net/dev | sed &quot;s/:/ /&quot; | awk &#039;($2+$10&gt;1000000000){print $1}&#039; | xargs --max-args=1 --no-run-if-empty ppp-off&lt;/blockquote&gt;&lt;br /&gt;
First, &lt;strong&gt;grep &lt;/strong&gt;filters all lines from &lt;em&gt;/proc/net/dev&lt;/em&gt; that contain &lt;em&gt;ppp&lt;/em&gt;.&lt;br /&gt;
Then, &lt;strong&gt;sed &lt;/strong&gt;changes the colon into a space using the regex &lt;em&gt;s/:/ /&lt;/em&gt;.&lt;br /&gt;
Next, &lt;strong&gt;awk &lt;/strong&gt;parses the values of the 2nd and 10th column [bytes sent and received] and if the sum exceeds 1GB it prints the value in the first column [the interface].&lt;br /&gt;
Finally, &lt;strong&gt;xargs &lt;/strong&gt;invokes ppp-off for every interface returned.&lt;br /&gt;
&lt;br /&gt;
Why I needed this is left as an exercise to the reader. 
    </content:encoded>

    <pubDate>Sat, 11 Feb 2012 09:37:27 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/127-guid.html</guid>
    
</item>
<item>
    <title>Modern COM Programming in D</title>
    <link>http://lunesu.com/index.php?/archives/126-Modern-COM-Programming-in-D.html</link>
            <category>D</category>
    
    <comments>http://lunesu.com/index.php?/archives/126-Modern-COM-Programming-in-D.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=126</wfw:comment>

    <slash:comments>5</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=126</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    I finally got around to asking for permission to share the slides of a tech talk I did more than a year ago: &lt;a href=&quot;http://lunesu.com/uploads/ModernCOMProgramminginD.pdf&quot; title=&quot;Modern COM Programming in D&quot; target=&quot;_blank&quot;&gt;Modern COM Programming in D&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
In the slides I explain how I&#039;ve made a projection for COM into D, which allows you to use COM objects without the usual hassle of refcount/QueryInterface/HRESULT/BSTR/etc... Sharing the code will be hard (mostly because of the shape it&#039;s in) but the slides basically contain all you need. Actually, D has progressed a lot since, so a rewrite might be in order anyway.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;UPDATE:&lt;/strong&gt; Add your comments below or on &lt;a href=&quot;http://www.reddit.com/r/programming/comments/ow7qc/modern_com_programming_in_d/&quot; title=&quot;Reddit&quot;&gt;Reddit&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;c&quot;&gt;import std.stdio, comxml;

void main()
{
    // Create a new empty document 
    auto doc = XmlDocument();

    // Load an XML document from an inline string
    doc.LoadXml(&quot;&lt;root&gt;世界你好&lt;a&gt;hello&lt;/a&gt;&lt;a&gt;world&lt;/a&gt;&lt;/root&gt;&quot;);

    // Get the first node&#039;s value 
    auto text = doc.DocumentElement.FirstChild;
    // Write the node&#039;s value to the console
    writeln(text.NodeValue);

    // Perform a simple XPath query
    auto nodes = doc.SelectNodes(&quot;/root/a/text()&quot;);

    // Do iteration through the child nodes
    foreach (node; nodes.First)
        writeln(node.NodeValue);

    // Access the child nodes by index 
    for (uint t = 0; t &lt; nodes.length; ++t)
        writeln(nodes[t].NodeValue);
}
&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Tue, 24 Jan 2012 16:53:25 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/126-guid.html</guid>
    
</item>
<item>
    <title>Server-side email filtering</title>
    <link>http://lunesu.com/index.php?/archives/125-Server-side-email-filtering.html</link>
            <category>Knowledge Base</category>
    
    <comments>http://lunesu.com/index.php?/archives/125-Server-side-email-filtering.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=125</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=125</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    I hate etc/ and everything in it, but I realize it might not be etc/&#039;s fault. The fault might lie with Google and Bing: most of the results I get are people asking the same question on some forum. These threads often end without any answer. Or worse, wrong information. About half the threads eventually end up with the members discussing a complete different issue. Anyway, I figured it out. The following example assumes you&#039;re &lt;a href=&quot;http://lunesu.com/index.php?/archives/112-Converting-mailbox-format-from-mbox-to-Maildir.html&quot; title=&quot;Converting mailbox format from mbox to Maildir&quot;&gt;using the &lt;strong&gt;maildir&lt;/strong&gt; format for your mailbox&lt;/a&gt;.&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Create a file called &lt;strong&gt;.procmailrc&lt;/strong&gt; in your home folder and add the following contents:&lt;blockquote&gt;DEFAULT=$HOME/Maildir/&lt;br /&gt;
MAILDIR=$HOME/Maildir&lt;br /&gt;
&lt;br /&gt;
:0:&lt;br /&gt;
* ^Mailing-list: list staff@somedomain\.com&lt;br /&gt;
.SomeFolder/&lt;br /&gt;
&lt;/blockquote&gt;&lt;br /&gt;
&lt;li&gt;Tell postfix to use &lt;strong&gt;procmail &lt;/strong&gt;for mail filtering/processing by adding/changing the following line to /etc/postfix/main.cf:&lt;blockquote&gt;mailbox_command = procmail -a &quot;$EXTENSION&quot;&lt;/li&gt;&lt;/blockquote&gt;&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Restart postfix&lt;blockquote&gt;sudo /etc/init.d/postfix reload&lt;/blockquote&gt;&lt;/li&gt;&lt;br /&gt;
&lt;/ol&gt;&lt;br /&gt;
As you can see, the rules in .procmailrc use regular expressions to find the right mail. Each rule starts with colon-zero-colon (see &lt;strong&gt;man procmailrc &lt;/strong&gt;for more options), followed by a line with the regular expression. Here, &lt;strong&gt;^&lt;/strong&gt; means beginning of the line. Note that dots must be escaped with a backslash. A wildcard would be written as &lt;strong&gt;.*&lt;/strong&gt;&lt;br /&gt;
The next line describes what to do when the regular expression is matched. In this case we want procmail to deliver the mail to a folder called SomeFolder. (If you&#039;re using &lt;strong&gt;mbox &lt;/strong&gt;instead of maildir this would be a filename rather than a folder name.)&lt;br /&gt;
&lt;br /&gt;
Add as many rules as you want, separating them with an empty line. 
    </content:encoded>

    <pubDate>Tue, 24 Jan 2012 08:58:04 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/125-guid.html</guid>
    
</item>
<item>
    <title>OpenWRT on Netgear WNDR3700, IPv6 edition!</title>
    <link>http://lunesu.com/index.php?/archives/124-OpenWRT-on-Netgear-WNDR3700,-IPv6-edition!.html</link>
    
    <comments>http://lunesu.com/index.php?/archives/124-OpenWRT-on-Netgear-WNDR3700,-IPv6-edition!.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=124</wfw:comment>

    <slash:comments>3</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=124</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    Happy IPv6 day everyone!&lt;br /&gt;
&lt;br /&gt;
&lt;!-- s9ymdb:145 --&gt;&lt;img class=&quot;serendipity_image_center&quot; width=&quot;646&quot; height=&quot;195&quot;  src=&quot;http://lunesu.com/uploads/ipv6.PNG&quot;  alt=&quot;&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Here&#039;s how I went about it:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Triple-30 reset your router: with router on, press reset and hold; after 30 secs, pull the plug but keep reset; after 30 secs put back the plug, keep reset; after 30 secs release reset and power cycle.&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Confirm triple-30 reset: router management page should ask for factory password. If not, retry triple-30 reset.&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;With router off, hold reset and turn on router. Keep reset until power led blinks green (After ~35 secs.)&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;tftp -i 192.168.1.1 PUT &lt;a href=&quot;http://downloads.openwrt.org/backfire/10.03/ar71xx/openwrt-ar71xx-wndr3700-squashfs-factory.img&quot;&gt;openwrt-ar71xx-wndr3700-squashfs-factory.img&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Do nothing! Wait until the firmware is completely initialized. Check with ping -t 192.168.1.1&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Access http://192.168.1.1/ (Luci) and change root password under Administration. There&#039;s no default password.&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Still in Luci, configure your wan interface. Apply &amp;amp; save. Reboot.&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;SSH to root@192.168.1.1&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;sysupgrade http://downloads.openwrt.org/snapshots/trunk/ar71xx/openwrt-ar71xx-generic-wndr3700-squashfs-sysupgrade.bin&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;opkg install kmod-ipv6 radvd ip kmod-ip6tables ip6tables 6to4 kmod-sit&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;vim /etc/config/network&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Add to end:&lt;blockquote&gt;config interface 6rd&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;option proto 6to4&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;option adv_subnet 1&lt;/blockquote&gt;&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;vim /etc/config/radvd&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Change interface option &#039;ignore&#039; to 0&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;/etc/init.d/network restart&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;In Luci, add the &#039;6rd&#039; interface to the wan zone&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;In Luci, add the following firewall rule: name 6to4, source wan, protocol 41, target accept. Save.&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;In Luci, make sure radvd starts at startup. Apply &amp;amp; Save. Reboot.&lt;/li&gt;&lt;br /&gt;
&lt;/ol&gt; 
    </content:encoded>

    <pubDate>Wed, 08 Jun 2011 14:46:21 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/124-guid.html</guid>
    
</item>
<item>
    <title>Facebooc</title>
    <link>http://lunesu.com/index.php?/archives/123-Facebooc.html</link>
    
    <comments>http://lunesu.com/index.php?/archives/123-Facebooc.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=123</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=123</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    Nice IP address they got, by the way:&lt;blockquote&gt;TCP    [2002:74e2:70fd:e472::3]:3405  [2620:0:1cfe:face:b00c::3]:443  ESTABLISHED&lt;/blockquote&gt; 
    </content:encoded>

    <pubDate>Sat, 19 Feb 2011 13:28:09 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/123-guid.html</guid>
    
</item>
<item>
    <title>New sport: extreme hot-plugging</title>
    <link>http://lunesu.com/index.php?/archives/122-New-sport-extreme-hot-plugging.html</link>
    
    <comments>http://lunesu.com/index.php?/archives/122-New-sport-extreme-hot-plugging.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=122</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=122</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    I was bored so I tried pulling out the harddisk of my laptop while it was running. Windows (7) kept running and didn&#039;t crash. Of course, I couldn&#039;t actually open any programs, but it didn&#039;t lock up. I put the harddisk back in and after a while the programs that I had tried to open all opened up at once. Pretty impressive &lt;img src=&quot;http://lunesu.com/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
I tried to same trick on Ubuntu 10.4. As soon as I pulled out the harddisk, the gnome UI died. The taskbars disappeared. My console window stayed open however, and &#039;top&#039; (started before I pulled the HDD out) kept running as well. Once I exited &#039;top&#039; the system was pretty useless, of course. I put the HDD back in, but that didn&#039;t do much. Ubuntu didn&#039;t seem to be able to recover the way Windows did. I also was unable to login from a new tty. 
    </content:encoded>

    <pubDate>Sat, 19 Feb 2011 02:21:44 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/122-guid.html</guid>
    
</item>
<item>
    <title>Shouting Winamp to Icecast</title>
    <link>http://lunesu.com/index.php?/archives/121-Shouting-Winamp-to-Icecast.html</link>
    
    <comments>http://lunesu.com/index.php?/archives/121-Shouting-Winamp-to-Icecast.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=121</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=121</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    Did I mention how great the Squeezebox Boom sounds? Well, it sounds great. &lt;br /&gt;
&lt;br /&gt;
I have bought Shukar Collective&#039;s latest album, &lt;a href=&quot;http://www.amazon.com/gp/product/B000W3N7A0/ref=dm_att_alb5&quot; title=&quot;Shukar Collective - Rromatek&quot;&gt;Rromatek&lt;/a&gt;, on Amazon today. (Amazon MP3s can only be bought from the US; nothing a VPN can&#039;t solve.) Once the download finished I listened to the CD on my laptop, but my Dell has terrible speakers. I immediately wished I could listen to the CD from the Squeezebox instead.&lt;br /&gt;
&lt;br /&gt;
The solution I came up with was to hook my Winamp up to the Icecast server on my NAS. Turns out that&#039;s harder than you&#039;d think. There&#039;s a Winamp DSP plugin that does just that (&lt;a href=&quot;http://www.oddsock.org/&quot; title=&quot;Oddcast&quot;&gt;Oddcast&lt;/a&gt; aka Edcast), but it was abandoned, apparently because of &quot;legal reasons&quot;. &lt;br /&gt;
&lt;br /&gt;
Luckily, Icecast now accepts Shoutcast clients, but the protocol used by Icecast is not the same as the one from Shoutcast and the Shoutcast Source Plugin (get it &lt;a href=&quot;http://www.shoutcast.com/download&quot; title=&quot;Shoutcast Radio Tools&quot;&gt;here&lt;/a&gt;) doesn&#039;t understand Icecast. Fortunately, since version 2.2, Icecast can handle Shoutcast sources, by adding a single line to your &amp;lt;listen-socket&amp;gt; section in icecast.xml:&lt;blockquote&gt;&amp;lt;shoutcast-mount&amp;gt;/strm&amp;lt;shoutcast-mount&amp;gt;&lt;/blockquote&gt;I wanted a new mount for my Winamp, not to interfere with the one from Ices, so it became:&lt;pre name=&quot;code&quot; class=&quot;xml&quot;&gt;
    &amp;lt;listen-socket&amp;gt;
        &amp;lt;port&gt;8000&amp;lt;/port&amp;gt;
        &amp;lt;shoutcast-mount&amp;gt;/winamp&amp;lt;/shoutcast-mount&amp;gt;
    &amp;lt;/listen-socket&amp;gt;
    &amp;lt;mount&amp;gt;
        &amp;lt;mount-name&amp;gt;/winamp&amp;lt;/mount-name&amp;gt;
    &amp;lt;/mount&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
In Winamp, go to Preferences, Plugins, DSP/Effects and configure the SHOUTcast Source DSP. Check &quot;Use SHOUTcast v1 mode (for legacy servers)&quot;. Disable &quot;Make this server public&quot; on the Yellowpages tab. Select an audio format on the Encoder tab. Press connect, and we&#039;re done. 
    </content:encoded>

    <pubDate>Sun, 13 Feb 2011 07:49:43 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/121-guid.html</guid>
    
</item>
<item>
    <title>Squeezebox Boom + Icecast = Win</title>
    <link>http://lunesu.com/index.php?/archives/120-Squeezebox-Boom-+-Icecast-Win.html</link>
    
    <comments>http://lunesu.com/index.php?/archives/120-Squeezebox-Boom-+-Icecast-Win.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=120</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=120</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    Been to Hong Kong for Chinese New Year and one of the gadgets I bought there was a &lt;a href=&quot;http://www.logitech.com/en-us/speakers-audio/wireless-music-systems/devices/4707&quot; title=&quot;Logitech Squeezebox Boom&quot;&gt;Logitech Squeezebox Boom&lt;/a&gt; (1880HK$). I had heard about the Squeezebox line before, but had never actually seen one. I have looked on taobao.com but there were only few sellers and (hence?) more expensive than abroad. (There&#039;s one seller that seems to have quite a supply and selling them at half the market price, but that&#039;s just too shady.)&lt;br /&gt;
&lt;br /&gt;
&lt;!-- s9ymdb:143 --&gt;&lt;img class=&quot;serendipity_image_right&quot; width=&quot;110&quot; height=&quot;102&quot;  src=&quot;http://lunesu.com/uploads/180px-Boom_200.serendipityThumb.jpg&quot;  alt=&quot;&quot; /&gt;The Squeezebox Boom has Wifi, so I just had to hook up the power and it was set. It detected my wifi network, and I entered my password. First surprise: the Squeezebox &lt;strong&gt;had to &lt;/strong&gt;connect to a Squeezebox server. You can install your own (Squeezebox Server aka Squeezecenter) or you can let it use Logitech&#039;s mysqueezebox.com. It appears the Squeezeboxes are very thin clients, with most of the logic (and plugins, add-ons, apps...) handled by the server. I didn&#039;t feel like installing a server (it kind-of defeats the purpose of the Squeezebox, if you ask me) so I went with mysqueezebox.com. The first time you connect you must create an account, but this can be done right from the Squeezebox. &lt;br /&gt;
&lt;br /&gt;
After the initial setup I was shown the main menu. Because I was using mysqueezebox.com (as opposed to my own server) I could only choose &quot;Internet Radio&quot;. However, it was a very extensive list of well known radio stations, and in about 10 minutes I was listening to Studio Brussels! The quality was really good, and definitely better than the &lt;a href=&quot;http://us.store.creative.com/Creative-D100-Wireless-Bluetooth-Speakers-Black/M/B003N9SR00.htm&quot; title=&quot;Creative Labs D100&quot;&gt;Creative D100&lt;/a&gt; speakers I had bought 1 month earlier.&lt;br /&gt;
&lt;br /&gt;
But still no access to my own music collection. Second surprise: the Squeezebox does not understand UPnP or DLNA. I thought that was a major bummer. It would have allowed me to simply hook it up to my &lt;a href=&quot;http://www.buffalotech.com/products/network-storage/home-and-small-office/linkstation-live-ls-chl/&quot; title=&quot;Buffalo LinkStation Live&quot;&gt;Buffalo LinkStation Live&lt;/a&gt;&#039;s Twinkymedia Server. It seemed I had to install a Squeezebox Server.&lt;br /&gt;
&lt;br /&gt;
Squeezebox Server was installable on my Linkstation using: &lt;blockquote&gt;ipkg install squeezecenter&lt;/blockquote&gt;That went well (albeit it was a somewhat older version), but it was immediately apparent that the 64Mb RAM of the Linkstation were not enough for the hefty perl + mysql Squeezecenter. The NAS was constantly swapping and became unresponsive.&lt;br /&gt;
&lt;br /&gt;
What I basically wanted was simple: when I still had my original Xbox with &lt;a href=&quot;http://xbmc.org/&quot; title=&quot;XBox Media Center&quot;&gt;XBMC&lt;/a&gt;, I had made a startup script that immediately started Party Mode as soon as the XBox was turned on. Filling the room with music was a simple act of pressing a button. Most of the time I didn&#039;t care about which CD was playing. (Without Party Mode I would spend minutes figuring out what music I felt like listening and usually ending up with one of my favorites, never choosing 90% of the music I actually had.)&lt;br /&gt;
&lt;br /&gt;
I had heard about &lt;a href=&quot;http://www.icecast.org/&quot; title=&quot;Icecast.org&quot;&gt;Icecast&lt;/a&gt; before. It&#039;s a music (media, to be more exact) streamer, similar to shoutcast. It was easily installed on my NAS using &lt;blockquote&gt;ipkg install icecast&lt;/blockquote&gt;. Icecast itself is just the streaming server, it doesn&#039;t actually read music itself, but needs a Icecast Source to provide it with the bits. That job is done by &lt;a href=&quot;http://www.icecast.org/ices.php&quot; title=&quot;Icecast Source&quot;&gt;Ices&lt;/a&gt;, also installable using&lt;blockquote&gt;ipkg install Ices0&lt;/blockquote&gt;(Apparently nobody has built Ices2 for the ARM yet?) The input for Ices is a text file with the playlist. Because Ices0 (as opposed to Ices2) only understand MP3, I had to make a playlist with only my MP3s, skipping Flac and Ogg:&lt;blockquote&gt;find /mnt/disk1/share/music -name \*.mp3 &amp;gt; playlist.txt&lt;/blockquote&gt;&lt;br /&gt;
Icecast and Ices could now be started with:&lt;blockquote&gt;/opt/bin/icecast -c /opt/etc/icecast.xml -b&lt;br /&gt;
/opt/bin/ices -c /opt/etc/ices.conf.dist -B&lt;/blockquote&gt;I could now connect to my own radio station from Winamp! I then proceeded to add the URL to my Favorites on mysqueezebox.com but it wouldn&#039;t work. The Squeezebox cannot play streams on the LAN because the server (and in this case, mysqueezebox.com) must be able to access the stream, for some metadata I presume. The solution was easy: open a random port on the router and forward the traffic to the Icecast server: success!&lt;br /&gt;
&lt;br /&gt;
One caveat though: the LinkStation would be constantly streaming music, even when nobody was listening, causing non-stop churning of the harddisk. I wanted to started Ices when the first listener connected and to stop it once the last listener went away. That could be done by adding an authentication section to icecast.xml:&lt;pre name=&quot;code&quot; class=&quot;xml&quot;&gt;&amp;lt;authentication type=&quot;url&quot;&amp;gt;
  &amp;lt;option name=&quot;listener_add&quot; value=&quot;http://localhost:8081/icecast.php&quot;/&amp;gt;
  &amp;lt;option name=&quot;listener_remove&quot; value=&quot;http://localhost:8081/icecast.php&quot;/&amp;gt;
  &amp;lt;option name=&quot;auth_header&quot; value=&quot;icecast-auth-user: 1&quot;/&amp;gt;
&amp;lt;/authentication&amp;gt;&lt;/pre&gt;With these settings, the Icecast server would contact the mentioned URLs when a listener (dis)connected. In the PHP file I could then start/stop the Ices server:&lt;pre name=&quot;code&quot; class=&quot;php&quot;&gt;&amp;lt;?
$action = $_POST[&#039;action&#039;];
$mount = $_POST[&#039;mount&#039;];

header(&quot;icecast-auth-user: 1&quot;);

function store($c)
{
  $file = fopen(&quot;/tmp/count&quot;, &quot;c+&quot;);
  $count = fgets($file);
  if ($count !== false)
    rewind($file);
  else
    $count = 0;
  $count = intval($count) + intval($c);
  fputs($file, $count.&quot;\n&quot;);
  fclose($file); 
  return $count;
}
  
function start_ices()
{
  $array = array();
  exec(&quot;ps&quot;, $array);
  foreach($array as $line)
    if (strpos($line, &quot;/opt/bin/ices&quot;) !== false)
      return;
  exec(&quot;/opt/bin/ices -c /opt/etc/ices.conf.dist -B&quot;);
  sleep(1);//echo $i;
}

function stop_ices()
{
  exec(&quot;kill `cat /opt/var/log/icecast/ices.pid`&quot;);
}

if ($action == &quot;listener_add&quot; &amp;&amp;amp; $mount == &quot;strm&quot; &amp;&amp;amp; store(1) == 1)
  start_ices();
if ($action == &quot;listener_remove&quot; &amp;&amp;amp; $mount == &quot;strm&quot; &amp;&amp;amp; store(-1) == 0)
  stop_ices();

?&amp;gt;Success.
&lt;/pre&gt;I can&#039;t believe how hard it is to create a global setting in PHP. I needed an atomic increment/decrement for the user count. The store($) function basically serves as a global InterlockedAdd, loading a integer from a tempfile, adding a value to it, writing the result back to the file and returning it to the caller.  Please let me know if there&#039;s a easier way to accomplice that. 
    </content:encoded>

    <pubDate>Thu, 10 Feb 2011 23:03:38 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/120-guid.html</guid>
    
</item>
<item>
    <title>What's your mean?</title>
    <link>http://lunesu.com/index.php?/archives/119-Whats-your-mean.html</link>
    
    <comments>http://lunesu.com/index.php?/archives/119-Whats-your-mean.html#comments</comments>
    <wfw:comment>http://lunesu.com/wfwcomment.php?cid=119</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://lunesu.com/rss.php?version=2.0&amp;type=comments&amp;cid=119</wfw:commentRss>
    

    <author>nospam@example.com (Lio)</author>
    <content:encoded>
    老外苦学汉语十年，到中国参加汉语等级考试，试题如下：&lt;br /&gt;
    请解释下文中每个“意思”的意思—&lt;br /&gt;
　　阿呆给领导送红包时，两人的对话颇有意思。&lt;br /&gt;
　　领导：“你这是什么意思？”&lt;br /&gt;
　　阿呆：“没什么意思，意思意思。”&lt;br /&gt;
　　领导：“你这就不够意思了。”&lt;br /&gt;
　　阿呆：“小意思，小意思。”&lt;br /&gt;
　　领导：“你这人真有意思。”&lt;br /&gt;
　　阿呆：“其实也没有别的意思。”&lt;br /&gt;
　　领导：“那我就不好意思了。”&lt;br /&gt;
　　阿呆：“是我不好意思。”&lt;br /&gt;
        老外泪流满面，交白卷回国了。&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://translate.google.com/#auto|en|%E8%80%81%E5%A4%96%E8%8B%A6%E5%AD%A6%E6%B1%89%E8%AF%AD%E5%8D%81%E5%B9%B4%EF%BC%8C%E5%88%B0%E4%B8%AD%E5%9B%BD%E5%8F%82%E5%8A%A0%E6%B1%89%E8%AF%AD%E7%AD%89%E7%BA%A7%E8%80%83%E8%AF%95%EF%BC%8C%E8%AF%95%E9%A2%98%E5%A6%82%E4%B8%8B%EF%BC%9A%0D%0A%20%20%20%20%E8%AF%B7%E8%A7%A3%E9%87%8A%E4%B8%8B%E6%96%87%E4%B8%AD%E6%AF%8F%E4%B8%AA%E2%80%9C%E6%84%8F%E6%80%9D%E2%80%9D%E7%9A%84%E6%84%8F%E6%80%9D%E2%80%94%E2%80%94%0D%0A%E3%80%80%E3%80%80%E9%98%BF%E5%91%86%E7%BB%99%E9%A2%86%E5%AF%BC%E9%80%81%E7%BA%A2%E5%8C%85%E6%97%B6%EF%BC%8C%E4%B8%A4%E4%BA%BA%E7%9A%84%E5%AF%B9%E8%AF%9D%E9%A2%87%E6%9C%89%E6%84%8F%E6%80%9D%E3%80%82%0D%0A%E3%80%80%E3%80%80%E9%A2%86%E5%AF%BC%EF%BC%9A%E2%80%9C%E4%BD%A0%E8%BF%99%E6%98%AF%E4%BB%80%E4%B9%88%E6%84%8F%E6%80%9D%EF%BC%9F%E2%80%9D%0D%0A%E3%80%80%E3%80%80%E9%98%BF%E5%91%86%EF%BC%9A%E2%80%9C%E6%B2%A1%E4%BB%80%E4%B9%88%E6%84%8F%E6%80%9D%EF%BC%8C%E6%84%8F%E6%80%9D%E6%84%8F%E6%80%9D%E3%80%82%E2%80%9D%0D%0A%E3%80%80%E3%80%80%E9%A2%86%E5%AF%BC%EF%BC%9A%E2%80%9C%E4%BD%A0%E8%BF%99%E5%B0%B1%E4%B8%8D%E5%A4%9F%E6%84%8F%E6%80%9D%E4%BA%86%E3%80%82%E2%80%9D%0D%0A%E3%80%80%E3%80%80%E9%98%BF%E5%91%86%EF%BC%9A%E2%80%9C%E5%B0%8F%E6%84%8F%E6%80%9D%EF%BC%8C%E5%B0%8F%E6%84%8F%E6%80%9D%E3%80%82%E2%80%9D%0D%0A%E3%80%80%E3%80%80%E9%A2%86%E5%AF%BC%EF%BC%9A%E2%80%9C%E4%BD%A0%E8%BF%99%E4%BA%BA%E7%9C%9F%E6%9C%89%E6%84%8F%E6%80%9D%E3%80%82%E2%80%9D%0D%0A%E3%80%80%E3%80%80%E9%98%BF%E5%91%86%EF%BC%9A%E2%80%9C%E5%85%B6%E5%AE%9E%E4%B9%9F%E6%B2%A1%E6%9C%89%E5%88%AB%E7%9A%84%E6%84%8F%E6%80%9D%E3%80%82%E2%80%9D%0D%0A%E3%80%80%E3%80%80%E9%A2%86%E5%AF%BC%EF%BC%9A%E2%80%9C%E9%82%A3%E6%88%91%E5%B0%B1%E4%B8%8D%E5%A5%BD%E6%84%8F%E6%80%9D%E4%BA%86%E3%80%82%E2%80%9D%0D%0A%E3%80%80%E3%80%80%E9%98%BF%E5%91%86%EF%BC%9A%E2%80%9C%E6%98%AF%E6%88%91%E4%B8%8D%E5%A5%BD%E6%84%8F%E6%80%9D%E3%80%82%E2%80%9D%0D%0A%20%20%20%20%20%20%20%20%E8%80%81%E5%A4%96%E6%B3%AA%E6%B5%81%E6%BB%A1%E9%9D%A2%EF%BC%8C%E4%BA%A4%E7%99%BD%E5%8D%B7%E5%9B%9E%E5%9B%BD%E4%BA%86%E3%80%82%0D%0A&quot; title=&quot;Google Translate&quot;&gt;Chinese to English translation&lt;/a&gt;&lt;br /&gt;
Foreigners learn Chinese bitter years, to China to participate in Chinese language level test, questions are as follows:&lt;br /&gt;
 Please explain below each &quot;meaning&quot; means —&lt;br /&gt;
 Dumb bribe the leaders, the two men rather meaningful dialogue.&lt;br /&gt;
 Leadership: &quot;What do you mean? &quot;&lt;br /&gt;
 Dumb: &quot;no meaning, meaning mean. &quot;&lt;br /&gt;
 Leadership: &quot;You mean this is not enough. &quot;&lt;br /&gt;
 Dumb: &quot;a mere trifle, a mere trifle. &quot;&lt;br /&gt;
 Leadership: &quot;You are so interesting. &quot;&lt;br /&gt;
 Dumb: &quot;In fact, no other meaning. &quot;&lt;br /&gt;
 Leadership: &quot;Then I was embarrassed. &quot;**&lt;br /&gt;
 Dumb: &quot;I am sorry. &quot;&lt;br /&gt;
   Foreigners in tears, has done nothing back home.&lt;br /&gt;
&lt;br /&gt;
** &quot;不好意思&quot; means &quot;I&#039;m embarrassed&quot;, but it&#039;s also said when accepting a gift.&lt;br /&gt;
&lt;br /&gt;
Lǎowài kǔxué hànyǔ shí nián, dào zhōngguó cānjiā hànyǔ děngjí kǎoshì, shìtí rúxià: &lt;br /&gt;
  Qǐng jiěshì xià wénzhōng měi gè “yìsi” de yìsi—&lt;br /&gt;
  Ādāi gěi lǐngdǎo sòng hóngbāo shí, liǎng rén de duìhuà pō yǒuyìsi. &lt;br /&gt;
  Lǐngdǎo:“Nǐ zhè shì shénme yìsi?” &lt;br /&gt;
  Ādāi:“Méishénme yìsi, yìsi yìsi.” &lt;br /&gt;
  Lǐngdǎo:“Nǐ zhè jiù bùgòu yìsi le.” &lt;br /&gt;
  Ādāi:“Xiǎoyìsi, xiǎoyìsi.” &lt;br /&gt;
  Lǐngdǎo:“Nǐ zhè rén zhēn yǒuyìsi.” &lt;br /&gt;
  Ādāi:“Qíshí yě méiyǒu bié de yìsi.” &lt;br /&gt;
  Lǐngdǎo:“Nà wǒ jiù bù hǎoyìsi le.” &lt;br /&gt;
  Ādāi:“Shì wǒ bù hǎoyìsi.” &lt;br /&gt;
    Lǎowài lèi liú mǎnmiàn, jiāobáijuàn huíguó le. 
    </content:encoded>

    <pubDate>Fri, 28 Jan 2011 08:13:12 +0000</pubDate>
    <guid isPermaLink="false">http://lunesu.com/index.php?/archives/119-guid.html</guid>
    
</item>

</channel>
</rss>