Archive for March 2007
Problems with MD5 and mod_python
When calculating MD5 hashes from mod_python in Debian Testing the result of MD5 calculations were all wrong. Something as simple as:
hash= md5.new("string").hexdigest()
would yield a result with a bunch of leading zeros instead of the actual result. No users could authenticate to the web site because of that.
running the same code directly in python interpreter would work fine and the results were ok.
I tracked down the problem to the php4-mhash and libmhash2, once these were removed from the system MD5 was back to normal on mod_python.
Software Raid on Ubuntu and Debian
Although this procedure is not taken from the Managing RIAD on Linux, you should still get it because it is a great book!
After many, many attempts to get software RAID working on both Debian and Ubuntu the system would always lockup during boot and would not do any thing after that.
The system wont boot after a fresh install.
After banging my head a few hundred times I finally found a procedure that works!!!!!!
Install Ubuntu or Debian as you normally would, and configure RAID right from the installer. Once the installation is done the server will not boot, how stupid is that. what you need to do now is to insert the Ubuntu CD again and boot in Rescue mode.
Once the rescue mode reaches the disk partitioning screen press ESC and Select “Execurte a Shell” from the list.
Now mount your boot device, which you can do with
mount /dev/md0 /mntchroot /mnt
Now you should use grub to write the MBR to both disks. Type
grub
if you get an error like
'Error opening terminal: bterm' just set your terminal to something else like so:
export TERM=linux
You may not see a clear display, meaning the lines will overlap but it works. Now run grub again.
For disk 1:
grub device (hd0) /dev/hda root (hd0,0) setup (hd0) quit
For Disk 2:
grub device (hd1) /dev/hdb root (hd1,0) setup (hd1) quit
If you’re not sure which devices you have just do:
cat /boot/grub/device.map
Should look like this:
(hd0) /dev/hda (hd1) /dev/hdb
Use those! After doing this reboot your server, and you should now be able to boot your machine using RAID!
You should repeat this procedure every time you rebuild your RAID set or upgrade your Kernel.
WordPress and Source Code Posts
If you try to use the TinyMCE editor bundled in with WordPress to edit posts you’ll soon realize that posting source code or any other preformatted section to you blog is going to be any thing but pain free!
For developers, Linux and shell enthusiasts posting source code snippets, configurations, or shell commands is an everyday need, and Blogs, should make this easy and effortless, but they don’t!
Like many others I disabled the Visual editor and went back to the dark ages when web development was done on vi and icons were square and had a 16 color pallete…
The problem is that in an effort to “cleanup” the resulting post content WordPress and many others insert, or remove line breaks, replace them with <BR> tags, delete spaces and tabs, etc, etc, rendering all preformatted code into a useless pile of junk.
After digging in WordPress’s insides, I found that the culprit behind all the pain was the WordPress TinyMCE plugin. This is not a WordPress plugin, but a JavaScript TinyMCE plugin that does some WordPress related functions.
One of the things it does is to scan <pre> code sections and replace all new lines with <br> tags. This is ridiculous!!!!!!!!
Why would anyone want to do this? The <pre> HTML section as the name implies is pre-formated it DOES not need your help to format so you should leave it alone.
Well to fix this terrible oversight you should edit the file wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js.
Search for cleanup: and look for the comment that reads (at least in version 2.1.1 it did)
// Look for \n in <pre>, replace with
and comment the whole while loop. Like so
/* var startPos = -1;
while ((startPos = content.indexOf(‘<pre’, var=”" endpos=”content.indexOf(‘<pr>”>’, startPos+1);
var innerPos = content.indexOf(‘>’, startPos+1);
var chunkBefore = content.substring(0, innerPos);
var chunkAfter = content.substring(endPos);
var innards = content.substring(innerPos, endPos);
innards = innards.replace(/\n/g, ‘
‘);
content = chunkBefore + innards + chunkAfter;
}*/
Save the file and edit your posts with source code without any problems!
Just a word of advice, select the whole section of the post that has the source code snippet and then apply the Pre formatted style to it. If you select the pre formatted and then write the text it will insert a new <pre> HTML tag for every line you type. This is also very annoying. Maybe in another post I’ll take care of that…
