Personal reference material

This site is mostly for me personally. After years of dragging reference material from site to site, file format to file format, I decided my personal website needed to be a repository for the stuff I need to hold on to.

I created a project to do this, and I've been dumping documentation into this site ever since.

It's organized by topic, if would be great if any of the material collected here helps you in any way. However, don't hold your breath.

Some great examples of putting CSS3 to superb use.

img/css-examples/progress-bar.png

Ivan Vanderbyl implemented this progress bar in pure CSS. The example here includes some fantastic CSS animations.

img/css-examples/spinner.png

Jordan Dobson has implemented a resizable AJAX loading spinner that looks great and uses zero, that's right, zero images.

img/css-examples/bon-bon-buttons.png

Bon Bon buttons were created by Simon (Simurai) with the goal of using as little markup as possible. Not production ready, but they work in Safari, FF, and Chrome.

Find out what features are supported in which browsers at http://caniuse.com/

Type

Font smoothing

Fonts are vector based, so font smoothing was introduced a long time ago to handle the display of typefaces on pixel-based displays.

Although it's not currently available as of 2010, the WebKit engine supports a property called -webkit-font-smoothing. Changing this value to antialiased may produce a better result than the default.

You can put this in your css file now though, it won't hurt a thing.

html {
    -webkit-font-smoothing: antialiased;
}

Credit to Tim Van Damme:

http://maxvoltar.com/archive/-webkit-font-smoothing

Articles

Jeffrey Way illustrates a technique using CSS3 and some proprietary WebKit sauce to create an effect that looks like something you'd do with Photoshop.

There is a 13 minute video that outlines the technique.

http://net.tutsplus.com/tutorials/html-css-techniques/subtle-css3-typography-that-youd-swear-was-made-in-photoshop/


WebKit supports styling scrollbars

http://webkit.org/blog/363/styling-scrollbars/

Supporting IE

IE is usually left out when it comes to these CSS3 techniques. However there is a project that utilizes HTC scripts to enable the newer stuff.

http://css3pie.com

Cheat sheets

The guys at Sencha have created this reference that hits most of the high spots for CSS3. It includes animation, rounded corners, and a lot of the well-known CSS3 additions. It does a good job of handling the tricky ones like text-overflow: ellipsis giving you the additional information you need to make those work.

http://downloads.sencha.com/extras/css3-cheat-sheet.pdf

Tips

User selection

Both Mozilla and WebKit support a property called user-select. When a user clicks and drags a text selection over nodes in the DOM this property can determine whether an element is included.

A lot of people wonder why you would want to do this as you are presuming what the user should and should not be able to select. A good example would be navigation buttons. Within Word as you select text you do not expect to also select the formatting toolbar or the margin and tab indicator.

With user-select you can provide the expected behavior of not selecting elements of the application.

To turn user selection off:

