I use Google Reader, and share the stuff that I want people to think I'm interested in ;)
Prepare to have your mind blown.
Certain dinosaurs—physically disparate enough that we've always thought of them as different species—may actually be the same animal at different stages of its life cycle. Also: Those big, protective-looking bone formations surrounding some dinos' heads and necks probably weren't all that useful as a defense against predators.
Case in point, triceratops. Or, maybe we should be calling it torosaurus now, I'm not sure. See, according to research done by scientists at Montana's Museum of the Rockies, the familiar triceratops is really just the juvenile form of the more-elaborately be-frilled and be-horned torosaurus.
This extreme shape-shifting was possible because the bone tissue in the frill and horns stayed immature, spongy and riddled with blood vessels, never fully hardening into solid bone as happens in most animals during early adulthood. The only modern animal known to do anything similar is the cassowary, descended from the dinosaurs, which develops a large spongy crest when its skull is about 80 per cent fully grown.
Scannella and Horner examined 29 triceratops skulls and nine torosaurus skulls, mostly from the late-Cretaceous Hell Creek formation in Montana. The triceratops skulls were between 0.5 and 2 metres long. By counting growth lines in the bones, not unlike tree rings, they have shown clearly that the skulls come from animals of different ages, from juveniles to young adults. Torosaurus fossils are much rarer, 2 to 3 metres long and, crucially, only adult specimens have ever been found. The duo say there is a clear transition from triceratops into torosaurus as the animals grow older. For example, the oldest specimens of triceratops show a marked thinning of the bone where torosaurus has holes, suggesting they are in the process of becoming fenestrated.
There are other species this might apply to, as well. Some with even bigger shifts in appearance.
While this is a Big Hairy Deal for dinosaur science, it also elicits a little bit of a "duh" moment when you go back and look at the animals in question. What you should really be getting out of this story is an illustration of how difficult it is to study a creature that's been extinct for millions of years.
After all—as my husband pointed out—nobody would be shocked to learn that a baby chick, an adult chicken, and plate of parmigiana were all the same animal. But that's because we've experienced chickens. Were an alien to drop in on Earth for one afternoon, they might be just as amazed at the life cycle of poultry as we are now at the triceratops/torosaurus'. Paleontologists are tasked with reconstructing the lives of animals nobody has ever seen alive. And that creates a world where the obvious just isn't.
New Scientist: Morph-o-saurs: How shape-shifting dinosaurs deceived us
(Via John Taylor Williams)
Image courtesy Flickr user lindseywb, via CC
Posted on 29 July 2010 | 3:19 pm
Oscar, a three-year old British cat, has joined the rarefied ranks of bionic animals. After a horrifying accident chopped off his hind legs, Oscar has gotten a second lease on life through two bionic leg implants.The provisional headline for this post was "Oscar Purrstorius" Bionic Cat Walks on Prosthetic Legs [Wired via Gizmodo]
Posted on 25 June 2010 | 7:33 pm
Years ago, CSS browser support was patchy and buggy, and only daring web designers used CSS for layouts. Today, CSS layouts are commonplace and every browser supports them. But the same can't be said for CSS3 and HTML5. That's where Faruk Ateş’s Modernizr comes in. This open-source JavaScript library makes it easy to support different levels of experiences, based on the capabilities of each visitor’s browser. Learn how to take advantage of everything in HTML5 and CSS3 that is implemented in some browsers, without sacrificing control over the user experience in other browsers.
Posted on 22 June 2010 | 2:00 am
National Geographic has a gallery of vintage national park posters from the 1930s.
Created in the mid-1930s in response to the Great Depression, the Works Progress Administration and its Federal Arts Project were focused in part on providing artwork for public buildings while assisting struggling artists. Artists were tasked with creating posters that promoted the landscapes and wildlife of America's parks. The program ended in 1943, and the largest collection of WPA-era prints--including the selection in this gallery--is now in the Library of Congress.
Photo gallery: Vintage U.S. Park Posters [National Geographic]
![]()
Posted on 16 June 2010 | 8:48 am
The CSS standard states that borders and padding should be applied on top of the specified width of an element. As such, if I have a 200px div, and apply 40px worth of borders and padding, total, the width will then be 240px. This makes perfect sense; however, Internet Explorer actually did things differently. They adopted a model where the maximum width is what you specified. The borders and padding are then factored into that width, reducing the content area. As a result, the width of the element never exceeds the stated width of 200px.
As we mostly work with extremely sensitive floated layouts, where even the addition of a 1px border can break the design, I wonder: did Internet Explorer get it right?
“The box-sizing CSS property is used to alter the default CSS box model used to calculate widths and heights of elements. It is possible to use this property to emulate the behavior of browsers that do not correctly support the CSS box model specification.”
This means that, if you should decide that you want to mimic Internet Explorer’s original interpretation of the box model, you can. The default value for box-sizing is “content-box.” This simply means that the width and height of an element do not include the borders and padding (or margins).
By changing this value to “border-box,” the width and height values then include the borders and padding.
#box {
width: 200px;
height: 200px;
background: red;
padding: 10px;
border: 10px solid black;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
Because we’ve declared box-sizing with a value of “border-box,” the final width of the #box element, styled above, will be 200px.
Especially for floated layouts, this can save you a lot of headaches! But with that said, I’m still undecided. What are your thoughts on Internet Explorer’s interpretation of the box model?
Posted on 11 June 2010 | 9:32 am
Everything you wanted to know about web fonts but were afraid to ask. Richard Fink summarizes the latest news in web fonts, examining formats, rules, licenses, and tools. He creates a checklist for evaluating font hosting and obfuscation services like Typekit; looks at what’s coming down the road (from problems of advanced typography being pursued by the CSS3 Fonts Module group, to the implications of Google-hosted fonts); and wraps it all up with a how-to on making web fonts work today.
Posted on 8 June 2010 | 2:00 am
“At the heart of every location-based application is positioning and geolocation. In this tutorial you will learn the geolocation capabilities of HTML5 and the basic principles needed to take advantage of them in your next HTML5 app!”
Nettuts+ sister site Mobiletuts+ has just posted a fantastic entry-level tutorial on using HTML5 for Geolocation with your mobile web app. If you’re interested in HTML5 and mobile development for mobile devices, make sure to check out the tutorial!
( Continue Reading at Mobiletuts+ )
Posted on 3 June 2010 | 6:38 am
It’s nothing to be ashamed of: you probably don’t write perfect JavaScript the first time. While debugging JavaScript is usually done manually, today’s quick tip will teach you how to use JSLint, a tool for catching JavaScript bugs. Think of it as spell-check for JavaScript.
Here’s Wikipedia’s definition of a Lint program:
In computer programming, lint was the name originally given to a particular program that flagged some suspicious and non-portable constructs (likely to be bugs) in C language source code. The term is now applied generically to tools that flag suspicious usage in software written in any computer language.
JSLint is one such program for JavaScript, written by Douglas Crockford (of course). You hand it your JavaScript and it let’s you know what to fix.
After you head over the JSLint Website, the first step is to choose the practices you want to enforce; you can choose the Crockford-recommend settings by clicking the “Good Parts” button.

