Monthly Archives: August 2011

Book Review: Desirable Future: Consumer Electronics in Tomorrow’s World

Here’s a review I did on amazon.com for Desirable Future: Consumer Electronics in Tomorrow’s World.
Review

This is a thought provoking book that explores advances in complementary science, technology, medicine and engineering and how consumer electronics will change our society, our planet and our selfs.

This book covers almost every topic you could think of in terms of electronics.
Some of the discussed topics are the death of the PC, advancements in wired and wireless networks, Moore’s law, new types of CPUs and computing, Singularity, environmental impact from e-waste and manufacturing consumer electronics, and etc.

The author explains each topic well enough for most people to understand.
Two themes that are echoed throughout the book are that future devices will be smaller, faster and mostly wireless while using less power. Also, socialites will become heavily dependent on technology to function.

I enjoyed reading “Desirable Future” but was left wondering who Jack Challoner was and how he knows so much, until I opened the back cover. It turns out that Jack Challoner has written more than 30 books and is a consultant science editor for books, magazines, science activity packs and Cd-ROMs.

I recommend this book for anyone fascinated with technology.

Video: Future Technology (2020)

Larry Battle

I love to program, and discover new tech. Check out my stackoverflow and github accounts.

More Posts - Website

Follow Me:
Twitter

How to remember anything

How to remember anything

Larry Battle

I love to program, and discover new tech. Check out my stackoverflow and github accounts.

More Posts - Website

Follow Me:
Twitter

Code of the day: Javascript convert bytes to KB, MB, GB, etc

Note: This uses the IEC standard. That means 1 KB = 1024, not 1000 like the SI standard.

/**
* @function: getBytesWithUnit()
* @purpose: Converts bytes to the most simplified unit.
* @param: (number) bytes, the amount of bytes
* @returns: (string)
*/
var getBytesWithUnit = function( bytes ){
	if( isNaN( bytes ) ){ return; }
	var units = [ ' bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB' ];
	var amountOf2s = Math.floor( Math.log( +bytes )/Math.log(2) );
	if( amountOf2s < 1 ){
		amountOf2s = 0;
	}
	var i = Math.floor( amountOf2s / 10 );
	bytes = +bytes / Math.pow( 2, 10*i );
 
	// Rounds to 3 decimals places.
        if( bytes.toString().length > bytes.toFixed(3).toString().length ){
            bytes = bytes.toFixed(3);
        }
	return bytes + units[i];
};

Output:

console.log( getBytesWithUnit( ) );			// returns undefined.
console.log( getBytesWithUnit( 'non a number.' ) );	// returns undefined.
console.log( getBytesWithUnit( '123' ));		// returns '123 bytes'.
console.log( getBytesWithUnit( 1024 ));		// returns '1 KB'.
console.log( getBytesWithUnit( (1024 * 1024) + 1024 )); // returns '1.001 MB'.
console.log( getBytesWithUnit( 1024 * 1024 * 1024 )); // returns '1 GB'.
console.log( getBytesWithUnit( 1024 * 1024 * 64 )); // returns '64 MB'.

Update
I updated the script to support both the SI and IEC standard.
Check it out here http://bateru.com/news/2012/03/code-of-the-day-converts-bytes-to-unit/

Larry Battle

I love to program, and discover new tech. Check out my stackoverflow and github accounts.

More Posts - Website

Follow Me:
Twitter

Code of the day: Check to see if a element has a event.

// hasEvent checks to see if a element contains a event.
// @requires jQuery 1.3.2+
// @params el: string, jQuery object, node element.
// @params eventName: string, name of the event.
// @returns boolean
var hasEvent = function( el, eventName ){
	if( !$( el ).length || !$( el ).data( 'events' ) ){
		return false;
	}
	return !!$( el ).data( 'events' )[ eventName ];
};

Demo: (requires firebug or google chrome)

var el = $( '<div/>' ).click( $.noop );
console.clear();
console.log( hasEvent( el, 'click' ) );// returns true;
 
console.log( hasEvent( el, 'focusNow' ) );// returns false;
el.bind( 'focusNow', $.noop );
console.log( hasEvent( el, 'focusNow' ) );// returns true;
 
console.log( hasEvent( document.body, 'onload' ) );// returns false;
$(document.body).bind( 'onload', $.noop );
console.log( hasEvent( document.body, 'onload' ) );// returns true;

Larry Battle

I love to program, and discover new tech. Check out my stackoverflow and github accounts.

More Posts - Website

Follow Me:
Twitter