Ubuntu 12.04 with Gimp 2.8

After upgrading to Ubuntu 12.04 from 10.04, I realized Gimp was at an older version (2.6) than 2.8.

Presently, here’s how 12.04 can run 2.8 without much hassle:

  • sudo add-apt-repository ppa:otto-kesselgulasch/gimp
  • sudo apt-get update
  • sudo apt-get install gimp gimp-plugin-registry

Gimp 2.8 in Single-Window Mode

Drupal Modules

I recently completed a project for a customer that afforded me the opportunity to dive into Drupal on better terms. On my first introduction to the software several years back (and Joomla for that matter) I determined I would be able to use my cross-browser theming skills more effectively if I chose WordPress as a base CMS.

This time around I was able to spend a considerable chunk of time reading the documentation (especially around the Theming Guide) and examples on other’s sites. Some topics online seemed incomplete so I did end up reviewing some chapters in a few books on Drupal 7 in particular. In my mind it seems like the developers of WordPress and Drupal are migrating toward each other in feature sets, but delivering solutions from different perspectives. WordPress appears to be geared more toward out of the box social publishing, with an easy installer, and an easy updater. It can be pushed in almost any direction, but doesn’t seem to be the goal of the software creators. Drupal on the other hand feels more like a collection of building blocks for a web database. While Drupal has fields, blocks, regions, views, and fine grained permissions with roles… URL aliases require a module to automate their selection. There’s even a module to hook up Filemaker Pro and Drupal.

Back to the modules:

I utilized the following:

For spam free contact forms (almost):

For easy page editing:

For dynamic content:

For development and style:

Android on VirtualBox

This was fun. A bit of a test drive of Android-x86 3.2 using VirtualBox. I had a hard time getting the internet to work on it, just like I would have if I was at the store playing with it. :-)

There are how-tos at: http://www.android-x86.org/

Budget Wireless Distribution

Working for a non-profit organization requires a special type of ingenuity at times. In this case it was due to the requirement of setting up easy to use systems that are sustainable, yet affordable. Below are some pictures that show a wireless distribution system that I helped setup that serves the needs of 10 families, 4 guest apartments, and 2 work shops.

The Internet access is being provided via a business DSL modem in the lower level of the building with a red star on it. From there, a multi-purpose wireless router (RT-N16) is configured with DD-WRT and acts as the LAN’s gateway and firewall. Other common services it provides to the LAN include ones like local DNS, static DHCP, DynDNS client, SSH client/server, and OpenVPN client/server. It also has real time traffic monitoring, traffic graphs over time, QOS capabilities, and other exciting features. Nobody actually uses the wireless from the RT-N16 though, as it is being used only as a powerful, yet inexpensive wired appliance.

From there the only wired client connected is the main AP, a Bullet M2 HP. This little piece of equipment is quite exciting. A tough 600 mW self contained outdoor router built on Linux. It has already survived through the year long seasonal variations and is rated to operate at temperatures between -40C to 80C. Along with a 9dBi outdoor omnidirectional antenna mounted to it, they provide over 600,000 square ft. of network coverage through trees, hills and buildings with users reliably connecting in their homes over 250 feet away (though with the right antenna and conditions, the Bullet M2 HP is rated to perform at distances of over 50km away).

Continue reading

Gnome background changer

Gnome 2.3 on Ubuntu 10.04 LTS (Lucid Lynx) doesn’t appear to have an automatic wallpaper changer built in. While it appears there are many ways to accomplish this, I decided to write my own little script to get some time in with bash… alternative ways I have found include using “Wallpaper-tray” (which doesn’t appear to be in 10.04), Desktop Drapes, or a variation of the script below using things like “gconftool-2“.

