<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Braindump]]></title>
  <link href="http://thinktainer.github.io/atom.xml" rel="self"/>
  <link href="http://thinktainer.github.io/"/>
  <updated>2017-02-11T19:38:04+00:00</updated>
  <id>http://thinktainer.github.io/</id>
  <author>
    <name><![CDATA[Martin Schinz]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[DNSMasq for Using Docker Service Containers in and Out of Docker]]></title>
    <link href="http://thinktainer.github.io/2017/02/11/dnsmasq-for-using-docker-service-containers-in-and-out-of-docker/"/>
    <updated>2017-02-11T18:56:11+00:00</updated>
    <id>http://thinktainer.github.io/2017/02/11/dnsmasq-for-using-docker-service-containers-in-and-out-of-docker</id>
    <content type="html"><![CDATA[<p>In order to be able to use services installed via <a href="https://docs.docker.com/compose/">docker-compose</a> from both in-
and outside of the docker network I have started using <a href="https://wiki.archlinux.org/index.php/dnsmasq">DNSMasq</a>. This
lets me resolve hosts and services in the <code>.dev</code> domain from both inside and outside of the docker network. I have
created a <a href="https://www.freedesktop.org/wiki/Software/systemd/">systemd</a> service definition, that starts DNSMasq after
the network comes up. It ties into <a href="https://roy.marples.name/projects/openresolv/index">openresolv</a>, so that the
configuration survives dynamic network changes (like vpn). here are the config files:</p>

<p><code>/etc/systemd/system/dnsmasq-tld-dev.service</code></p>

<div><script src='https://gist.github.com/1797fad4e4de40e5087632eb3fcdcee7.js?file=dnsmasq-tld-dev.service'></script>
<noscript><pre><code>[Unit]
Description=DHCP server for local dev domain.
Wants=network-online.target
After=network.target network-online.target

[Service]
Type=forking
ExecStart=/usr/bin/dnsmasq -C /etc/dnsmasq-tld-dev.conf --pid-file=/var/run/dnsmasq-tld-dev.pid -u dnsmasq
PIDFile=/var/run/dnsmasq-tld-dev.pid

[Install]
WantedBy=multi-user.target</code></pre></noscript></div>


<p><code>/etc/resolvconf.conf</code></p>

<div><script src='https://gist.github.com/1797fad4e4de40e5087632eb3fcdcee7.js?file=resolvconf.conf'></script>
<noscript><pre><code># Configuration for resolvconf(8)
# See resolvconf.conf(5) for details

resolv_conf=/etc/resolv.conf
# If you run a local name server, you should uncomment the below line and
# configure your subscribers configuration files below.
name_servers=127.0.0.1
dnsmasq_resolv=/etc/dnsmasq-resolv.conf
#
#name_servers=8.8.8.8</code></pre></noscript></div>


<p><code>/etc/dnsmasq-tld-dev.conf</code></p>

<div><script src='https://gist.github.com/1797fad4e4de40e5087632eb3fcdcee7.js?file=dnsmasq-tld-dev.conf'></script>
<noscript><pre><code>interface=lo
bind-interfaces
listen-address=127.0.0.1
address=/dev/127.0.0.1
resolv-file=/etc/dnsmasq-resolv.conf</code></pre></noscript></div>



]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA['Bridged Network for Qemu in Arch Using Systemd']]></title>
    <link href="http://thinktainer.github.io/2016/03/17/bridged-network-for-qemu-in-arch-using-systemd/"/>
    <updated>2016-03-17T14:55:40+00:00</updated>
    <id>http://thinktainer.github.io/2016/03/17/bridged-network-for-qemu-in-arch-using-systemd</id>
    <content type="html"><![CDATA[<h2>The problem</h2>

<p>I want to run a windows virtual machine inside my <a href="https://www.archlinux.org/">arch
linux</a> development laptop, in order to be able to
run Microsoft&rsquo;s <a href="https://visualstudio.com">Visual Studio</a>, which I used to enjoy
using massively in the past, particularly in combination with Jetbrains'
<a href="https://www.jetbrains.com/resharper/">Resharper</a>. Recently I have gravitated
more towards a lighter stack, preferring <a href="http://fsharp.org">F#</a> over C#. The
tooling required to do the same kind of work in F# is much less than in C#
(depending on use case of course), and I have always favoured an approach that
lets me code using a text editor.</p>

<p>Enough rambling, so for this particular scenario I need VisualStudio, and by
extension Windows. I am going to go with Windows Server 2012 r2, as i find the
server Windows versions to be generally more amenable to running in a
virtualised environment. I also don&rsquo;t care much for news or music in a vm, so
running Windows Server doesn&rsquo;t limit me in any way.</p>

<h2>The options for virtualization</h2>

<p>Considering the options, it basically boils down to <a href="https://en.wikipedia.org/wiki/Hardware-assisted_virtualization">Hardware-assisted
virtualization</a>
versus <a href="https://en.wikipedia.org/wiki/Full_virtualization">Full virtualization</a>
(Vmware, Parallels, etc). I have long been on a Mac as my main box, and have
often felt the slowdown incurred by Full virtualization solutions, so being on a
shiny Arch Linux box, it was an easy decision to go with Hardware-assisted
(hvm).</p>

<p>The choice then is between <a href="http://xenproject.org/">xen</a> and
<a href="http://www.linux-kvm.org/page/Main_Page">kvm</a>, but I think the preparation for
the xen environment is a lot more intrusive than the kvm option. I also found a
recent performance
<a href="https://major.io/2014/06/22/performance-benchmarks-kvm-vs-xen/">comparison</a>
that essentially showed no major performance difference between the
technologies.  <em>Bring on the flame wars in the comments ;-)</em>
So kvm it is going to be for me.</p>

<h2>Installation</h2>

<p>Installing the required packages couldn&rsquo;t be easier given arch&rsquo;s excellent
package manager. <code>sudo pacman -S qemu</code> brings all the required bits onto my
machine, and looking through the installation instructions in the arch wiki
shows that I already have all the required kernel modules on my machine. So far
(I&rsquo;m 2 months in) the experience on arch with regards to package quality and
packages being up to date has been absolutely brilliant, so I&rsquo;m still in my
honey moon with this distro.</p>

<h2>Networking</h2>

<p>Here be dragons :-)</p>

