Joe Lanman

Web design and development when not playing computer games

Prototyping with jsFiddle.net

July 4, 2010

I’m a big fan of applications that do a simple thing well; jsFiddle.net is an innovative environment to work on HTML, CSS and JavaScript in the browser. Coded by Piotr Zalewa and designed by Oskar Krawczyk, it’s a tool I’ve found really useful for me and my team – the simple four-pane layout is brilliantly suited to front-end development:
(more…)

6 Comments

Usable multiple-selection with checkbox lists and jQuery

March 21, 2009

There are two out-of-the-box methods for multiple selection in HTML: checkboxes and the <select> tag. Neither are perfect – I’ll be discussing why, and proposing a sort of mashup of the best aspects of both, using jQuery.

(more…)

4 Comments

Uploading images and making thumbnails with web.py and PIL

September 27, 2008

I ran into an issue today while trying to implement image uploads. It’s a very basic implementation: taking files from a POST request, copying them to a local folder, and then making thumbnails of them.

I started with the file upload tutorial in the web.py cookbook.

The problem I was getting was that the Python Image library (PIL) was failing to make the thumbnails, with the error ‘image file is truncated’.

(more…)

1 Comment

Passing variables from a child template to a parent in Mako

September 17, 2008

After looking at Web.py’s own templating system, and considering Cheetah, I’ve ended up going with Mako for now. So far I’ve found it very straightforward, with some powerful-looking features to expand into in the future.

One of the great features is template inheritance – but I hit an issue recently with passing a variable from a child template to a parent. It’s not immediately obvious how to do this, but I found the answer on the Mako Google Groups archive (link here):

Child:


<%inherit file="meta.html"/>

<%def name="vars()">

	<% return (meta.id,) %>

</%def>

Parent:


<% (id,) = self.vars() %>

On a side note, I found out today that two of the Python libraries I’m using, Mako and SQLAlchemy, were coded by the same guy – Michael Bayer. Clever chap – not only are the libraries pretty impressive, but they are both well documented and he regularly contributes to the mailing lists for both projects. And he doesn’t even have a big internet head like some developers – though I tracked his blog down here:

http://techspot.zzzeek.org/

No Comments

Making a copy of a SQLAlchemy object

September 15, 2008

Should that be ‘a’ or ‘an’ SQLAlchemy object?

My current CMS project is based on creating templates in the back-end, and then using these to produce ‘inherited’ objects with the same attributes.

multiplicity

I quickly found that it’s surprisingly tricky to grab a template object using SQLAlchemy, and copy it into a similar, but separate, entity. Using the Python ‘copy’ function confuses SQLAlchemy – when you try to save it, it thinks it is merely a representation of the original (template) object.

Here’s how I create separate ‘clones’ from my template objects, defining a function on the object itself:

(more…)

No Comments

Having cake and also eating it: Compiz and dual-head on an ATI HD 2600

August 15, 2008

dual head photo

Only a day after complaining about my ATI card running under Ubuntu, I seem to have a solved a lot of the issues. Slightly embarrassing. To recap – my system is set up like this:

HP 8510p laptop with an ATI HD 2600 mobility card running Ubuntu 8.04 with a 1680×1050 screen, often connected to an external monitor (same resolution).

My ideal setup would be like this:

  • ‘Big desktop’ mode when plugged into an external monitor, allowing windows to be dragged between screens.
  • When the monitor is unplugged, to continue working on the laptop screen, without restarting Xorg.
  • Compiz-fusion providing ‘expose’ functionality amongst other things.
  • Generally not having crashes would be nice.

(more…)

1 Comment

The past is a foreign country

They do things in Windows there.*

So I’m making a valiant effort to move to Linux, and stay in Linux.  I like how easy it is to install development stuff (servers, compilers, libraries) and I like the ethos of open source software. I installed Ubuntu a few months ago, and again on my new HP laptop. Everything is snappy and responsive, but I have had a few problems…

(more…)

No Comments

Python-style startswith and endswith string functions in Javascript

July 10, 2008

The Python language has useful string methods to search for prefixes and suffixes:


my_string.startswith('pre')

The same thing can be achieved in Javascript using the rather powerful search and replace methods.

(more…)

1 Comment

Using JQuery and Javascript to parse XML to objects

July 8, 2008

Right – thought I’d post some actual code as proof of actual development.

I wrote the first version of my CMS back-end in PHP, and sent data to a Javascript front-end using JSON. This was fantastically fast and simple – the string only need be checked for dangerous syntax, and then eval-ed and it becomes Javascript objects ready to use. The pot-noodle of data formats.

(more…)

No Comments

Hello world!

June 25, 2008

Hello to the world.

PHP eh? Good old PHP.  I’ve been coding various apps and sites in PHP for a few years now – it’s been great, the documentation is excellent, there’s a huge community and it’s easy to put stuff together quickly. Special mention to the Codeigniter framework – it’s finally helped me get the whole MVC thing and has made my last few projects much more enjoyable.

But this post is about Python. I’ve decided to learn Python since it seems to get recommendations from all quarters and appears to be both pragmatic and elegant.  My first project is going to be my new portfolio/blog site (current version here), and I’ll be writing about my experiences here. Developing in Python seems to be smoother in Linux, so I’ve installed Ubuntu, and I’ll probably be mentioning my experiences learning a new OS too.

It’ll be like the Incredible Journey.

No Comments

WP SlimStat

Asynchronous Google Analytics for WordPress plugin powered by WordPress Expert at minilibra.com.