nav, .toolbars {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

Exploring existing CSS tricks and techniques to make developing with this technology easier.

The tricky stuff

Positioning with CSS, like the box model, trips up a lot of designers. It's one of those things that isn't clear upon first explanation.

This article on Stop Design does a very good job of educating on CSS positioning.

http://stopdesign.com/archive/2003/09/03/absolute.html

CSS content property

Credit for most of this content goes to http://css-tricks.com.

Entities

When doing something like this

li:before {
    content: '\00bb';
}

You need the hexidecimal values for HTML entities, the above code puts a double arrow before the list item.

Here is a table of conversions:

http://www.evotech.net/blog/2007/04/named-html-entities-in-numeric-order/

Here is a converstion tool from the same site:

http://www.evotech.net/articles/testjsentities.html

Other tricks

More available at http://css-tricks.com/css-content/.

Design-focused resourced for web development.

Typography

img/design/lettering-js-example.png

Jason Santa Maria uses lettering.js to apply style to each individual letter on this example from Lost World's Fairs.

A great resource for learning how traditional typographic style can be applied to web development.

http://webtypography.net/

James Godfrey and Patrick Wilkey outline 34 sins to avoid when excersizing your typographic prowess.

http://www.rayelder.com/teaching/_downloads/pdf/typographic-sins.pdf

Articles

Resolution Independent Mobile UI David Kaneda from Sencha discusses the rise of higher pixel density devices and how we need to be careful desigining interfaces.

As a general rule, because of the way the protocol works, you needed a separate IP address for each domain you wanted to place behind SSL. This is no longer entirely true.

http://playnice.ly/blog/2011/01/03/multi-domain-ucc-ssl-certificates-on-nginx-with-1-ip-address/

This post outlines the steps that one company went through to use UCC SSL certificates to support different domains.

The Web Framework for perfectionists with deadlines

Optimization

Database guidelines to keep your system running quickly and avoid data bottlenecks for as long as possible.

http://docs.djangoproject.com/en/dev/topics/db/optimization/

Interesting projects

Luke Plant has a project for creating fake data and auto-populating your Django models with a facsimile of real data. There are some really good reasons that you always want to use fake data: protecting sensitive data, performance testing, and creating fixtures. Check it out at http://pypi.python.org/pypi/django-anonymizer/

I've experimented with creating ePub formatted documents. As an Apple product user, I wanted them to work well on the iPad and iPhone.

Authoring content

Hands down my favorite desktop publishing tool is Adobe InDesign.

It offers some nice tooling for publishing in the ePub format. This guide is written for CS4 but the guidelines apply more broadly.

Fonts

This article was helpful in choosing the typefaces that I used. Apple is somewhat non-standard when it comes to supporting this format.

http://www.michaelcritz.com/2010/04/02/fonts-for-ipad-iphone/

The simplest workflow

vim myfile

With Git, you have to be explicit:

git add myfile

Now we commit locally:

git commit

Now we push:

git push

Getting up stream changes

This is something I do quite often, I fork on Github and push up my own changes but at some point I also want to pull down what's been going on with the main branch.

Register the upstream:

git remote add upstream git://github.com/somewhere/something.git

Now pull down the up stream changes:

git fetch upstream
git merge upstream/master

This will merge, and now one of these will push it back to your forked repo:

git push

More info here http://help.github.com/forking/

Dealing with branches and tags that have the same name

Pretend for a moment that you've created a branch and a tag with the name "foo".

Normally you can delete the branch and to update GitHub, you'd do this

git push origin :foo

With a tag of the same name, you'll see this warning from GitHub.

error: dst refspec foo matches more than one.

The proper way to accomplish this is to tell it you are specifically targetting heads.

git push origin :refs/heads/foo

Long-lived branches

As soon as you incorporate some QA practices into you development cycle, your repository can get more complicated. It doesn't have to, but a lot of people choose to create a branch that testing is done out of. Developers can fix bugs in this branch and QA is isolated from master branch instability.

Create a test branch

git branch test

Developers checkout this branch

git checkout test

They fix the bug

vim src/buggyfile.py
git add src/buggyfile.py
git commit -m 'Fixed the foo because it was bugging the bar'

QA tests it out, and now we come to the end of the sprint and merging of master and test needs to occur

git checkout master
git merge test

Now we want to basically move the HEAD for test to the commit we created when we merged master and test.

Let's pretend we do a git log and figure out the hash for that commit is 7482cd250a86b1c05d7e2ed361b9a9413882f36c.

We are going to tell git that, being that we are in the test branch, and we've already merged test into master, we want to move the pointer for HEAD of test to the commit with hash 7482cd250a86b1c05d7e2ed361b9a9413882f36c.

git reset --merge 7482cd250a86b1c05d7e2ed361b9a9413882f36c

Thanks to Tim Pope.

Rebasing

Rebasing modifies the commit tree.

Here is a good Stack Overflow question that outlines some general techniques.

http://stackoverflow.com/questions/495345/git-removing-selected-commits-from-repository

Blogs

Good article by Jeff Kreeftmeijer that outlines some of the things he's learned while working with Git.

http://jeffkreeftmeijer.com/2010/git-your-act-together/

A good portion of this material is from Jeremy Keith's HTML5 for Web Designers.

Jeremey Keith has a blog, check out the html5 tag on it.

Basic template

<!DOCTYPE html>
<html lang="en">
    <head>
    <meta charset="utf-8" />
    <title>Something clever</title>

    <link rel="stylesheet" href="css/main.css" type="text/css" />

    <!--[if IE]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
    </head>
    <body>
    </body>
</html>

Another well-tested alternative is this HTML5 boilerplate.

Detecting support

Figuring out if the browser that is rendering your content can support the <audio> or offline storage is not hard, but it's not something you want to repeatedly write Javascript for either.

Use Modernizr. Simple as that.

If you're curious as to which browsers support which feature check out http://caniuse.com/

Styling

You can start using the new elements.

section, article, header, footer, nav, aside, hgroup { display: block; }

If you use section, check out this guide

To get IE to behave, use Remy Sharp's JS tool in a conditional comment:

<!--[if IE]>
    <script
    src="http://html5shiv.googlecode.com/svn/trunk/html5.js">
    </script>
<![endif]-->

Headings

Use Geoffrey Sneddon's tool to generate outlines. http://bkapart.com/html5/9.

Notable features

Editable content

You can make an element editable like so

<ul contenteditable>
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
</ul>

Placeholders

You can provide hints or examples in form fields with placeholder

<input name="email" type="email" placeholder="Your email address" />

Offline storage

Here's a nice video outlining how offline storage works.

http://www.youtube.com/watch?v=h0uZIljjElo&feature=player_embedded

Audio support

This becomes much easier in HTML5.

<audio autoplay="autoplay" controls="controls">
    <source src="file.ogg" />
    <source src="file.mp3" />
    <a href="file.mp3">Download this file.</a>
</audio>

Specifying two source tags allows it to degrade gracefully. Don't support OGG? That's fine, we'll use the MP3.

And video is similar

<video controls preload>
    <source src="cohagenPhoneCall.ogv" type="video/ogg; codecs='vorbis, theora'" />
    <source src="cohagenPhoneCall.mp4" type="video/mp4; 'codecs='avc1.42E01E, mp4a.40.2'" />
    <p> Your browser is old. <a href="cohagenPhoneCall.mp4">Download this video instead.</a> </p>
</video>

Web Workers

Web workers attempt to provide threads to Javascript processes in the browser. It allows you to do stuff in the background as long as you aren't modifying the DOM. For example, this would be a great way to monitor a chat server for new messages and then notify a view that it has a new chat message.

This guide is a fun way to get an overview of HTML5 Web Workers

http://wearehugh.com/public/2010/08/html5-web-workers/

Google Chrome Frame

A lot of the stuff that HTML5 and CSS3 simply don't work well or not at all in Internet Explorer. Google provides a product called Google Chrome that brings a WebKit browser into Internet Explorer as a plugin.

http://code.google.com/chrome/chromeframe/

ARIA

I'll be honest with you, making an accessible website falls into a lower category of priority than writing tests and documentation. I feel guilty about this. As a developer creating a website I can make the eperience for someone with a visual impairment 1 ba zillion times better if I follow some simple rules. And just like writing tests almost always creates a better code, making a website accessible almost always makes the information architecture better.

So like excersising, I have to develop a discipline to do this.

As it relates to HTML5, there are some things to discuss. The most basic unit is role. A full list of these are available at http://bkapart.com/html5/10.

Validation

Check out Henri Sivonen's HTML5 validator at http://validator.nu.

Resources for developing OS-native applications for Apple's iOS devices.

Doing wireframes and mockups

Adobe Illustrator vector template
http://www.mercuryintermedia.com/blog/index.php/2009/03/iphone-ui-vector-elements
Briefs
http://giveabrief.com

Apple's Mobile Safari browser changed the way the Internet is consumed on mobile devices. It introduced us to the concept of the viewport, pinching to zoom in and out, and was the closest to desktop browsing any device or software had come since the invention of the smart phone.

Home screen icon

From within MobileSafari, you can add the current site to an iOS device's home screen.

The icon used here can be specified by creating a 114 by 114 pixel icon in PNG format.

Put this in the head of your document.

<link rel="apple-touch-icon" href="/apple-touch-icon.png">

If you want to prevent the device from adding the gloss, do this.

<link rel="apple-touch-icon-precomposed" href="/apple-touch-icon.png">

Media queries

With the iPad, iPhone, retina display and the ability to rotate the device's orientation developing for all scenarios can be challenging.

Luckily, @media queries save the day.

http://stuffandnonsense.co.uk/blog/about/hardboiled_css3_media_queries

Here is an excerpt from Stuff and Nonsense.

/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}

