Instant Handlebars.js book review and giveaway

(I received a review copy of this book.)

TL;DR
Instant Handlebars.js is a well written and organized book with good code samples. Highly recommended.

When starting a new project with a new framework, I often learn just enough to do what I need for that project, but sometimes miss out on more advanced techniques or helpful background information.

Luckily I received a copy of Gabriel Manrick’s Instant Handlebars.js two days after starting just such a new project. Instant Handlebars.js nicely supplemented the basic info I had found online and provide both more background information and advanced techniques that I might have otherwise missed.

Packt Publishing’s Instant series is similar to A Book Apart‘s web design series but for developers: short and to the point with useful information. The instant series provides that information without drowning what you need to know in a sea of pages and pages of data.

Instant Handlebars.js complemented my project without superceding it by doing exactly what it promised, moving from a typical quick start to more in depth features like Expressions, Helpers and Partials with Structuring Your Handlebars App and Precompilation sections for intermediate and advanced readers.

‘Structuring Your Handlebars App’ section includes using Handlbebars with Require.js and provides both theory and code. This leads directly into an in-depth ‘Precompilation’ discussion using Node.js.

Packt Publishing has provided 3 e-copies for a giveaway. Comment on this post to enter. Winners will be randomly chosen December 20th.

Tagged

Grunt.js Fatal error: spawn ENOENT

Today I installed Yeoman 1.0.0-rc.1.1 on Mac 10.8.4., but got a Fatal error: spawn ENOENT error after Grunting a fresh Yeoman generated webapp.

Several GISs later, Java was revealed as the culprit.

Oh yeah, Java!

Oracle’s Java version 7u17 and below have been disabled by Apple on OS X. Updating to the latest release will allow Java to be run on Mac OS X.

Updating Java resolved the issue for me.

If you’re having issues with PhantomJS, check your Java.

Tagged , , , ,

Displaying two rounded corners in IE

TL;DR Nothing fancy, but this might save you some time if you’re using CSS3PIE and SASS.

Four rounded corners were easy enough to do using CSS3, save for IE, of course.

I already had a SASS mixin:

@mixin border-radius($radius) {
  -webkit-border-radius: $radius;
     -moz-border-radius: $radius;
          border-radius: $radius;
}

A GIS for rounded corners in IE suggested CSS3PIE.

After time wasted trying different configurations, I learned to always use an absolute link for PIE.htc.

I first tried

behavior: url(PIE.htc);

and

behavior: url(css/PIE.htc);

with no success.

Only

behavior: url(/PIE.htc);

worked.

I needed one box to round only two corners, so I copied this CSS from border-radius.com.

-webkit-border-bottom-right-radius: 8px;
-webkit-border-bottom-left-radius: 8px;
-moz-border-radius-bottomright: 8px;
-moz-border-radius-bottomleft: 8px;
border-bottom-right-radius: 8px;
border-bottom-left-radius: 8px;

CSS3PIE didn’t support this format, but did support the shorthand code.

border-radius: 0 0 8px 8px;

So I added a mixin to handle specific corners and made CSS3PIE happy.

@mixin border-radius-specific($radius1, $radius2, $radius3, $radius4) {
  -webkit-border-radius: $radius1, $radius2, $radius3, $radius4;
     -moz-border-radius: $radius1, $radius2, $radius3, $radius4;
          border-radius: $radius1, $radius2, $radius3, $radius4;
}
Tagged , , ,

Learning JavaScript Design Patterns by Addy Osmani; O’Reilly Media

If you want to take the step from spaghetti code to web application, read this book.

I’ve incorporated two patterns into a recent project. Understanding and coding within the patterns was a much better coding experience and resulted in a much better app.

Read. This. Book.

I reviewed this book as an ePub on the iPad for O’Reilly’s Blogger Review Program.

I review for the O'Reilly Blogger Review Program

Tagged ,

Buying a car online: dealer scheme not to deliver vehicle

You got such a good deal that we can’t afford to deliver it to you.

We recently found and purchased a truck online. The deal took until late afternoon to complete, but the dealership (based 110 miles away) agreed to deliver the truck. They went so far as to call me stating that they’d be on the road in an hour.

A short time afterwards, they called to tell me that they couldn’t find a driver and that because I got such a good deal on the truck, that they couldn’t afford to hire one to drive the truck to us.

It sounded like BS to me, but my wife had been in a minor accident earlier that day which rendered our only car undriveable and my brother lived near the dealership and had offered to drive to up to me. He had test driven the truck for me earlier that day and was kind enough to deliver the truck to us that night.

