Monday, July 20, 2009

Python Imaging Library Macbook

Well, I'm thinking of installing a new framework called Pinax, which is a souped up version of django. I'm hoping to create a test case by rolling my own blog.

Anyway, one of the features of Pinax is that it comes with everything including the kitchen sink. Including the dreaded Imaging module. Now I say it's dreaded, because in order to get it running you need to be using PIL (Python Imaging Library), which in itself depends on libjpeg, which is a massive headache to install.

Why? Because libjpeg will only build to either i386 or PPC architecture (sound familiar?), and NOT to a fat client.

Normally, this isn't a problem, except that the build phase for PIL does build to a fat client. Which means the damn thing won't work.

After a lot of hunting, I found someone else who had the exact same problem.

To cut to the chase, the solution can be found here.

Incidentally, you can install libjpeg7 no problem.

Wednesday, January 28, 2009

I hate apple

I really really do. Sometimes I think the people at Cuppertino intentional make things weird just to trip me up.

Anyway, I needed to install libxml2 onto my system, because the default version just won't cut it. But of course, the system ignores what I installed and keeps using the /usr/lib version.

So I overwrite it. Sensible right? I mean, I'm just using the latest version of some code written BY THE GUYS THAT CAME UP WITH IT IN THE FIRST PLACE ... naturally the whole system breaks down.

So I boot out, reinstall the libxml2 libraries that come with the installation disc and hunt around and find out that I'm not alone.

I hate apple. I wish adobe would come out with a flash IDE for Linux so I can just switch over and use an operating system THAT ACTUALLY WORKS.


mycomputer$ export ARCHFLAGS='-arch i386 -arch ppc -arch ppc64 -arch x86_64'

mycomputer$ ./configure --with-python=/Library/Frameworks/Python64.framework/Versions/2.6 --prefix=/usr/local/libxml2-2.7.3

mycomputer$ make && sudo make install

cd /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
sudo ln -s /usr/local/libxml2-2.7.3/lib/python2.6/site-packages/* ./


Note that when you are passing over the value for --with-python, you are only passing the dir where python2.6 is located

Two invaluable sites:

James Clark
lsimons

Wednesday, January 7, 2009

Why "but he's our SOB" is really just an SOB

I never liked Christopher Hitchens. OK, I'll admit that I found his debate with his brother to be pretty sweet, but on the whole I've felt him to be pompous and fanatical.

Like a lot of atheists, he's as devoted to his anti-religious screed as the people he decries are devoted to their own religions. But I could live with that. I could live with his insults to my religion, especially regarding circumcision. I could live with the vitriol he directs at religious Jews in general. I could live with the backhanded insults he gave to America, probably the worlds greatest Democracy. A country founded primarily by religious Christians.

I could live with it, because I understood the principle of "the enemy of my enemy is my friend". Hitchens made it very clear, that as much as he despised religious people, as much as he despised G-d in general, as much as he tried to tear us down at every opportunity, at least he would help support us in the fight against islamic fascism.

Then of course, he backed Obama, the former Senator who tried to stop the very successful surge. Why? Because Palin, the vice presidential candidate was too religious for him.

What we learn from this is the following "the enemy of my enemy, may be helpful, but know that sooner or later the son of a bitch will stab you the back."

I'm only thinking of this now because of this post I read on Martin Kramers blog. All I could think to myself was "what a pompous bastard!"

Well, not so much that as this. If you see that someone is a fanatic, if you see that they have an axe to grind, and that they are over the top in their statements, know that such people are never to be trusted. It doesn't really matter what their philosophy is or viewpoints are. It can be views similiar to your own. But fanaticism and nuttiness in general indicates someone who simply wishes to sow chaos and grief.

why don't pirate ads are useless

A lot of media industries are concerned about pirating. Which is fair enough as it goes, as they stand to lose a lot of money.

One of the more reasonable suggestions that they've been trying to implement is a public awareness campaign. The idea in itself is fine, but the implementation is pathetic.

In a sane world run by sane people, these corporations would buy airtime on radio, commercials on TV, and advertising space in newspapers. In other words, they would pay for this solely out of their own pocket. When someone takes a lot of time and trouble to say something people tend to at least listen.

But that's not at all what they do. Sure, they pay to film the commercial. But they play it on our time.

What do I mean by "our time"? Well, when you purchase a ticket to see a movie for $15, then the time spent watching the movie is your time. This isn't commercial TV, where the content providers have to air commercials in order to pay expenses. This is a movie, you paid for it, you expect it without having to see pointless crap that has nothing to do with the film.

Instead, after having paid the money, you get a 2 minute commercial chastising you not to buy pirated DVDs.

Well, I suppose that's a cheesy thing to do, but it's tolerable right? Here's where it becomes intolerable.

When I go to blockbuster and rent a DVD or I buy a DVD, I get to see the same damn commercial. Why? Is it not obvious to the idiots in charge that if I paid for the DVD then I am clearly not pirating illegal copies? No, it is not obvious to the idiots in charge, not because they are idiots, but because they themselves are thieves.

When you steal someone else's time, that is stealing. When you force me to watch one of your damn commercials on a disk that I bought or rented, you are stealing my time. You are stealing from me.

Such commercials are no more than the whining of a thief. And I suspect that anyone who watches it has nothing but contempt for the people who made them see it.

Thursday, January 1, 2009

Vexxar is an underrated comic

Hunter Cressel is the guy who came up with the classic mac parody. If you haven't seen it, check it out!

He also has a comic called vexxarr. It follows a cynical alien overlord who is only competent at staying alive in a universe run by a God with a very ironic sense of humor.

Anyway, every now and then Hunter has Vexxar or his various companions make observations that are just classic, like his observations regarding Linux enthusiasts. Today was a perfect example. This one is about a rule known as Ripley's Law.

John Derbyshire got it right

I was googling for an answer to the question "What do arabs really think of Palestinians" and stumbled on an article written by John Derbyshire in 2002.

This is the money quote:
All of this applies to the Palestinians. I spent some of my formative years in Hong Kong, a barren piece of rock with zero natural resources, under foreign occupation, chock-full of refugees from the Mao tyranny. The people there weren't lounging in UNRWA camps or making suicide runs at the governor's mansion. They were trading, building, speculating, manufacturing, working — with the result that Hong Kong is now a glittering modern city filled with well-dressed, well-educated, well-fed people, proud of what they have accomplished together, and with a higher standard of living than Britain herself. If, following the Oslo accords — or for that matter, in the 20 years of Jordanian occupation — the Palestinians had taken that route, had set aside their fantasies of revenge and massacre, and concentrated on building up something worth having, I might have respect for them. As it is, I don't.

setting up django with mod_python

Important:

Before you do anything else, if you intend to use the admin feature in Django, make sure you go to your httpd.conf file and comment out this line:
LoadModule php5_module libexec/apache2/libphp5.so
For some reason mod_python.so and libphp5.so do not play nice together when it comes to the admin section of Django. If some kind person could either explain why or direct me to a site that has an explanation, that would be great.

Installing Django:

django can be found at - http://www.djangoproject.com/

I downloaded the svn version. Usually, I end up with several different versions. My django directory typically looks like this:

./
../
trunk_9600
trunk_9634
trunk_9650

I simply rename the trunks according to their version number and symlink ln -s ./django-trunk ./trunk_whatever This way, when I set up the symlink in the site-package directory to the django install, it is set up to the symlink django-trunk, which itself is linked to whichever trunk I happen to be using.

To link to the site-packages directory, do the following two commands:

  • SITE_PACKAGES_DIR=`python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`
  • ln -s `pwd`/django-trunk/django $SITE_PACKAGES_DIR/django

Very good, now setting up apache.

Leopard is a bit quirky, but I want to use their way of doing things if at all possible. Here are some links to get around various problems:

kevin covers some basics on virtualhosting
aking discusses an important quirk to get multiple virtual host names working

I do my work on localhost, so my /etc/hosts file looks like:
127.0.0.1 localhost site1.dev something.whatever

then in my httpd-vhosts.conf file I have:

NameVirtualHost *

<VirtualHost 127.0.0.1 >
ServerName localhost
DocumentRoot "/Users/ronny/Sites"
</VirtualHost >

<VirtualHost * >
ServerName something.whatever
DocumentRoot "/Users/tickletik/Sites/mysite"

<Location "/" >
SetHandler mod_python
PythonHandler django.core.handlers.modpython
PythonPath "sys.path+['/Users/tickletik/Somewhere']"
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug On
</Location >
</VirtualHost >

There are a few points to keep in mind
  • I'm assuming you are using the django tutorial, so I named it "mysite". mysite.settings is used with the DJANGO_SETTINGS_MODULE
  • if I wanted the DocumentRoot for something.whatever to be "/Users/tickletik/Sites" then I would have had to set Location to < Location "/mysite/" > DO NOT forget both slashes!