<p>Considering the options for the network it becomes evident that there two ways
about it:</p>

<ul>
<li>The fully integrated solution, that makes it really easy on the user, by
effectively creating vlans and bridges in the kvm / qemu stack, and hiding
that completely from the user. This solution doesn&rsquo;t allow to have an
optimised interface in the guest, and as a result of that is slower than the
other solutions.</li>
<li>The bridged networking version, which pushes most of the management complexity
onto the user, but provides the benefit of a virtio interface, that maps the
io directly to the host, and is much faster as a result.</li>
</ul>


<p>Thinking <em>how hard can it be</em> I decide to take a stab at the bridged networking
option. Now this is a bit of a pain on a laptop, if you want the guest os
(windows in my case) to be able to call out to the network. This is a solid
requirement in my case, for being able to get windows updates, etc.</p>

<p>The reason it is difficult is that wireless interfaces in linux don&rsquo;t allow
bridging on the kernel network stack (promiscuous mode), which means that they
can&rsquo;t be slaved to the bridge.</p>

<p>The alternative is to create a bridge device and forward the guest&rsquo;s traffic via
network address translation (NAT), to the wifi interface, using the linux
firewall (iptables).</p>

<p>Having NetworkManager as my main mechanism for connecting to wifi (I find the
gui way a bit easier than arch&rsquo;s preferred netctl), I need to come up with a way
of making the bridge start on system startup, and when I start the vm for the
interface to attach to the bridge. The attaching bit is pretty much handled for
me in recent versions of kvm, where I can give it a flag with a bridge
interface, and it will handle the rest.</p>

<p>So I decide to buy into the brave new world that is systemd, and think I&rsquo;ll be
able to use this knowledge in the future, as that behemoth seems to not stop for
anything, and given the engineering power behind it, I would be surprised to see
it go away any time soon.</p>

<h3>Create the bridge, and start on system startup</h3>

<p>To create the bridge device I add the file</p>

