<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Marc's Codelog</title>
    <description>A personal blog from Marc Climent about my experiences as a developer, geek and father.</description>
    <link>http://codelog.climens.net/</link>
    <atom:link href="http://codelog.climens.net/feed.xml" rel="self" type="application/rss+xml" />
    
      <item>
        <title>Bye bye Kurobox</title>
        <description>&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Broadcast message from root@kurobox (pts/0) (Sat Jan 24 23:55:26 2015):
The system is going down for system halt NOW!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;With this message my &lt;a href=&quot;http://buffalo.nas-central.org/wiki/Category:Kurobox&quot;&gt;Kurobox&lt;/a&gt; turned off -actually it didn’t because something is broken in the ACPI kernel stuff- for the last time.&lt;/p&gt;

&lt;p&gt;I’ve just replaced it by a brand new &lt;a href=&quot;https://www.synology.com/products/DS215j&quot;&gt;Synology DS215j&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;some-history&quot;&gt;Some history&lt;/h2&gt;

&lt;p&gt;I acquired this machine from an online store called Revogear.com -now extinct- in November 2006, more than eight years ago. I can’t think how many things happened since then, in my professional and personal life and obviously in this unstoppable tech world.&lt;/p&gt;

&lt;p&gt;But there it stood, running &lt;em&gt;almost&lt;/em&gt; 24/7 since I installed it at my parents’ home where I lived then. It was very appealing: a small sized low power Linux server with 128Mb of RAM, a &lt;a href=&quot;http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MPC8241&quot;&gt;MPC8241 RISC processor&lt;/a&gt; @266MHz, a 3.5” HD IDE bay, Gigabit Ethernet and a single USB 2.0 port.&lt;/p&gt;

&lt;p&gt;It really was a rebranded &lt;a href=&quot;http://buffalo.nas-central.org/wiki/Category:HG&quot;&gt;Buffalo Linkstation HG&lt;/a&gt; with some modifications to make it more customizable and a nice Kanji logo on the side. More customizable didn’t mean &lt;em&gt;easily&lt;/em&gt; customizable, because it was pretty low level stuff using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netcat&lt;/code&gt; and sending some esoteric commands over the wire. But that was pretty fun, at least for me 8 years ago.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://commons.wikimedia.org/wiki/File:Buffalo_kuro-box.jpg#mediaviewer/File:Buffalo_kuro-box.jpg&quot; title=&quot;'Buffalo kuro-box' by Saoyagi2. Licensed under CC0&quot;&gt;&lt;img src=&quot;http://upload.wikimedia.org/wikipedia/commons/thumb/d/d7/Buffalo_kuro-box.jpg/640px-Buffalo_kuro-box.jpg&quot; alt=&quot;Buffalo kuro-box&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the Kurobox HG, Buffalo released the PRO, which changed the processor architecture from PowerPC to the now popular ARM and over the years the project was discontinued and forgotten. At the beginning it looked promising and there was a vibrant community and many pages and forums to find and ask stuff but soon started to languish with the poor effort from Buffalo to continue with this series.&lt;/p&gt;

&lt;p&gt;As of today, many Linux distros still provide PowerPC packages but the main support is for Intel x86 platform. On the other hand, &lt;a href=&quot;http://electronics.stackexchange.com/a/42077&quot;&gt;ARM is gaining traction&lt;/a&gt;, specially in the NAS field, as Synology, QNAP and others are using architecture for their low-end products. The &lt;a href=&quot;http://popcon.debian.org/&quot;&gt;Debian Popularity Contest&lt;/a&gt; has some figures about this fact, although it still offers good support for PowerPC. Fedora Project &lt;a href=&quot;http://fedoraproject.org/wiki/Architectures/PowerPC#Supported_Architectures&quot;&gt;dropped 32bit PowerPC support&lt;/a&gt; four releases ago.&lt;/p&gt;

&lt;h2 id=&quot;obsolescence&quot;&gt;Obsolescence&lt;/h2&gt;

&lt;p&gt;There are several problems that have arisen with my Kurobox during its lifetime. I don’t know which one of them is the most important but the sum of them made me replace it.&lt;/p&gt;

&lt;p&gt;Having just an IDE bay does not help. It’s not difficult at all to find IDE disks -and they are cheap- but they are not larger than 160-250Gb. Mine is 250Gb and it’s always full and slow. Even if I don’t put all my backups there -mainly photos- there’s not enough room. I know I can add an external USB drive but that idea is not a good idea because it won’t perform well given the limited hardware resources.&lt;/p&gt;

&lt;p&gt;The processor was modest at the time of purchase but now is completely outdated. This is a bottleneck for file transfers, no matter if I use SCP, SMB or NFS, the transfer rate is never better than 1MB/s and generally is about 600-700KB/s. Compiling a kernel took about 20-24h…&lt;/p&gt;

