All posts by kortsi

Temporarily Disable PostgreSQL Triggers

4.55 avg. rating (90% score) - 11 votes

To temporarily disable all triggers in a PostgreSQL session, use this:

That disables all triggers for the current database session only. Useful for bulk operations, but remember to be careful to keep your database consistent.

To re-enable:

Disable a Single Trigger

To disable just a single trigger, use ALTER TABLE:

The difference to the previous method is that ALTER TABLE will globally disable the trigger, affecting all database sessions, not just the current one.

To disable all triggers for one table:

To re-enable:

 

Ubuntu 12.04 Active Directory Authentication

4.20 avg. rating (83% score) - 5 votes

Update 2015-06-16: Ubuntu 14.04 Active Directory Authentication

Authenticating Linux users against Active Directory has traditionally been hard. There’s a multitude of HOWTOs on how to do it, and every one of them seems to do it a bit differently. This is because environments and goals vary, and there are many ways to achieve a particular goal. I will add my version to the mix. This one fetches users and groups from Active Directory LDAP using a machine account added using the Samba tools, and authenticates users to the Active Directory Key Distribution Center using Kerberos. Continue reading Ubuntu 12.04 Active Directory Authentication

Checking PostgreSQL Disk Usage

0.00 avg. rating (0% score) - 0 votes

This query sums total disk space used by the table including indexes and toasted data for the 20 largest tables:

via Disk Usage – PostgreSQL wiki.

Apache HTTP authentication against WordPress password database

0.00 avg. rating (0% score) - 0 votes

The stock mod_auth_mysql package in Ubuntu is not able to authenticate against the phpass password hashes stored in the WordPress database.

There seems to be a patch lying around to enable phpass authentication in mod_auth_mysql. Its inclusion in mod_auth_mysql has been requested a long time ago, and again more recently, but for one reason or another it has been declined. Inclusion of the patch into the Debian package has also been requested.

Thanks to Peter Lamberg, there are good instructions around on how to apply the patch and enable it. I’ve made available a pre-compiled 64-bit package here: Continue reading Apache HTTP authentication against WordPress password database

Serving Python scripts with Apache mod_wsgi, part II – mod_rewrite

5.00 avg. rating (91% score) - 1 vote

In part I, we learned how to configure Apache to server any .py file as a web application using mod_wsgi. I promised to tell you more about WebOb and multiprocessing and multithreading, and exception handling. I’ll save those topics for later articles. Instead, in this part I will talk about using mod_rewrite – if, why and how to get rid of the .py extension. You will need the test apps from part I to try these out. Continue reading Serving Python scripts with Apache mod_wsgi, part II – mod_rewrite

Make WordPress Twenty Eleven theme post pages full wide

0.00 avg. rating (0% score) - 0 votes

I wanted to make the indivitual post pages 100% wide, and also the headings a bit bigger. Here’s the CSS to do it:

Example H1

Example text 1

Example H2

Example text 2

I used the Add to All plugin to do it. Seems to work fine. Thanks go to:

AVH First Defense Against Spam « WordPress Plugins

0.00 avg. rating (0% score) - 0 votes

I added the AVH First Defence Against Spam plugin to my site. Please report to me If you can’t post comments:

WordPress › AVH First Defense Against Spam « WordPress Plugins.

Serving Python scripts with Apache mod_wsgi, part I

5.00 avg. rating (97% score) - 5 votes

I admit it, I’m a long-time PHP programmer. I got stuck with it for a long time with all my web-based stuff, simply because it is so easy to set up. Well, there is no set-up, it just works. You just add pages to your web server root and give a .php extension to them, and they get requests and give back responses. Nice and simple.

I still use PHP for quick and dirty things (like running shell commands through web interfaces – yes, really, really naughty…) For doing more complex work, I prefer Python. But I miss the PHP-like way of just adding pages or “web applications” with zero-setup. I will examine the possibilities in Python for this kind of behaviour in this article.

Please remember, there are many, some say even too many, Python web frameworks available already that handle all this stuff for you “automagically”. You are almost certainly better off with using one of them, if you want to get work done. But they all require some kind of setup work.

Then there’s the thing with all kinds of frameworks, that instead of you calling some library, the behaviour of which you understand, to do your work, a framework calls your code. That is all right when things work as expected. But whenever there are glitches, you need to start digging around the framework code to see exactly what’s wrong. And if it is a big framework, that could mean a lot of digging around. For that reason, if you’re a reasonably seasoned programmer, I think it might not be half bad an idea to create your own minimalistic framework, using existing, good quality libraries the behaviour of which you understand, and which you can easily poke in the Python shell if you think something’s not working like it should. Or just to see what’s available, and try out the available code.

Also, knowing how stuff works never hurts. This article is also about learning how the Apache http requests are dispatched to Python code through mod_wsgi. I insist on knowing how things work, so I’m doing it the hard way. Continue reading Serving Python scripts with Apache mod_wsgi, part I