Manning

Illustration

As I bought yet another book few days ago, I noticed that most of my IT book purchases are going to Manning. Whenever I need a book they are first site that I check. If there is book there, I will check no further.

Probably main reason for this is their stance toward DRM - there is none! Once I buy PDF book I can read it on whichever device I want to. I can make million of copies. Only thing they add is your name on footer of every page. Cynics would call this social DRM but I find this acceptable and quite unobtrusive when reading on computer or paper.

Most e-book readers are notoriously lousy when it comes to PDF and Manning fortunately recognized this as of late. Almost all new books are coming with mobi (Kindle) and ePub support alongside PDF (and you only pay once for all three). Some older books are getting e-book versions also, but Manning is taking their time.

Selection of books is quite nice, especially in .NET compartment where you can find gem as C# in Depth by Jon Skeet, easily the best book on C#. Other authors and books are also way above minimum quality. I would definitely say that, at least for books that I have read, quality ranges from good to excellent.

If you want to get view of newest technology where book is just in writing, Manning has solution for that also. It is called MEAP (Manning Early Access Program) and, in nutshell, it enables you book access as it is being written. You buy book in advance and every month or so you get next few chapters to read and that goes on until book is completed. During that time you have access to author and you can give him notice of error, steer him in other direction, or just annoy the hell out of him. :) Rarely it happens that MEAP book is cancelled and in that case Manning offers full refund (or two free books for your emotional suffering).

Nice touch is that I probably never paid full price for a book. It is really hard to find time in year when there isn’t some coupon code to take 30% or more from purchase (they adore giving 42% discounts). If you are patient enough there is also Deal of the Day offering where each day there is a book with discount. I find it almost impossible to pay full price.

There are bad things also. Site looks like something from 10 years ago, their account center is almost impossible to find and, once you find it, you will curse at annoying interface. Other than this, they are pretty close to being perfect.

P.S. For company with colorful book covers, they have a really ugly logo.

P.P.S. No, I was not paid for promoting them.

Mercurial Over Both Http and Https

My last post about Mercurial left us with Mercurial server listening to https-only requests. This is probably best solution security-wise but there might be valid reasons for having it on http also (e.g. performance within local network).

Solution lies in editing “/etc/apache2/sites-available/hg” to have two configurations - one for http and one for https:

NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /srv/hg/cgi-bin
    <Directory "/srv/hg/cgi-bin/">
        SetHandler cgi-script
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog /var/log/apache2/hg.log
    <Location />
        AuthType Basic
        AuthName "Mercurial"
        AuthUserFile  /srv/hg/.htpasswd
        Require valid-user
    </Location>
    RewriteEngine on
    RewriteRule (.*) /srv/hg/cgi-bin/hgweb.cgi/$1
</VirtualHost>

<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /srv/hg/cgi-bin
    <Directory "/srv/hg/cgi-bin/">
        SetHandler cgi-script
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog /var/log/apache2/hg.log
    <Location />
        AuthType Basic
        AuthName "Mercurial"
        AuthUserFile  /srv/hg/.htpasswd
        Require valid-user
    </Location>
    RewriteEngine on
    RewriteRule (.*) /srv/hg/cgi-bin/hgweb.cgi/$1
    SSLEngine on
    SSLOptions +StrictRequire
    SSLCertificateFile /srv/hg/https.crt
    SSLCertificateKeyFile /srv/hg/https.key
</VirtualHost>

After quick Apache restart your Mercurial will answer both http and https requests.

Mercurial Over Https

My guide on making Mercurial server left us with http as a protocol of choice. This might be ok in local network but https would be more comfortable choice. This post starts with already running Mercurial server on Ubuntu.

Apache does come with https module which has to be enabled:

sudo a2enmod ssl
 Enabling module ssl.
 See /usr/share/doc/apache2.2-common/README.Debian.gz on how to configure SSL and create self-signed certificates.
 Run '/etc/init.d/apache2 restart' to activate new configuration!

Before restarting Apache we need to create few things (key, certificate signing request, certificate) and easiest way is to create it ourself (write whatever you want for organization details):

openssl genrsa -out https.key 1024
 Generating RSA private key, 1024 bit long modulus
 ..........++++++
 ......++++++
 e is 65537 (0x10001)