To use this script, do the following:

  • Right-click on the desktop and choose “Change Desktop Background
  • Look through the backgrounds, and make sure the ones listed are the ones you want to have the script randomly select
  • Open up a text file using “gedit“, and add the contents of the script:
    #!/bin/bash
    installedDir=~/Pictures/backgrounds/random
    i=0
    while read line; do
       data=`echo "${line}" | grep -i filename`
       if [ "$data" != "" ]; then
          filenameCutLength=$((${#data}-11))
          filename=$(echo $data | cut -b11-$filenameCutLength)
          if [ "$filename" != "(none)" ] || [ "$filename" != 
          "random.img" ]; then
             extension=$(echo ${filename,,} | 
             cut -b$(expr ${#filename} - 2)-${#filename})
             if [ "$extension" == "jpg" ] || [ "$extension" 
             == "png" ] || [ "$extension" == "svg" ]; then
                fileArray[$i]=$(echo $filename)
                i=$(expr $i + 1)
             fi
          fi
       fi
    done << EOF
       $(grep deleted="false -A7 ~/.gnome2/backgrounds.xml)
    EOF
    fileArrayLength=`echo $[ ( $RANDOM % ${#fileArray[@]} ) ]`
    cp "${fileArray[$fileArrayLength]}"
    "$installedDir/random.img"
  • Save the file as “gRandomBackground.sh” in a directory (this example uses: “/home/$USER/Pictures/backgrounds/random”, if you install it elsewhere, be sure to change the $installedDir variable in the script)
  • Open “Terminal” and enter the command: crontab -e If you haven’t used crontab before, stick with the default, “nano
  • Paste the following as one line into the editor: 0 */3 * * * bash ~/Pictures/backgrounds/random/gRandomBackground.sh This will change the background every three hours, on the hour. “Ctrl+O, and then Ctrl+W” should get the crontab saved and also get you exited out of nano. For more information on how to use cron, see Google.
  • Open up the “Appearance Preferences” dialog again, by right-clicking on the desktop and selecting “Change Desktop Background
  • Click the “Add…” button and browse to the directory that gRandomBackground.sh is installed to
  • Select the “random.img” background, click the “Open” button, and then the “Close” button

Your background should change every three hours.

Screensavers in Ubuntu 9.x

I used to do some incredible tweaking for my screensaver in Ubuntu, especially because gnome-screensaver wouldn’t allow for editing the particular screensaver options like xscreensaver would (see: https://wiki.ubuntu.com/ScreenSaver). These days, I don’t want to tweak… I just want the thing to shut off when I am watching fullscreen flash video, so that I don’t have to wiggle the mouse every ten minutes. :-)

So I made a simple toggle script and created a launcher for the script on the desktop. Gonna watch video? Double-click the icon. Done watching video, double-click the icon.

#!/bin/bash
PID=`pidof gnome-screensaver`
 
if [ "$PID" != "" ]; then
	#gnome-screensaver is running shut it down
	killall -9 gnome-screensaver
else
	#gnome-screensaver is not running, start it up
	gnome-screensaver
fi

Recursive find and replace

From time to time I find myself wanting to replace a bit of text, in multiple files, throughout a huge directory tree (particularly in the case of a WordPress migration).

Here’s a method I frequently use (other examples I’ve seen out there make use of perl, xargs, grep, etc.):

user@host:~$ cd Directory_To_Start_From
user@host:~$ find . -type f -exec sed -i 's/Text_To_Find/Replacement_Text/g' {} ;

The find command will return a list of all the files in the directory tree and execute the sed command on each one it locates. In the example below, I added the “-name” option to the find command to allow for working only on files with the .js extension:

user@host:~$ cd website
user@host:~$ find . -type f -name "*.js" -exec sed -i 's/var pageName="example page";/var pageName="Final Page";/g' {} ;

In the next one, the text to find and replace has special characters (in this case the ‘/’ in the URL).

user@host:~$ cd website
user@host:~$ find . -type f -exec sed -i 's/http://www.example.com/old_directory//http://newsubdomain.example.com/new_directory//g' {} ;

See the following links to read more about escaping special characters:

Sloppiness at 1and1

So I have been noticing issues with 1and1 again. Yesterday when trying to get into my hosting control panel at admin.1and1.com, I received a “HTTP Error 503 Service unavailable” error, and thought to myself… really, on the admin panel… really?

Today while checking out my own site, I noticed that all of the PHP files I tried browsing to returned “500 Internal Server Error” errors.

Now this has gone too far… so I called them up. At first the person I talked to explained that I needed to force PHP5 using a .htaccess file, and proceeded to tell me that they could make the change for me. Calmly, I responded by saying that I did not want a change, and that it had been working fine the way it was for months.

She put me on hold, and while I waited… it started working. She told me that the shared hosting server “had a glitch”.

Afterwards, I ssh’ed into my server. Look what I found:

(uiserver):uXXXXXXXX:~ > ls -al
total XX
-rw-r--r--  1 uXXXXXXXX XXXXXXXX   16 Feb  3 14:06 info.php

I thought, “weird, I didn’t put that there”.

(uiserver):uXXXXXXXX:~ > cat info.php 
<? phpinfo(); ?>

Shame on you 1and1, for not cleaning up after yourself. Well, I guess you get what you pay for.

Databases on 1and1

After wanting to test WordPress 3.0 on a 1and1 hosting account, I ran into the following issue… the particular setup I was dealing with had only one database available, and it wasn’t MySQL 5, but instead MySQL 4… furthermore, it was a version lower than 4.1.2, which more recent versions of WordPress require as a minimum.

So after doing a bit of research on what others had done, I went about fixing the problem. Interestingly enough, 1and1 could have made some money in this situation if they would allow customers to simply purchase another database to add to their packages, but no, they want an entire upgrade to be purchased.

The first step was to backup the website and database. I ssh’ed into the web host:

username@localhostname:~$ ssh $username@example.com

Then I backed up the database. The command below will dump all of the databases on the host (in this case, only one MySQL 4.x database) into a dated bzip file, in the home directory.

username@remotehostname:~$ mysqldump -C -A -u $databaseUsername -h $databaseHostName -p$databasePassword | bzip2 -cq9 &gt; ~/`date +%F-%I-%M-%p`-db-backup.sql.bz2

Now to backup the site itself (not only in case disaster struck, but this would get a local copy of the sql dump I just made as well). On a local OS X workstation (or Ubuntu, if that suits your tastes) I ran something similar to the following:

username@localhostname:~$ mkdir ~/website_backups
username@localhostname:~$ rsync -avz --exclude="logs" $username@example.com: ~/website_backups/

From there, I was able to log into the 1and1 control panel and delete the existing database. This allowed me to setup a new one, and in particular, choose MySQL 4 or 5 as the type.

Back to the 1and1 hosting account:

username@localhostname:~$ ssh $username@example.com

I uncompressed the sql dump:

username@remotehostname:~$ bunzip2 2010-01-14-01-59-PM-db-backup.sql.bz2

and was greeted with the raw sql in the file, “2010-01-14-01-59-PM-db-backup.sql”. From here it was only a hop skip and a jump away to restoration. It was necessary to edit the sql file in order to have it restore properly to the newly created database that was just created:

username@remotehostname:~$ nano -w 2010-01-14-01-59-PM-db-backup.sql

And I changed the $oldDatabaseName to $newDatabaseName.

--
-- Current Database: `$oldDatabaseName`
--
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `$oldDatabaseName`;
USE `$oldDatabaseName`;

ctrl+o, enter, and ctrl+x, to save the file and exit nano. The sql dump was now ready to restore to the new database.

username@remotehostname:~$ mysql -u $databaseUsername -h $databaseHostName -p$databasePassword $databaseName &lt; 2010-01-14-01-59-PM-db-backup.sql

The only other things to do were to update any existing applications that needed the new database name, username, hostname, and password.

As a note, if you are updating a WordPress install to point to a new database, this info can be changed in the file, wp-config.php.