Archive for the ‘Software’ Category

Buying Photoshop is more expensive then downloading it… no really

Thursday, January 3rd, 2008

I've been using GIMP for image editing but to be honest it's just not cutting it especially when it comes to EPS files. I love GIMP and I respect all the hard work people have put in to it. I also respect all the hard work people have put in to Photoshop.

I don't need the box or manuals and I want photoshop now (I don't want to have to 'think' about the money I'm spending).. Brilliant! they have a download option. But hang on..

Picture 1
Picture 2
wtf. It's more expensive to DOWNLOAD Photoshop CS3 then it is for someone somewhere to pop photoshop in another cardboard box and post 2Kg of paper and DVD I will NEVER look at. I've been looking at the two screen grabs and I just can't believe it!

Total Guitar Magazine: Decryption Error

Tuesday, December 4th, 2007


Like most metalheads I own a guitar I can't play. I also subscribe to Total Guitar Magazine. This month I noticed that I couldn't decrypt the special 'VIP Area' of the CD.

Bugger-1

Basically If I was using a PPC Mac I would be able to decrypt the data. It seems they have included the PPC only shared library for blowfish. Hmm. Well as it happens I have a copy of the x86 library that I can use to decrypt the data.

If you are suffering from this problem:

  1. Download the library here.
  2. Look inside any OSX app by right clicking (or CTRL clicking) on the application icon and selecting 'Show Package Contents'
    Showcontent
  3. Now navigate down to
    Contents/Resources/lib/python2.5/lib-dynload/Crypto/Cipher/
  4. Copy the Blowfish.so into the Cipher Folder, there should be one there already so you'll be asked if you want to replace the existing one

You should be able to run the decryptor.app now and get access to your MP3s.
Whoever makes this application should be able to make the decryption library Universal so lets hope they do that in the future.

PostgreSQL, SQLAlchemy, Dropping all tables and sequences

Friday, November 23rd, 2007


I've been working in deployment scripts for my current project and sometimes I need to drop all the tables and sequences from the database so I can create everything from scratch. I had been doing a

 
DROP SCHEMA public CASCADE;
CREATE SCHEMA public AUTHORIZATION bob;
GRANT ALL ON SCHEMA public TO bob;
 

This was great but a little destructive and over the top. It removes stored procedures and triggers as well which isn't what I want. So I looked at the SQLAlchemy docs and there is a metadata command drop_all()

 
def drop_tables():
    metadata.drop_tables()
 

Unfortunately this doesn't CASCADE so this isn't going to work in cases where tables have foreign keys (which is most of the time). It also leaves sequences in place.

So I looked at dropping each table in turn with a cascade. So how do you get a list of tables and sequences in the database? I could hard code the names of the tables and sequences but that seemed a little poor.

It turns out that PostgreSQL has a set of views that expose the inner workings of your database and a few queries can give you all the information you need.

 
def get_table_list_from_db():
    """
    return a list of table names from the current
    databases public schema
    """
    sql="select table_name from information_schema.tables"\
        "where table_schema='public'"
    execute = metadata.execute
    return [name for (name, ) in execute(text(sql))]
 
def get_seq_list_from_db():
    """return a list of the sequence names from the current
       databases public schema
    """
    sql="select sequence_name from information_schema.sequences"\
        "where sequence_schema='public'"
    execute = metadata.execute
    return [name for (name, ) in execute(text(sql))]
 
def drop_all_tables_and_sequences():
    execute = metadata.execute
    for table in get_table_list_from_db():
        try:
            execute(text("DROP TABLE %s CASCADE" % table))
        except SQLError, e:
            print e
 
    for seq in get_seq_list_from_db():
        try:
            execute(text("DROP SEQUENCE %s CASCADE" % table))
        except SQLError, e:
            print e
 

The information_schema is full of interesting information. It's actually a 'view' of lower level database tables. You can find all sorts of performance and configuration information in there. Quite handy :) Here are some docs.

Good luck.