... Thoughts on Programming and Photography

Blog

The British Humanist Association Tagged under: humanist, atheist, religion, ethics

The British Humanist Association

I've just joined them, after watching another of Richard Dawkin's More4 Episodes. They fit my belief set almost exactly, and they might fit yours too - read more here.

We used them to organise a non-religious naming ceremony for our daughter, and I've finally got round to joining up properly. Oh, and if you haven't already - don't forget to read The God Delusion.

2010-09-01 17:52:00 0 people have commented on this post
Getting Organised - part 1 Tagged under: gtd, productivity, todo, organisation, android

Getting Organised - Part 1

If you're like me and constantly looking for new ways to improve your productivity and like to keep track of everything, I'd suggest you check our RememberTheMilk.com

You can keep track of everything, complete with tags, due date, priorities, and recurring events.

I've even convinced my wife to start using it, with lists for shopping, home chores, personal tasks and work tasks.

So after reading Dave Allen's now infamous Getting Things Done book, I'm now using rememberthemilk, 3banana notes and Google calendar to manage my life, and I finally feel that the technology is there to make it all work, with synchronization between my Android phone and the rich web clients meaning I've always got everything with me. I'll be writing more about my favourite apps as well as how I use them in future posts.

2010-05-14 21:20:00 0 people have commented on this post
Replacing EverNote with 3Banana Tagged under: productivity, notes, android

Replacing EverNote with Snaptic's 3Banana Notes

I have recently switched from EverNote to 3Banana on my HTC Desire Android mobile phone for taking quick short notes. I found that EverNote was far too slow to be useful, taking several seconds to load your existing notes from the server, presumably because it doesn't keep a local cache of your notes, fetching them from the server each time you want to make a quick amendment. It is also very much geared towards creating new notes. The process for accessing existing notes is buried in the menus.

In contrast 3banana seems much more mature, faster and better laid out for accessing existing notes and creating new ones, only accessing the server when needed.

Seeing as I don't run Windows I can't comment on evernote's desktop client, but the Snaptic web client seems equally well equipped with support for tags etc.

You can get 3Banana from the Android market.

2010-05-14 21:10:00 0 people have commented on this post
Camera Cheat sheet - part 1 - The basics Tagged under: camera, technique, photography

Camera Cheat sheet - Part 1 - The basics

I've put this brief intro together in the hope that it will explain the basics of some of the jargon you'll encounter around digital cameras, and how to make the most of your photos. It's part one in a series of posts, the size of which I haven't decided yet. Enjoy!

Aperture or f/number

Relates to the size of the circular hole through which light enters the camera. A wider aperture means more light will enter the camera. A higher f/number gives a smaller aperture (less light), a lower f/number gives a wider aperture (more light). Aperture controls depth of field, which is the amount of an image which is in focus. A wider aperture (smaller number) gives a smaller depth of field, meaning less of the area in front of and behind the object you have focussed on will be in sharp focus. Use wider apertures for portraits (such as f/11), and narrower ones (such as f/2.8) for landscapes.
Larger aperture lenses tend to be more expensive as they use higher-quality and more glass elements in their construction.

Shutter Speed

Controls how many milliseconds the shutter remains open, capturing light for your image. The longer the shutter is open, the more chance there is that you will either shake the camera, or the subject you are photographing moves, blurring the image.
You will usually need a tripod for any exposure longer than 1/60 of a second. For fast-moving objects you will need faster shutter speeds to capture them without blurring the image. (1/200 or faster). Cameras with vibration reduction or steady-shot technology will allow longer exposures without blurring the image through camera shake, but will not affect motion-blur from fast-moving objects.

White balance and colour temperature

Often left on auto. A higher "K" (Kelvin) value, the higher the colour temperature, and the warmer (redder) an image will look, a lower temperature results in a cooler (bluer) image.
For example you may have to change this to reduce the orange tinge you often get under tungsten lighting, by setting a lower colour temperature in post-processing, or selecting the correct temperature preset in the camera.

Focal length

Our eyes' natural focus length is around 50mm, anything lower than this is called wide-angle (17 - 50mm), anything higher than this (50mm+) is called telephoto. Wide angle lenses allow you to see a larger field of view (more objects), but those objects will look smaller. Telephoto lenses will show you a smaller field of view, but the objects in that field will look larger (more "zoomed in").
Typically telephoto lenses will have a higher f/number (thus let in less light) than wide-angle lenses.

Exposure Compensation

In certain circumstances, you may find that the exposure that your camera has picked for an image is too dark or too bright, in this case you can re-take the image and adjust the exposure compensation to correct it.
For example by default a camera will underexpose snow, making it look grey, rather than white.

ISO

This number relates to the sensitivity of the camera to light. The default is normally 100 ISO. The higher the ISO the more sensitive to light, but the more noise (speckles) you will get on the image.
In digital cameras it will simply amplify the signal. Useful in low light, or at night, to increase the shutter speed you can use and reduce blur, but at the cost of slightly increased noise.

RAW vs JPEG

An image saved as RAW saves the un-processed information straight from the camera's sensor. It means that you will have to process the image before you can see it on screen or share it with friends. However it also means that the camera hasn't decided for you what the image should look like, and things like the colour temperature can be set correctly.
It also allows you to make bigger changes to the brightness and colour of the image than you would by re-processing a JPEG image that's already been saved by the camera.

Modes