openssl req -new -key https.key -out https.csr
 You are about to be asked to enter information that will be incorporated
 into your certificate request.
 What you are about to enter is what is called a Distinguished Name or a DN.
 There are quite a few fields but you can leave some blank
 For some fields there will be a default value,
 If you enter '.', the field will be left blank.
 -----
 Country Name (2 letter code) [AU]: 
 State or Province Name (full name) [Some-State]: 
 Locality Name (eg, city) []: 
 Organization Name (eg, company) [Internet Widgits Pty Ltd]: 
 Organizational Unit Name (eg, section) []: 
 Common Name (eg, YOUR name) []: 
 Email Address []: 

 Please enter the following 'extra' attributes
 to be sent with your certificate request
 A challenge password []: 
 An optional company name []: 

openssl x509 -req -days 36500 -in https.csr -signkey https.key -out https.crt
 Signature ok
 subject=...
 Getting Private key

Once keys are created we must enter following lines in “/etc/apache2/sites-available/hg” (I left other stuff for clarity):

NameVirtualHost *
<VirtualHost *>
    ServerAdmin webmaster@localhost
    DocumentRoot /srv/hg/cgi-bin
    <Directory "/srv/hg/cgi-bin/">
        SetHandler cgi-script
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog /var/log/apache2/hg.log
    <Location />
        AuthType Basic
        AuthName "Mercurial"
        AuthUserFile  /srv/hg/.htpasswd
        Require valid-user
    </Location>
    RewriteEngine on
    RewriteRule (.*) /srv/hg/cgi-bin/hgweb.cgi/$1
    SSLEngine on
    SSLOptions +StrictRequire
    SSLCertificateFile /srv/hg/https.crt
    SSLCertificateKeyFile /srv/hg/https.key
</VirtualHost>

With this we are ready for restart:

/etc/init.d/apache2 restart
 * Restarting web server apache2
     [warn] NameVirtualHost *:80 has no VirtualHosts
 ... waiting [warn] NameVirtualHost *:80 has no VirtualHosts

After these changes Mercurial is listening ONLY on https. Since we made self-signed certificate, browser will complain about verification, but that is quite normal.

P.S. To use both http and https, read some more.

Childproofing and Live Wires

Illustration

Neon screwdriver is one piece of equipment that I always have somewhere in my house. It is great tool to check power sockets - put it in one hole, then another, if it lights there is some power. But that is not all. It can also double as a screwdriver! :)

Another thing I always have at home are my children. They are reason why all my power sockets these days have childproofing inserts. Since my home uses schuko sockets, insert is just piece of plastic that prevents inserting items in single hole. Only when both holes are touched simultaneously insert rotates a bit and allows for insertion of plug. That enables me to have protection for my kids and to insert plug without any tools or effort. Unfortunately this also means that I cannot easily use my neon screwdriver.

However, if you have two neon screwdrivers, things change dramatically. It is easy to synchronously insert both screwdrivers through holes and thus get reading. If socket is live, both of them will light up. Live one will light because your body is making connection (oven neon screwdriver) with live wire and neutral one will light up since your body is transferring little bit of current from live wire. If you have two identical neon screwdrivers you can see that neutral one is little bit dimmer.

However, you can just as easily remove one from socket in order to test other one. Remember that once screwdriver is in hole, protection will not close. As protection is open, continue tests as you usually would. Once both neon screwdrivers are out of hole child protection will close automatically.

P.S. Be very, very careful when dealing with live wires. Do not trust neon screwdriver. Test both of them on live socket first in order to see whether bulb still works.

From SVN to Mercurial

Moving from SVN to Mercurial is obvious if you don’t want history. Folder copy/paste action is more than enough. If we want to get whole history, that is where things get more involved. This guide is written with assumption of Ubuntu installation of Mercurial. If you are using something other, do adjust a little (yes, it also works on Windows).

First thing that we need is “python-subversion” package installed. For some reason I could not find this through Ubuntu Software Center. It worked from Synaptic Package Manager without issues. Afterward we need to enable Mercurial’s convert extension. Just edit “/home/josip/.hgrc” (do change folder if your name is not Josip) and add these lines to it:

[extensions]
hgext.convert=

Last thing to do is actual conversion:

mkdir TestRepo

hg convert svn://192.168.0.3/TestRepo TestRepo
 initializing destination TestRepo repository
 scanning source...
 sorting...
 converting...
 32 
 31
 ...
 1 
 0

cd TestRepo

hg update
 49 files updated, 0 files merged, 0 files removed, 0 files unresolved

Your Mercurial repository awaits. :)

P.S. If folder with Mercurial repository is empty, you probably forgot to do “hg update”.