20seven

Devigner blog about development and design

Emacs Series

I am going to attempt to participate in the National November Writer’s Month with Eric Florenzano, Eric Holscher, Brian Rosner, Justin Lilly and James Tauber. I’m going into this daunting experiment with a mostly positive attitude. (I think i can…) We’ll see.

I’ve never done a series here on 20seven before so over the next few weeks I’ll be doing a six part series on GNU emacs as my development environment. I’ll be mixing in some posts on art and photography as well as Django related posts so bear with me.
Here’s what to expect in the Emacs Series:

Part One: Distraction Free Programming with GNU Emacs
Comparing emacs to great distraction free apps like Writeroom and Aperture and how to manage your windows.

Part Two: Emacs Terminal Emulator
Never have to switch between terminal and emacs and how to set this up.

Part Three: Dired Directory Management
A quick comparison of Dired and ECB and how to make Dired work for you.

Part Four: Setting up Emacs for Python Programming
How to setup your emacs configs for Python using Rope, Ropemacs and YaSnippet for code completion, tags and Python docs.

Part Five: SCM in Emacs
An overview of SCM and it’s capabilities in emacs.

Part Six: Search and Replace
Just what it says.

Now, let’s hope I can pull this off and I wish my friends luck with their blogs as well!

[Update: i’ve made my dotemacs available in case anyone wants to take a peek. Suggestions are welcome]

Django Cachebuster

In a chat with James Tauber he mentioned he needed a cachebuster and for a few projects including Pinax I need to ensure my css and javascript edits are not being cached in the browser. This is a standard feature in Rails but not in Django so I whipped up a simple setup of tag helpers to do the trick.
Introducing the stupidly simple django-cachebuster written while watching the Football Sunday. I’ll probably continue to add new tags to simplify my projects. Ideas are welcome.

For now it has two helpers, css_tag and js_tag. Using the template tags will return a full css or javascript tag with the filename and a sha1 hash appended based on the name and edit date of the file. When the file is changed the hash is updated.

Usage

I didn’t like the way the code blocks formatted so I’ll just let you read the “Usage” over at github.

Pinax Setup and Deployment

For the past four or five months I’ve been helping out and contributing to the Pinax project which is gaining popularity and buzz very quickly. If you’re not up to speed on what Pinax is, the best and most amusing way is to watch the video of James Tauber’s talk at Djangocon or simply dive in and get your social network up and running.

After the launch of Cloud27 and Djangocon, there has been much more activity surrounding Pinax and a few questions about deployment. While the documentation is being worked on, I figured I would write up some general principals on the deployment of your project.

Checkout

Obviously, you need something to work with so go get the source or using subversion…

svn checkout http://django-hotclub.googlecode.com/svn/trunk/ django-hotclub

Structure

First glance at your directory structure will reveal the following:

  • pinax/ contains a django project and templates
  • external_apps/ contains external re-usable apps brought in via svn:externals
  • local_apps/ contains re-usable apps that aren’t yet externalized
  • core_apps/ contains non re-usable apps specific to pinax site
  • external_libs/ contains external libraries

Dependencies

The only real dependency is python imaging library which is required for Photologue and its image uploader and resizing. Other dependencies that may be required for your particular server are located in the external_libs directory if you find you need them. It’s nice that you don’t have to run around google trying to find these packages, (with the exception of PIL) they are all provided for you.

Settings and Customization

Typically, the only thing you really need to change are the database connections and type depending on your preference. Create a localsettings.py file in the pinax directory and add the following (if you do not want to use the default sqlite3 setup).


# 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = 'dev.db'
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''

When you have these settings set, simply run the following to create your database and install the fixtures.

python manage.py syncdb

Django-Photologue

Pinax has photo sharing capabilities and uses some of the functionality provided by django-photologue. As stated in the dependencies, you will need to have PIL installed on your server to take advantage of these features.

mod_wsgi

For Apache and mod_wsgi deployments hers is a sample virtual to get you up and running.


<VirtualHost 208.00.00.000:80
    ServerName somedomain.com
    ServerAlias www.somedomain.com
    DocumentRoot /home/somedomain/public_html
    WSGIScriptAlias / /path/to/your/django.wsgi
    WSGIProcessGroup uniquename
    WSGIDaemonProcess uniquename user=apacheuser group=apachegroup threads=25
</VirtualHost>

Sample django.wsgi file:


import sys
sys.stdout = sys.stderr
import os
from os.path import abspath, dirname, join
from site import addsitedir
path = addsitedir(abspath(join(dirname(__file__), 
    'django-hotclub', 'external_libs')), set())
if path: sys.path = list(path) + sys.path

sys.path.insert(0, abspath(join(dirname(__file__), 
    'django-hotclub', 'external_apps')))
sys.path.insert(0, abspath(join(dirname(__file__), 
    'django-hotclub', 'local_apps')))
sys.path.insert(0, abspath(join(dirname(__file__), 
    'django-hotclub', 'core_apps')))
sys.path.insert(0, abspath(join(dirname(__file__), 
    'django-hotclub')))

from django.core.handlers.wsgi import WSGIHandler

os.environ['DJANGO_SETTINGS_MODULE'] = 'pinax.settings'

application = WSGIHandler()

Here is a good overview on using mod_wsgi with django if you want more information.

mod_python

For Apache and mod_python deployments here is a sample virtual setup to get you going. The following makes the assumption that you have installed the dependencies you might need.


<VirtualHost 208.00.00.000:80
    ServerName somedomain.com
    ServerAlias www.somedomain.com
    DocumentRoot /home/somedomain/public_html
    <Location />
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE pinax.settings
        SetEnv PYTHON_EGG_CACHE "/path/to/your/python-eggs"
        PythonPath "['/path/to/your/django-hotclub'] + sys.path"
    </Location>
    Alias /media/ /src/django-trunk/django/contrib/admin/media/
    <Location /media/>
        SetHandler none
    </Location>
    Alias /site_media/ /path/to/your/django-hotclub/pinax/site_media/
    <location /site_media/>
        SetHandler none
    </Location>
</VirtualHost>

Additional Resources

If you have any additional question or need help, the quickest way to get it is to join us in the #pinax irc channel on freenode.

[UPDATE] Eric Holscher has also posted a nice Getting Started Guide worth checking out.

A Quick Way to Build Graphviz and Pygraphviz

Eric Holscher put up a nice screencast Saturday on using the excellent django command extensions. I’ve used it before but wasn’t aware of all the nice features the guys had built into it so I needed to get my Mac up to speed with graphviz. Fine and dandy but pygraphviz didn’t play nicely with the graphviz images available, so I needed to build it.
I am providing my shell script that will download and build all dependencies including graphviz and pygraphviz for use with django command extensions.

Instructions

ZIP DOWNLOAD: gv-pygv.sh

Once you have the download, extracted the zip file. Add the following to your bash_profile.

export PATH="/usr/local/bin:/usr/local/sbin:$PATH"

Then in terminal simply run:

sh gv-pygv.sh

The script will download and build the following dependencies along with Graphviz and pygraphviz.

  • cairo
  • freetype
  • gd
  • fontconfig
  • urw-fonts
  • glib
  • libpng
  • pango
  • zlib

In addition, I ran into dependency issues with Cairo so i have included those in the shell script but commented them out. If you run into issues with pkg-config and/or pixman, simply uncomment them and re-run the shell script.

NOTE: I take no responsibilities if your mac grows hair and implodes because of this shell script. You are however required to share any and all lottery winnings with me.

Painterly Portrait Post Processing Tutorial

Since posting this picture of my son Brodey on Flickr many months ago, I have received a lot of emails asking how I did the post work. Many people think it’s HDR, some say it’s got the Dave Hill feel to it.

Attitude Reprocessed

I will go through my recipe in detail. It’s not a hard process. It’s something I’ve refined to work for me and over time, it’s become second nature. I have even used it on landscapes with great success. A lot of this works better with higher contrast images and good lighting (not that I’m great at lighting).
Feel free to use the techniques but please don’t republish this article or the images used in it.

Note: Click any image to see larger views.

Shot Details

For this shot, I setup under a bridge in the mid afternoon sun. Dialed down so I could overpower the sun coming in from the sides of the bridge and setup a SB-600 controlled via CLS to the left of the camera through a white umbrella.

Reduce Saturation of RAW Image

I don’t like overly saturated images so the first thing I do is reduce the overall saturation. I usually go back in later and add in a little saturation for certain colors which we’ll do in a later step.Post Article - Step 1

Vignette

For some images, vignettes work nicely. Especially this image because I think combined with the graffiti it adds a feel of darkness and grunge.

Increase Saturation in Blues