/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
/* Styles */
}

/* Smartphones (portrait) ----------- */
@media only screen
and (max-width : 320px) {
/* Styles */
}

/* iPads (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}

/* iPads (landscape) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}

/* iPads (portrait) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}

/* Desktops and laptops ----------- */
@media only screen
and (min-width : 1224px) {
/* Styles */
}

/* Large screens ----------- */
@media only screen
and (min-width : 1824px) {
/* Styles */
}

/* iPhone 4 ----------- */
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}

Techniques

Jordan Dobson demonstrates how to recreate a tab bar
http://jordandobson.com/webkit_mask_iphone_nav/retina/

Developing with Javascript can be painful. However libraries like jQuery and debuggers like Firebug have made things a lot more fun.

Tools

Firediff allows you to see what changes happen to the DOM, giving you a log of attribute differences. Great for tackling complex interactions.

http://www.incaseofstairs.com/firediff/

Lighter frameworks

Underscore.js provides some Ruby-esque features that make the language more pleasant to use. It's similar to jQuery and Prototype.js.

http://documentcloud.github.com/underscore/

Backbone.js is an MVC framework to make working with and maintaining larger Javascript applications easier.

http://documentcloud.github.com/backbone/

Who doesn't love Linux? It's easy to configure, it never gives you any pain of any kind, and every distribution is consistent with the others.

