Source Guru

Archive for December, 2008

Console Love

by Mez on Dec.27, 2008, under Personal

Ok, so, some of you may know that I recently switched from using Xchat + ctrl_proxy to irssi for my main IRC connection. I did this as I’d been pestered literally thousands of times to “get a real IRC client”.

While I don’t agree with this philosophy (Xchat IS a real IRC client!), I have to admit, I’ve not regretted switching to irssi! Combining it with screen means that I can see the same IRC session from anywhere, and using irssi gives me quite a few cool new features (I’m a HUGE fan of regexes!). So, irssi, after getting used to switching channels, and managing everything is great for me. I can now authenticate to OFTC using SSL, I can use IPv6, and many many other things. Slick.

Anyway, as I’ve said, I also use screen. This is one of the best tools ever created by man. It’s increased my productivity, and it’s so simplistic to use.

So, why am I writing this now?

Well, over the past few ways, I’ve finally got around to using mutt for the first time, and while it’s not as pretty as some of the email clients you get out there, it does exactly what I need. And, although I’ve spent the last 2 days tweaking my configuration, getting confused, rereading the mutt manual, shouting and swearing, getting even more confused, rereading the mutt manual again, I’ve found that mutt, for me, is actually an email client that does what I want it to.

For example, using mutt, I now no longer have to worry that I’ll send an email to a mailing list using the wrong address, I can subscribe to a better “Inbox Zero” philosophy (Inbox Zero Status: 0!) and managing my email seems to come more naturally.

Mutt may be hard to get used to, a pain to configure just the way you want it, but, in the end, it makes sense. I’d reccomend everyone try it at least once!

So, yeah, I’ve moved my ubuntu email address over to mutt (in a screen window alongside irssi!) and will be moving the others just as soon as I can be bothered to goto all the different places and combine my .procmailrc. But I’ve made a start, and, for the forseeable future, it’ll be my mail client of choice.

It seems though, I’m spending a lot more time in an xterm than I am in anything else.

Maybe I should start using bitlbee too ;)

9 Comments :, , , , , , more...

zsh seems to be getting a lot of press of late …

by Mez on Dec.17, 2008, under Personal

And so it should – it’s an awesome shell.

Anyway, I’ve just spent a lot of time sorting out my zsh so it does titles in the right way. By this, I mean changing the title of your xterm window, and/or your screen window.

Anyway, here’s the code that I use for my zsh titles

precmd () {
 case $TERM in
 screen)
 print -Pn "\e]0;%n@%m: %~\a"
 print -Pn "\ekzsh: %~\e\\"
 ;;
 xterm*|rxvt)
 print -Pn "\e]0;%n@%m: %~\a"
 ;;
 esac
}

preexec () {
 case $TERM in
 screen)
 print -Pn "\e]0;%n@%m: $1\a"
 print -Pn "\ek$1\e\\"
 ;;
 xterm*|rxvt)
 print -Pn "\e]0;%n@%m: $1\a"
 ;;
 esac

}

I find this works in the same way that the default bash shell does ;) though – it also works quite nicely with screen, and sets the screen titles for you too :D

Also – my prompt lines are (inspired by Daniel Silverstone circa 2005)

export RPROMPT='%B%d%b %t '
export PROMPT='%B%n@%m %#%b '

Happy zsh’ing folks!

7 Comments :, , , , , more...

Hacky HTML

by Mez on Dec.09, 2008, under Personal

Ok, so working on a new site, I’ve realised that an image I’ve floated to the right of my text seems to be overlapping the items beneath it.

Ok, so, that’s obviously not what we want!!!!

Normally, I’d use clearfix for this, however, I have the issue that I will also be using a sidebar (at times) and well, clearfix will interfere with this:-

So, that’s obviously not something we want! – I had to find a nice way of doing this, without it interfering with everything else!

I thought about this, and thought I’d do a bit of voodoo with CSS and make this work!

Yay! It worked!

How’d I do this you may ask. Well, the containing div needed the following CSS (which also, quite niftily extends the height of the float if it’s the shorter one, making it the full height of the containing div

overflow: hidden;
padding-bottom: 32767px;
margin-bottom: -32767px;

The only issue? – It doesn’t work in any Internet Explorer Version, or Opera <= 8 – though it works in pretty much every other browser (according to browsershots)

*sigh* back to the drawing board, unless anyone else has some suggestions?

Edit: I was wrong – it works in IE7, but not in IE8
Edit 2: and it works in IE8 if you tell it to run in IE7 compatibility mode

10 Comments :, , more...

Django – S3 Storage Engine

by Mez on Dec.02, 2008, under Personal

After having read James Bennett‘s article on Django Media and Performance I decided that I wanted to be using S3 for storing and serving media for a new site that I’m working on (in Django)

So, it seems that it’s not that easy. I did first of all experiment with using FUSE, but decided against it.

Anyway, looking through some obscure documentation, I found that Django can use custom storage methods. So, I thought I’d write one.

You can find the file here

The code requires you to have Amazon’s S3 API installed.

So, how do you use it? It’s pretty simple really. First of all – you need to setup your configuration – so edit settings.py and add the following (changing the values to suit your needs!)

S3_SETTINGS = {
    'aws_key': 'XXXXXXXXXXXXXXXXXXXX',
    'aws_secret_key': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    'bucket': 'bucket_name',
    'default_perm': 'public-read',
    'vanity_url': False
}

The settings should be self-explanatory – apart from ‘vanity_url’. S3 allows you to CNAME a domain name to a bucket with a similar name – for example, I could CNAME files.sourceguru.net to files.sourceguru.net.s3.amazonaws.com and it would allow me to serve information from that bucket as if they were coming from my own domain. (infact, I’m tempted to do this – I’ve too much stuff in my files section!) – the vanity_url – when set to True – will use the bucketname as the domain instead of <bucketname>.s3.amazonaws.com.

Now, to use it in a model, it’s as simple as adding an import line at the top of the models file

from site.app.s3storage import S3Storage

and then, in your model

class Item(models.Model):
    storage = S3Storage()
    image = models.ImageField(upload_to='path', storage=storage)

Pretty simple, :D

Hope this helps some people out there!

5 Comments :, , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!