Now I’ll add back in some saturation for just the blues which will help pull out Brodey’s eyes and shirt. A little bit of blue exists in the graffiti which will make for some nice accents.

Add Definition

Post ArticleBefore I send the image over to Photoshop, Aperture 2.0 has a very nice definition tool which I use to prep the image with some detail. In version 1.5 (the original image) I used the edge sharpen tool.

Send to Photoshop

This is as far as I go in Aperture. With Aperture 2.1 you can do a lot of the following steps but I prefer photoshop for the heavier lifting.

Duplicate Base Layer and Add A S-Curve

Post ArticlePost Article - S CurveDuplicate the base layer and go to Image >> Adjust >> Curves to add an S-Curve. I always click on options and choose “Enhance Monochromatic Contrast”. It will effect the luminosity of the image this way instead of blowing your colors.

Shadow/Highlight

Post Article - S/HWith the duplicated layer still selected, go to Image >> Adjust >> Highlight/Shadow. Unless the highlights are blown, I typically only work with the shadows to lighten some of the dark areas. For this image my main concern is Brodey’s hair, shirt and a little bit of the graffiti. I think this is a fantastic tool and one that is often overlooked in photoshop.

Duplicate Layer and Set To Soft Light

Duplicate this newly edited layer (your second layer) and set the blending mode to “Soft Light”. Most of my images seem to work best with this blending mode. “Vivid Light” and a few others can be used as well so play around after the next step and see which you prefer for the image you’re working on.

High Pass For Detail

Post ArticleI’m a fan of using High Pass for adding detail instead of unsharp mask. I think it does a much more painterly job when sharpening and can add some very nice effects to the image. Go to filters >> other >> High Pass and set the radius slider to about 9. This is highly dependent on the image, but for most I find this setting where I like it. The reason I set the blending mode prior to this step is so I can see the effect of the High Pass tool in real time. If you don’t, the image will look embossed like the tiny preview in the dialog.

Dodge Hair, Eyes and Wrinkles

Post ArticleI go back to layer two, the layer that I did the curves and highlight/shadow to and dodge (lighten) the midtones in the eyes, hair and shirt’s wrinkles to pull out some more details. If you dodge the wrinkles in the clothing, it tends to give it a more three dimensional look.

Burn Shadows in Wrinkles

After I dodge, I usually go back and burn some of the wrinkles just to pull out more of that third dimension. Be careful not to pull the focus of the image into a area where you don’t want it.

Duplicate Layer and Move to Top

When the dodge and burn is complete, duplicate the layer and move it to the top of the stack. We’re going to soften the image a little. When using the highpass and dodge tools, the image can quickly become too harsh with detail in my taste. Some people may want to avoid this step but I typically do it on all portraits. It softens the skin too and helps hide blemishes.

Add Gaussian Blur

Post ArticleChoose Filter >> Blur >> Guassian and set your radius slider to around 1.5, just enough to blur the image and hide some of the harsh details. Apply the filter and set the layers opacity to your liking. For this image I set it to about 80% opacity. Notice you still have more detail than the original image but not too harsh.

Step Fifteen Erase Eyes

Now that the image is softened, I want the original harsh detail from the earlier steps in the eyes to draw them out. I use the eraser tool with a soft edged brush to remove the gaussian layer at the eyes.

When I’m satisfied with my edits and save the image which sends it back to Aperture for cataloging.

Post Article

$6000 Dollar Fine - Whose Business Is It

The New Mexico Human Rights Commission is fining a husband-wife team of Christian photographers $6000 dollars for refusing to photograph a lesbian commitment ceremony. Read the full article if you want more background on this case. There are a couple of blog posts that touch on the subject at MarioBurgers and ThomasHawk. If you read the posts and comments, the opinions of the readers and authors seem to be split into two issues and three sides. Discrimination vs. Freedom of Choice from the angle of Christians, Gay Rights Activists and Business Owners. What immediately struck me is the rights (or lack of in this case) that a business owner has in refusing projects.

Religion vs. Gay Rights In This Case

In my interpretation of this case without knowing either party, it seems to have turned into playground mud-slinging between Christians and Gay Rights Activists. It’s obviously about someone who was disgruntled because they were refused service and that service provider may be hiding behind their religious convictions. This is NOT what I want to discuss here, nor do I want this to turn into a reincarnation of the situation. If it does, I’m going to whack you in the back of the head with Skeptic Magazine!