<p><code>/etc/systemd/network/qbr0.netdev</code>:</p>

<div><script src='https://gist.github.com/45a09a798026a7b6a147.js?file=etc-systemd-network-qbr0.netdev'></script>
<noscript><pre><code>[NetDev]
Name=qbr0
Kind=bridge
</code></pre></noscript></div>


<p>For it&rsquo;s network configuration I add:</p>

<p><code>/etc/systemd/network/qbr0.network</code></p>

<div><script src='https://gist.github.com/45a09a798026a7b6a147.js?file=etc-systemd-network-qbr0.network'></script>
<noscript><pre><code>[Match]
Name=qbr0

[Network]
Address=172.20.0.1/16
DHCP=yes
</code></pre></noscript></div>


<p>In order to enable the network part of systemd I need to enable the
systemd-networkd daemon. <code>systemctl enable systemd-networkd</code>. Simple enough.</p>

<h3>Allow qemu to connect to the bridge</h3>

<p>In order for qemu to be allowed to use the bridge I add the file
<code>/etc/qemu/bridge.conf</code>, containing only the line: <code>allow qbr0</code>.</p>

<h3>Add dnsmasq to provide ip&rsquo;s to guests</h3>

<p>In order for the guests to be able to receive ip&rsquo;s I add dnsmasq to serve ips on
the bridge device.</p>

<p>I add the configuration file: <code>/etc/dnsmasq-qbr0.conf</code> (apologies for top level
folder, this is all still a bit rough around the edges).</p>

<div><script src='https://gist.github.com/45a09a798026a7b6a147.js?file=etc-dnsmasq-qbr0.conf'></script>
<noscript><pre><code>interface=qbr0
except-interface=lo
bind-interfaces
dhcp-host=52:54:00:A0:06:34,id:*,172.20.109.230,12h
dhcp-range=172.20.0.2,172.20.255.254,12h
</code></pre></noscript></div>


<p>Note the assignment of the fixed ip, this is so that I can reliably rdp to the
same instance without having to go down the dns route.</p>

<p>I also add a service to systemd, to make this start up on system start (adding
dependencies to the network service to have started before):
<code>/etc/systemd/system/dnsmasq-qbr0.service</code></p>

<div><script src='https://gist.github.com/45a09a798026a7b6a147.js?file=etc-systemd-dnsmasq-qbr0.service'></script>
<noscript><pre><code>[Unit]
Description=DHCP server for kvm vms.
Wants=network-online.target
After=network.target network-online.target

[Service]
Type=forking
ExecStart=/usr/bin/dnsmasq -C /etc/dnsmasq-qbr0.conf --pid-file=/var/run/dnsmasq-qbr0.pid -u dnsmasq
PIDFile=/var/run/dnsmasq-qbr0.pid

[Install]
WantedBy=multi-user.target
</code></pre></noscript></div>


<h3>Adding a start script for the kvm instance</h3>

<p>Finally I modify <a href="http://ubuntuforums.org/showthread.php?t=2289210&amp;p=13334367#post13334367">a
script</a>
from the ubuntu forums by the awesome okky-htf, shout out, couldn&rsquo;t have done it
without you!</p>

<p>This is what I run to start the vm:</p>

<div><script src='https://gist.github.com/45a09a798026a7b6a147.js?file=start.sh'></script>
<noscript><pre><code>#!/bin/bash

# virtio drivers
#OPTS=&quot;-drive id=virtiocd,if=none,format=raw,file=/home/thinktainer/Downloads/virtio-win-0.1.102.iso&quot;
#OPTS=&quot;$OPTS -device driver=ide-cd,bus=ide.1,drive=virtiocd&quot;

# boot media
#OPTS=&quot;$OPTS -drive id=cd0,if=none,format=raw,readonly,file=/run/media/thinktainer/VMS/iso/win2012_eval.iso&quot;
#OPTS=&quot;$OPTS -device driver=ide-cd,bus=ide.0,drive=cd0&quot;

# System Drive
OPTS=&quot;$OPTS -drive id=disk0,if=none,cache=unsafe,format=raw,file=/home/thinktainer/virt/win2012&quot;
OPTS=&quot;$OPTS -device driver=virtio-scsi-pci,id=scsi0&quot;
OPTS=&quot;$OPTS -device scsi-hd,drive=disk0&quot;

