Jul 292010
 

I recently decided to get back into desktop applications. Since about 2000 I’ve focused on developing for the web using Perl and PHP (mostly PHP). But sometimes it is nice to write a desktop app, instead of having to write a web app for everything. I’ve written some applications using the PHP CLI option, but that isn’t quite the same as a gui. My motivation was to write a GUI that controlled ffmpeg and would allow me to capture screen casts for tutorials I needed to make.

I started my adventure looking at a GUI frontend for PHP. And ran across PHP-GTK+. I installed it, and looked at some tutorials on it, but the more I looked, the more it looked like the community was inactive and stale. I also couldn’t find any way to package my application to share with others. They would need to install PHP, compile GTK+ (which wasn’t all that easy), reconfigure PHP and then run my application. Although most of the programs would be for my eyes only, it would be nice to have the option to share from time to time. So that was the end of the road for my PHP adventure.

I then decided to look at other languages for developing the application. I considered some of the options out there, Java, C, Ruby, Python, but decided to give Python a try. I’ve coded Java before, and I wasn’t a fan. Always seemed like overkill for everything I wanted to do. I’ve heard lots of good stuff about Python, and it is usually installed with most Linux installations, so this was my language of choice.

I then began looking for a good IDE for Python. Being a big fan of Eclipse, I ran across pydev for Ecplise. A simple install into the software manager in Eclipse, and I was off to the races. You will need to configure the location to your python binary, which for me (Ubuntu 9.10) was in /usr/bin/python2.6 Enabling this, gives you all the fancy code completion which I love so much. If you need to set it up, you need to visit (In Eclipse) Window -> Preferences -> Pydev -> Interpreter – Python -> New… and browse to your python binary. (If you do not have python available, you may need to install it first using apt-get or Synaptic Package Manager. Just search for python, and it should install everything you need to get started.) Here are some tutorials for getting started with Python:

I’ve used Glade once before, very briefly just to figure out what it was. It is a GUI drawer. Similar to the GUI drawer in Visual Basic, it allows you to layout your interface without using code. It creates XML files which can be imported by your application (and it has bindings for many languages) that create your interface. You just need to connect your code to the signals in the GUI, and you can make magic happen. You will need to install Glade via Synaptic Package Manager. The current version is the 3.6 series. Here are some great tutorials to get you started with Glade:

So, my first dabble in GUI desktop programming in a decade, and my first taste of python. About 5 hours later I had written the application I wanted. It is an 84 line python script binding to one glade file for the interface. It allows me to select a window, and using a pre-set configuration, launch ffmpeg and record a screencast. Still a lot of work to do before it is ready to be shared, but it is a great start. Using pydev via Eclipse for the Python coding, and Glade for the interface design, you should be able to turn out some simple desktop apps in a matter of hours.

This is probably just the beginning of my python coding, so you may see more here on that in the future.

May 052010
 

Here are some neat database commands I recently came across while I was trying to get statistics and status information on some mysql and postgres databases.

Postgres

This will give you a list of all of the databases in the server.*
select datname from pg_database;

* If you don’t know how to connect to postgres from the command line, don’t fear (well fear a little). What I had to do was su to the user that is a DB user, and then run /usr/local/pgsql/bin/psql This launched a command line client (without needing a password), that let me query the server. I can’t provide a better understanding then that, as this is the first time I’ve ever interacted with a postgres server.

This tells you how big a particular database is.
SELECT pg_size_pretty(pg_database_size('xythosdocs'));
The output is like this:
pg_size_pretty
----------------
2834 MB
(1 row)

Mysql

Get all database sizes:
SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB", sum( data_free )/ 1024 / 1024 "Free Space in MB" FROM information_schema.TABLES GROUP BY table_schema;
Produces output like this on the command line:


+--------------------+----------------------+------------------+
| Data Base Name     | Data Base Size in MB | Free Space in MB |
+--------------------+----------------------+------------------+
| blogadmin          |           0.35750008 |       0.00098896 | 
| blogs              |          90.60342026 |      27.73141003 | 
| information_schema |           0.00781250 |       0.00000000 | 
| musicschedule      |           0.00548172 |       0.00020599 | 
| mysql              |           0.54032421 |       0.00000000 | 
| phpflash           |           0.77745819 |       0.00000000 | 
+--------------------+----------------------+------------------+

Get some status information on the sever. Run this from the command line:
mysqladmin -uroot -p status
Phpmyadmin also provides a lot of process status information if you have that installed.

Apr 052010
 

In one of my many Linux Game RSS feeds, I ran across an announcement for L++. This is a multiplayer version of the old Lemmings game. Lemmings is a puzzle game where you have to guide your no-brain lemmings from the entrance, to the exit.