&lt;p&gt;As it is the HG version it came with 128Mb RAM soldered on the motherboard and it’s a tight number to run a lot of processes. I have used it as a test web server with a LAMP stack -it was &lt;a href=&quot;http://www.lighttpd.net/&quot;&gt;lighttpd&lt;/a&gt; instead of Apache-, SSH server, mail server with &lt;a href=&quot;http://www.courier-mta.org/&quot;&gt;Courier MTA&lt;/a&gt;, DNS server with &lt;a href=&quot;http://cr.yp.to/djbdns.html&quot;&gt;djbdns&lt;/a&gt;, &lt;a href=&quot;http://mldonkey.sourceforge.net/Main_Page&quot;&gt;MLdonkey&lt;/a&gt; server and &lt;a href=&quot;http://rakshasa.github.io/rtorrent/&quot;&gt;rtorrent&lt;/a&gt;/&lt;a href=&quot;https://www.transmissionbt.com/&quot;&gt;Transmission&lt;/a&gt; headless server. This was really too much: in the last years I have only used it as a NAS with a Transmission server. It worked, just required some patience.&lt;/p&gt;

&lt;p&gt;Finally, upgrading the kernel or installing a new Linux distro are difficult tasks. I wanted to update the original kernel a couple of years ago because it was too outdated and the thing is facing Internet so, from a security standpoint was a good idea. The documentation was too hard to find -mostly at &lt;a href=&quot;http://buffalo.nas-central.org/wiki/Main_Page&quot;&gt;Buffalo@NAS-Central&lt;/a&gt;-, many 404, many pages in Japanese and too many visits to (https://archive.org/) to find just some instructions on how to do it. I succeeded but was not &lt;em&gt;that&lt;/em&gt; fun and some stuff is broken, specially the ACPI part as I can’t reboot and shutdown anymore -unless I unplug the cord-.&lt;/p&gt;

&lt;h2 id=&quot;the-newcomer&quot;&gt;The newcomer&lt;/h2&gt;

&lt;p&gt;Now I’m pretty happy :happy: with the Synology ds215j. I don’t like that is not as open as the Kurobox but the default software is really cool and works out of the box. Nowadays I value more my free time and I don’t enjoy that much hacking with old rare hardware.&lt;/p&gt;

&lt;p&gt;So, farewell ol’ good Kurobox!&lt;/p&gt;
</description>
        <pubDate>Sat, 24 Jan 2015 23:15:00 +0000</pubDate>
        <link>http://codelog.climens.net/2015/01/24/bye-bye-kurobox/</link>
        <guid isPermaLink="true">http://codelog.climens.net/2015/01/24/bye-bye-kurobox/</guid>
      </item>
    
      <item>
        <title>DIY Arduino Christmas tree lights</title>
        <description>&lt;p&gt;Last year I built a &lt;em&gt;very simple&lt;/em&gt; light switch with and Arduino board and a relay shield, I put a video on Youtube buy here is the detailed explanation of the code and the parts used.&lt;/p&gt;

&lt;iframe width=&quot;768&quot; height=&quot;576&quot; src=&quot;//www.youtube.com/embed/XrC3mWwxlI0&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;The only drawback is that the Relays have mechanical switching parts and are a bit noisy, specially in the silence of the night.&lt;/p&gt;

&lt;p&gt;I bought the board and the shield on &lt;a href=&quot;ttp://tienda.bricogeek.com/&quot;&gt;BricoGeek&lt;/a&gt;, which is a fine shop from Spain but they can be found anywhere. The other smaller parts were bought at my local electronics shop.&lt;/p&gt;

&lt;p&gt;So, these are the required parts:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://arduino.cc/en/Main/ArduinoBoardUno&quot;&gt;Arduino Uno board&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.seeedstudio.com/wiki/Relay_Shield_V2.0&quot;&gt;Relay shield&lt;/a&gt; - I’ve got v1.3 but for this particular project it’s irrelevant.&lt;/li&gt;
  &lt;li&gt;Non blinking Christmas tree lights. Mine are LED and connected directly to the mains power.&lt;/li&gt;
  &lt;li&gt;Universal power supply. USB 5V supply is not enough to power the Relays, so you need an external supply of 9V for them to work properly.&lt;/li&gt;
  &lt;li&gt;Electrical tape (to &lt;strong&gt;cover the USB port&lt;/strong&gt; of the Arduino and avoid accidental contact with the AC power damaging the board)&lt;/li&gt;
  &lt;li&gt;Two wire electrical cable&lt;/li&gt;
  &lt;li&gt;Male and female AC plugs&lt;/li&gt;
  &lt;li&gt;Small regular screwdrivers for the relays and maybe other types to mount the plugs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The job is easy, just be careful because mains current levels are dangerous and some parts of the board leave it exposed.&lt;/p&gt;

&lt;p&gt;The electrical cable has two wires, just cut one of them and connect one lead to the &lt;em&gt;COM1&lt;/em&gt; and the other to the &lt;em&gt;NO1&lt;/em&gt;. If you have more lights just connect them to &lt;em&gt;COM2&lt;/em&gt;, &lt;em&gt;COM3&lt;/em&gt;, &lt;em&gt;COM4&lt;/em&gt; and &lt;em&gt;NO2&lt;/em&gt;, &lt;em&gt;NO3&lt;/em&gt; and &lt;em&gt;NO4&lt;/em&gt; respectively.&lt;/p&gt;

