Welcome to maniacmartin, the personal site of Martin Smith.
I'm listening to The Clash – The Guns of Brixton

22 May 2008

WordPress won’t upload

Filed under: Computer — martin @ 11:28 am

Something that’s been bugging me for a while is that when I updated my Wordpress install (using svn), file uploads ceased to work. Attempting to upload a file resulted in the message “An error occurred in the upload. Please try again later.”.

It seems that the latest Wordpress uses Flash to show a progress bar during the upload. This site details many possible solutions, but the easiest one that’s guaranteed to work is downloading the No-Flash-Uploader plugin. Simply drop it in your wp-content/plugins folder, then activate it in the Dashboard, and your uploads are fixed.

PwManager for Windows

Filed under: Computer — Tags: — martin @ 11:22 am

Having just put Windows XP back (in a dual boot configuration) I wanted to share the password manager that I have in the KDE system tray with Windows. I looked on the internet, and the only thing that has been ported is the pwmanager_dump program. However, combined with some the Windows ext2 driver, GNUWin32 tools (grep, awk, xargs etc) and a program that copies its command-line argument to the Windows clipboard, I have a hacked-up working pwmanager that syncs with linux.

I’m not 100% certain, but I think all of the tools I use are under the GPL, except for CopytoClipboard.exe, whose license I do not know. To get it to work, simply edit the first line of the bat file to point to your pwd file - of course you’ll have used the Windows ext2 driver to mount your linux partition to a Windows drive letter.

PwManager in Windows

14 April 2008

Virgin CEO: “This net neutrality thing is a load of bollocks”

Filed under: Computer — martin @ 10:22 am

Whilst I’m not one to cover a news story that’s already been covered elsewhere, TorrentFreak has a priceless quote from Virgin Media’s CEO: “This net neutrality thing is a load of bollocks”.

Virgin seem to have no problems in admitting that they are throttling sites that do not pay Virgin extra cash, despite the fact that these sites have already paid their own hosting providers.Read the full story here, and if you’re a customer, ring up, moan and consider switching

23 December 2007

Publisher 2000 BorderArt causing instant reboots

Filed under: Computer — martin @ 4:04 pm

I have discovered a most annoying bug with Microsoft Publisher 2000’s BorderArt feature.

It all started when I was making a poster for dad on his Windows XP PC, using his version of Publisher 2000, the Office afterthought desktop publishing application. All of a sudden, dad’s PC rebooted instantly. That is to say it went straight from working to BIOS, with no errors and no visible shutdown sequence. Thinking it was probably a rural power blip, I just reloaded Publisher and remade the poster I had lost. However, by the third instant reboot, I began to see a pattern emerge, and tested it a final time to get some proof.

Dad has virtually all Office settings on the default for Office 2000 Small Business Edition, and rarely ventures outside of Thunderbird, Firefox, Word and Publisher. He never even got round to working out what Excel does. In Publisher, If you make a rectangle shape, then click Format, Line/Border Style, More Styles…, a dialog box will appear.

In the BorderArt tab, you can select one of many tacky picture borders for your rectangle.

Except on dad’s PC, once you scroll about two-thirds of the way down the list of possible BorderArt types, the PC will instantly reboot as if you’ve hit the reset button. No errors, no blue screen of death (thanks to SP2 suppressing one maybe), nothing.

Unfortunately I cannot do more extensive testing because the reboots are very annoying, and because I don’t have a pile of Windows boxes around to test on. However, I would be very interested to hear if this has happened to anybody else, and into any insights and possible fixes would be much appreciated.

17 December 2007

Random Topic Generator

Filed under: Computer — Tags: — martin @ 1:18 am

It happens way too often. You’re in an msn conversation with someone who’s really cool, then the conversation runs dry. But you really don’t want it to end. You could be completely random like me, and change the topic if the previous topic runs dry.

/usr/share/dict/words contains a comprehensive list of wacky words (some that don’t look like real words to me, and many plurals that have apostrophes for no good reason). These could be potential topic ideas. It has many proper nouns, so first we must filter out words beginning with capital letters. Then take a random number, modulo the number of words, and find the nth element in the filtered list

x=$RANDOM;let x%=`grep "^[:lower:]" /usr/share/dict/words | wc -l`; grep "^[:lower:]" /usr/share/dict/words | head -n$x | tail -n1

13 December 2007

Recovering Truncated or Corrupt Tar Archives

Filed under: Computer — martin @ 8:07 pm

I was unfortunate enough to use resize2fs to resize an ext3 partition. The result, which at first appeared OK, was a corrupt filesystem.