Freedom of Choice for Business

What I do want to touch on is the rights of a business to refuse the work requested from them. Should a business have this right? Thomas Hawk has used McDonalds as an analogy to provoke thought on the subject and to illustrate discrimination.

Should McDonalds be allowed to only serve white people if they wanted to?

I personally don’t think that’s a fair comparison. His example is an obvious civil rights issue and what he refers to is a simple product based business model. Common sense as a business owner should come into play in cases like that. What we have here is two people conducting a service based business. Some may think of photography as a product, but in all actuality the process of creating is more of a service with a end result which may be a product, digital or tangible. This holds true for web developers, designers, artists, ad agencies, etc. After the service process, there’s usually an extended relationship in negotiating rights, reviewing images and ordering prints and albums. After completion of the project there is usually a request for reprints, more rights negotiation and ultimately repeat business.

Most service based business require a much more intimate relationship with the client and one that may be used as an example of the quality and type of work as well as the clientele they choose to work with. I’m sure most web developers and designers, myself included, have been asked if they would develop a site for someone in the porn industry. I myself, without thought, turn the projects down for obvious reasons. However, if a project with that scope was accepted, and other existing or potential clients were aware, I’m sure there would be some loss of business from the industries I will do work and in some cases a loss of existing clients.

The ultimate question is, should the government and courts dictate who I choose to do business with? Absolutely not. That’s one of the luxuries of being self employed. I choose the work I’m comfortable with on a basis of project scope and if it will be good for future business. I often ask myself, do I want this kind of work in my portfolio? Will this client be hard to get along with? Is there any conflict in moral and ethical beliefs? Does this client and project fit into my chosen target market? Is this client an honest person and will I have problems with him/her in the future? I don’t want the courts asking these questions for me.

Aperture 2.1 Update With New Tools

Released today, Aperture 2.1 introduces an open plug-in architecture that lets photographers use specialized third-party imaging software from right within Aperture. In fact, customers downloading the Aperture 2.1 update will receive the new Dodge & Burn plug-in. Developed by Apple, it adds brush-based tools for dodge (lighten), burn (darken), contrast, saturation, sharpen and blur. Aperture 2 customers can download the free Aperture 2.1 Update by visiting the Aperture download site or by running the software update.

Apple is working closely with key developers to bring the most requested plug-ins to Aperture such as:

  • Nik Software’s Viveza plug-in, powered by U Point technology, which provides a powerful, precise and easy way for photographers to selectively control and adjust color and light in their digital images;
  • PictureCode’s Noise Ninja plug-in that delivers advanced high ISO noise analysis and reduction;
  • Digital Film Tools’ Power Stroke plug-in that features a simple, stroke-based interface to quickly mask and intuitively perform targeted adjustments;
  • The Tiffen Company’s Dfx plug-in that provides an expansive suite of creative filters and effects;
  • dvGarage’s dpMatte plug-in, which is a high performance chroma key tool for creating seamless composites, and the HDRtoner plug-in that enables the selection of multiple photos to create a single high dynamic range (HDR) image; and
  • Image Trends’ plug-ins that include Fisheye-Hemi to quickly and effortlessly correct fisheye lens distortion, ShineOff which automatically removes shine from faces and PearlyWhites that automatically whitens and brightens teeth.

New Design for the Transition to Movable Type

After a few days of sketching and PS mockups I think I finally have the new 20seven.org design close to being in a state that I’m comfortable enough to start working on the CSS for the big switch to Movable Type. However, I’m sure after I sleep on this tonight I’ll probably wake up tomorrow with something I don’t like. A design for yourself is always ten times harder to work on. I thought I’d throw it out there for thoughts.

[Update] I’ve bailed on MT4. I’ll update in another post about why I’ve gone this route.

Happy Cog and Wordpress 2.5

Happy Cog has been working with Wordpress to develop a new interface. Screenshots or downloads of the 2.5 sneak peak are available on the Wordpress site.

“The WordPress navigation has confounded even sophisticated users. With the new design, we’ve cut the number of navigation options in half, separating the primary functions (writing, managing posts and pages, editing the blog’s design, and managing comments) from secondary functions. This presents information at a more comfortable pace, revealing only the information that’s necessary.”

From what I can see Jeffrey Zeldman and crew have done a fantastic job at cleaning up the clunky interface; one of my major beefs with it. Keep in mind that it is only release candidate one.