Updating my MacBook Pro from HDD to Crucial m4 SSD using Time Machine and Mac OS X Lion

Finally I upgraded my Mid 2010 MacBook Pro with a nice Crucial m4 SSD with 512GB. I was thinking about changing my hard drive for month but now the price dropped from 600 to 400 EUR and I went for it.

It took a little while to collect relevant informations so I want to share a workflow:

  1. Backup your complete system with time machine!
  2. Swap your drives (ifixit.com) without touching your battery.
  3. Check if your SSD runs the newest firmware and upgrade if necessary.
  4. Boot from your OS X Lion recovery partition (hold ALT key on Mac startup).
  5. Use the disk utility to restore from time machine.
  6. Go outside or hang out with friends or family!
  7. Enable trim support in OS X Lion for your SSD.

Done.

Since a couple of days it really makes fun using my MacBook Pro again. It dropped packaging time for a 1,5 GB big IPA file with ADT from 12 to almost 6 minutes. This is a huge benefit, so if you’re still using normal HDDs for daily work I recommend switching to SSD as soon as possible!

UPDATE – added xbench results:

Name Score Detail
System Info    
  Xbench Version   1.3
  System Version   10.7.4 (11E53)
  Physical RAM   8192 MB
  Model   MacBookPro6,2
  Drive Type   M4-CT512M4SSD2
Disk Test 409.65  
Sequential 253.88  
  Uncached Write 405.78 249.14 MB/sec [4K blocks]
  Uncached Write 324.52 183.61 MB/sec [256K blocks]
  Uncached Read 128.80 37.69 MB/sec [4K blocks]
  Uncached Read 408.86 205.49 MB/sec [256K blocks]
Random 1060.10  
  Uncached Write 1452.92 153.81 MB/sec [4K blocks]
  Uncached Write 608.33 194.75 MB/sec [256K blocks]
  Uncached Read 2231.07 15.81 MB/sec [4K blocks]
  Uncached Read 1007.15 186.88 MB/sec [256K blocks]

Set WP-Syntax tab width

Since I’m using the WP-Syntax plug-in on my blog I tried to optimize font size and the tab width. Like a lot of developers I heavily use tabs in my source code. These tabs are really wide within the browser so I was looking for a way to minimize the used space.

I’m not a CSS guy but it seems like there is no way to set a specific tab width. So why not replace the tab with white space?

My change to wp-syntax/wp-syntax.php:

function wp_syntax_highlight($match)
{
    global $wp_syntax_matches;
 
    $i = intval($match[1]);
    $match = $wp_syntax_matches[$i];
 
    $language = strtolower(trim($match[1]));
    $line = trim($match[2]);
    $escaped = trim($match[3]);
    $code = wp_syntax_code_trim($match[4]);
 
    // INSERT JUST THIS LINE OF CODE
    $code = str_replace ( '\t' , '   ' , $code );
    .
    .
    .

Amazing Math Tutorial Video Site

I really need to quote this bit-101 blog post.
It’s the first time I heard about that great website:

http://www.khanacademy.org/

I don’t have much more to say about this. Do you need to learn or brush up on any subject related to math? You will find a wealth of data here in a massive number of videos, each 10 minutes or under. Seriously, anything you want to learn is here, from the basics to advanced calculus. Where does this guy find the time?

I got the link from Brook Andrus’ site, where she gives a bit more info on the author. Pretty amazing guy.

http://www.brooksandrus.com/blog/2010/10/01/the-wrath-of-khan-the-genesis-of-21st-century-education

UPDATE: There’s another one: http://patrickjmt.com/

FFK10 – Flashforum conference notes

Every year I spend two days sitting in the audience of the Flashforum conference (FFK) listening to great speakers and getting impressed by their experiments and thoughts. It’s also a good way to renew some of the basic knowledge in Flash development and of course to meet some friends in the Flash scene.

So this are most of my notes:

Flash / Flex development:

  • Jessee Freemans Flash Augmented Reality Debug Tool provides an easy way to start with augmented reality development.
  • Use stunning Hype-Framework effects.
  • Dive into dynamic sound generation with André Michelles Audio-Sandbox.
  • Have a look at the PushButton-Engine for component based development.
  • Remember that Flex 4 includes a lot of performance features! It’s highly recommended to switch as soon as possible. For example the Embed-tag reduces PNG file size and lots of improvements are made within the Flex components.
  • Watch the Adobe TV video preview: Flex for mobile devices
  • See Christian Cantrell’s blogpost One Application , Five Screens (Including the iPad)
  • Great tip: ByteArray.org – Why cacheAsBitmap is bad
  • Adobe’s Mobile Development Guide for the Flash platform (applies also to desktop applications) contains performance tips like:

    • DisplayObject.width / height should be divisible by 2 as often as possible
    • Try to avoid Events and / or stop propagation as soon as possible
    • Set DisplayObject.mouseEnabled=false if possible
    • Stop MovieClip animations when removed from stage
    • Use TextField.opaqueBackground=true if possible
    • Use final statement (final class ClassName {})
    • Use BitmapData.get / setVector()

HTML / JavaScript basics:

  • Use “Sprites” with HTML / CSS (load only one bitmap graphic containing all the asset images for your page and show only the particular relevant parts) and preload next page assets using AJAX while your current page is idle.
  • Since usually only 2 simultaneous domain http requests are supported by browsers it’s a good practice to distribute contents from various ip addresses (use asset-servers for example).
  • Load only visible parts of your site using JavaScript viewport events.

Useful workflow utils:

Embed fonts with Adobe Flash IDE

Almost every Flash project needs some embedded fonts and it is a good practice to compile the fonts into a separate SWF file. So here is a simple way to create a file that contains only embedded fonts. The SWF file will also show the exact internal font names:

  1. Copy and paste the ActionScript code below into the first keyframe of your timeline.
  2. Create new fonts in flash library and export them for ActionScript.
    A good tutorial can be found here.
  3. Run ONLY the code for step 2 to evalute and trace the exact font names.
  4. Assign the exact font names to the actual library symbols and their export class name.
  5. Run ONLY the code for step 4 to export the swf.
Security.allowDomain( "*" );
 
// Step 1: Create new fonts in flash library
//         and select "Export for ActionScript".
 
 
// Step 2: Run ONLY this code to evalute and trace the exact font names.
/**/
var embeddedFonts : Array = Font.enumerateFonts ( false );
var c : uint = embeddedFonts.length;
for ( var i : uint = 0; i < c; i++ )
{
	var font : Font = embeddedFonts[ i ] as Font;
	var className : String = font.fontName.split( " " ).join( "" );
 
	var lowerFontStyle : String = font.fontStyle.toLowerCase();
	if ( lowerFontStyle.indexOf( "bold" ) != -1 ) className += "Bold";
	if ( lowerFontStyle.indexOf( "italic" ) != -1 ) className += "Italic";
 
	trace( className );
}
/**/
 
// Step 3: Assign the exact font names to the actual
//         library symbols and their export class name.
 
 
// Step 4: Export the swf using ONLY this code. 
/**/
var posX : int = 10;
var posY : int = 10;
 
var embeddedFonts : Array = Font.enumerateFonts ( false );
	embeddedFonts.sortOn( "fontName", Array.CASEINSENSITIVE );
 
var c : uint = embeddedFonts.length;
for ( var i : uint = 0; i < c; i++ )
{
	var font : Font = embeddedFonts[ i ] as Font;
 
	var lowerFontStyle : String = font.fontStyle.toLowerCase();
 
	var textFormat : TextFormat = new TextFormat();
		textFormat.bold = ( lowerFontStyle.indexOf( "bold" ) != -1 );
		textFormat.italic = ( lowerFontStyle.indexOf( "italic" ) != -1 );
		textFormat.font = font.fontName;
		textFormat.size = 14;
 
	var className : String = font.fontName.split( " " ).join( "" );
	if ( textFormat.bold ) className += "Bold";
	if ( textFormat.italic ) className += "Italic";
 
	Font.registerFont( Class( getDefinitionByName( className ) ) );
 
	var boldItalic : String = "";
	if ( textFormat.bold && textFormat.italic )
	{
		boldItalic = "( needs to be BOLD and ITALIC ! )";
	}
	else if ( textFormat.bold )
	{
		boldItalic = "( needs to be BOLD ! )";
	}
	else if ( textFormat.italic )
	{
		boldItalic = "( needs to be ITALIC ! )";
	}
 
	var textField : TextField = new TextField();
		textField.autoSize = TextFieldAutoSize.LEFT;
		textField.defaultTextFormat = textFormat;
		textField.embedFonts = true;
		textField.text = font.fontName + "\t" + boldItalic;
		textField.x = posX;
		textField.y = posY;
 
	posY += textField.height + 5;
 
	addChild( textField );
}
/**/

URLRequest with HTTP authentication

I found a good explanation how to support HTTP authentication with URLRequests here.

That’s the most interesting part:

Best I can tell, for some reason, this only works where request method is POST; the headers don’t get set with GET requests.

Interestingly, it also fails unless at least one URLVariables name-value pair gets packaged with the request, as indicated above. That’s why many of the examples you see out there (including mine) attach “name=John+Doe” — it’s just a placeholder for some data that URLRequest seems to require when setting any custom HTTP headers. Without it, even a properly authenticated POST request will also fail.

You’ll almost surely have to modify your crossdomain.xml file to accommodate the header(s) you’re going to be sending. In my case, I’m using this, which is a rather wide-open policy file in that it accepts from any domain, so in your case, you might want to limit things a bit more, depending on how security-conscious you are:

<?xml version="1.0"?>
<cross-domain-policy>
    <allow-access-from domain="*" />
    <allow-http-request-headers-from domain="*" headers="Authorization" />
</cross-domain-policy>

… and that seems to work; more information on this one is available from Adobe here).

Apparently, Flash player version 9.0.115.0 completely blocks all Authorization headers (more information on this one here), so you’ll probably want to keep that in mind, too.

So this little code snippet explains the basics:

// Base64Encoder contained in Flex SDK
import mx.utils.Base64Encoder;
 
// Encode username and password
var base64Encoder : Base64Encoder = new Base64Encoder();        
    base64Encoder.encode( "username:password" );
 
// Create authorization request header
var urlRequestHeader : URLRequestHeader = new URLRequestHeader( "Authorization", "Basic " + base64Encoder.toString() );
 
// URLRequest setup
var urlRequest : URLRequest = new URLRequest( "url" );        
    // Needs to send some data!!        
    urlRequest.data = new URLVariables( "name=John+Doe" );        
    // Only supported with POST method!!        
    urlRequest.method = URLRequestMethod.POST;        
    // Apply authorization request header        
    urlRequest.requestHeaders = new Array( urlRequestHeader );

How to embed everything in a Word.doc

This summer I was getting crazy because I couldn’t find out how to embed all graphics within a Word document.

The idea behind this simply was to bring loads of XML data into Word documents. So I decided to automatically create HTML data out of the XML, open it in Word and save it with all it’s images and related stuff as one single file.

This german forum helped me. The solution is quite simple:

  • CTRL (or Apple) + A
  • CTRL (or Apple) + SHIFT + F9
  • CTRL (or Apple) + S

Microsoft documentations – pff.

Additional Links:
Word Shortcut Keys
Fields in MacWord