Hoe to get a book to print and publish an eBook

I cam across this wonderful post the other day by Robert Nystrom. It outlines the challenges and tasks he had to accomplish in order to publish his book Game Programming Patterns. This is is a quote from his post:

This gratuitously, vaingloriously long post is about climbing back down the mountain—all of the stuff required to turn a web site into a book. Remember on Mr. Rogers Neighborhood where they would take a trip to a factory to see how cute little piglets are turned into hotdogs or something charming like that? This is like that, but marginally less incarnadine.

via Zero to 353 Pages: Bringing My Web Book to Print and eBook – journal.stuffwithstuff.com.

For a further discussion surrounding ebook publishing, see the related HN discussion.

VirtualMin, SSL Perfect Forward Secrecy and StartSSL

I’ve recently been setting this website up to use SSL. To do so I used a couple of great guides and tools on the internet. I got my SSL certificate for free from StartSSL. I found the guide by Eric Mill invaluable to working through the relatively poor UI that StartSSL has to gain the free certificate.

To check the state of your SSL certificate you can the SSL Test Tool from Qualys SSL Labs.

To start with I received a C grade. I had two things to remedy:

  1. I had SSL3 enabled which is vulnerable to an attack called POODLE
  2. I did not have Perfect Forward Secrecy enabled, which prevents back decryption of previous conversations even when an attacker gains access to your private key (which happened with Heartbleed).

To remedy both these elements I needed to set Apache to use the correct SSL Protocols and the correct ciphers. More specifically I had to prioritise the ciphers that I prefered clients to use. I specifying the more secure ciphers first, clients that support it, will use Forward Secrecy as a priority.

Using Webmin you can go to Servers -> Apache Webserver -> Global Configuration -> Edit Config files

Comment out the existing SSL config. Change to the following:

SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on

I got this from Configuring Apache, Nginx, and OpenSSL for Forward Secrecy. See the Apache section.

If you want to install your SSL certificate in VirtualMin, you need to select your virtual server, then go to Server Configuration -> Manage SSL Certificate.

By default VirtualMin will have install a self-signed certificate, which sadly could be MITMed, which is why we are using the certificate from StartSSL, since they as a Certificate Authority have verified who I am (in the loosest sense of the word, by validating they can send an email to the domain for which I am trying to request a certificate for). More expensive certificates require you to prove your actual identity. More more expensive certificates allow you to have one certificate for multiple subdomains . The whole thing is a racket but I digress.

Luckily a new EFF backed program is coming called Let’s Encrypt, which will issue free certificates and they will be easy to install. This guide will become obsolete (is the hope).

Back to VirtualMin we need to install the certificate that StartSSL has provided us. You need to upload the signed certificate and the private key you used, but you need it in a PEM format. To do that you can use the following command:

openssl rsa -in mydomain.com.key -outform PEM -out mydomain.com.pem.key

You can now upload that via VirtualMin. Now you also need to rest of the certificate chain. You want to get the SHA-2 version since SHA-1 is vulnerable. You can download the Class1 StartSSL PEM file directly from StartSSL.

Now go to the CA Certificate tab and upload that file. Once uploaded you should see the following:

Certificate authority name StartCom Class 1 Primary Intermediate Server CA
Organization StartCom Ltd.
Issuer name StartCom Certification Authority
Issuer organization StartCom Ltd.
Expiry date Oct 24 20:54:17 2017 GMT
Certificate type Self-signed

If you don’t take the SHA-2 certificate then you’ll be downgraded. Google will also be downgrading sites that use SHA-1 based on this too in the future so it is worth getting right now.

To check your SHA configuration, you can use the wonderful shaaaaaaaaaaaaa.com.

Once you have completed this guide, you should get an A grade on the SSL Labs page.


MetricsGraphics.js – a library based on D3.js, optimized for visualizing and laying out time-series data

MetricsGraphics.js is a library built on top of D3 that is optimized for visualizing and laying out time-series data. It provides a simple way to produce common types of graphics in a principled, consistent and responsive way. The library currently supports line charts, scatterplots and histograms as well as features like rug plots and basic linear regression.

via MetricsGraphics.js – a library based on D3.js, optimized for visualizing and laying out time-series data.

Other alternatives for time series graphing are:

Video: How marble is mined in Italy

There is something incredibly beautiful in the artistry of the workers in this video mining marble in Italy. They work together using massive diggers, orchestrated by a foreman, who with the minimum of movement directs what feels like a graceful piece of industrial music.

Source: https://www.nowness.com/story/artist-yuri-ancarani-il-capo

“Marble quarries are places so unbelievable and striking, they almost feel like they are big theaters or sets,” says Yuri Ancarani, the filmmaker behind today’s excerpt from the documentary, Il Capo (The Chief), which follows a quarry boss as he guides his men through the extraction process, using a silent language of gesture and sign.

Ancarani was captivated by the otherworldly landscapes of the quarry. He spent nearly a year filming on Monte Bettolgi, in the Carrara region of the Apuan Alps, in Northwest Italy, eventually deciding to focus his film on the hypnotic, and rather dramatic moment when the monumental marble blocks are freed from the mountainside, and fall to the ground with an earth-shattering thud.

“I was so taken by the chief. How he can move gigantic marble blocks, but his own movements are light”

“I was so taken by the chief, watching him work,” says Ancarani, who’s film is currently showing as part of Artists’ Films International, a touring program of film, video and animation, at the Whitechapel Gallery in London. “How he can move gigantic marble blocks using enormous excavators, but his own movements are light, precise and determined.”

