I just noticed that some idiot has decided to steal bandwidth by linking to an image on my website. I went hunting around looking for a suitable replacement when I came across an entry by Jeremy Zawodny
Unfortunately the site has decreased the size of the image to 24×24 which means you don’t get the full effect of the image. I did consider using the infamous goatse image but decided against it.
I used mod_rewrite to change the image by adding a couple more rules to my .htaccess file.
RewriteCond %{HTTP_REFERER} ^http://(www\.)agneasy\.splinder\.com.*$
RewriteRule ^.*pics/badger_logo\.png$ /pics/babyshit\.jpg [L]
After a while I will just block the IP and have done with it.
Job Search Statistics
I have added some job search statistics to RSS Job feed website. Every search is now added to a table and counted so that I can see which searches are the most popular.
Most Common Job Search Words
Apache Error
I created a duplicate website on my box today for testing the rss jobs site and lo and behold a famous error.
Invalid command ‘PerlHandler’, perhaps mis-spelled or defined by a module not included in the server configuration.
Basically I have not got mod_perl working for the localhost server. I edited httpd.conf and added the following and we are in business.
AddModule mod_perl.c
Alias /perl/ /var/www/perl/
SetHandler perl-script
PerlHandler Apache::Registry
Options +ExecCGI
I now have a mirror of the live site on the local machine for testing.
Postgresql: Function foo() does not exist
Very often we are humbled by the simplest things and tonight I got a good one.
I had created a plpgsql function that was called from within a trigger to check for some duplicates in a table, blah blah. The function was working because I had tested it. It was registered in the “pg_proc” table and the two “proargtypes” were type 1043 ie varchar. This function was there, I could see it and if I was a character in Tron I could touch it, so why the hell when one of my scripts ran did I get: function foo does not exist.
I’ll tell you why, I was not using the correct schema. Ahhhhhhhhhhhh.
I had tested it while logged in as the user who created it and that users schema is different from the user that needs to use it from the website. A quick
grant usage on schema foo to bar;
sorted that problem.
Uklug Cleanup
I started cleaning up the back end of the RSS jobs site today. This mainly involved tidying up some cron jobs. There was one change that I had to make because a couple of the larger rss job feeds that I get have duplicate entries in them. This means people searching the site would get lots of jobs duplicated in their results. This is not good so I added some checks to stop the duplicates getting in. There are probably still a few problems with the smaller sites but I can deal with them as I encounter them.
I would dearly love to move the site to templates but that is a fairly large job so it can wait, besides why fix that which is not broken.
I suppose I should really fix the HTML at some point but that can wait until the move to Template Toolkit 😉
rsync and vfat filesystems
When I have added a few CD’S to my ogg collection I need to copy them across to my H320. This is OK if you copy the CD over as soon as it has been copied but I don’t normally work that way. We just got some CD’s for Christmas and I already had a few copied to the hard drive so as usual I use rsync to do it.
I noticed that rsync would always copy everything rather than do an update of the files. I found out that this is because of limitations on a vfat file system. The following command sorted it.
rsync -av –modify-window=1 * /mnt/usb/
Counting files of a particualr type
I am pretty sure there is an easier way to do this but this is how I done it the first time.
find ./ -name “*.ogg” -print | perl -wne ‘$i++; END{print “$i\n”}’
I then thought about it a bit and came up with
find ./ -name “*.ogg” -print | xargs ls | wc -l
now that is much neater 😉 but wait, we don’t need the “xargs ls”
find ./ -name “*.ogg” -print | wc -l
I then thought about doing it this way
ls -R | grep “.ogg” | wc -l
I’m going to leave it there 😉
iRiver Playlist Error
I tried to make up a few playlists today for my H320 iRiver. I am using vim to make them not an application and this had me stumped for a while.
Then I realised that the iRiver expects a DOS formatted file. Basically Linux text files use “\n” for a newline and MS windows uses “\r\n”. To get it to work I had to save the file as a dos file. This can be done in vim as follows.
:set fileformat=dos
For those that don’t like vim then a Perl one liner will do the same thing.
perl -i.bak -pe ‘s/(?<!\r)\n/\r\n/g;’ *.m3u
It is safe to run this on a file that has already been converted to the msdos format. It also creates a backup file in case anything goes horribly wrong.
So a simple example of an m3u playlist is as follows:
#EXTM3U
\cypress_hill\a_to_the_k.ogg
Of course the “\r\n” is not visible but its there 😉 The example m3u file above is in the ROOT directory of the mp3 player. Remember that on the H320 and probably on the other iRiver makes as well you need to use the A-B button to view your playlist when the player has stopped.
Blog Spam Project
I was approached tonight by Henry Stern with respect to registering my interest in a project to help curb blog Spam. Apparently it has been noted that I wrote a SpamAssassin plugin for Movable Type. Wonders never cease.
I think a project would be good, as for what would come out of it that remains to be seen. There are a good few blogging tools out there and I doubt getting them all pulling together would be feasible. Although this is not really a necessary requirement to start one.
Postgresql oom-killer
I have never seen the oom-killer before. I had heard stories from battle hardened veterans about their tussles with the beast but these stories where all just myths to me, until today, when the beastie raised its head in my logs.
Dec 20 18:08:50 debian kernel: oom-killer: gfp_mask=0x1d2
59071 Dec 20 18:08:51 debian kernel: DMA per-cpu:
59072 Dec 20 18:08:51 debian kernel: cpu 0 hot: low 2, high 6, batch 1
59073 Dec 20 18:08:51 debian kernel: cpu 0 cold: low 0, high 2, batch 1
59074 Dec 20 18:08:51 debian kernel: Normal per-cpu:
59075 Dec 20 18:08:51 debian kernel: cpu 0 hot: low 32, high 96, batch 16
59076 Dec 20 18:08:51 debian kernel: cpu 0 cold: low 0, high 32, batch 16
59077 Dec 20 18:08:51 debian kernel: HighMem per-cpu:
59078 Dec 20 18:08:51 debian kernel: cpu 0 hot: low 14, high 42, batch 7
59079 Dec 20 18:08:51 debian kernel: cpu 0 cold: low 0, high 14, batch 7
59080 Dec 20 18:08:51 debian kernel:
59081 Dec 20 18:08:51 debian kernel: Free pages: 1040kB (112kB HighMem)
59082 Dec 20 18:08:51 debian kernel: Active:253987 inactive:249 dirty:0 writeback:5 unstable:0 free:260 slab:2326 mapped:254 013 pagetables:680
59083 Dec 20 18:08:52 debian kernel: DMA free:16kB min:16kB low:32kB high:48kB active:12296kB inactive:0kB present:16384kB
59084 Dec 20 18:08:52 debian kernel: protections[]: 0 0 0
59085 Dec 20 18:08:52 debian kernel: Normal free:912kB min:936kB low:1872kB high:2808kB active:873984kB inactive:996kB prese nt:901120kB
59086 Dec 20 18:08:52 debian kernel: protections[]: 0 0 0
59087 Dec 20 18:08:52 debian kernel: HighMem free:112kB min:128kB low:256kB high:384kB active:129668kB inactive:0kB present: 131008kB
59088 Dec 20 18:08:52 debian kernel: protections[]: 0 0 0
59089 Dec 20 18:08:52 debian kernel: DMA: 0*4kB 0*8kB 1*16kB 0*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096k B = 16kB
59090 Dec 20 18:08:52 debian kernel: Normal: 0*4kB 0*8kB 1*16kB 2*32kB 1*64kB 0*128kB 1*256kB 1*512kB 0*1024kB 0*2048kB 0*40 96kB = 912kB
59091 Dec 20 18:08:52 debian kernel: HighMem: 0*4kB 0*8kB 1*16kB 1*32kB 1*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4 096kB = 112kB
59092 Dec 20 18:08:52 debian kernel: Swap cache: add 848298, delete 845230, find 151472/187493, race 0+3
59093 Dec 20 18:08:52 debian kernel: Out of Memory: Killed process 6332 (postmaster).
It would appear I was being a bit greedy with Postgres.