OPTS=&quot;$OPTS -name win2012 -cpu host,kvm=off -smp 8,sockets=1,cores=4,threads=2 -enable-kvm -machine type=q35,accel=kvm&quot;

# Memory
OPTS=&quot;$OPTS -m 12G&quot;
OPTS=&quot;$OPTS -mem-path /dev/hugepages&quot;
OPTS=&quot;$OPTS -mem-prealloc&quot;
OPTS=&quot;$OPTS -balloon none&quot;

# Hardware clock
OPTS=&quot;$OPTS -rtc clock=host,base=utc&quot;

# Boot priority
OPTS=&quot;$OPTS -boot order=c&quot;

# Graphics passthrough
#OPTS=&quot;$OPTS -device vfio-pci,host=02:00.0,multifunction=on&quot;

# A USB tablet device in the guest allows for accurate pointer tracking
# between the host and the guest.
OPTS=&quot;$OPTS -device piix3-usb-uhci -device usb-tablet&quot;

# Network
#OPTS=&quot;$OPTS -netdev tap,vhost=on,ifname=$VM,script=/usr/local/bin/vm_ifup_brlan,id=brlan&quot;
#OPTS=&quot;$OPTS -device virtio-net-pci,mac=52:54:00:xx:xx:xx,netdev=brlan&quot;
#OPTS=&quot;$OPTS -netdev user,id=user.0 -device virtio-net-pci,netdev=user.0&quot;

OPTS=&quot;$OPTS -netdev bridge,br=qbr0,id=d0&quot;
OPTS=&quot;$OPTS -device virtio-net-pci,mac=52:54:00:A0:06:34,netdev=d0&quot;

# Disable display
#OPTS=&quot;$OPTS -vga qxl&quot;
#OPTS=&quot;$OPTS -monitor none&quot;
#OPTS=&quot;$OPTS -daemonize&quot;

OPTS=&quot;$OPTS -vga none&quot;
OPTS=&quot;$OPTS -serial null&quot;
OPTS=&quot;$OPTS -parallel null&quot;
OPTS=&quot;$OPTS -display none&quot;

# QEMU Guest Agent
OPTS=&quot;$OPTS -chardev socket,path=/tmp/qga.sock,server,nowait,id=qga0&quot;
OPTS=&quot;$OPTS -device virtio-serial&quot;
OPTS=&quot;$OPTS -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0&quot;


/usr/bin/qemu-system-x86_64 $OPTS
</code></pre></noscript></div>


<p>I have set up rdp in the guest, hence the graphics are disabled at the bottom.
For the initial installation plus boot the start up order needs to be changed,
and the drives for the cd iso&rsquo;s need to be enabled.</p>

<p>I use this script to rdp into the instance, and am very happy with the
performance and stability of the set up.</p>

<div><script src='https://gist.github.com/45a09a798026a7b6a147.js?file=connect.sh'></script>
<noscript><pre><code>#!/bin/bash

xfreerdp &quot;/w:3200&quot; &quot;/h:1800&quot; &quot;/f&quot; &quot;/u:Administrator&quot; &quot;/p:PASSWORD&quot; &quot;/clipboard&quot; &quot;/v:172.20.109.230&quot;
</code></pre></noscript></div>