Password-less SSH access

Add your public key to the authorized_keys file in one command

You probably know that SSH supports password-less authentication using public and private keys. It involves copying your public key, normally called id_rsa.pub to the remote machine using scp. You then have to ssh into the remote machine and add the contents of the key to the .ssh/authorized_keys file. This one line command does all that in 1 step.

ssh remote-machine 'cat >> .ssh/authorized_keys' < .ssh/id_rsa.pub

Thanks to this post for the tip.

Linux man pages

I've seen this in Gentoo specifically when running man [ARG].

ESC[1mNAMEESC[0m
       /sbin/ldconfig - configure dynamic linker run-time bindings

ESC[1mSYNOPSISESC[0m
       ESC[1m/sbin/ldconfig ESC[22m[ ESC[1m-nNvXV ESC[22m] [ ESC[1m-f conf ESC[22m] [ ESC[1m-C cache ESC[22m] [ ESC[1m-r root ESC[22m] ESC[4mdirectoryESC[24m ...
       ESC[1m/sbin/ldconfig -l ESC[22m[ ESC[1m-v ESC[22m] ESC[4mlibraryESC[24m ...
       ESC[1m/sbin/ldconfig -pESC[0m

Setting the pager environment variable can fix the display of ESC characters:

export PAGER="less -E -r"

As a Software Engineer I've used Apple products since 2003. Here is a collection of commands and tips that make my life a littler easier.

Application listening to network ports

sudo lsof -i -P | grep -i "listen"

Thanks to Stefan Saasen. http://juretta.com/

Here are a few Python frameworks, most of them web related, that I'm interested in.

Django
http://djangoproject.com
web2py
http://web2py.com/
Flask
http://flask.pocoo.org/
CherryPy
http://www.cherrypy.org/
Werkzueg
http://werkzeug.pocoo.org/
Twisted
http://twistedmatrix.com/trac/
Bottle
http://bottle.paws.de/docs/dev/index.html
TurboGears
http://turbogears.org/
Pylons
http://pylonshq.com/

I believe strongly in test-driven development. In the Python world, Nose is my favorite test runner.

http://somethingaboutorange.com/mrl/projects/nose

Tips along the way

Using class level setup and teardown

Nose has class-level setup and teardown, but they are a bit tricky to use. In the internals of the test runner, these happen outside of the actual test case instance, so these need to be class methods:

class MyTest(TestCase):
    @classmethod
    def setup_class(cls):
        // do something, remember you don't have an instance of cls, but the
        //class object itself

    @classmethod
    def teardown_class(cls):
        // do something, remember you don't have an instance of cls, but the
        //class object itself

Python is a programming language that lets you work more quickly and integrate your systems more effectively. You can learn to use Python and see almost immediate gains in productivity and lower maintenance costs.

Little things I missed the first time through

When I first started learning Python I was eager to start building something right away. The language is simple and elegant and I felt like I could jump right in since I was already familiar with other dynamic languages.

There were certain things that I missed while reading those early chapters. Here are just a few.

The dict data type, it's unordered

The Python documentation states this very plainly.

CPython implementation detail: Keys and values are listed in an arbitrary order which is non-random, varies across Python implementations, and depends on the dictionary's history of insertions and deletions.

Built-in any function

This is a handy function that can simplify complex statements

if any((foo, bar, baz)):
    print 'One of these is truthy'

Collapsing two simple variable assignments

var1 = something
var2 = somethingElse

Can be collapsed to:

var1, var2 = something, somethingElse

Favorite standard library modules

contextlib

Context managers allow you to write something like this:

with open('file.txt') as fp:
    content = fp.read()

Opening your file this way automatically closes the pointer when you exit the context.

There is a standard lib called contextlib, available since 2.5, that can help you write these (because they are not completely trivial to write).

   from contextlib import contextmanager

   @contextmanager
   def tag(name):
       print "<%s>" % name
       yield
       print "</%s>" % name

   >>> with tag("h1"):
   ...    print "foo"
   ...
   <h1>
   foo
   </h1>

Working with HTML
-----------------

Sanitizing HTML can be tricky.  James Socol has created a project that works to
make it a lot easier.  Check out https://github.com/jsocol/bleach.

Software engineers typically have focus problems. We manage a lot of details and are responsible for delivering thought work. At some point in my career I discovered that my focus problem was related to how I was managing my time.

Getting Things Done

David Allen created a system for work-life management that involves some simple principles for handling the amount of stuff that comes at a human being. He named it Getting Things Done or abbreviated GTD.

I currently implement GTD with OmniGroup's OmniFocus on my iPhone, my Mac, and my iPad.

I have no doubt that I would have gone insane without this system many years ago.

Using OmniFocus to report daily scrums

For a few years I've been a team member on several agile development teams. Part of the duty of a scrum team member is to report their daily scrum.

I utilize a custom OmniFocus perspective to remind me of what I've done the previous day.

img/time-management/done-today.png

Pomodoro technique

Once you've captured the tasks you need to do on a day-to-day basis and you are managing them in a trusted system, you have to actually do the work.

I still found trouble maintaining focus but found a technique that works well for me.

Invented by Francesco Cirillo, the Pomodoro Technique outlines some simple procedures that you follow to improve your focus and concentration. In a nutshell, you work 25 minutes on a task and take small breaks inbetween.

I highly recommend this for anyone who considers themselves ADD. You can read the free Pomodoro Technique book.

Fixing silly stuff

When CTRL-D and CTRL-U start scrolling one line at a time, which can happen by accidentally hitting 1 CTRL-D or 1 CTRL-U.

:set scroll=0

Sudo writing

On occasion I will edit a file using my local unix account that has permission to read but not to write. When I go to write the file, Vim presents an error telling me I do not have permission.

Here is a handy command that can be ran to get past this.

:w !sudo tee % > /dev/null

tee is a small utility that takes standard in and pipes it to standard out.

Advanced visual block mode

This is a comman pattern, I start with something like this

Cap'n Reynolds
Zoe
Hoban
Inara
Jayne
Kaylee
Simon
River
Derrial

And I need to surround each one with something else like

firefly_character("Cap'n Reynolds")

This is a long list, I don't want to do it manually so in Vim put the cursor on the C in Cap'n and type this:

<CTRL-V>9jIfirefly_character("<ESC>

You'll end up with this:

firefly_character("Cap'n Reynolds
firefly_character("Zoe
firefly_character("Hoban
firefly_character("Inara
firefly_character("Jayne
firefly_character("Kaylee
firefly_character("Simon
firefly_character("River
firefly_character("Derrial

Now that's one rainbow special, to get the double rainbow we are going to do it with the ragged ending too.

Again put the cursor on the C in Cap'n and type this:

<CTRL-V>9j$A")<ESC>

And you get this

firefly_character("Cap'n Reynolds")
firefly_character("Zoe")
firefly_character("Hoban")
firefly_character("Inara")
firefly_character("Jayne")
firefly_character("Kaylee")
firefly_character("Simon")
firefly_character("River")
firefly_character("Derrial")

Examples

Some of the top designers in the industry get together to demonstrate the capabilities.

http://lostworldsfairs.com/

Tooling

FontSquirrel offers a great service for converting your existing fonts (make sure have license to use them first).

http://www.fontsquirrel.com/fontface/generator

Google also offers a handful of fonts that you can use. Their instructions are good and you can even download the original font to use in mockups.

http://code.google.com/webfonts

Another service, TypeKit, has a large selection of high quality fonts. You can sign up for a limited free plan, or pay a yearly fee to get access to their library.

http://typekit.com/

I haven't used the Open Font Library service, but the idea sounds great. Would be worth keeping an eye on as it appears it's not a finished product yet.

http://openfontlibrary.org/

Podcasts about it

http://5by5.tv/bigwebshow/1

Jeffrey Zeldman and Dan Benjamin grill Ethan Dunham of Fontspring and Font Squirrel and Jeffrey Veen of Typekit about real fonts on the web

Google has devoted some resources to helping web developers improve the performance of their sites. There are tutorials, guidelines, and tools to save bandwidth and make page loads faster.

http://code.google.com/speed/articles/