L++ has all of the original single player content, plus a lot of extra player created content. It has a built in level editor (which I found wasn’t super easy to use) and 8 player network multiplayer.

It is quite surprising how fun multiplayer lemmings could be. If you are a lemmings fan, and have a friend or two, I’d highly recommend giving this a try.

Update: I just went to the site, and they currently have taken the download off as they remove some of the copyrighted content that was in the game. You can read more here: http://lplusplus.co.cc/topic.php?topic=16. Oddly enough, I only downloaded the windows version as that was the machine I was on when I decided to try this. I guess I’ll have to wait with you to give it a try.

Apr 052010
 

I recently installed the excellent OpenShot video editor for Ubuntu because I had to splice together some video from our curling league. We had two cameras shooting the action from the Semi-Final, and Final games.

OpenShot is a very easy to use program from making some basic movies and it handled the two different format videos pretty well.

However, after installing, I noticed that I could no longer use AMSN, my instant messenger of choice. When launching from the terminal, I would receive an error about GStreamer problems. This also affected Pidgin, and I’ve heard reports of problems with Empathy and others too. The problem lies in frei0r-plugins package, which messes up gstreamer for some programs, and is required by OpenShot. The easy solution to get it working is to remove frei0r-plugins, but of course, OpenShot won’t work anymore.
sudo apt-get purge frei0r-plugins

After searching the net a bit, I ran across a launchpad page that pointed the finger at libgavl. The problem is fixed in libgavl 1.1.1. Of course, 1.1.0 is the highest version you can get with Ubuntu 9.10.

So, to correct this once and for all, you can compile 1.1.1 yourself, or you can download the .deb for Ubuntu 10.04. So, go here: http://packages.ubuntu.com/lucid/libgavl1 and download the correct version for your architecture, and you should be good to do.

I got some warnings about an older, more supported version being available in the repositories, but you can safely ignore that.

Oct 222009
 

Just surfing the web and came across this excellent site with advanced awstats configuration information. As you all know, I do enjoy using awstats, and have had to modify it in the past.

Well, this site has lots of cool scripts and modifications to make awstats more useful: http://www.internetofficer.com/awstats/

My favourite modifications so far are:

And don’t forget to check out my own tutorial on adding robots (Blog Post/Wiki Entry)

Aug 312009
 

I’ve configured awstats to provide statistics on visitors of the websites on the server. I’ve also configured xymon to notify me when the website is not accessible. xymon uses a bot to check every 5 minutes to make sure the site is still up. As you can imagine, this generates a lot of hits, that aren’t really people.

So, since I don’t want to disable monitoring, I thought I should at least configure my stats so that they reflect people, and this bot.

awstats has an excellent robot detecting feature, but they do not yet detect xymon. So, in order to make the change, you need to dive into the robots.pm file, normally saved in /usr/local/awstats/wwwroot/cgi-bin/lib/