&lt;p&gt;You can also use NCn instead of NOn: NC stands for Normally Closed which means it’s connected -closed- when pin is low (0) and disconnected -open- when pin is high. NCn works the opposite.&lt;/p&gt;

&lt;p&gt;A detailed explanation of the relay can be found on &lt;a href=&quot;http://www.seeedstudio.com/wiki/Relay_Shield_V2.0&quot;&gt;Seeedstudio wiki page&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, mount the plugs on both sides of the cable, male on one side an female on the other.&lt;/p&gt;

&lt;p&gt;Finally put some electrical tape over the Arduino USB connector and mount the Relay Shield on top of the Arduino board.&lt;/p&gt;

&lt;p&gt;Finally it’s time to program the board. On my Github &lt;a href=&quot;https://github.com/mcliment/arduino-christmas-lights&quot;&gt;arduino-christmas-lights&lt;/a&gt; project you can find the example code.&lt;/p&gt;

&lt;p&gt;Basically on the code you can see two state arrays &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;states1[]&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;states2[]&lt;/code&gt;, one for each connected light. They should be the same size to maintain synchronization between both light strips. On each state array you can define the HIGH/LOW sequences, as long as you want.&lt;/p&gt;

&lt;p&gt;Finally there’s a loop that turns the relay on and off with a 500ms delay between changes. If you put two equal consecutive states, the relay will maintain it’s state.&lt;/p&gt;

&lt;p&gt;As you can see it’s very simple, but works and opens a world of possibilities. For example syncing the lights with a song adjusting the patterns and the delay to the rhythm.&lt;/p&gt;

&lt;p&gt;If you have any doubt just add a comment, drop me a line or add an issue on the Github project.&lt;/p&gt;

&lt;p&gt;Merry Christmas and have fun!&lt;/p&gt;

</description>
        <pubDate>Mon, 15 Dec 2014 21:06:00 +0000</pubDate>
        <link>http://codelog.climens.net/2014/12/15/diy-arduino-christmas-tree-lights/</link>
        <guid isPermaLink="true">http://codelog.climens.net/2014/12/15/diy-arduino-christmas-tree-lights/</guid>
      </item>
    
      <item>
        <title>Back to blogging</title>
        <description>&lt;p&gt;It’s been roughly 3 years and a half since my last blog post. Why I abandoned my blog? Don’t I have anything to say?&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/joelmontes/4762384399&quot; title=&quot;Journal Entry by Joel Montes de Oca, on Flickr&quot;&gt;&lt;img src=&quot;https://farm5.staticflickr.com/4093/4762384399_f126047d2b_b.jpg&quot; alt=&quot;Journal Entry&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;reasons-for-not-blogging&quot;&gt;Reasons for not blogging&lt;/h2&gt;

&lt;p&gt;I can identify several.&lt;/p&gt;

&lt;p&gt;But first of all is laziness and procrastination. Both are tied but the effect is the same: willing to post but never finding time to do so, there’s always something better to do. As I grow, I tend to be more rigid with this kind of stuff: &lt;strong&gt;do it or don’t&lt;/strong&gt; but don’t keep telling yourself: “I’ll do it later”.&lt;/p&gt;

&lt;p&gt;On the other hand, I’ve not been vegetating on my couch watching TV cheap soap operas the whole time but, definitely I could’ve found some time to post many things if I wanted.&lt;/p&gt;

&lt;p&gt;But on my discharge I can say that this last year has been quite enduring with the kid, having children changes your life.&lt;/p&gt;

&lt;h2 id=&quot;why-coming-back&quot;&gt;Why coming back?&lt;/h2&gt;

&lt;p&gt;Writing. I have written a lot of things in the past, specially when I was younger and I find it a good exercise.&lt;/p&gt;

&lt;p&gt;Learning. Explaining things is a &lt;a href=&quot;http://www.scilearn.com/blog/how-students-learn-by-explaining-their-thinking&quot;&gt;great way to learn&lt;/a&gt;, and explaining those things in another language -if you’re proficient in English, you may have noticed it’s not mine- makes me improve my fluency, add new vocabulary and it’s fun.&lt;/p&gt;

&lt;p&gt;Showing. Internet is for showing off. Period. Anyone in their houses can show the world the stuff they do, what they think, who they are. And they can reach the whole connected world, just as I do.&lt;/p&gt;

&lt;h2 id=&quot;will-this-last&quot;&gt;Will this last?&lt;/h2&gt;

&lt;p&gt;Who knows. Maybe I become lazy again, or feel I don’t have anything to share or feel I don’t have time to. Time will tell.&lt;/p&gt;

&lt;p&gt;But for the moment, I welcome myself back, and you too.&lt;/p&gt;

