MacBook Dual Boot

I recently replaced the Superdrive of my MacBook Pro with a regular HDD in order to add some disk space to my chronically full SSD. Installation went fine until I came to the point where I wanted to put Windows 7 on the new HDD: Windows simply refused to boot. I tried all sorts of rescue tools, boot managers, etc but no luck. Until I stumbled upon the following instructions in the Apple discussion forums:

  1. Insert Windows CD and boot to normal OSX.
  2. Run Boot Camp, partition your OSX drive and wait for it to reboot.
  3. When MacBook goes to reboot hold down power button until it shuts off.
  4. Swap out OSX drive in primary HDD location with purposed Windows HDD.
  5. Power on and delete all partitions, format and install Windows to new drive [Hold the option key on startup to boot from CD].
  6. I personally installed all updates and made sure Windows was running fine here. I was able to reboot and MacBook would power on straight into Windows. I could hold down option key and see the Superdrive and the Windows Drive.
  7. Take out Windows drive, replace with OSX and run Boot Camp and remove partition, shutdown.
  8. Take out Superdrive, move Windows into Superdrive with HDD Caddy, replace OSX back into original position.

Prerequisites: Regular OSX drive in drive bay 0, superdrive in drive bay 1 (=standard config), Windows 7 DVD

Weird right? But anyhow, this worked like a charm for me and I finally have a fully working dual boot system again. Oh, and on a side note: if you plan to share data between MacOS and Windows via a HDD partition, your best format option is probably going to be exFAT: Windows can’t read hfs+, MacOS can’t write NTFS and FAT32 has some nasty limitations like 4GB maximum file size.

WordPress Customization

After my work is done on XBox One game Ryse, I can finally invest some time in my blog again. Yay! For starters I have cleaned up the website code, as initially (due to time constraints) I had made all my changes directly to the wordpress source. Not a good idea, as these changes have to be painfully reapplied every time the software is updated.

Child Themes

A very convenient way to customize a wordpress site is the use of of child themes. The concept is simple: You create a new theme that inherits the settings of an existing theme and overwrite whatever you need to. To do so, simply create a folder for your theme in the wp-content/themes directory and put a file called style.css inside. Here’s the beginning of my style.css:

/*
 Theme Name:     Twenty Eleven Customized
 Author:         Theodor Mader
 Author URI:     http://theomader.com
 Template:       twentyeleven
 Version:        1.0.0
*/

@import url("../twentyeleven/style.css");

/* =Theme customization starts here
-------------------------------------------------------------- */

Note that the Theme Name and the Template entries are required. You can now overwrite the original theme’s styles by simply adding your code after the import statement.

Syntax Highlighter

I had also made quite some changes to the Syntax Highlighter Evolved plugin to better fit my blog’s style and contents. Fortunately the plugin is nicely customizable and with only a bunch of lines of code you can load a custom style sheet and custom syntax definitions.

In order to get a custom style sheet into syntax highlighter, you simply need to add a filter for syntaxhighlighter_themes and add the name of your style sheet the array of style sheets that gets passed in. Don’t forget to register your stylesheet with WordPress as well, for example via wp_register_style. Syntax definitions (or ‘brushes’ as they are called in Syntax Highlighter) can be added in a similar way via the syntaxhighlighter_brushes filter. Since these are java scripts they also need to be registered with WordPress via wp_register_script. For the sake of simplicity, I added the php code to functions.php of my child theme and do the script/style registration via the init action. Here’s the relevant code from my functions.php:

<?php
    
////////////// syntax highlighter customizations /////////////////

add_action( 'init', 'sh_register_customizations' );
add_filter( 'syntaxhighlighter_themes', 'sh_add_custom_style' );
add_filter( 'syntaxhighlighter_brushes', 'sh_add_custom_brushes' );
 
// Register with wordpress
function sh_register_customizations()
{
  $sh_customizations_uri = get_stylesheet_directory_uri() . '/syntaxhighlighter/';
    
  // customized sh style
  wp_register_style('syntaxhighlighter-theme-default_custom', $sh_customizations_uri . 'shCoreDefaultCustom.css', array('syntaxhighlighter-core'), '0.1');

  // custom sh brushes
  wp_register_script( 'syntaxhighlighter-brush-cg', $sh_customizations_uri . 'shBrushCg.js', array('syntaxhighlighter-core'), '0.1' );
  wp_register_script( 'syntaxhighlighter-brush-cppcustom', $sh_customizations_uri . 'shBrushCppCustom.js', array('syntaxhighlighter-core'), '0.1' );
  wp_register_script( 'syntaxhighlighter-brush-csharpcustom', $sh_customizations_uri . 'shBrushCSharpCustom.js', array('syntaxhighlighter-core'), '0.1' );
}

function sh_add_custom_style($themes)
{
  $themes['default_custom'] = 'Default Custom';
  return $themes;
}

function sh_add_custom_brushes( $brushes )
{
  $brushes['cg'] = 'cg';
  $brushes['cppcustom'] = 'cppcustom';
  $brushes['csharpcustom'] = 'csharpcustom';
 
  return $brushes;
}

?>

Oh, and here’s a neat trick I picked up on another website: You can expand the syntaxhighlighter code boxes by adding for example width: 150%; (on hover) and a transition like transition: width 0.2s ease 0s; to the .syntaxhighlighter style.

.syntaxhighlighter {
    transition: width 0.2s ease 0s;
}

.syntaxhighlighter:hover {
    width: 150% !important;
}

Note that this scales up the boxes by a fixed 150% instead of the exact required size but unfortunately I haven’t found a way do to the proper scaling without some form of scripting. You can toggle overflow: visible; on hover but so far I couldn’t figure out how to make this a smooth transition via css alone.

Links