Book Review: Crucible of Gold by Naomi Novik

Crucible of Gold is the latest book in the fantastic Temeraire series by Naomi Novik.

The series is a historical account of the Napoleonic war with a nice fantasy twist: dragons exist. What follows is an epic story around Temeraire and his Captain, Will Laurence, as they combat Napoleon and travel around the world seeking allies. Part of the concept is that dragons exist, can speak human languages, and form a special bond with specific humans. Britian’s Aerial Corps assign a captain to each dragon, who stays with them for life. Laurence, as a Naval Captain, discovers a dragon egg on a captured ship and when it hatches, the new dragon Temeraire picks Laurence as his Captain.

Naomi Novik’s beloved series returns, with Capt. Will Laurence and his fighting dragon Temeraire once again taking to the air against the broadsides of Napoleon’s forces and the friendly—and sometimes not-so-friendly—fire of British soldiers and politicians who continue to suspect them of divided loyalties, if not outright treason.

 

For Laurence and Temeraire, put out to pasture in Australia, it seems their part in the war has come to an end just when they are needed most. Newly allied with the powerful African empire of the Tswana, the French have occupied Spain and brought revolution and bloodshed to Brazil, threatening Britain’s last desperate hope to defeat Napoleon.

The book starts with a summons from an old friend, Arthur Hammond, reinstating Laurence as a proper Captain and sending them to Rio to help with the war and prevent Napoleon from gaining more allies. As per usual, their plans go wrong, they lose a number of friends, and discover things are a lot worse than they can imagine. The story takes a number of twists and turns that you don’t see coming, and keeps you wanting more right to the end.

I first found Temeraire in a bookshop down the coast when I was after a new book to read. Since I love stories about dragons, it quickly became a favourite and I’ve loved the series ever since. It brings a new twist to the dragon story, and the personality each of the dragons has is unique and entertaining.

I highly recommend anyone who enjoys fantasy, dragons, or even (Napoleonic) history,  to read this series. You won’t be disappointed!

Rating: 5/5

Book Details:
Title: Crucible of Gold
Series: Temeraire
Author: Naomi Novik
Links: Official WebsiteKindle EditionShelfari

Automatic Javascript Minification in Zend Framework

I recently wrote Integrating LESS with Zend Framework the easy way, in which I outlined a simple way to automatically compile LESS into CSS during development in a Zend Framework application, so it can be saved and deployed with little effort. The next logical step is to automatically minify Javascript using the same method, to make it easy to deploy too.

First up, I am going to assume that you do your Zend Framework development with the ‘APPLICATION_ENV = development‘ flag, and you deploy with ‘APPLICATION_ENV = production‘. Without these flags set, this trick won’t work.

Step One

Decide where your raw Javascript files are going to live, and where the minified output will be saved. In my case, I used ./public/js/ and ./public/js/script.js. Once you have these worked out, you can add it to your HTML:

<script src="<?php echo $this->baseUrl("/js/script.js"); ?>"></script>

Step Two

We need to add an _init function into the Bootstrap class which will be triggered on each page load.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
 * Minify the Javascript using JShrink
 *
 * @link: https://github.com/tedivm/JShrink
 */
protected function _initJShrink()
{
    /**
     * It should already be minified in production!
     */
    if (APPLICATION_ENV == "production") {
        return;
    }
 
    /**
     * Import the JShrink library, after checking our ENV
     *  since we don't need it if the file is already minified 
     */
    include APPLICATION_PATH."/../library/JShrink/src/JShrink/Minifier.php";
 
    /**
     * Define the files we wish to Minify
     */
    $sDir    = APPLICATION_PATH."/../public/js/";
    $aInputs = Array(
        "jquery.min.js",
        "bootstrap-transition.js",
        "bootstrap-alert.js",
        "bootstrap-modal.js",
        "bootstrap-dropdown.js",
        "bootstrap-scrollspy.js",
        "bootstrap-tab.js",
        "bootstrap-tooltip.js",
        "bootstrap-popover.js",
        "bootstrap-button.js",
        "bootstrap-collapse.js",
        "bootstrap-carousel.js",
        "bootstrap-typeahead.js",
        "custom.js",
    );
    $sOutput = "script.js";
 
    /**
     * Open the JS files and minify contents
     */
    $sInput = "";
    foreach ($aInputs as $sFile) {
        $sFile    = file_get_contents($sDir.$sFile);
        $aOptions = array('flaggedComments' => false);
        $sInput  .= JShrink\Minifier::minify($sFile, $aOptions)."\n";
    }
 
    /**
     * Save the Contents into the output file
     */
    file_put_contents($sDir.$sOutput, $sInput);
}

Step Three

That is it.

You will need to update the files list every time you add/remote a Javascript file, since it doesn’t automatically import like LESS, but it’s still basically automatic. Easy!

March 29, 2012Permalink 1 Comment

I would use Rhythmbox if…

I used Rhythmbox a few Ubuntu releases ago when it was the default media player. It was nice and fast, and got the job done. Then Ubuntu switched over to Banshee for 11.04, I gave it a try. My overall impression was that Banshee suffered big time from the mono stack, it was slow and resource intensive when managing a large media library.

But I stuck with Banshee for a couple of useful features:

  • Automatic media organising – Banshee automatically renames files to keep your media folder clean.
  • Song ‘Score’ based off skip count, number of plays, etc. – Identifies the songs you enjoy most, to make the random play list more intelligent.

Now that Rhythmbox is set to become the new default media player in 12.04, I went looking for my favourite features to switch back… but they aren’t there.

I’m sticking with Banshee for now.

Encrypted Home directories + SSH Key Authentication

Encrypted Home directories + SSH Key Authentication

There is an interesting it-makes-sense-when-you-think-about-it issue with Encrypted Home directories and SSH key authentication I’ve recently discovered in Ubuntu (it will affect any distro though). Since Encrypted home directories aren’t decrypted until the login is successful, and your SSH keys are stored in your home directory, the first SSH connection you make will require a password. If you have password authentication turned off, you’ll have big issues.

I found a question on Super User which explains solutions to this issue. My solution follows closely on this answer, although I have added in a symbolic link to make it easier to manage.

1. Create .ssh folder in /home for the keys to be stored

sudo mkdir /home/.ssh

2. Move existing authorized_keys file into .ssh dir as username

sudo mv ~/.ssh/authorized_keys /home/.ssh/username

3. Create symbolic link to authorized_keys file in user .ssh dir

ln -s /home/.ssh/username ~/.ssh/authorized_keys

4. Update sshd config file to set the new path for the authorized_keys file

sudo vim /etc/ssh/sshd_config

Change the AuthorizedKeysFile line to:

AuthorizedKeysFile      /home/.ssh/%u

5. Reboot the computer

sudo shutdown -r now

6. Login to your server and you shoud be presented with a minimal un-decrypted home directory… You will need to create and edit a .profile file in there to get ecryptfs to mount your home directory.

sudo vim ~/.profile

Add these lines:

ecryptfs-mount-private
cd /home/username

7. Log out/Restart, and go back in again. You should be promoted for your password after SSH key auth, and then be presented with your decrypted home directory.

You should now be able to login using SSH keys every time, no matter if your home dir is decrypted or not :-)

March 17, 2012Permalink 1 Comment

Playing with WordPress Themes

The styles of my blog may be a bit weird for a few hours…

I’m playing with new themes, trying to get a look and feel that I like.