</description>
        <pubDate>Fri, 28 Nov 2014 21:59:00 +0000</pubDate>
        <link>http://codelog.climens.net/2014/11/28/back-to-blogging/</link>
        <guid isPermaLink="true">http://codelog.climens.net/2014/11/28/back-to-blogging/</guid>
      </item>
    
      <item>
        <title>Lessons learned optimizing MySQL</title>
        <description>&lt;p&gt;This week I’ve been quite entertained at work optimizing a big &lt;a href=&quot;http://dev.mysql.com/&quot;&gt;MySQL database&lt;/a&gt;, 18M rows and about 10Gb of table data for a high traffic web site (11M unique views per month). Not optimizing for performance is overkill in this case, so I have been learning and enjoying a lot during these days.&lt;/p&gt;

&lt;p&gt;The first thing to note is that &lt;strong&gt;database servers are complex beasts&lt;/strong&gt; (don’t underestimate them) and each and every database provider has its own strengths but also its own caveats.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/logo-mysql.png&quot; alt=&quot;MySQL logo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Sooner or later you’ll face a behavior that may seem counter-intuitive and there’s when you must &lt;strong&gt;read a lot of documentation&lt;/strong&gt;. In this case, &lt;a href=&quot;http://www.mysqlperformanceblog.com/&quot;&gt;MySQL Performance Blog&lt;/a&gt; and &lt;a href=&quot;http://dev.mysql.com/doc/refman/5.5/en/&quot;&gt;MySQL documentation&lt;/a&gt; have been of great help, as well as the now unmantained-but-still-useful &lt;a href=&quot;http://hackmysql.com/&quot;&gt;Hack MySQL&lt;/a&gt; site, which provides great tips very well explained.&lt;/p&gt;

&lt;p&gt;Second. As always, &lt;strong&gt;doing an 80% optimization consumes 20% of the time&lt;/strong&gt; and most of it is quite straightforward. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EXPLAIN&lt;/code&gt;, review results, create index, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EXPLAIN&lt;/code&gt; again. This way you can do a good job just knowing some indexing basics. Your indexes may be a bit fat, but will do the job.&lt;/p&gt;

&lt;p&gt;Then you’ll need to &lt;strong&gt;be patient&lt;/strong&gt;, creating indexes is not always fast, in fact the number, size and heterogeneity of the columns involved will increase the time it takes to create them. While you wait, the best is to read good books about MySQL or relational databases like: &lt;a href=&quot;http://www.amazon.com/gp/product/0471719994/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0471719994&amp;amp;linkCode=as2&amp;amp;tag=climecodel-20&amp;amp;linkId=ZJBKQJURN7Z5WTGN&quot;&gt;Relational Database Index Design and the Optimizers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You’ll need to &lt;strong&gt;be organized&lt;/strong&gt;. Creating indexes randomly just looking a couple of slow &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SELECT&lt;/code&gt;s is something, but you must look at the big picture: make an inventory of all the application queries, no matter how unimportant look like because if they attack a big table with a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;WHERE&lt;/code&gt; or an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ORDER BY&lt;/code&gt; they will perform bad. Fact. This list will help you organize the indexes and see which ones are used and which not and where.&lt;/p&gt;

&lt;p&gt;Learn as well &lt;strong&gt;what the configuration parameters mean&lt;/strong&gt;, MySQL has a bunch of them. Just increasing numbers will not always solve your bottlenecks. If you see something strange, there might be a parameter misconfigured and causing bad results.&lt;/p&gt;

&lt;p&gt;Sometimes you’ll &lt;strong&gt;find yourself frustrated&lt;/strong&gt; by something that you can’t understand. I found that almost anything in this field has an explanation, even a reasonable one.&lt;/p&gt;