Then, paste in your JavaScript and hit the JSLint button. If you’re code is less than perfect, you’ll get a list of errors to fix.

(function () {
var anObject = {};
var anElem = document.getElementById("wrap");
var aString = "This is a string"
if (aString === "This is a string") {
anotherString = aString;
}
function person(name, age) {
this.name = name;
this.age = age;
}
var aPerson = new person("John", 25);
}());
/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */
"use strict";
(function () {
var anObject = {}, aPerson, anotherString,
anElem = document.getElementById("wrap"),
aString = "This is a string";
if (aString === "This is a string") {
anotherString = aString;
}
function Person(name, age) {
this.name = name;
this.age = age;
}
aPerson = new Person("John", 25);
}());
This page explains in depth the concepts behind JSLint. Thanks for reading and watching!
Posted on 1 June 2010 | 9:07 am
Magento is a stunningly powerful e-commerce platform. In this miniseries, we’ll learn how to get started with the platform, getting to know the terminologies, setting up a store and all related aspects of it and finally learn how to customize it to make it our very own.
In this fourth part, we’ll lay the groundwork for our theme which we’ll be building completely from scratch. Excited? Let’s get started!
In the last parts, we learned how to get your Magento store from installed to ready for deployment including how to set up your products, product categories, taxes, shipping, payment gateways and many more.
We also took a look at the basics of Magento theming. We learnt the general idea behind Magento themes, the various terminologies behind it and the basic structure of a theme.
Our goal for building this theme is fairly straightforward: to practically understand how to build a Magento theme. With that in mind, I’m going to keep the theme as simple as possible.
Since the Magento coding process is reasonably complicated for someone used to WordPress, we’re going to take it extremely slow. Today, we’ll build just the core part our theme, the skeleton that gets used in each view of the site. I’ll also explain the general principle behind the process so we can move on to each individual view in future parts.
The source files, both the front end and back end, are included but try to not use it just yet. We’ll be defining just the core parts without defining what content is to be displayed, how it should be displayed and where the content is to be pulled from. So, if you try to use this right now, you’re going to see a bunch of gibberish since Magento pulls in all absent files from its default theme thus completely ruining our look. So my advice is, wait for a bit.