Using SSHFS, I mapped ~martin on Andrew’s laptop to /media/sshfs on mine. I then told tar to make an archive of what was on my partition, and save it to the SSHFS. It errored out midway because of the severely corrupted filesystem, but I didn’t think it wouldn’t present a problem because the files in tars are simply stored back to back - it is a very basic archive tool.

After running badblocks, which was all clear, then formatting the partition to ext3 again, I attempted to extract the tar. GNU tar consumed CPU cycles for ages without writing any files, then complained about corruption. I assume it was walking the tar to check it wasn’t corrupt. This, as you can imagine, is not very handy. I perused the manpage looking for a switch that would disable the scan and just extract what it can, upto the corruption, but I could not see such a switch

I found a website that suggested finding where the last intact file in the tar ended, and feeding tar just that part of the file. They supplied a perl script to do the job.

The problem is that this perl script was unbelievably slow, and had probably only been tested on small files, not my 30GB tar, so Andrew wrote this python script to do the same thing, using information from Wikipedia and from BestSolution’s perl script. Andrew’s version started searching from the end of the tar, not the beginning, because we knew that my tar was corrupt at the end.

After a few minutes of watching it make a non-corrupt tar, we realised we were going to have to load the whole tar from the disk twice - once to repair it, and again to actually extract it. Surely a better way would be to just start extracting the truncated one, and give up when we get to the truncated file. Andrew’s Aerauntar does just that.

Usage:
python aerauntar.py archivename destinationfolder

So the moral of the story is not to tar backups from corrupt filesystems, always pay attention to errors and never assume that a program will operate as you think it will.

18 October 2007

Fixing File Uploads after upgrading to PHP5

Filed under: Computer — martin @ 1:21 pm

As some of you may know, I upgraded from PHP4 to PHP5 recently. And it went smoothly - or so I thought. Now, it seems I overlooked the fact that the reference $HTTP_POST_FILES has been phased out. This has been replaced with $_FILES. This is great, since Zen Cart, custom scripts, old phpBB installations and other old php scripts where users can upload a fail now fail spectacularly as they access an empty array.

First I wanted to write a perl script which I fed a list of files, but with 10GB of websites, this would take ages (and given a list , the number of arguments exceeded perls limit). So instead I ran this command from /var/www/vhosts
find . -name '*.php' -exec perl -p -i -e 's/\$HTTP_POST_FILES/\$_FILES/g' {} \;
find . -name '*.inc' -exec perl -p -i -e 's/\$HTTP_POST_FILES/\$_FILES/g' {} \;

to spawn a new perl instance per file, without checking jpegs and stuff.

4 October 2007

Wildcard Parsing in Linux Shells

Filed under: Computer — martin @ 10:11 pm

I have just discovered a quirk in linux shells.

When you issue a command with a wildcard, bash will replace the wildcard with a list of matching files. So when you type mogrify -resize 640x *.jpg
on a folder containing beach.jpg, pc.jpg and college.jpg, the shell will rewrite that as
mogrify -resize 640x beach.jpg college.jpg pc.jpg

and mogrify is given the options -resize 640x beach.jpg college.jpg pc.jpg (filenames in alphabetical order)

Now let us consider a folder with the following files: -r foo.bar foofolder barfolder
where foofolder and barfolder are folders. Issuing a rm *, might, at first glance just delete the files and not the folders. But alas this is expanded to
rm -r foo.bar foofolder barfolder
and rm recieves these options -r foo.bar foofolder barfolder
In fact, only the -r file will survive.

OK, you say, but who has files beginning with hyphens? Well, it could happen. And some commands, like tar, dont need a hyphen at the beginning of their arguments.

martin@xenon:~/tests$ ls
folder -r
martin@xenon:~/tests$ rm *
martin@xenon:~/tests$ ls
-r

24 September 2007

Andrew’s PHP unzip poem

Filed under: Computer — martin @ 11:22 am

When I thought I needed to recompile PHP 5 to get the unzip function for Installatron for Plesk Reloaded, Andrew helped me find yum install php-pecl-zip and everything all started to work.
Andrew made this poem to summarise [line breaks added]:

When PHP does not comply,
think for a moment, and try not to cry,
For if you see it needs a zip,
you better go get yum here quick,
Since compiling you really need not do,
if you can just simply use the ’su’,
And then when that command has run,
you can sit back well and call it done.

17 September 2007

Running a command as a /bin/false user

Filed under: Computer — martin @ 9:07 pm

In case anyone else wants to run a command as a user whose default shell is set to /bin/false, type this:
su -s command username

If you want a shell:
su -s bash username

Older Posts »