&lt;p&gt;Finally, don’t overlook other thinks. &lt;strong&gt;Database performance is important&lt;/strong&gt; but there may be a lot of room to improve in your code, don’t blame MySQL as the root of all problems!&lt;/p&gt;
</description>
        <pubDate>Fri, 05 Aug 2011 11:41:18 +0000</pubDate>
        <link>http://codelog.climens.net/2011/08/05/lessons-learned-optimizing-mysql/</link>
        <guid isPermaLink="true">http://codelog.climens.net/2011/08/05/lessons-learned-optimizing-mysql/</guid>
      </item>
    
      <item>
        <title>Simple Mini Profiler Glimpse plugin</title>
        <description>&lt;p&gt;I recently published on Github a simple small project (&lt;a href=&quot;https://github.com/mcliment/miniprofiler-glimpse-plugin&quot;&gt;miniprofiler-glimpse-plugin&lt;/a&gt;) to integrate the results collected by the excellent &lt;a href=&quot;http://miniprofiler.com/&quot;&gt;MiniProfiler&lt;/a&gt; created by the people at Stackoverflow with &lt;a href=&quot;http://getglimpse.com/&quot;&gt;Glimpse&lt;/a&gt;, the Firebug for ASP.NET and MVC applications.&lt;/p&gt;

&lt;p&gt;Creating Glimpse plugins is really easy (just implement &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;IGlimpsePlugin&lt;/code&gt; and decorate it with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GlimpsePluginAttribute&lt;/code&gt;), implement the methods and reference the plug-in assembly in the project where you are using Glimpse. &lt;a href=&quot;http://mef.codeplex.com/&quot;&gt;MEF&lt;/a&gt; will do the gluing and the &lt;a href=&quot;http://json.codeplex.com/&quot;&gt;JSON.NET&lt;/a&gt; will do its best to deserialize the results in a human readable way.&lt;/p&gt;

&lt;p&gt;To use this plug-in, just compile it and reference the assembly in your Glimpse-enabled project. I you have questions, suggestions or bug reports, you can use Github’s own issue reporting system, drop me a line o fork the project and make your improvements.&lt;/p&gt;

&lt;p&gt;So, I hope you like it.&lt;/p&gt;

&lt;p&gt;Link: &lt;a href=&quot;https://github.com/mcliment/miniprofiler-glimpse-plugin&quot;&gt;miniprofiler-glimpse-plugin&lt;/a&gt; [github.org]&lt;/p&gt;
</description>
        <pubDate>Sun, 19 Jun 2011 16:01:35 +0000</pubDate>
        <link>http://codelog.climens.net/2011/06/19/simple-mini-profiler-glimpse-plugin/</link>
        <guid isPermaLink="true">http://codelog.climens.net/2011/06/19/simple-mini-profiler-glimpse-plugin/</guid>
      </item>
    
      <item>
        <title>Carbon Copy Cloner saved my day</title>
        <description>&lt;p&gt;This post is just an agreement to the great people behind &lt;a href=&quot;http://www.bombich.com/&quot;&gt;Carbon Copy Cloner&lt;/a&gt;, a great piece of backup software for Mac.&lt;/p&gt;

&lt;p&gt;I trusted Time Machine, and actually it seemed a good program and a very convenient way of making and managing backups but… it does not matter how pretty is if when you need to restore a backup it gives you strange errors.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/ccc-logo.png&quot; alt=&quot;Carbon Copy Cloner logo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The whole story is that I wanted to upgrade my Mac hard drive to a bigger one and &lt;a href=&quot;http://support.apple.com/kb/PH6425&quot;&gt;reading Time Machine documentation&lt;/a&gt;, seems that I can use the OSX Installation disk to restore a backup to a new fresh drive. Well, that’s just theory but when doing as instructed I got an “Error -22” after about an hour restoring… epic fail. Good that I did keep the original drive untouched.&lt;/p&gt;

&lt;p&gt;Then I tried donationware Carbon Copy Cloner to create a bootable clone backup of my working hard drive. After a couple of hours I had an external USB that mimicked my original drive. I replaced the hard drive, created a new partition and cloned again the external drive backup to the new one. Now I’m writing this on my upgraded Mac.&lt;/p&gt;

&lt;p&gt;So, thanks to Carbon Copy Cloner from Bombich I was able to upgrade without problems. Great job!&lt;/p&gt;
</description>
        <pubDate>Sun, 12 Jun 2011 21:13:43 +0000</pubDate>
        <link>http://codelog.climens.net/2011/06/12/carbon-copy-cloner-saved-my-day/</link>
        <guid isPermaLink="true">http://codelog.climens.net/2011/06/12/carbon-copy-cloner-saved-my-day/</guid>
      </item>
    
      <item>
        <title>Troubleshooting MSDTC, RPC and NServiceBus issues</title>
        <description>&lt;p&gt;At first it seemed easy, but it’s been a long distance hurdle race. At the end, I have solved the problems I’ve found and my painful experience can be useful for other people, so this is it.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/nservicebus.png&quot; alt=&quot;NServiceBus old logo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;First of all, my topology is the following: a client, in this case for testing purposes, my machine, which is running an ASP.NET web application and a NServiceBus host that processes all the messages. This has been configured following &lt;a href=&quot;http://docs.particular.net/&quot;&gt;the official documentation&lt;/a&gt; and &lt;a href=&quot;http://docs.particular.net/samples/&quot;&gt;looking at the samples&lt;/a&gt; (check out the full &lt;a href=&quot;https://github.com/Particular/NServiceBus&quot;&gt;NServiceBus source code&lt;/a&gt;, you’ll need it). It’s a bit messy but with some trial and error you can make sense of it. There are some obscure properties that have to be googled to know what they mean.&lt;/p&gt;

&lt;p&gt;Processing the messages is not trivial for the bus host. Some of them attack the database and need to use &lt;abbr title=&quot;Microsoft Distributed Transaction Coordinator&quot;&gt;MSDTC&lt;/abbr&gt; to manage the transactions. This means that &lt;abbr title=&quot;Microsoft Distributed Transaction Coordinator&quot;&gt;MSDTC&lt;/abbr&gt; must be up and running without problems.&lt;/p&gt;

&lt;p&gt;One trick I learned after a lot of researching is &lt;a href=&quot;https://web.archive.org/web/20120331064930/http://blog.zoolutions.se/post/2010/04/01/Conquering-NServiceBus-part-5-e28093-Troubleshooting-DTC.aspx&quot;&gt;the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Runner.exe&lt;/code&gt; tool from NServiceBus&lt;/a&gt;. This comes with NServiceBus source code (and I think that also with paid version) and ends up in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;build\tools\MsmqUtils&lt;/code&gt; if you build it with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;build.bat&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;build-net4.bat&lt;/code&gt;. Just open a command line as administrator and run:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Runner.exe /i&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will install &lt;abbr title=&quot;Microsoft Distributed Transaction Coordinator&quot;&gt;MSDTC&lt;/abbr&gt; and configure it properly. I don’t think you’ll need anything else but check the &lt;abbr title=&quot;Microsoft Distributed Transaction Coordinator&quot;&gt;MSDTC&lt;/abbr&gt; configuration in &lt;em&gt;Component Services -&amp;gt; Computers -&amp;gt; My Computer -&amp;gt; Distributed Transaction Coordinator -&amp;gt; Local DTC&lt;/em&gt;. Right click to go to properties and ensure everything is configured like in this &lt;a href=&quot;https://web.archive.org/web/20120331064930/http://blog.zoolutions.se/post/2010/04/01/Conquering-NServiceBus-part-5-e28093-Troubleshooting-DTC.aspx&quot;&gt;Troubleshooting DTC&lt;/a&gt; post.&lt;/p&gt;

&lt;p&gt;At this point, I recommend you to disable the Windows Firewall on both machines, at least for domain network, just to be sure it’s not interfering and breaking the tests, we will solve this later.&lt;/p&gt;

&lt;p&gt;Then, &lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=5e325025-4dcd-4658-a549-1d549ac17644&quot;&gt;DTCPing&lt;/a&gt; is your friend. This small tool will check the DTC connectivity between two machines. It’s a bit awkward. You have to start the tool in both machines, then put the name of the other and click ping on each one. This will make a test and if everything goes well, you’ll see a detailed log without errors:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;++++++++++++Validating Remote Computer Name++++++++++++
Please refer to following log file for details:
	C:\tools\DTCPing\LOCALMACHINE2928.log
Invoking RPC method on REMOTEMACHINE
RPC test is successful
++++++++++++RPC test completed+++++++++++++++
++++++++++++Start DTC Binding Test +++++++++++++
Trying Bind to REMOTEMACHINE
Received reverse bind call from REMOTEMACHINE
Binding success: LOCALMACHINE--&amp;gt;REMOTEMACHINE
++++++++++++DTC Binding Test END+++++++++++++
Please send following LOG to Microsoft for analysis:
	Partner LOG: REMOTEMACHINE5928.log
	My LOG: LOCALMACHINE2928.log
++++++++++++Start Reverse Bind Test+++++++++++++
Received Bind call from REMOTEMACHINE
Trying Reverse Bind to REMOTEMACHINE
Reverse Binding success: LOCALMACHINE--&amp;gt;REMOTEMACHINE
++++++++++++Reverse Bind Test ENDED++++++++++
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here started my nightmare, I got the damned: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RPC error 5 (Access denied)&lt;/code&gt;. After hours googling for the problem I found &lt;a href=&quot;http://blogs.msdn.com/b/distributedservices/archive/2008/11/12/troubleshooting-msdtc-issues-with-the-dtcping-tool.aspx&quot;&gt;this post about &lt;abbr title=&quot;Microsoft Distributed Transaction Coordinator&quot;&gt;MSDTC&lt;/abbr&gt; problems&lt;/a&gt; (I was looking for RPC problems, which actually was the root cause). The cause is that remote RPC is disabled in Windows workstations by default.&lt;/p&gt;

&lt;p&gt;I opened for the N-th time the registry and added the RPC key to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HKLM\Software\Policies\Microsoft\Windows NT&lt;/code&gt; and the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RestrictRemoteClients&lt;/code&gt; DWORD value to 0. Rebooted without much hope. Magically, DTCPing worked and life seemed better and brighter.&lt;/p&gt;

&lt;p&gt;Then, the Windows Firewall must be configured. In Windows Server 2008 (or Windows 7, it’s the same interface), go to &lt;em&gt;Control Panel -&amp;gt; System and Security -&amp;gt; Windows Firewall&lt;/em&gt; (or just execute &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;firewall.cpl&lt;/code&gt; at the command prompt). Go to &lt;em&gt;Advanced Configuration&lt;/em&gt; to open a new window. Go to inbound rules and look for the Distributed Transaction Coordinator. If they are disabled, enable them. On the workstation the firewall can be enabled. Beware that DTCPing may not work, because the Firewall is only allowing connections to/from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;svchost.exe&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;msdtc.exe&lt;/code&gt; (if you want it to work, add a rule for that process).&lt;/p&gt;

</description>
        <pubDate>Mon, 06 Jun 2011 16:19:47 +0000</pubDate>
        <link>http://codelog.climens.net/2011/06/06/troubleshooting-msdtc-rpc-and-nservicebus-issues/</link>
        <guid isPermaLink="true">http://codelog.climens.net/2011/06/06/troubleshooting-msdtc-rpc-and-nservicebus-issues/</guid>
      </item>
    
      <item>
        <title>Using fail2ban with nginx in Debian</title>
        <description>&lt;p&gt;Taking a look at the logwatch mails I see a common pattern of attacks, coming from China and trying to find details of my server configuration, which is something I don’t like.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/fail2ban-logo.jpg&quot; alt=&quot;fail2ban logo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Looking around I found &lt;a href=&quot;http://www.fail2ban.org/&quot;&gt;fail2ban&lt;/a&gt; which is a tool that does some regex matches on the server logs (sshd, httpd, authd, …) and takes proper actions, like banning the offending IP.&lt;/p&gt;

&lt;p&gt;I then installed fail2ban in my Debian box:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;apt-get install fail2ban
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then, I took a look at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/fail2ban/jail.conf&lt;/code&gt; and found some entries for Apache but none for &lt;a href=&quot;http://nginx.org/&quot;&gt;nginx&lt;/a&gt;, my server of choice, so I decided to create a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jail.local&lt;/code&gt; to add some nginx stuff (this is recommended in Debian to allow hassle-free upgrades).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/nginx-logo.png&quot; alt=&quot;nginx logo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I started copying the Apache sections of the default fail2ban as the log files in my case use the same format that allows me to use Awstats easily. Then, I modified my log routes to point to the nginx ones and using Apache rules, if they don’t work I’ll tune them later.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-cfg&quot; data-lang=&quot;cfg&quot;&gt;[nginx]
enabled = true
port    = http,https
filter  = apache-auth
logpath = /var/log/nginx*/*error.log
maxretry = 6

[nginx-noscript]
enabled = false
port    = http,https
filter  = apache-noscript
logpath = /var/log/nginx*/*error.log
maxretry = 6

[nginx-overflows]
enabled = false
port    = http,https
filter  = apache-overflows
logpath = /var/log/nginx*/*error.log
maxretry = 2&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Although this is ok, the bots I see don’t leave a trace in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;error.log&lt;/code&gt; but in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;access.log&lt;/code&gt; so I took a look at the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;filter.d&lt;/code&gt; folder where an interesting &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apache-badbots.conf&lt;/code&gt; was present. Then, I found the default fail2ban documentation in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/share/doc/fail2ban&lt;/code&gt; where there’s an usage example of the badbots script. I added I to my &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jail.local&lt;/code&gt;:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-cfg&quot; data-lang=&quot;cfg&quot;&gt;[apache-badbots]
enabled  = true
port    = http,http
filter   = apache-badbots
logpath  = /var/log/nginx*/*access.log
bantime  = 172800
maxretry = 1&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Finally, I added this to the top of the file, to send mails to myself when a rule matches and a host is banned.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-cfg&quot; data-lang=&quot;cfg&quot;&gt;[DEFAULT]
action = %(action_mwl)s&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Finally, restart the service and start receiving mails:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo /etc/init.d/fail2ban restart
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I’m sure this will need further adjustments, but it’s a beginning in my bot fighting war. I’ll make some updates as I find interesting results.&lt;/p&gt;
</description>
        <pubDate>Sun, 13 Feb 2011 14:03:16 +0000</pubDate>
        <link>http://codelog.climens.net/2011/02/13/using-fail2ban-with-nginx-in-debian/</link>
        <guid isPermaLink="true">http://codelog.climens.net/2011/02/13/using-fail2ban-with-nginx-in-debian/</guid>
      </item>
    
      <item>
        <title>How msiinv saved my day</title>
        <description>&lt;p&gt;In my &lt;a href=&quot;/2011/01/12/install-asp-net-mvc-3-rc-manually/&quot;&gt;previous post&lt;/a&gt; I reported my problems installing MVC3 in my machine. That led me to further investigation as that worked perfectly in my co-workers’ machines.&lt;/p&gt;

&lt;p&gt;I tried to repair Visual Studio 2010 and told me that it had troubles with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vs_setup.msi&lt;/code&gt;… strange. Looking around I found a post that led me to &lt;a href=&quot;http://blogs.msdn.com/b/astebner/archive/2005/07/01/using-msiinv-to-gather-information-about-what-is-installed-on-a-computer.aspx&quot;&gt;an explanation of the msiinv.exe tool&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It took me a while to get the tool as the author’s site is broken, but Stackoverflow &lt;a href=&quot;http://stackoverflow.com/questions/239264/anyone-got-a-copy-of-msiinv-exe&quot;&gt;came on rescue&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Then, I ran the tool:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msiinv -p &amp;amp;gt; msiinv.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then opened the file and… surprise!&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Microsoft Visual Studio 2010 Professional - ESN
    Product code:    {725041D1-9F45-30D3-A78E-DF08C4E1A297}
    Product state:    (1) The product is advertised, but not installed.
    Package code:    {9E58363D-E4A9-49D3-82B7-42584AFCA9E7}
    AssignmentType:    1
    Language:    3082
        Package:    vs_setup.msi
    0 patch packages.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Strange. I tried to fix it with MSI:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;msiexec /f {725041D1-9F45-30D3-A78E-DF08C4E1A297}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It asked me for the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vs_setup.msi&lt;/code&gt;, it’s in the root of the Visual Studio 2010 DVD in case it’s not found automatically. Magically it worked and now it’s installed:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Microsoft Visual Studio 2010 Professional - ESN
    Product code:    {725041D1-9F45-30D3-A78E-DF08C4E1A297}
    Product state:    (5) Installed.
    Package code:    {9E58363D-E4A9-49D3-82B7-42584AFCA9E7}
    Version:    10.0.30319
    AssignmentType:    1
    Publisher:    Microsoft Corporation
    Language:    3082
       Installed from: D:\VS2010\
    Package:    vs_setup.msi
    Help link:    http://go.microsoft.com/fwlink/?LinkId=133405
    Local package:    C:\Windows\Installer\3f3bc84.msi
    Install date:    2011\01\14
    0 patch packages.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Great! Now the ASP.NET MVC3 RTM setup package worked like a charm.&lt;/p&gt;
</description>
        <pubDate>Fri, 14 Jan 2011 11:22:31 +0000</pubDate>
        <link>http://codelog.climens.net/2011/01/14/how-msiinv-saved-my-day/</link>
        <guid isPermaLink="true">http://codelog.climens.net/2011/01/14/how-msiinv-saved-my-day/</guid>
      </item>
    
      <item>
        <title>Install ASP.NET MVC 3 Manually</title>
        <description>&lt;p&gt;&lt;strong&gt;Update 14-jan-2011:&lt;/strong&gt; I found the root solution to all my problems with msiinv, check &lt;a href=&quot;/2011/01/14/how-msiinv-saved-my-day/&quot;&gt;my post on the subject&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I don’t know exactly why but I can’t install the MVC 3 package provided by &lt;a href=&quot;http://www.microsoft.com/web/downloads/platform.aspx&quot;&gt;Web Platform Installer&lt;/a&gt; nor the &lt;a href=&quot;http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d2928bc1-f48c-4e95-a064-2a455a22c8f6&quot;&gt;standalone one&lt;/a&gt;, so I uncompressed it and tried to figure out how to install it manually.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/dotnetlogo.png&quot; alt=&quot;.NET logo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The problem I have is with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vs10-kb2465236-x86.exe&lt;/code&gt; that gives me a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;failed with 0x8007066a&lt;/code&gt; error. It seems to be for &lt;a href=&quot;http://support.microsoft.com/kb/2465236/en-us&quot;&gt;enabling Razor syntax&lt;/a&gt; but the prerequisites are Visual Studio 2010 Ultimate ENU. I have Visual Studio 2010 Professional ESN and that may be the reason or may not.&lt;/p&gt;

&lt;p&gt;Anyway, I found the way to install the package manually, although the Razor Intellisense stuff is not available in my setup.&lt;/p&gt;

&lt;p&gt;First you have to uncompress the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AspNetMVC3Setup.exe&lt;/code&gt; into a folder and then install the following files (I got the sequence from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;parameterinfo.xml&lt;/code&gt; file, which describes the installation process):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;del&gt;VS10-KB2465236-x86.exe&lt;/del&gt; (it fails in my case, I don’t install it)&lt;/li&gt;
  &lt;li&gt;AspNetWebPages.msi - ASP.NET Web Pages&lt;/li&gt;
  &lt;li&gt;AspNetWebPagesVS2010Tools.msi - ASP.NET Web Pages Visual Studio 2010 Tools&lt;/li&gt;
  &lt;li&gt;AspNetMVC3.msi - ASP.NET MVC 3 Runtime&lt;/li&gt;
  &lt;li&gt;AspNetMVC3VS2010Tools.msi - ASP.NET MVC 3 Visual Studio 2010 Tools&lt;/li&gt;
  &lt;li&gt;NuGet.msi - NuGet&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that’s all. In case you have Web Developer Express instead of full Visual Studio, you have ton install the tools specifically for that edition, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AspNetWebPagesVWD2010Tools.msi&lt;/code&gt; instead of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AspNetWebPagesVS2010Tools.msi&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AspNetMVC3VWD2010Tools.msi&lt;/code&gt; instead of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AspNetMVC3VS2010Tools.msi&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Good luck!&lt;/p&gt;
</description>
        <pubDate>Wed, 12 Jan 2011 15:49:08 +0000</pubDate>
        <link>http://codelog.climens.net/2011/01/12/install-asp-net-mvc-3-rc-manually/</link>
        <guid isPermaLink="true">http://codelog.climens.net/2011/01/12/install-asp-net-mvc-3-rc-manually/</guid>
      </item>
    
  </channel>
</rss>