Full Auto (AUTO on most camera dials) - Camera controls everything for you, including ISO and Flash
Program (P) - Camera controls Aperture and Shutter speed to give correct exposure, may or may not control ISO
Aperture Priority (A or Av) - Camera determines shutter speed to use, based on the aperture you have chosen to give a correct exposure
Shutter Priority (S or Tv) - Camera determines aperture to use, based on the shutter speed requested to give correct exposure
Full Manual (M) - All settings can be changed simultaneously, up to you to work out correct exposure (maybe using a light meter).

Try to use your camera in Aperture priority, Shutter Priority, and Program modes, rather than leaving it on Auto, to learn more about how these affect your image. 2010-05-14 20:30:00 0 people have commented on this post
OpenID with CherryPy Tagged under: Python, OpenId, Cherrypy, authentication

Implementing OpenID with CherryPy

 Seeing as I've just spent most of the weekend trying to get OpenID authentication working on richbeales.net, I thought I'd share how I did it, and some pitfalls I encountered along the way.

Installation was easy, and the documentation on both OpenID and python-openid is reasonably good, however there seems to be a lack of sample code.  API references are all well and good, but they don't show you *exactly* how it should be done.

So, for anyone attempting the same thing, I'm going to reproduce the relevant sections of my login script for Richbeales.net so that others don't have to waste their weekends. 

Firstly, you'll need to install python-openid itself, which seems to be quite well distributed, so on my debian-based system, this was as easy as "apt-get install python-openid".  So, with that installed, and your website already up and running with Python and some sort of web framework (Cherrypy in this case), you'll need to do something like the following:

#! /usr/bin/python
import cherrypy, logging
from openid.consumer.consumer import Consumer, AuthRequest, SuccessResponse
from openid.store.memstore import MemoryStore

class Login(object):

    def __init__(self):
        self.store = MemoryStore()
        self.returnurl = ''

    @cherrypy.expose
    def default(self, *args, **kwargs):
        if len(args) == 1:
            self.returnurl = args[0]
            return self.PrintLoginForm()

    @cherrypy.expose
    def index(self):
        return self.PrintLoginForm()

    @cherrypy.expose
    def do(self,openid_url='',returnurl='',loginsubmit=''):
        self.returnurl = returnurl
        consumer = Consumer(cherrypy.session, self.store)
        username = self.FormatUserName(openid_url)
        cherrypy.log('initialised consumer', context='', severity=logging.DEBUG, traceback=False)
        auth = consumer.begin(username)
        cherrypy.log('begin called', context='', severity=logging.DEBUG, traceback=False)
        auth.addExtensionArg('sreg','type.email','')
        newurl = auth.redirectURL('http://*.mysite.com','http://www.mysite.com/login/verify')
        cherrypy.log('redirect called to '+ newurl, context='', severity=logging.DEBUG, traceback=False)
        raise cherrypy.HTTPRedirect(newurl)
 
    @cherrypy.expose
    def verify(self, *args, **kwargs):
      try:
        cherrypy.log('verifying ' + str(args) + str(kwargs), context='', severity=logging.DEBUG, traceback=False)
        consumer = Consumer(cherrypy.session, self.store)
        completedict = {'openid.mode':'check_authentication'}
        for k,v in kwargs.iteritems():
          completedict[k] = v
        result = consumer.complete(completedict,'http://www.mysite.com/login/verify?janrain_nonce=' + completedict['janrain_nonce'])
        if type(result) is SuccessResponse:
            cherrypy.log('complete success' + str(result.signed_fields), context='', severity=logging.DEBUG, traceback=False)
            username = self.FormatUserName(result.identity_url)
            #
            # Do your site-specific login here
            #
            return self.PrintSuccess()
        else:
            cherrypy.log('complete failure ' + str(result), context='', severity=logging.DEBUG, traceback=False)
            return self.PrintFailure(result.message)
      except Exception, inst:
          cherrypy.log(str(inst), context='', severity=logging.DEBUG, traceback=False)
          return self.PrintFailure()
        
    def FormatUserName(self, usrname):
       return usrname.strip().replace('http://','').rstrip('/')

    def PrintSuccess(self):
          return "<a href="/%s">Proceed</a>" % (self.returnurl)
        

    def PrintFailure(self, extrainfo = ''):
        return "Failed to log in - auth failed %s <a href="/login/%s">Try Again</a>" % (extrainfo, self.returnurl)

    def PrintLoginForm(self):
        return """
            <p>Please log in using OpenID</p>­
            <form action="/login/do" method="post">
            <label for="openid_url">Your Open ID: </label><input name="openid_url" id="openid_url" style="background: transparent url(/img/openid-inputicon.gif) no-repeat" type="text">

            <a href="http://www.openid.net">Get an Open ID</a>
            <input name="loginsubmit" value="Log In" type="submit">
            <input name="returnurl" value="%s" type="hidden">
            
            </form>
        """ % (self.returnurl)
­

One thing that tripped me up for a while was the "realm" parameter to auth.RedirectURL, I was simply putting "mysite.com" whereas the real answer was "http://*.mysite.com", again not something you'll find out just by reading the API docs.  Obviously replace mysite.com with your own domain name whereever you see it.

I've still got a little way to go (like retrieving nicknames and email addresses from the OpenID provider), but the above will certainly work for authentication.  Good luck (and let me know if you can help with the email retrieval!  Cheers.

­ 2010-05-09 19:03:49 2 people have commented on this post