The basic template looks like so. We have a generic logo up top along with a simple menu which lets the user access his account, wish list and cart along with letting him checkout or logout.
Below that, we have a utility bar that contains a breadcrumb style navigation to let the user know the contextual hierarchy of the site. We also let the user search through our store through the search input on the right.
The content area is currently empty since its contents will vary depending on which view Magento is loading. So we’ll keep is empty for now and handle it later when we’re building each individual page.
The footer is fairly generic with a link to report bugs and copyright information.
We’ll first look at the HTML for the theme’s skeleton. I’m assuming you’re fairly fluent in HTML and CSS so I’ll skip to the more important parts.
<!-- Lumos!--> <!DOCTYPE html> <html lang="en-GB"> <head> <title>Cirrus - Magento Theme</title> <link rel="stylesheet" href="css/cirrus.css" /> </head> <body> <div id="wrapper" class="border"> <div id="header"> <div id="logo"><img src="images/logo.gif" /></div> <div id="hud"> <h3>Welcome, Sid</h3> <ul class="links"> <li><a href="#" title="My Account">My Account</a></li> <li ><a href="#" title="My Wish list">My Wish list</a></li> <li ><a href="#" title="My Cart">My Cart</a></li> <li ><a href="#" title="Checkout">Checkout</a></li> <li><a href="#" title="Log Out" >Log Out</a></li> </ul> </div> </div> <div id="utilities"> <div id="breadcrumbs">Home » State of Fear</div> <div id="header-search"><input type="text" class="border" value="Search our store" /></div> </div> <div id="content" class="product"> <h1>Content here</h1> </div> <div id="footer" class="border"> Help Us to Keep Magento Healthy - Report All Bugs (ver. 1.4.0.1) © 2008 Magento Demo Store. All Rights Reserved. </div> </div> </body> </html>
First up, note that I’ve wrapped everything under a wrapper div to make it easier to manage things. Also note that the header, content and footer section get their individual blocks.
The search input is fairly useless at this point. We’ll hook it up properly during when we’re integrating with Magento. Same with the various links. Currently, I’ve put them there as placeholders. Once we dig into Magento, we’ll get them working.
* {
margin: 0;
padding: 0;
border: none;
outline: none;
color: #333;
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 14px;
list-style: none;
line-height: 1.3em;
}
a {
color : #7db000;
}
h1, h2, h3, h4 {
font-weight: normal;
}
h1 {
font-size: 32px;
margin-bottom: 10px;
}
h2 {
font-size: 24px;
margin: 10px 0 12px 0;
}
h3 {
font-size: 20px;
margin-bottom: 5px;
}
h4 {
font-size: 20px;
}
.border {
border: 1px solid #666;
}
/* Base Elements */
#wrapper {
width: 920px;
margin: 10px auto;
padding: 20px;
}
#header {
margin: 0 0 20px 0;
overflow: auto;
}
#content {
margin: 20px 0;
overflow: auto;
}
#footer {
padding: 10px;
border: 1px solid #E1E1E1;
background: #F3F3F3;
text-align: center;
}
/* Header content */
#logo {
float: left;
}
#hud {
float: right;
width: 320px;
height: 50px;
padding: 10px;
border: 1px solid #E1E1E1;
background: #F3F3F3;
}
#hud li a {
float: left;
font-size: 12px;
margin: 0 10px 0 0;
}
#utilities {
clear: both;
margin: 20px 0;
overflow: auto;
padding: 7px 10px;
border: 1px solid #E1E1E1;
background: #F3F3F3;
}
#breadcrumbs {
float: left;
}
#header-search {
float: right;
}
Nothing fancy here. Very basic CSS to place the elements in position and style it just a tiny bit. Let’s move on.
This part is a little tricky so stay with me here. Magento uses XML files to handle a page’s layout and also to define which elements are available to be rendered. The aim is that instead of mucking around with arcane code, you can just edit the XML file and be done with it without worrying about dependencies.
Each view/screen/module gets its own XML file along with a master file to define the general layout of the site. That master file is the page.xml file we’re going to create now.
The complete file for today looks like so. I’ll explain each bit part by part below.
<?xml version="1.0"?>
<layout version="0.1.0">
<default translate="label" module="page">
<label>All Pages</label>
<block type="page/html" name="root" output="toHtml" template="page/1column.phtml">
<block type="page/html_head" name="head" as="head">
<action method="addCss"><stylesheet>css/cirrus.css</stylesheet></action>
</block>
<block type="page/html_header" name="header" as="header">
<block type="page/template_links" name="top.links" as="topLinks"/>
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
<block type="core/template" name="top.search" as="topSearch"/>
</block>
<block type="core/text_list" name="content" as="content"/>
<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml"/>
</block>
</default>
</layout>
Disregard the initial XML and layout version declarations. They’re of no significance to us now.
<block type="page/html" name="root" output="toHtml" template="page/1column.phtml">
First, we create a master block for all the data. Consider this the equivalent of the wrapper DIV element we used in our HTML. Next, we instruct it to use page/1column.phtml as the template for our page. Don’t worry, we haven’t created the file yet. We’ll do so later in this tutorial.
<block type="page/html_head" name="head" as="head">
<action method="addCss"><stylesheet>css/cirrus.css</stylesheet></action>
</block>
Next, we define the elements to be included in the head section of the page. Magento, by default, includes a load of CSS and JS files but we won’t be requiring any of their functionality today. So, we’ll just include our CSS file.
<block type="page/html_header" name="header" as="header">
<block type="page/template_links" name="top.links" as="topLinks"/>
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
<block type="core/template" name="top.search" as="topSearch"/>
</block>
We’re defining what goes into the header of our site. We want the menu/links at the top as well as the breadcrumbs and the search.
<block type="core/text_list" name="content" as="content"/>
We’ll need the content part, of course, so we’re including the content part. We won’t define anything about this section here since Magento just loads up all the necessary content into this block.
<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml"/>
And finally, we’ve included our footer. We also tell Magento where to load its template from.
You’re probably wondering why we specify a template path for some blocks whilst omitting it for others. It’s a rather higher level topic but did you note that each block has a type attribute? When it’s type matches one of those predefined by Magento, you need not specify a template. It’s auto loaded. Nifty, no?
And with this, our base page.xml file is complete.
Ok, now that we’ve specified our layout we can move on to creating the 1column.phtml file that we specified in the XML earlier.
This file is nothing but a skeleton template which calls in the header, content area and footer as needed. Our file looks like so:
<!-- Lumos!--> <!DOCTYPE html> <html lang="en-GB"> <head> <?php echo $this->getChildHtml('head') ?> </head> <body> <div id="wrapper" class="border"> <?php echo $this->getChildHtml('header') ?> <div id="content" class="product"> <?php echo $this->getChildHtml('content') ?> </div> <?php echo $this->getChildHtml('footer') ?> </div> </body> </html>
This is pretty much our original HTML file except that we use the getChildHtml method to acquire each block’s content. The template needs to be pretty page agnostic as it’s the master page from which each page is rendered.
Now comes the slightly hard part: cutting up our core HTML blocks by functionality, creating the required templates files for each functionality and then populating those files.
We’ll tackle each in order of appearance
getChildHtml(‘head’) maps directly to page/html/head.phtml. Our file looks like so:
<title><?php echo $this->getTitle() ?></title>
<link rel="icon" href="<?php echo $this->getSkinUrl('favicon.ico') ?>" type="image/x-icon" />
<link rel="shortcut icon" href="<?php echo $this->getSkinUrl('favicon.ico') ?>" type="image/x-icon" />
<?php echo $this->getCssJsHtml() ?>
<?php echo $this->getChildHtml() ?>
<?php echo $this->getIncludes() ?>
You’ll see that we let Magento dynamically create the titles. Other than that, do notice the getCssJsHtml method being called. This method imports all the CSS and JS files that we specified in the page.xml file.
getChildHtml(‘header’) maps directly to page/html/header.phtml. Our file looks like so:
<div id="header">
<div id="logo"><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></div>
<div id="hud">
<h3>Welcome</h3>
<?php echo $this->getChildHtml('topLinks') ?>
</div>
</div>
<div id="utilities">
<?php echo $this->getChildHtml('breadcrumbs') ?>
<?php echo $this->getChildHtml('topSearch') ?>
</div>
We use Magento’s API to acquire the logo first. Then to further modularize things, we get the HTML for the breadcrumbs, links and the search function.
Note that the name is purely semantic. As you can see, you’re not limited to the header in it’s purest, strict technical sense. You can also tack on other elements as needed.
getChildHtml(‘footer’) maps directly to page/html/footer.phtml as specified in the XML file. Our file looks like so:
<div id="footer" class="border">
<?php echo $this->__('Help Us to Keep Magento Healthy') ?> - <a href="http://www.magentocommerce.com/bug-tracking"
onclick="this.target='_blank'"><strong><?php echo $this->__('Report All Bugs') ?></strong></a>
<?php echo $this->__('(ver. %s)', Mage::getVersion()) ?> <?php echo $this->getCopyright() ?></address>
</div>
With the footer, you’re free to include any info you deem fit. I just included the default content since I couldn’t think of anything clever to say there.
With the core elements finished, we can move on to the smaller functional blocks specified in the header section now i.e. the breadcrumbs, links and the search feature.
getChildHtml(‘topLinks’) maps directly to page/html/template/links.phtml. Our file looks like so:
<?php $_links = $this->getLinks(); ?>
<?php if(count($_links)>0): ?>
<ul class="links"<?php if($this->getName()): ?> id="<?php echo $this->getName() ?>"<?php endif;?>>
<?php foreach($_links as $_link): ?>
<li<?php if($_link->getIsFirst()||$_link->getIsLast()): ?> class="<?php if($_link->getIsFirst()): ?>first<?php endif; ?><?php if($_link->getIsLast()): ?> last<?php endif; ?>"<?php endif; ?> <?php echo $_link->getLiParams() ?>><?php echo $_link->getBeforeText() ?><a href="<?php echo $_link->getUrl() ?>" title="<?php echo $_link->getTitle() ?>" <?php echo $_link->getAParams() ?>><?php echo $_link->getLabel() ?></a> <?php echo $_link->getAfterText() ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
I know it looks a little complicated, but all it does is loop through an array of links and then spit it out, whilst adding a special class if it’s the first or last item in the list. If you’d prefer, you can scrap all this, and just hard code your top menu.
getChildHtml(‘breadcrumbs’) maps directly to page/html/breadcrumbs.phtml. Our file looks like so:
<?php if($crumbs && is_array($crumbs)): ?>
<div id="breadcrumbs">
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<?php if($_crumbInfo['link']): ?>
<a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->htmlEscape($_crumbInfo['title']) ?>"><?php echo $this->htmlEscape($_crumbInfo['label']) ?></a>
<?php elseif($_crumbInfo['last']): ?>
<strong><?php echo $this->htmlEscape($_crumbInfo['label']) ?></strong>
<?php else: ?>
<?php echo $this->htmlEscape($_crumbInfo['label']) ?>
<?php endif; ?>
<?php if(!$_crumbInfo['last']): ?>
<span>» </span>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
As with before, it merely loops through the crumbs to render the text. The naughty bits in there checks whether the crumb is a link, to format it as such, and check whether it’s the final element so it doesn’t have to render a separator. There’s nothing else to this block.
getChildHtml(‘topSearch’) maps directly to catalogsearch/form.mini.phtml. Our file looks like so:
<div id="header-search">
<form id="search_mini_form" action="<?php echo $this->helper('catalogsearch')->getResultUrl() ?>" method="get">
<input id="search" type="text" name="<?php echo $this->helper('catalogsearch')->getQueryParamName() ?>" value="<?php echo $this->helper('catalogsearch')->getEscapedQueryText() ?>" class="input-text border" />
</form>
</div>
Magento does all the weight lifting here. All you need to do is call the proper API method for the URLs and such.
If you’ve noticed that the string passed on to the getChildHtml method maps directly to the as attribute used in the page.xml file, then congrats, you’re an astute reader and you get a delicious cookie!