You will need to make two changes for it to detect this new robot (it tells you this at the top of the file). So, at the end of the @RobotsSearchIDOrder_list1 = ( array, I added:

  • ‘Hobbit[_+ ]bbtest-net/4.2.3’

And then at the top of Other robots reported by users in %RobotsHashIDLib = (, I added:

  • ‘Hobbit[_+ ]bbtest-net/4.2.3′,’xymon’,

Once I deleted the files in /var/lib/awstats/ and reprocessed my logs, the statistics better reflected my visitors. Beware that if you delete files from /var/lib/awstats/ and don’t have the original log files around, you will lose the history for that period of time. Also, this change should be reflected on all sites that you have running on this server and using awstats.

My webserver only had logs for August, so I only deleted the file for August, and left the file for July with the missed detections since I cannot rebuild it. I’ve since changed the configuration of the log rotater.

Later I’ll be posting a more in depth tutorial on installing awstats, and also on modifying the robots.pm file, since I couldn’t find much about it online.

UPDATE: As promised, here is a more detailed how-to on updating the robots file: http://wiki.cornempire.net/doku.php?id=awstats:awstatsrobots

Jul 102009
 

I just noticed this today. I monitor a number of sites and servers using the great Xymon system monitoring tool (Linky). It is based on early Big Brother code. Anyway, today I noticed that the graphs were all blue. Something like this:

Bad Xymon Graph

Bad Xymon Graph

I’m using Xymon 4.2.3 on the servers, and both servers show the graph like this using Firefox 3.5 on Linux. Google Chrome development version, SeaMonkey 1.1.5, Epiphany and Galeon all display the graph correctly.

I have no solution, but I thought I’d post my experience.

Mar 122009
 

I recently updated my server and I store a good number of passwords in my pwman database. It is a great little command line program for storing passwords in a secure manner. I do this so that I can log into my machine from anywhere in the world to retrieve passwords if needed, and I’m not tied to a thumb drive that I could lose/break, or a computer that may not have the necessary OS/ports for me to use.

If you need to migrate your database, you can follow these steps:

  1. Grab a copy of your old database. It is usually called pwman.db and is stored in your /home/yourname/.pwman/ If you can’t find it, there is a config file in this directory that will tell you where it is.
  2. Install pwman3 on your new server. (command for Debian based Linux OSes)
    apt-get install pwman3
  3. Run pwman3 and configure the same master password as your old database. (Not sure if this is required, but I thought it was a good idea)
  4. Make a copy of your database, and then put your old one in your new /home/yourname/.pwman/ folder.

The next time you run pwman3, you will have all your old passwords!

Feb 192009
 

In my last few attempts at configuring my mythtv installation (my most recent being today when I replaced the hard drive), I’ve gotten this error when I log into my box through SSH:

MythTV status for localhost
===========================
Status...........: Wed Feb 18 2009, 8:30 PM
Total Disk Space.: Total space is 548,770 MB, with 158,049 MB used (28.8%)
Next Recording In: 2 Hours, 59 Minutes
 
Encoders:
mythbox (1) - Idle
 
Scheduled Recordings:
2009-02-18 23:30:00 - CSI: NY (WBZ)
2009-02-19 00:30:00 - Stargate SG-1 (Space: The Imagination Station)
2009-02-19 10:30:00 - Stargate SG-1 (Space: The Imagination Station)
2009-02-19 12:30:00 - First Wave (Space: The Imagination Station)
2009-02-19 19:30:00 - Coronation Street (CBNT CBC St. John's)
2009-02-19 22:30:00 - CSI: Crime Scene Investigation (WBZ)
 
Schedule Conflicts:
Unable to access MythTV Perl API. Try with --verbose to find out why.

I get most of the status for the server, but I don’t get the read outs of the conflicts because of the error.

What happens (as far as I understand it) is that when the cronjob generates the motd, it runs as root, and root does not have a link to the mythtv config, so it can’t get the data from the database.  So, to get around this, we need to create a link in /root/.mythtv/ to the config.xml file for the server.  For me, this runs from my home directory /home/thomas/.mythtv/config.xml so:

sudo ln -s /home/thomas/.mythtv/config.xml /root/config.xml

Once you make this change, the next time the cronjob runs it should populate the motd correctly.

Notes: I’m running this server on Ubuntu 8.04.02 64-bit.

You can find more information on this issue here.

Jan 182009
 

I’ve recently come across a game that I’m becoming quite a fan of.  CS2D is an overhead shooter that is modeled after the popular Counter Strike mod of Half Life.  Back in the day, I used to play the 3D mod of Half Life, but I have not played it recently.

I’m a big fan of this game because of its simple and fun game play.  If you have some non-hardcore gamers, they will probably get a kick out of the quick and addictive gameplay. It is also seamlessly cross platform with all of my Windows and Mac friends playing along too.  And it also has a simple to use map editor that allows the creative juices to flow.  This will be a brief tutorial on how to use triggers to create doors that open, and breakable glass.

Using the in game editor to make a map is a piece of cake.  Some of the more advanced stuff can be a bit tricky though.  I’m working on a map where the Counter Terriorists must escort a VIP from a brick residence to a boat anchored just off shore.  However, a group of Terrorists have found the location first, and are able to begin some fortifications of the ship with the goal of preventing the VIPs escape.  I wanted to make the building a little more realistic by adding a window, and a door or two.

  1. Create the map
  2. Place your floor terrain where you want the door to be
  3. Go to the Entity menu, (the bulb with the points coming out of it) and select ‘Func_DynWall’
  4. Place it, and edit the entry by right clicking or double clicking.
  5. Change the Tile/Frame # to the number of the tile that you want to appear when the door is closed.
  6. Give the DynWall a unique name
  7. Elsewhere on your map, you want to create the button to open the door. From the entity menu, place a ‘Trigger_Use’ entity and edit it.
  8. Select the button type, and where you want it to appear, and who should be allowed to use it.
  9. Then, for the Trigger box, type in the name of your door (if you have multiple doors opened by a single trigger, separate them with commas)

Once you test this map out, you should now have open-able and close-able doors.

To create breakable glass, do the following:

  1. Place some terrain that looks like a window
  2. Add an entity that is ‘Env_Breakable’
  3. Edit this entity, and give the wall/glass some health, and determine which material you want to make it of.

You can test the map, and you should now be able to break the glass and walk through it once it is broken.

I may post some other map tricks in the future.

NOTE: Bots don’t handle glass/doors well.  If the is no clear path between their start and their objective, they will not realize that doors/glass is a viable alternative and will NOT actually move.  Keep this in mind if designing offline maps.

Attachment: Bridge Test map for Fiid who commented below.