Il Capo is on show at the Whitechapel Gallery until October 12, 2014.

Cropper – a free, open source screenshot program for Windows

Cropper is a screen capture utility written in C#. It makes it fast and easy to grab parts of your screen. Use it to easily crop out sections of vector graphic files such as Fireworks without having to flatten the files or open in a new editor. Use it to easily capture parts of a web site, including text and images. It’s also great for writing documentation that needs images of your application or web site.


Get it on CodePlex: https://cropper.codeplex.com/

Cool tools for wireframing

Axure RP gives you the wireframing, prototyping and documentation tools needed to make informed design choices, persuade any skeptics, and document your design… and maybe win a few fans along the way. Choose the Standard edition for prototyping or go Pro to add documentation and collaboration features.


Balsamiq Mockups is a rapid wireframing tool that helps you Work Faster & Smarter. It reproduces the experience of sketching on a whiteboard, but using a computer.

Making mockups is fast. You’ll generate more ideas, so you can throw out the bad ones and discover the best solutions.


My approach to comments on this blog

I don’t receive that many comments on this blog. As a result it allows me to be ruthless.

I like receiving on-topic questions or comments that add to the discussion. If your comment simply states “I came across this blog and I think it is great” whilst linking back to a website that appears to be spammy, then prepare to get blacklisted.

You will be marked as spam if you comment is off-topic and/or your comment website links to a spammy website (I have a low threshold) .

Don’t waste my time or I will waste yours. I error on the side of fuck you.

Common .htaccess Redirects

I’ve recently been redirecting one website content to another. Here are some useful common .htaccess file redirects.

#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
#Redirect a sub folder to another site
Redirect 301 /subfolder http://www.domain.com/
#This will redirect any file with the .html extension to use the same filename but use the .php extension instead.
RedirectMatch 301 (.*)\.html$ http://www.domain.com$1.php
#You can also perform 301 redirects using rewriting via .htaccess.
#Redirect from old domain to new domain
RewriteEngine on
RewriteBase /
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
#Redirect to www location
RewriteEngine on
RewriteBase /
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
#Redirect to www location with subdirectory
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/directory/index.html [R=301,NC]
#Redirect from old domain to new domain with full path and query string:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*) http://www.newdomain.com%{REQUEST_URI} [R=302,NC]
#Redirect from old domain with subdirectory to new domain w/o subdirectory including full path and query string:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/subdirname/(.*)$
RewriteRule ^(.*) http://www.katcode.com/%1 [R=302,NC]
Rewrite and redirect URLs with query parameters (files placed in root directory)
Original URL:


Desired destination URL:


.htaccess syntax:
RewriteEngine on
RewriteCond %{QUERY_STRING} id=1
RewriteRule ^index\.php$ /path-to-new-location/? [L,R=301]
Redirect URLs with query parameters (files placed in subdirectory)
Original URL:


Desired destination URL:


.htaccess syntax:
RewriteEngine on
RewriteCond %{QUERY_STRING} id=1
RewriteRule ^sub-dir/index\.php$ /path-to-new-location/? [L,R=301]
Redirect one clean URL to a new clean URL
Original URL:


Desired destination URL:


.htaccess syntax:
RewriteEngine On
RewriteRule ^old-page/?$ $1/new-page$2 [R=301,L]
Rewrite and redirect URLs with query parameter to directory based structure, retaining query string in URL root level
Original URL:


Desired destination URL:


.htaccess syntax:
RewriteEngine On
RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA]
Rewrite URLs with query parameter to directory based structure, retaining query string parameter in URL subdirectory
Original URL:


Desired destination URL:


.htaccess syntax:
RewriteEngine On
RewriteRule ^/?category/([^/d]+)/?$ index.php?category=$1 [L,QSA]
Domain change – redirect all incoming request from old to new domain (retain path)
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example-old\.com$ [NC]
RewriteRule ^(.*)$ http://www.example-new.com/$1 [R=301,L]
If you do not want to pass the path in the request to the new domain, change the last row to:
RewriteRule ^(.*)$ http://www.example-new.com/ [R=301,L]
#From blog.oldsite.com -> www.somewhere.com/blog/
retains path and query, and eliminates xtra blog path if domain is blog.oldsite.com/blog/
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI}/ blog
RewriteRule ^(.*) http://www.somewhere.com/%{REQUEST_URI} [R=302,NC]
RewriteRule ^(.*) http://www.somewhere.com/blog/%{REQUEST_URI} [R=302,NC]

Source: https://gist.github.com/ScottPhillips/1721489

Google Material Design Bootstrap Theme

Material Design for Bootstrap is a theme for Bootstrap 3 which let you use the new Google Material Design in your favourite front-end framework.


Read more about Material Design for Bootstrap visiting the Github page.

Via Material Design for Bootstrap Theme

Bing Code Search for C# in Visual Studio

Ask a C# related question and get snippets inside your IDE.

Write your question as a special comment starting with three slashes ///. Your question may mention variables.Press the Tab key on the same line to get answers; press Enter to insert selected snippet.

via Bing Code Search for C# in Visual Studio.

Ben Powell is Microsoft .NET developer providing innovative solutions to common business to business integration problems. He has worked on projects for companies such as Dell Computer Corp, Visteon, British Gas, BP Amoco and Aviva Plc. He originates from Wales and now lives in Germany. He finds it odd to speak about himself in the third person.

%d bloggers like this: