Plugins

This is where I store all the plugins that I write for different software. You can either browse through every plugin, or choose a category.

Amarok Script: Playlog

I just finished Playlog, my first Amarok plugin, written in Perl. I grew tired of last.fm having the sole properties of my listening-log, and such, this script everything that you listen to, along with the time that you listen to it, into two nice and handy MySQL tables. In the future, I plan to write some kind of analysis script for the data.

This was also my first piece of software to send in to kde-apps.org: Playlog.

Here is the Perl source code, in case you are interested. I release it under the GPL.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl
 
use strict;
use DBI;
 
my $dbh = DBI->connect( 'DBI:mysql:database=playlog;host=localhost',
	'playlog', '',
	{ 'RaiseError' => 1 }
);
$dbh->do( 'CREATE TABLE IF NOT EXISTS songs ( song_id INT(11) NOT NULL AUTO_INCREMENT, song_artist VARCHAR(255), song_album VARCHAR(255), song_title VARCHAR(255), PRIMARY KEY (song_id) )' );
$dbh->do( 'CREATE TABLE IF NOT EXISTS playlog ( play_time INT(11), song_id INT(11) )' );
 
sub cleanup {
	$dbh->disconnect;
}
 
$SIG{'TERM'} = 'cleanup';
 
while ( <> ) {
	if ( m/^trackChange$/ ) {
		chomp( my $artist = `dcop amarok player artist` );
		chomp( my $album = `dcop amarok player album` );
		chomp( my $song = `dcop amarok player title` );
		my $id;
		my @s = &qsong( $artist, $album, $song );
		if ( ! $s[0] ) {
			$dbh->do( sprintf(
				'INSERT INTO songs ( song_artist, song_album, song_title ) VALUES ( %s, %s, %s )',
				$dbh->quote( $artist ),
				$dbh->quote( $album ),
				$dbh->quote( $song )
			) ) or die $dbh->errstr;
			@s = &qsong( $artist, $album, $song );
		}
		$dbh->do( sprintf(
			'INSERT INTO playlog ( play_time, song_id ) VALUES ( %d, %d )',
			time,
			$s[0]
		) );
	}
}
 
sub qsong {
	my ( $artist, $album, $song ) = @_;
	my $sth = $dbh->prepare( sprintf(
		'SELECT song_id FROM songs WHERE song_artist = %s AND song_album = %s AND song_title = %s',
		$dbh->quote( $artist ),
		$dbh->quote( $album ),
		$dbh->quote( $song )
	) ) or die $dbh->errstr;
	$sth->execute();
	return $sth->fetchrow_array();
}

WordPress Plugin: Hello Anyone

Hello Anyone is a variant of Matt Mullenweg’s Hello Dolly WordPress plugin. Hello Anyone allows you to choose any lines to be randomly displayed on every page in your Admin panel. You can easily manage the lines and the CSS.

Screenshot with example from WordPress Plugin: Hello Anyone
Screenshot with options page from WordPress Plugin: Hello Anyone

Download and Install

  • Download Hello Anyone 1.0.
  • Unzip the file and then upload it to your plugin directory (/wp-content/plugins/) and activate it under the “Plugins” tab.
  • Go to “Hello Anyone” under the “Options” tab and start adding lines!

Changelog

  • 2006-10-21, version 1.0:
    • Initial release

WordPress Plugin: CurMusic

CurMusic adds two additional fields to every post, “artist” and “song”. You can use them to show your readers what you were listening to when you wrote the post. The information is shown by adding a PHP function to the theme. The style of the artist/song string can be customized through the option page.

Download and Install

  • Download CurMusic 1.0.
  • Unzip the file, upload it to your plugin directory (/wp-content/plugins/) and activate the plugin in the “Plugins” tab.
  • Edit your theme (Presentation -> Theme Editor) and add this where you want the music announcement to be: <?php echo_curmusic(); ?>. Note that you should know the difference between HTML and PHP before doing this. If you don’t, feel free to ask in a comment.

Todo

  • Music statistics
  • Mass-management of songs and artists
  • Overview of songs and artists

Changelog

  • 2006-10-17, version 1.0:
    • Initial release

WordPress Plugin: Chemical Formula Formater

Chemical Formula Formater is a WordPress plugin that automatically formats chemical formulae. Ok, not really formulae, but it alters the chemical notation of elements. What it really does is adding <sub> tags to any numbers between 0 and 99 following chemical elements.

Example

Let’s say I write O2 (an oxygen molecule). Chemical Formula Formater automatically alters it to: O2.

Download and Install

  • Download the zipped Chemical Formula Formater 1.0.
  • Unzip the file and upload it to your plugin directory, wp-content/plugins/.
  • Activate the plugin through the “Plugins” tab in your WP-Admin.
  • That’s it! It doesn’t even have an options page!

Changelog

  • 2006-09-15, version 1.0:
    • Initial release

WordPress Plugin: Favicon Head

Favicon Head is a simple way to automatically include correct tags for linking to your favicon in the head of every page in your blog. No file editing is required, you only have to upload the file to the plugin directory and activate it. The default favicon location is favicon.ico, but can be changed through the options page.

Features:

  • Animated favicon support
  • Custom favicon location
  • Works in WordPress 1.5 and 2

Download and Install

  • Download Favicon Head 1.1.
  • Unzip the file and upload it to wp-content/plugins/.
  • Click the “Plugins” tab in the WP admin panel and activate Favicon Head.
  • Go to the “Options” tab and click the “Favicon Head” sub-page in order to change the favicon location from /favicon.ico.

Changelog

  • 2006-11-21, version 1.1:
    • Animated favicon support added (patch by pp)
  • 2006-08-21, version 1.0:
    • Initial release

Irssi plugin: Hot-or-Not

This is my first irssi script, and it is very useful. If you ever get bored while hanging around on IRC, just type /horny and you will see something along the lines of:

01:34 -!- Irssi: 24 years old female, rated 8.4. Enjoy. http://pix2.hotornot.com/pics/HU/HU/HY/KM/ALBMBQBPXVKK.jpg
01:34 -!- Irssi: 19 years old female, rated 9.5. Enjoy. http://pix2.hotornot.com/pics/HU/H8/NE/HZ/AUHLORORSYXA.jpg
01:34 -!- Irssi: 18 years old female, rated 9.1. Enjoy. http://pix2.hotornot.com/pics/HU/HU/KS/KM/ALAZBRGQBQUR.jpg

This script fetches three random pictures from the Hot-or-Not API. It only gets images of females younger than 25 years and with a Hot-or-Not rating above 8, which means that I don’t care about minorities. Download the Irssi Hot-or-Not 0.1 source code, .pl or .zip.

Enjoy.

 
# /horny - Show URLs to random Hot-or-Not girls' pictures.
#
# /horny
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
# 
#	Version 0.1 - 2006-07-29 - Tim A Johansson tim@gurka.se
#  Initial release
#
 
use Irssi;
use vars qw($VERSION %IRSSI); 
$VERSION = "0.1";
%IRSSI = (
	authors	=> "Tim A Johansson",
	contact	=> "tim@gurka.se",
	name	=> "Irssi Hot-or-not",
	description	=> "/horny - Show URLs to random Hot-or-Not girls' pictures.",
	license	=> "GPL",
	url		=> "/irssi-plugin-hot-or-not/",
);
 
sub cmd_horny {
	use LWP::Simple;
	my $max_age = '25';
	my $min_rating = '8.1';
	for (my $i = 0; $i < 3; $i++) {
		$_ = get("http://services.hotornot.com/rest/?app_key=479NUNJHETN&method=Rate.getRandomProfile&retrieve_num=1&gender=female&max_age=$max_age&min_rating=$min_rating&get_rate_info=true");
		# Please don't steal my API key. Get your own for free at http://dev.hotornot.com/. It is used for tracking applicatons.
		if (m/gender>(.*?)<.*?age>(.*?)<.*?pic_url>(.*?)<.*?rating>(.*?)</) {
			Irssi::print($2 . ' years old ' . $1 . ', rated ' . $4 . '. Enjoy. ' . $3);
		} else {
			Irssi::print('Error: could not recognize string: ' . $_);
		}
	}
}
 
Irssi::command_bind('horny', 'cmd_horny');

WordPress Plugin: The Holy Blog

Tired of your old, boring blog? Are all its plugins just plain lame? Does it lack a divine touch? Then The Holy Blog is just what you need! (Holy Book — get the pun? Haha.) The Holy Blog appends a random Bible verse on every page in your blog. Here are som of the features:

  • Verse cache for saving bandwidth and processing time
  • Fully customizable CSS
  • Choose verse update frequency
  • Verse statistics
  • Valid HTML/XHTML
  • Random verse fetched from the ESV

Download and Install

Here, you can download The Holy Blog 1.1. Unzip it and upload the-holy-bible.php to your plugin directory, wp-content/plugins/. Now, you just have to go to the plugin tab in your administration panel and activate the plugin. To change the default settings, go to the options page conveniently located under “Options”.

Changelog

  • 2006-07-26, version 1.1:
    • Options page
    • Current verse in options page
    • Verse statistics
    • Next-verse countdown
    • Custom CSS
    • Resetable CSS
    • Variable update frequency
    • “Update now”-option
  • 2006-07-26, Version 1.0
    • Initial release

WordPress Plugin: Hot-or-Not Admin Panel

“Hot-or-Not Admin Panel” is my second WordPress plugin. Its purpose is to encourage administration of your blog by displaying a picture of a random girl from Hot or Not in the upper right corner of the administration panel. Gender, age and rating are configurable.

Example

Hot or Not Admin Panel screenshot

Download and Install

The current version of Hot-or-Not Admin Panel is 1.7. Download the zipped file here: hotadminpanel.zip. To install the plugin, just unzip it, upload it to the wp-content/plugins/ folder and activate it through the plugin tab in the administration panel.

Hot or Not Admin Panel works perfectly well on both WordPress 1.5 (Strayhorn) and 2.0, although it does not work in WordPress 1.2. Note that you will need either allow_url_fopen set to TRUE in your php.ini, or CURL support.

Changelog

  • 2006-07-28, version 1.7:
    • Replaced the admin_notices hook with admin_footer. Same effect, except admin_notices didn’t exist before WP 2.0.2.
    • Custom wp_remote_fopen() in WP 1.5. (1.5 is now supported.)
    • Added HTML debug comments
  • 2006-07-28, version 1.6.1:
    • Replaced the fopen/CURL option and switch with wp_remote_fopen(). Thanks, “Midwestern City Boy”.
  • 2006-07-27, version 1.6:
    • Added CURL alternative for fopen. Thanks, Mark
  • 2006-07-26, version 1.5:
    • Changelog added
    • Options page added (dude, this quadrupled the file size)
    • Options for gender, age and rating added
  • 2006-07-22, version 1.0:
    • Initial release

WordPress Plugin: ChessNotator

“ChessNotator” is a plugin that I wrote for WordPress. I don’t see why it wouldn’t work in WP 1.5, but I’ve only tested it in 2.0. The plugin allows you to paste a pure PGN text file between <chess> tags, and creates a nicely formatted table with the players’ names and the moves. Here is an example:

Example

Kasparov vs The World
 
1. e4 c5
2. Nf3 d6
3. Bb5+ Bd7
4. Bxd7+ Qxd7
5. c4 Nc6
6. Nc3 Nf6
7. O-O g6
8. d4 cxd4
9. Nxd4 Bg7
10. Nde2 Qe6
11. Nd5 Qxe4
12. Nc7+ Kd7
13. Nxa8 Qxc4
14. Nb6+ axb6
15. Nc3 Ra
16. a4 Ne
17. Nxe4 Qxe4
18. Qb3 f5
19. Bg5 Qb4
20. Qf7 Be
21. h3 Rxa4
22. Rxa4 Qxa4
23. Qxh7 Bxb2
24. Qxg6 Qe4
25. Qf7 Bd4
26. Qb3 f4
27. Qf7 Be
28. h4 b5
29. h5 Qc4
30. Qf5+ Qe6
31. Qxe6+ Kxe6
32. g3 fxg3
33. fxg3 b4
34. Bf4 Bd4+
35. Kh1 b3
36. g4 Kd5
37. g5 e6
38. h6 Ne
39. Rd1 e5
40. Be3 Kc4
41. Bxd4 exd4
42. Kg2 b2
43. Kf3 Kc3
44. h7 Ng6
45. Ke4 Kc2
46. Rh1 d3
47. Kf5 b1=Q
48. Rxb1 Kxb1
49. Kxg6 d2
50. h8=Q d1=Q
51. Qh7 b5
52. Kf6+ Kb2
53. Qh2+ Ka1
54. Qf4 b4
55. Qxb4 Qf3
56. Kg7 d5
57. Qd4+ Kb1
58. g6 Qe4
59. Qg1+ Kb2
60. Qf2+ Kc1
61. Kf6 d4
62. g7 1-0

The following code was used to generate the table:

<chess>
[Event "Kasparov vs the World"]
[Site "Internet"]
[Date "1999.10.22"]
[EventDate "?"]
[Round "?"]
[Result "1-0"]
[White "Kasparov"]
[Black "The World"]
[ECO "B52"]
[WhiteElo "?"]
[BlackElo "?"]
[PlyCount "124"]

1. e4 c5 2. Nf3 d6 3. Bb5+ Bd7 4. Bxd7+ Qxd7 5. c4 Nc6
6. Nc3 Nf6 7. O-O g6 8. d4 cxd4 9. Nxd4 Bg7 10. Nde2 Qe6
11. Nd5 Qxe4 12. Nc7+ Kd7 13. Nxa8 Qxc4 14. Nb6+ axb6
15. Nc3 Ra8 16. a4 Ne4 17. Nxe4 Qxe4 18. Qb3 f5
19. Bg5 Qb4 20. Qf7 Be5 21. h3 Rxa4 22. Rxa4 Qxa4
23. Qxh7 Bxb2 24. Qxg6 Qe4 25. Qf7 Bd4 26. Qb3 f4
27. Qf7 Be5 28. h4 b5 29. h5 Qc4 30. Qf5+ Qe6
31. Qxe6+ Kxe6 32. g3 fxg3 33. fxg3 b4 34. Bf4 Bd4+
35. Kh1 b3 36. g4 Kd5 37. g5 e6 38. h6 Ne7 39. Rd1 e5
40. Be3 Kc4 41. Bxd4 exd4 42. Kg2 b2 43. Kf3 Kc3 44. h7 Ng6
45. Ke4 Kc2 46. Rh1 d3 47. Kf5 b1=Q 48. Rxb1 Kxb1 49. Kxg6 d2
50. h8=Q d1=Q 51. Qh7 b5 52. Kf6+ Kb2 53. Qh2+ Ka1
54. Qf4 b4 55. Qxb4 Qf3 56. Kg7 d5 57. Qd4+ Kb1
58. g6 Qe4 59. Qg1+ Kb2 60. Qf2+ Kc1 61. Kf6 d4 62. g7 1-0
</chess>

Download

You can download the current version of ChessNotator (1.0) here. It is zipped, so you will need to unzip it.

Installation

  • Move the file chessnotator.php to the plugin folder, wp-content/plugins.
  • Go to the Plugins tab in the administration panel and activate the plugin.
  • Post a PGN file!