As it turned out, the minor accident actually totalled the car, so the very next week we were shopping for a replacement online.

And we found one in New Mexico from a dealership which claims on their website “We deliver to anywhere in New Mexico for free.”

Great. We’re about 1.5 hours from the New Mexico border. I send directions to a truck stop where we’ll meet the delivery. We get close to finalizing the deal, but as you may guess the salesman says, “You got such a good deal that we can’t afford to deliver it to you.”

Now I get it. I offer to abandon the deal saying that I wouldn’t buy from a dealership I couldn’t trust. Suddenly they can deliver the car. And they did, eventually, deliver the car to (the wrong) truck stop just west of the Texas border.

Fair warning. This appears to be a common scheme dealerships use to get an extra few hundred dollars out of buyers. If you’ve had a similar experience, please share it in the comments.

####

Feature image provided by Lee J. Haywood.

Tagged

Maintainable JavaScript by Nicholas C. Zakas; O’Reilly Media

TL;DR

It’s easy to blaze your own coding trail, perhaps particularly so with Javascript. This book provides a comprehensive glimpse into the workflow and practices of an experienced Javascript developer. It’s a good read whether you’re blazing your own trail or trying to clear one for a group.

####

Maintainable Javascript provides a useful mix of intermediate and advanced Javascript concepts and practices based on widely accepted theory and grounded in the author’s real world experience.

The book is broken into 3 sections.

  1. Style Guidelines
  2. Programming Practices
  3. Automation

Style Guidelines

A nice survey of style guidelines found in several libraries and well-known approaches to coding Javascript including JSLint and JSHint.

Programming Practices

Presents a great deal of information from both the author’s experience and general theory. I learned something even in the areas in which I was already familiar.

Automation

Convincing arguments for automation with some examples, but no mention of Codekit or LiveReload.

Maintainable Javascript reads like a worthy sequel to Douglas Crockford’s Javascript: The Good Parts.

I reviewed this book as an ePub on the iPad for O’Reilly’s Blogger Review Program.

I review for the O'Reilly Blogger Review Program

Tagged

A quick workflow tip using SASS, Sprite Right and Codekit

TL;DR

  1. Export your spritesheets as a SASS partial
  2. Import the partial into your SASS document
  3. That’s it. Everytime you save your spritesheet, CodeKit automatically processes your stylesheet with your new spritesheet classes.

I use Sprite Right to manage sprites and CodeKit to speed development. Using SASS partials, you can combine these two Mac apps to save a lot of time.

First, using SpriteRight, export your spritesheet as a SASS partial.

I use _sprites.scss. (Note the ‘s’ before ‘css’. The underscore prevents SASS from directly compiling a file, thereby producing an unneeded CSS file.)

  • Click ‘Settings’ in SpriteRight to manage your export settings.
  • Choose your file output path.
  • Select ‘Export example CSS’
  • Set your output path
  • Prefix your filename with an underscore and use the .scss extension.

 

After saving and exporting, you’ll be asked if you really want to use the .scss extension. (Yup.)

 

 

 

 

Second, import the partial into your main SASS file.

@import "sprites";

Third, there is no third. On save, CodeKit will

  1. Compile your SASS document importing all of your spritesheet classes.
  2. Refresh your test site in Chrome or Safari
  3. Allow you to admire your work

More OS X upgrade problems: -bash: git: command not found

Missing Git is another apparently well known Mountain Lion upgrade problem.

Around the web there are two common solutions.

  1. Download (or re-download) Xcode.
  2. Export the Git PATH.

One option is quicker than the other.

Tagged , , ,

Upgrading to Mountain Lion: Forbidden 403, You don’t have permission to access /~username/ on this server

One of these days I’m going to research OS X upgrades before the fact. One of these days.

After upgrading to Mountain Lion my local websites did not run anymore. I received a nice little “403 Forbidden Error”.

A quick GIS revealed that this was common knowledge, but the same GIS quickly found a fix.

Neil Gee’s Forbidden 403, You don’t have permission to access /~username/ on this server pointed me in the right direction, but my websites still didn’t work.

Changing Neil’s settings for my username.conf from

<Directory "/Users/username/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

to

<Directory "/Users/username/Sites/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>

worked for me. (I use a lot of symlinks and Dropbox in my workflow.)

Tagged ,

A modest proposal for campaign finance reform

I’ve got a great new idea for campaign finance reform.

It would be more honest to just let people (cough, cough, corporations) purchase votes.

Let’s say 1 vote is worth 1000 dollars. Then anyone can buy enough votes to select the candidate they want.

This will remove any doubts about corruption and the money raised can be used to pay down the national debt.

Who’s with me?