<p>This is all, I hope someone finds this useful, I&rsquo;m mainly leaving it here for
myself, to be able to repeat this in the future. Comments (particularly
alternatives for the networknig) are very welcome.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Running Powershell From FAKE]]></title>
    <link href="http://thinktainer.github.io/2015/06/03/running-ps-from-fake/"/>
    <updated>2015-06-03T15:16:01+01:00</updated>
    <id>http://thinktainer.github.io/2015/06/03/running-ps-from-fake</id>
    <content type="html"><![CDATA[<p>At my job we had a requirement for connecting one of our systems to a new
sql backend. As there are several other existing solutions in our code base that
already do schema migrations and db initialization I didn&rsquo;t get to use
<a href="http://dbup.github.io">dbup</a>, which would normally be my go to solution for
doing this kind of job in .NET.</p>

<p>I&rsquo;m strongly convinced that being able to run the same build on the build server
as on your local machine is a powerful thing, when it comes to troubleshooting
issues with it. So I generally abstain from putting any logic of <em>how</em> to build
on the build server, and rather let it figure out <em>when</em> to do it.
So I was stuck with powershell, and I wanted to make the existing scripts with
our build tool of choice: <a href="http://fsharp.github.io/FAKE/">FAKE</a>.</p>

<p>It turned out to be quite a task, as all the libraries in the
<a href="https://msdn.microsoft.com/en-us/library/System.Management.Automation(v=vs.85">System.Automation.Management</a>.aspx)
namespace looked frighteningly unfamiliar, and were obscured with the typical
windows security features that make it so hard to understand the usage patterns
for a Microsoft Windows Framework. I&rsquo;m sure I&rsquo;ll have forgotten how to do this
tomorrow, and I don&rsquo;t want to go through the process of piecing it together
again, so I&rsquo;m adding this post for future reference.</p>

<p>Here is the code:</p>

<div><script src='https://gist.github.com/f75e4492cc193b4bd9d8.js'></script>
<noscript><pre><code>Target &quot;BlitzDb&quot; &lt;| fun _ -&gt; 
    if isLocalBuild then
        let logPs = sprintf &quot;%A&quot; &gt;&gt; trace
        let runspaceConfig = RunspaceConfiguration.Create()
        use runspace = RunspaceFactory.CreateRunspace(runspaceConfig)
        runspace.Open()
        use runspaceInvoke = new RunspaceInvoke(runspace)
        runspaceInvoke.Invoke(&quot;Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted&quot;) |&gt; Seq.iter logPs
        runspaceInvoke.Invoke(&quot;Push-Location -Path &#39;./db/deploy&#39;&quot;)
        let ps = runspace.CreatePipeline()
        let cmd = Command(&quot;./db.fresh.ps1&quot;)
        cmd.Parameters.Add(&quot;ConnectToLocalDb&quot;, true)
        ps.Commands.Add(cmd)
        ps.Invoke() |&gt; Seq.iter logPs

</code></pre></noscript></div>


<p>One thing that is noteworthy is that even though the framework threw an
exception after the script&rsquo;s execution (which performed it&rsquo;s task perfectly),
this didn&rsquo;t bubble up to FAKE, so it&rsquo;s not fit to stop the build in case of
failure, at this point.</p>

<p>One of the things that you need to address when executing powershell scripts in
a non-interactive host, is that the <code>Write-Host</code> cmdlets you may be using will
no longer work, as they&rsquo;re effectively trying to write to console. I was able to
resolve this by changing them to <code>Write-Output</code>, after which the exceptions
stopped for me.</p>

<p>That is all.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[A Vagrant Mono Box to Explore FSharp on Linux]]></title>
    <link href="http://thinktainer.github.io/2014/09/13/a-vagrant-mono-box-to-explore-foundationdb-via-fsharp/"/>
    <updated>2014-09-13T16:15:41+01:00</updated>
    <id>http://thinktainer.github.io/2014/09/13/a-vagrant-mono-box-to-explore-foundationdb-via-fsharp</id>
    <content type="html"><![CDATA[<p>Today I am sharing a ubuntu-64 trusty <a href="http://www.vagrantup.com">Vagrant</a>
<a href="https://vagrantcloud.com/thinktainer/boxes/trusty64-vmw-fsharp-foundationdb">box</a>
in order to make it easy to get started with mono development on linux.</p>

<p><strong>tl;dr</strong> <code>vagrant init thinktainer/trusty64-vmw-fsharp-foundationdb</code></p>

<h2>Why I think it matters</h2>

<p>I have recently become a big fan of Microsofts ML language
<a href="http://www.fsharp.org">FSharp</a>. In my opinion one of the things that is holding
wider adoption of it back is the lack of a good cross platform story, like what
for instance <a href="http://clojure.org">clojure</a> or <a href="https://www.java.com/en/">java</a>
have to offer. <em>Minor niggle here, about the story for ruby and python on
Windows being far from great too.</em> One thing that has traditionally been painful
is the fact that the <a href="http://www.mono-project.com">mono</a> runtime was a bit of a
pain to get recent packages for. Without @tpokorras efforts with his high
quality mono-opt packages for all major linux flavours it would have meant
a developer would have needed to compile the runtime environment herself, in
order to get a recent version on her machine (in a non-standard installation
folder).  Obviously with the advent of <a href="http://xamarin.com">Xamarin</a>&rsquo;s great
cross platform tools and those being based on the mono runtime things have
started looking up a lot since then.</p>

<h2>Microsoft wants us to use their languages and tools</h2>

<p>I am convinced that the current trend for using linux as a .NET host is going to
gain even more momentum. Microsoft may be interested in such a development due
to the fact that Xamarin&rsquo;s cross platform story is a great way to channel people
down to the Azure platform as the cloud provider of the services for these
Xamarin apps. Another area where Microsoft is leaving the comfort zone of
Windows and actively seeking cross platform support by their framework is
<a href="http://www.asp.net/vnext">ASP.NET vNEXT</a>.  Again this may be useful for
Microsoft if they manage to get people onto their cloud platform by offering a
broader bandwith of choices, but in my opinion it is too early to tell if this is
in fact a vaible assumption. Regardless of what we are able to observe now, I
believe that Microsoft&rsquo;s cross platform efforts are going to be a great
investment in the long run, as it will make their services and potentially
devices more appealing to a wider audience of developers.</p>

<h2>FSharp is the ugly duckling at Microsoft</h2>

<p>Microsoft has one of if not the best solution for developing object orientated
software on a vm, namely
<a href="http://en.wikipedia.org/wiki/C_Sharp_(programming_language">CSharp</a>).  It has
been widely adopted by the public sector and the enterprise. For hobbyists and
&lsquo;recreational programmers&rsquo; not so much, at least that I&rsquo;m aware of. A great
amount of resource at Microsoft is dedicated to the advancement, refinement and
marketing of this tooling, and rightly so.</p>

<p>The story for FSharp at Microsoft is different. One example where Microsoft was
marketing C# and to an extent C++ and javascript was the
<a href="http://www.buildwindows.com">Build</a> conference in 2014. During the whole
conference there was not one single talk about F#. The tooling and integration
support for using F# leaves a developer wanting in a number of places. The most
obvious one in my opinion is that one has to ship the latest FSharp.Core
libraries as a compiled artifact when trying to host applications using them in
azure. These are windows boxes maintained by Microsoft, so it strikes me as odd
that the F# framework on these boxes is not the latest version available to
developers. There are more areas like sponsoring where Microsoft is hardly
visible when it comes to promoting F#. I find it hard to find reasons for why F#
is being left in the background to this extent. I am entertaining two possible
explanations, which are both purely speculative and quite absurd.</p>

<h2>This is great for the open source movement</h2>

<p>Due to the relative apathy of Microsoft in regards to engaging with the
community around FSharp, the community prospers. There is a number of problems
that have been solved by the FSharp open source community in a manner of great
technical excellence. Examples of this would be the number of highly useful type
providers, data analysis solutions and parsers.</p>

<p>The core language is open source, and accepting contributions from the
community. This is big news for a language that was developed under the umbrella
of a big corporate like Microsoft. Under the vision of Don Syme, who is not only
the father of F#, but also responsible for some of the key features that make C#
so attractive I believe there is a bright future for the language ahead.</p>

<p>The lack of percievable involvement from Microsoft in the current affairs of the
language makes it more palatable to people who feel an ingrained antipathy for
whatever reasons for the company. There is a great number of fantastic
programmers in this group, and it is a highly desirable to get some of them &lsquo;on
board&rsquo;, in order to start spreading the word.</p>

<p>A key ingredient to further the spread of F# in these communities is being able
to use it without having to use the Windows operating system.</p>

<p>I am hoping that my contribution will help this process along.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Fixing Vmware_fusion Nokogiri Build Error]]></title>
    <link href="http://thinktainer.github.io/2014/07/30/fixing-vmware-fusion-nokogiri-build-error/"/>
    <updated>2014-07-30T19:24:27+01:00</updated>
    <id>http://thinktainer.github.io/2014/07/30/fixing-vmware-fusion-nokogiri-build-error</id>
    <content type="html"><![CDATA[<p>When trying to install vagrant for the second time, I ran into an error about installing the nokogiri gem again. (This happened to me before, but I since forgot how I fixed it).
Thank god nowadays there is <a href="http://stackoverflow.com">stackoverflow</a>, so a solution to most problems is never far away.
This <a href="http://stackoverflow.com/a/23635023/672760">post</a> describes that one only needs to export an environment variable when trying to install the <a href="https://www.vagrantup.com/vmware">vagrant_fusion plugin</a>.</p>

<pre><code>    NOKOGIRI_USE_SYSTEM_LIBRARIES=1 vagrant plugin install vagrant-vmware-fusion
</code></pre>

<p>I hope I remember I have posted this the next time I upgrade my mac.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Ilmerge a .NET 4.5 Project]]></title>
    <link href="http://thinktainer.github.io/2014/04/13/ilmerge-a-net-4-dot-5-project/"/>
    <updated>2014-04-13T13:15:17+01:00</updated>
    <id>http://thinktainer.github.io/2014/04/13/ilmerge-a-net-4-dot-5-project</id>
    <content type="html"><![CDATA[<p>When packaging a console exe for easy deployment on a client machine I wanted to run ilmerge.exe recently. I have found that all it takes is to reference the right framework assemblies in the /targetplatform command line switch.
The full command on my machine then looks like:</p>

<figure class='code'><figcaption><span>ilmerge for .NET 4.5</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ps1'><span class='line'><span class="n">ilmerge</span> <span class="p">/</span><span class="n">t</span><span class="err">:</span><span class="n">exe</span> <span class="p">/</span><span class="n">targetplatform</span><span class="err">:</span><span class="s2">&quot;v4,$env:windir\Microsoft.NET\Framework64\v4.0.30319&quot;</span> <span class="p">/</span><span class="n">lib</span><span class="err">:</span><span class="p">.</span> <span class="p">/</span><span class="n">out</span><span class="err">:</span><span class="n">outname</span><span class="p">.</span><span class="n">exe</span> <span class="p">.\</span><span class="n">inname</span><span class="p">.</span><span class="n">exe</span> <span class="p">[</span><span class="n">additional-library</span><span class="p">.</span><span class="n">dll</span><span class="p">,</span> <span class="p">...]</span>
</span></code></pre></td></tr></table></div></figure>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Fixing Xen Daemon on a Laptop With Nvidia Optimus Graphics]]></title>
    <link href="http://thinktainer.github.io/2012/04/21/fixing-xen-daemon-on-a-laptop-with-nvidia-optimus-graphics/"/>
    <updated>2012-04-21T17:12:12+01:00</updated>
    <id>http://thinktainer.github.io/2012/04/21/fixing-xen-daemon-on-a-laptop-with-nvidia-optimus-graphics</id>
    <content type="html"><![CDATA[<p>When I tried to install xen on my new Inspiron laptop (15R N5110) - I ran into a bit of trouble with the pci probing of the xend daemon. It has something to do with the capabilities of the pci devices going into a loop or not being able to handle 2 graphics adapters. I found a similar problem <a href="https://bugzilla.redhat.com/show_bug.cgi?format=multiple&amp;amp;id=767742">here</a> and the same patch worked for me. I am posting this here again, so I don&rsquo;t forget and other people can find it.
The fix:</p>

<div><script src='https://gist.github.com/2266335.js'></script>
<noscript><pre><code>--- /root/pci.py   2012-03-31 16:36:52.633262092 +0100
+++ /usr/lib/xen-4.1/lib/python/xen/util/pci.py 2012-03-31 16:41:00.057262001 +0100
@@ -1266,7 +1266,12 @@
             pass
 
     def get_info_from_sysfs(self):
-        self.find_capability(0x11)
+   try:
+       self.find_capability(0x11)
+   except PciDeviceParseError, err:
+       log.error(&quot;Caught &#39;%s&#39;&quot; % err)
+       return False
+
         sysfs_mnt = find_sysfs_mnt()
         if sysfs_mnt == None:
             return False
</code></pre></noscript></div>


<p>The error message:</p>

<div><script src='https://gist.github.com/2266378.js'></script>
<noscript><pre><code>Traceback (most recent call last):
  File &quot;/usr/lib/xen-4.1/bin/../lib/python/xen/xend/server/SrvDaemon.py&quot;, line 341, in run
    servers = SrvServer.create()
  File &quot;/usr/lib/xen-4.1/bin/../lib/python/xen/xend/server/SrvServer.py&quot;, line 258, in create
    root.putChild(&#39;xend&#39;, SrvRoot())
  File &quot;/usr/lib/xen-4.1/bin/../lib/python/xen/xend/server/SrvRoot.py&quot;, line 40, in __init__
    self.get(name)
  File &quot;/usr/lib/xen-4.1/bin/../lib/python/xen/web/SrvDir.py&quot;, line 84, in get
    val = val.getobj()
  File &quot;/usr/lib/xen-4.1/bin/../lib/python/xen/web/SrvDir.py&quot;, line 52, in getobj
    self.obj = klassobj()
  File &quot;/usr/lib/xen-4.1/bin/../lib/python/xen/xend/server/SrvNode.py&quot;, line 30, in __init__
    self.xn = XendNode.instance()
  File &quot;/usr/lib/xen-4.1/bin/../lib/python/xen/xend/XendNode.py&quot;, line 1181, in instance
    inst = XendNode()
  File &quot;/usr/lib/xen-4.1/bin/../lib/python/xen/xend/XendNode.py&quot;, line 159, in __init__
    self._init_PPCIs()
  File &quot;/usr/lib/xen-4.1/bin/../lib/python/xen/xend/XendNode.py&quot;, line 282, in _init_PPCIs
    for pci_dev in PciUtil.get_all_pci_devices():
  File &quot;/usr/lib/xen-4.1/bin/../lib/python/xen/util/pci.py&quot;, line 474, in get_all_pci_devices
    return map(PciDevice, get_all_pci_dict())
  File &quot;/usr/lib/xen-4.1/bin/../lib/python/xen/util/pci.py&quot;, line 699, in __init__
    self.get_info_from_sysfs()
  File &quot;/usr/lib/xen-4.1/bin/../lib/python/xen/util/pci.py&quot;, line 1269, in get_info_from_sysfs
    self.find_capability(0x11)
  File &quot;/usr/lib/xen-4.1/bin/../lib/python/xen/util/pci.py&quot;, line 1236, in find_capability
    (&#39;Looped capability chain: %s&#39; % self.name))
PciDeviceParseError: Looped capability chain: 0000:01:00.0
[2012-03-31 12:51:43 2300] INFO (SrvDaemon:220) Xend exited with status 1.
[2012-03-31 12:57:25 2298] INFO (SrvDaemon:332) Xend Daemon started
[2012-03-31 12:57:25 2298] INFO (SrvDaemon:336) Xend changeset: unavailable.
[2012-03-31 12:57:26 2298] ERROR (SrvDaemon:349) Exception starting xend (Looped capability chain: 0000:01:00.0)
</code></pre></noscript></div>


<p>Hope this helps.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Recursively Rename Files to Their Directory Name and Keep Their Extension in Windows Power Shell]]></title>
    <link href="http://thinktainer.github.io/2011/07/21/recursively-rename-files-to-their-directory-name-and-keep-their-extension-in-windows-power-shell/"/>
    <updated>2011-07-21T09:30:30+01:00</updated>
    <id>http://thinktainer.github.io/2011/07/21/recursively-rename-files-to-their-directory-name-and-keep-their-extension-in-windows-power-shell</id>
    <content type="html"><![CDATA[<p>Just a quick one:</p>


<div><script src='https://gist.github.com/10581231.js'></script>
<noscript><pre><code>foreach($i in dir -Recurse -Include *.xml) {$parent = $i | Split-Path -Parent | Split-Path -leaf; $i | rename-item -newname {$parent + &#39;.xml&#39;}}</code></pre></noscript></div>




<p>That's it.</p>



]]></content>
  </entry>
  
</feed>