Now that we’ve built a very strong core, we can now move on to building the individual views of the store. In the next part, we’re going to build one of the core views of any store, the product view. Stay tuned!
And we are done! Today, we took the first step in creating our custom Magento theme, Cirrus. Hopefully this has been useful to you and you found it interesting. Since this is a rather new topic for a lot of readers, I’ll be closely watching the comments section so chime in there if you’re having any doubts.
Questions? Nice things to say? Criticisms? Hit the comments section and leave me a comment. Happy coding!
Posted on 28 May 2010 | 9:13 am
The latest episode of Freelance Radio, the official FreelanceSwitch podcast, is now available! This episode, the panel (John Brougher, Dickie Adams, Kristen Fischer and Von Glitschka) gives some of their favorite recommendations in four different categories.. Subscriptions to the podcast are available via iTunes and an archive of all podcasts will appear in the podcast section. We hope you enjoy it!
Subscribe to Freelance Radio on iTunes
You can subscribe on other podcast aggregators by using our podcast feed–it’s simply http://feeds.feedburner.com/FreelanceRadio. Download the podcast file (in MP3 format) via the link (right-click to save).
The Shownotes:
And that’s the episode! If you like it, please feel free to rate it in iTunes or your favorite podcast aggregator, and don’t forget to email your questions/comments via the Freelance Radio form. If you’d like to record a question/comment or submit an original outro song, you can upload them via this form.
Find out more about the panelists at the following sites:
Posted on 27 May 2010 | 9:09 am
“Aqualine is a unique and minimalist WordPress theme, that you can easily make customization to suit your needs. It is packed with an extensive options page – easily customise your theme without touching any code”
Posted on 27 May 2010 | 7:20 am
” Today I’ll show you 6 techniques you can use to extract a person/object from its background. From now on extraction won’t have secrets for you!”
Posted on 23 May 2010 | 10:25 am
A huge list of great Photoshop brushes to bookmark and download.
Posted on 23 May 2010 | 10:13 am
Scribd is my "favourite company of the month". First they show off their move from Flash to HTML5 and now they are generously taking time to share with us details on their implementation in a three part series.
The first part delves into the bowels of @font-face, starting with the simple:
and moving to how they support angled text such as this:

How do you encode the diagonal text in this document in a HTML page?
Short of using element transformations (-moz-transform, DXImageTransform etc.) which we found to be rather impractical, we encode the above HTML with a custom font created by transforming the original font. Here’s how our generated font looks in FontForge:
From the above font screenshot you also notice that we reduce fonts to only the characters that are actually used in the document; that helps save space and network bandwidth. Usually, fonts in the pdfs are already reduced, so this is not always necessary.
Naturally, for fonts with diagonal characters every character needs to be offset to a different vertical position (we encode fonts as left-to-right). In fact, this is how other HTML converters basically work: they place every single character on the page using a div with position:absolute:
HTML:At Scribd, we invested a lot of time in optimizing this, to the degree that we can now convert almost all documents to “nice” HTML markup. We detect character spacing, line-heights, paragraphs, justification and a lot of other attributes of the input document that can be encoded natively in the HTML. So a PDF document uploaded to Scribd may, in it’s HTML version, look like this (style attributes omitted for legibility):
HTML version:
HTML:Together with
tags for graphic elements on pages, we can now represent every PDF document in HTML while preserving fonts, layout and style, with text selectability, searchability, and making full use of the optimized rendering engines built into browsers.
I am looking forward to part 2 and 3!
Posted on 18 May 2010 | 9:10 am
“I felt these icons were wonderful to store away in your design stash for websites and layouts that needed a little color, a little graphic suggestion and a little something fresh.”
Posted on 18 May 2010 | 7:20 am
Projekktor is another JavaScript library that sits on top of the <video> tag to provide richer chrome and features, and also backwards compatibility via Flash. Once you load the shim, you can setup config and then you just have to use video:
<video class="projekktor" poster="poster.png" title="this is Projekktor" width="640" height="385" controls>
<source src="video.mp4" type="video/mp4" /> <!-- MPEG4 for Safari -->
<source src="video.ogv" type="video/ogg" /> <!-- Ogg Theora for Firefox 3.1b2 -->
</video>
Features
Posted on 18 May 2010 | 4:36 am
“Create an easily configurable set of contextual slideouts. Each can be opened in one of four directions – bottom-right (default), bottom-left, top-left and top-right, and each can be in one of three colors – green (default), blue, and red.”
Posted on 17 May 2010 | 7:06 am
A list of plugins to help make your WordPress site look great on mobile devices.
Posted on 17 May 2010 | 7:03 am
Google Chart Tools provide several ways to easily add charts to any web page. Charts may be static or interactive, and in this tutorial, we’ll learn how to use both of them.
There are two different types of graphs that Chart Tools can generate: image charts (static graphs) and interactive charts.
Image Charts are quite easy to use, however, interactive charts are far more flexible, because they can trigger events which we can use to interact with other elements in the page.
Yes, there is a super-easy way to include a chart in your page – as easy as writing a URL like this:
http://chart.apis.google.com/chart?cht=p3&chs=450x200&chd=t:2,4,3,1&chl=Phones|Computers|Services|Other&chtt=Company%20Sales&chco=ff0000
if you copy and paste this url in your browser, you’ll see the following:

You can place the image anywhere in your page using the URL as the src attribute of an image tag:
<img src='http://chart.apis.google.com/chart?cht=p3&chs=450x200&chd=t:2,4,3,1&chl=Phones|Computers|Services|Other&chtt=Company%20Sales&chco=ff0000'>
That’s the Google Charts API. Request are sent as GET or POST URLs, and the Google charts server returns a PNG image in response. The type of chart, data and options are all specified within the querystring of the URL. The API defines how to do that. Let’s review the different options.
http://chart.apis.google.com/chart?
This is the base URL; we’ll use it for all image chart requests. The rest are parameters in the form name=value separated by &.
There are only three mandatory parameters: cht, chs, and chd. The rest are optional.
cht=p3
This is the chart type. We are using a 3D pie chart which is p3. You can visit the chart gallery for all available chart types.
chs=450×200
This is the chart size in pixels (width x height).
chd=t:2,4,3,1
This is the data to display in the chart. The first letter (t) indicates the data format. In this case, we are using basic text format which is a list of comma separated values.
Each chart type has a few optional parameters to configure some aspects of your graph: title, labels, font types, colors, gradients, etc. This is what we have included:
chl=Phones|Computers|Services|Other
Chart labels for each pie slice.
chtt=Company%20Sales
Chart title.
chco=ff0000
Chart color in rrggbb hexadecimal format.
If you specify one single color, the slices will have different gradations. You can also specify a gradient with two colors (chco=ff0000,00ff00) or a color for each slice (chco=ff0000|3355aa|8322c2|112233).
This is it for image charts. There isn’t much to it! There are a lot of different chart types available, and, if you play with the parameters, you can get some really nice results. The Google Live Chart Playground is an excellent tool to do this. You play with parameters and see the changes in the generated image – an easy way to fine-tune the url for your graph!

To include interactive charts in your web pages, you have to use a different API: the Google Visualization API. In this case, the interface is not a URL. You’ll have to use a JavaScript library, and write a few lines of code – but nothing difficult.
There is a gallery of ready-made visualizations (graphs) that you can use. You can also create and share your own graph, but the visualizations in the gallery will probably cover most of your needs for displaying data.
The level of interactivity depends on the particular visualizations you use. Usually, the graph will react in a certain way when clicked (showing a tool tip or animating), but the really powerful feature is that they can trigger events and you can register callbacks to perform any action related to that event. Examples of events can be selecting a bar or a pie slice, mouseOver, mouseOut, etc.
We’ll use local data to feed the visualizations in our examples, but you can obtain your data in any other way. A common option would be to retrieve the data from a database using AJAX. You can even use the Visualization API; it also defines a way to request and offer (for servers) data in a format which can be immediatly used in any visualization, but we won’t cover that here.
It doesn’t matter how we get our data, but all visualizations need to receive it in a DataTable object. It’s basically a table with rows and columns. Each column is defined with a particular data type (and an ID and a Label which are optional).
To reference a particular cell in the table, you use the pair (row, column). Row is always a number, starting a zero. Column can also be a zero-based number or an optional ID.
If we want to display the earnings of our company in 2009 in a column chart, we have to prepare the data in the following way:
| Quarters 2009 | Earnings |
|---|---|
| Q1 | 308 |
| Q2 | 257 |
| Q3 | 375 |
| Q4 | 123 |
Two columns: the first one (with type ’string’) is the label for each bar in the chart, and the second one (with type ‘number’) is the value for that bar. We have four rows which means well have four bars to display.
How do we put that in a DataTable object? This is the code to do so – each line is explained later:
//create data table object
var dataTable = new google.visualization.DataTable();
//define columns
dataTable.addColumn('string','Quarters 2009');
dataTable.addColumn('number', 'Earnings');
//define rows of data
dataTable.addRows([['Q1',308], ['Q2',257],['Q3',375],['Q4', 123]]);
First we create our DataTable object with:
var dataTable = new google.visualization.DataTable();
Then we define the two columns in our table using the method addColumn(). The first value is the type and the second value is the optional label.
dataTable.addColumn('string','Quarters 2009');
dataTable.addColumn('number', 'Earnings');
And finally, we define the data rows using the addRows() method.
dataTable.addRows([['Q1',308], ['Q2',257],['Q3',375],['Q4', 123]]);
Each row is an array, and all data is also enclosed in another array.
Rows can also be defined one row at a time:
dataTable.addRow(['Q1',308]);
or even one cell at a time:
data.setValue(0, 0, 'Q1');
Here, the first two numbers are the row and column, respectively.
This is the way to create DataTable objects. Every visualization needs to be loaded with data in this format. That doesn’t mean that the table is the same for every visualization. The particular number and type of columns and rows has to be checked in the documentation for each chart.
For this first example, we’ll use a Column Chart to present our data. In the Google Visualization Gallery, we can click any chart type to see documentation and examples.
To use any visualization, we have to load the Google AJAX API before; it provides the core functionality needed in many other google APIs.
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
Now we can load the Visualization API using the google.load() function (from the AJAX API):
google.load('visualization', '1', {'packages': ['columnchart']});
The second parameter, ‘1,’ refers to the version of the API to load (‘1′ means the current version). ‘packages’ is an array with all the visualizations we are going to use. In this case, we’ll use only one: the column chart.
At this point, we have the necessary libraries to create our DataTable object and display our graph, however, we need to be sure that the visualization is completely loaded, otherwise we’ll get JavaScript errors and our graph won’t display.
The way to do this is by registering a callback. The function will be called when the visualization (API and package) is loaded.
//set callback
google.setOnLoadCallback (createChart);
Function createChart is where we create our data table and our chart. The final, complete code, is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Google Charts Tutorial</title>
<!-- load Google AJAX API -->
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
//load the Google Visualization API and the chart
google.load('visualization', '1', {'packages': ['columnchart']});
//set callback
google.setOnLoadCallback (createChart);
//callback function
function createChart() {
//create data table object
var dataTable = new google.visualization.DataTable();
//define columns
dataTable.addColumn('string','Quarters 2009');
dataTable.addColumn('number', 'Earnings');
//define rows of data
dataTable.addRows([['Q1',308], ['Q2',257],['Q3',375],['Q4', 123]]);
//instantiate our chart object
var chart = new google.visualization.ColumnChart (document.getElementById('chart'));
//define options for visualization
var options = {width: 400, height: 240, is3D: true, title: 'Company Earnings'};
//draw our chart
chart.draw(dataTable, options);
}
</script>
</head>
<body>
<!--Div for our chart -->
<div id="chart"></div>
</body>
</html>
The chart object is created with this line:
var chart = new google.visualization.ColumnChart (document.getElementById('chart'));
The argument is the DOM reference to the element containing the visualization. In this case, we have a <div id=”chart”></div>.
Then, we define the options we want and draw the chart:
var options = {width: 400, height: 240, is3D: true, title: 'Company Earnings'};
chart.draw(dataTable, options);
Our graph looks like this:

Note: All images here are static to make the tutorial available regardless of your browser or your JavaScript settings. Review the live demo for the interactive version.
The advantage of having a clearly defined data format is that once you know how to create and populate a DataTable object, you know how to feed any visualization. You just have to check the documentation to see the particular table (number and type of columns) you have to build.
For a pie chart, we can use the exact same table we have now. Let’s add a pie chart in the same page.
We have to add our new package in the google.load() line:
google.load('visualization', '1', {'packages':['columnchart','piechart']});
and extend our createChart function with these two lines:
var secondChart = new google.visualization.PieChart (document.getElementById('secondChart'));
secondChart.draw(dataTable, options);
The complete code is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Google Charts Tutorial</title>
<!-- load Google AJAX API -->
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
//load the Google Visualization API and the chart
google.load('visualization', '1', {'packages':['columnchart','piechart']});
//set callback
google.setOnLoadCallback (createChart);
//callback function
function createChart() {
//create data table object
var dataTable = new google.visualization.DataTable();
//define columns
dataTable.addColumn('string','Quarters 2009');
dataTable.addColumn('number', 'Earnings');
//define rows of data
dataTable.addRows([['Q1',308], ['Q2',257],['Q3',375],['Q4', 123]]);
//instantiate our chart objects
var chart = new google.visualization.ColumnChart (document.getElementById('chart'));
var secondChart = new google.visualization.PieChart (document.getElementById('Chart2'));
//define options for visualization
var options = {width: 400, height: 240, is3D: true, title: 'Company Earnings'};
//draw our chart
chart.draw(dataTable, options);
secondChart.draw(dataTable, options);
}
</script>
</head>
<body>
<!--Divs for our charts -->
<div id="chart"></div>
<div id="Chart2"></div>
</body>
</html>
And the generated charts:

Note: check the live demo for the interactive version.
This was easy in this case, because both visualizations used the same table columns and rows. But there are visualizations that need more columns or columns of different types, and you cannot use the data table directly. However, you can solve this by generating a different view of the original table to feed a visualization. We’ll review that shortly.
The data table for a column chart doesn’t have to be as simple as in the previous example. We can have bars representing the earnings for each quarter in the last three years, for example. In that case the data
table would look like so:
| Quarters | Earnings 2009 | Earnings 2008 | Earnings 2007 |
|---|---|---|---|
| Q1 | 308 | 417 | 500 |
| Q2 | 257 | 300 | 420 |
| Q3 | 375 | 350 | 235 |
| Q4 | 123 | 100 | 387 |
The only code we have to change from our first example is the DataTable object, to add two more columns and more data in each row:
//create data table object
var dataTable = new google.visualization.DataTable();
//define columns
dataTable.addColumn('string','Quarters');
dataTable.addColumn('number', 'Earnings 2009');
dataTable.addColumn('number', 'Earnings 2008');
dataTable.addColumn('number', 'Earnings 2007');
//define rows of data
dataTable.addRows([['Q1',308,417,500], ['Q2',257,300,420],['Q3',375,350,235],['Q4', 123,100,387]]);
The rest of the code does not change. The generated chart is:

But, what if now we want to use a pie chart to represent part of this data? We cannot use the same data table as we did before, because pie charts need a two-column table (slice label and value). There is an easy way to obtain a different table from an existing DataTable object and use it to feed a chart: data Views.
Views are a way to adapt our table for a different visualization. If we now want to display, in the same page, a pie chart showing the quarterly earnings distribution for last year, the table we need is only this:
| Quarters | Earnings 2009 |
|---|---|
| Q1 | 308 |
| Q2 | 257 |
| Q3 | 375 |
| Q4 | 123 |
A data view (DataView object) allows you to use only a subset of the original data. You can reorder or duplicate columns and rows or introduce columns with calculated values.
First, create the View object:
var view = new google.visualization.DataView(dataTable);
A data view is initialized with the original table and then we use the DataView methods to hide, show or filter columns or rows ( setColumns(), hideColumns(), setRows(), hideRows(), getFilteredRows, getColumnRange, etc ).
We can filter the original table to get only the first two columns (columns 0 and 1) using setColumns():
view.setColumns([0, 1]);
Now we can draw the pie chart using this view as a data table:
secondChart.draw(view, options);
Remember that we have to include the piechart package with google.load(), and we have to create the pieChart object with:
var secondChart = new google.visualization.PieChart
Now we can see both charts generated using the same data table:

Events provide an easy way to connect your visualizations with other elements on your page. Visualizations can trigger some events, and you can register a listener to react to that event and perform some action. The event model is similar to the browser event model. Once again, we have to look at the documentation to check the events triggered for each visualization.
To show how events work, let’s return to our first example, the simplest column chart:

This graph triggers events on mouseover, on mouseout and on select. That means we can make it much more interactive than it is by default.
Since this graphic shows earnings for a company, it could be interesting to show a message with a brief explanation of the most important achievements or sales for each quarter when the user places the pointer over a column (onmouseover event).
Our callback will be showDetails(), and we register it for the onmouseover event:
google.visualization.events.addListener(chart, 'onmouseover', showDetails);
The first parameter is the variable that contains our chart object.
We will also need to hide the message when the pointer goes out of the column so we need another function to be called when onmouseout event triggers:
google.visualization.events.addListener(chart, 'onmouseout', hideDetails);
Within the <body> or our HTML page we have to define four divs with the messages:
<body>
<!--Div for our chart -->
<div id="chart"></div>
<!--Divs for our messages -->
<div id="details0">These are the details for Q1...</div>
<div id="details1">Here you have the numbers for Q2...</div>
<div id="details2">Explanations for the third quarter...</div>
<div id="details3">Q4 was as expected...</div>
</body>
And then the callback functions just show or hide the corresponding message:
function showDetails(e) {
switch (e['row']) {
case 0: document.getElementById('details0').style.visibility='visible';
break;
case 1: document.getElementById('details1').style.visibility='visible';
break;
case 2: document.getElementById('details2').style.visibility='visible';
break;
case 3: document.getElementById('details3').style.visibility='visible';
break;
}
}
function hideDetails(e) {
switch (e['row']) {
case 0: document.getElementById('details0').style.visibility='hidden';
break;
case 1: document.getElementById('details1').style.visibility='hidden';
break;
case 2: document.getElementById('details2').style.visibility='hidden';
break;
case 3: document.getElementById('details3').style.visibility='hidden';
break;
}
}
Our functions accept a single parameter: the event fired. This object has all available information about the event details.
To know what bar we are over, we check the ‘row’ property of the event object. This information refers to the rows and columns of the DataTable object, but we know that row 0 corresponds to Q1, first column, and so on.
Note: Not all events pass the event object. Sometimes you have to use methods to get the information you need, read the visualization documentation to know how to get the information relative to the event fired.
The following listing include the complete code for this example. I have included a short internal CSS snippet to hide the message divs, and provide minimal formatting.
<html>
<head>
<title>Google Chart Tools Tutorial</title>
<style type="text/css">
#details0, #details1, #details2, #details3 {
visibility:hidden;
background: #FFFF7F;
border: solid 1px;
width: 350px;
padding: 5px;
font-size:smaller;
position:absolute;
top: 250px;
}
</style>
<!-- load Google AJAX API -->
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
//load thee Google Visualization API and the chart
google.load('visualization', '1', {'packages': ['columnchart']});
//set callback
google.setOnLoadCallback (createChart);
//callback function
function createChart() {
//create data table object
var dataTable = new google.visualization.DataTable();
//define columns
dataTable.addColumn('string','Quarters 2009');
dataTable.addColumn('number', 'Earnings');
//define rows of data
dataTable.addRows([['Q1',308], ['Q2',257],['Q3',375],['Q4', 123]]);
//instantiate our chart objects
var chart = new google.visualization.ColumnChart (document.getElementById('chart'));
//define options for visualization
var options = {width: 400, height: 240, is3D: true, title: 'Company Earnings'};
//draw our chart
chart.draw(dataTable, options);
//register callbacks
google.visualization.events.addListener(chart, 'onmouseover', showDetails);
google.visualization.events.addListener(chart, 'onmouseout', hideDetails);
}
function showDetails(e) {
switch (e['row']) {
case 0: document.getElementById('details0').style.visibility='visible';
break;
case 1: document.getElementById('details1').style.visibility='visible';
break;
case 2: document.getElementById('details2').style.visibility='visible';
break;
case 3: document.getElementById('details3').style.visibility='visible';
break;
}
}
function hideDetails(e) {
switch (e['row']) {
case 0: document.getElementById('details0').style.visibility='hidden';
break;
case 1: document.getElementById('details1').style.visibility='hidden';
break;
case 2: document.getElementById('details2').style.visibility='hidden';
break;
case 3: document.getElementById('details3').style.visibility='hidden';
break;
}
}
</script>
</head>
<body>
<!--Div for our chart -->
<div id="chart"></div>
<!--Divs for our messages -->
<div id="details0">These are the details for Q1...</div>
<div id="details1">Here you have the numbers for Q2...</div>
<div id="details2">Explanations for the third quarter...</div>
<div id="details3">Q4 was as expected...</div>
</body>
</html>
And this is the result:

Once again, check the live demo to see the interactivity.
As with the static images, there is a Google Code Playground where you can play with your visualizations and parameters, and view the results:

Hopefully, this should be enough to get you started with Google Chart Tools. Once you get the hang of it, you’ll find that a huge level of flexibility is available to you in your web applications. Thanks for reading!
Posted on 14 May 2010 | 8:53 am
CSS3 has a lot of great stuff in it. Transforms, new layout, media query, CSS object model, you name it. How do you keep up with the specs?
That is what Šime Vidas thought, so he whipped together a little iframe love:
Posted on 14 May 2010 | 3:23 am