Archive for the ‘Open Source’ Category

How to connect to a VNC machine that is behind a firewall using SSH tunneling, OS X and Chicken of the VNC

VNC is a very useful program for accessing a computer remotely. These are instructions for accessing a remote machine using OS X, Chicken of the VNC, and Vine Server when there is a firewall in the way.

VNC SSH Tunnel

Normally it is a fairly straightforward process to connect from a VNC client to a VNC server running on a remote machine. A firewall in the middle can complicate the process a bit.

Normal:
MY MACHINE -> VNC CLIENT < - -> VNC SERVER < - REMOTE MACHINE

Behind firewall:
REMOTE MACHINE -> VNC SERVER -> SSH TUNNEL < - -> VNC CLIENT < - MY MACHINE

  1. On MY MACHINE, create a local SSH user account and password - call it vnc_user
  2. On MY MACHINE, determine my public IP address - go to whatismyip.com (MY_IP_ADDRESS)
  3. On REMOTE MACHINE, turn on the Vine Server and set the password
  4. On REMOTE MACHINE, open up Terminal and enter the following command:

    ssh vnc_user@MY_IP_ADDRESS -R 5900:127.0.0.1:5900

    where MY_IP_ADDRESS is the IP address of MY MACHINE.

  5. Enter the password for the vnc_user. You should now be connected to MY MACHINE over SSH.
  6. On MY MACHINE, open up Chicken of the VNC. Connect to localhost and enter the password for the REMOTE MACHINE.
  7. You should now be connected to REMOTE MACHINE’s VNC server and be seeing their screen.
  8. Notes:

    • Make sure that you are not running a VNC server on MY MACHINE, or that it is turned off
    • If you are running a firewall on your own network, you may need to enable port forwarding for SSH to ensure that SSH requests on port 22 are connected to MY MACHINE and not blocked by your own firewall.

    Thanks to this article that describes how to do this and also includes an Applescript that makes the connection.

    Popularity: 5% [?]

New site design is live (also upgraded to the latest version of WordPress - 2.5)

New site design is finally live!

In preparation for upgrading a whole mess of sites to using the latest version of WordPress I decided it was time to finally upgrade my own site and to implement the new design I’d been working on for a while (for over a year now).

Check it out: www.gabrielserafini.com

Popularity: 15% [?]

How to fix PEAR installation of XML_RSS / XML_Tree invalid package.xml file problem

As part of getting an upgraded server set up and transferring sites from the older server, I had to re-install PEAR XML_RSS. One of its dependencies is XML_Tree.

Normally, this command should have worked with no problems:

pear install XML_RSS

It downloaded XML_RSS just fine, but then choked on XML_Tree, which was a required dependency.

Initial output:

# pear install XML_RSS
Did not download dependencies: pear/XML_Tree, use --alldeps or --onlyreqdeps to download automatically
pear/XML_RSS requires package "pear/XML_Tree"
No valid packages found
install failed

My next try was to specify installing XML_Tree:

# pear install XML_Tree
WARNING: "pear/XML_Tree" is deprecated in favor of "pear/XML_Serializer"
downloading XML_Tree-1.1.tgz ...
Starting to download XML_Tree-1.1.tgz (4,826 bytes)
.....done: 4,826 bytes
XML error: not well-formed (invalid token) at line 10
Download of "pear/XML_Tree" succeeded, but it is not a valid package archive
Error: cannot download "pear/XML_Tree"
Download failed
install failed

After some troubleshooting, here is how I fixed this problem:

  1. Change directory into the PEAR download cache directory: cd /tmp/pear/cache/
  2. Clear out all the old cache files: pear clear-cache
  3. You should see the downloaded file: XML_Tree-1.1.tgz
  4. Extract the files: tar xvfz XML_Tree-1.1.tgz
  5. Now edit the extracted package.xml file: vi package.xml
  6. Go to line 10 and change the รถ to an o. This is the character that is causing the XML validation of the package file to fail. Next, save the file (ESC :wq)
  7. Next, remove the old .tgz file: rm -rf XML_Tree-1.1.tgz
  8. We’re going to recreate the package: tar cfv - package.xml XML_Tree-1.1/ | gzip > XML_Tree-1.1.tgz
  9. Next, we’re going to install this package and not use the network: pear install -O XML_Tree-1.1.tgz

XML_Tree is now installed. You should now be able to continue installing XML_RSS normally.

Popularity: 6% [?]

How to sync audio and video for DVD playback using your remote speakers, AirPort Express, Rogue Amoeba’s Airfoil and VLC

Apple AirPort Express

I’ve been enjoying using my Apple AirPort Express to stream music from my laptop to our living room speakers using iTunes. The other evening I wanted to watch a DVD and use the good speakers to get the best sound, but you can’t do that without using a helper program.

Rogue Amoeba's Airfoil

I found a program that lets you route any audio signals to your AirPort Express — it’s called Airfoil (free to try out, $25 to purchase) and is made by Rogue Amoeba. It’s very simple to install and run. When I tried playing a DVD, though, the audio didn’t synch properly with the video.

This is the solution I found to fix the audio synchronization problem using VLC to play back the DVD and by adjusting the preferences and using VLC’s ability to buffer audio and adjust the synchronization settings.

How to increase audio buffering amount in VLC for DVD playback

  1. Open preferences in VLC
  2. Click on Advanced tab on bottom of screen
  3. Select Input/Codecs
  4. Select Access Modules
  5. Select DVD with menus [Note: to make this same adjustment when you are playing back regular files as opposed to DVDs, simply select File instead of DVD with menus and continue with the rest of the instructions]
  6. Change the default value (300 milliseconds) to 6000. This will increase the amount of audio data buffering to 6 seconds, which should be enough to synchronize the audio playback.
  7. Click Save to activate your changes (you may need to quit VLC to ensure the settings become active).
  8. Re-open the DVD using VLC and click Play.
  9. Click the “f” key repeatedly to adjust the amount of audio synchronization offset. It adjusts the audio offset downwards by 50 millisecond increments. I had to set mine to around -4900 milliseconds to correctly match the audio with the video output on my system. Press the “g” key to increase the offset in the other direction. Watch the actor’s lips and adjust the offset until it matches perfectly.
  10. Enjoy listening to your DVD audio through your speakers, streamed wirelessly!

Hacking the Gibson

Download VLC (Free Open Source video player)

Download Airfoil

Popularity: 10% [?]

WP-Cache 2.0 - useful for surviving the digg/reddit effect for your WordPress blog

Found this useful plugin from this site while working on a site that was in the middle of getting dugg/reddited:

WP-Cache is an extremely efficient WordPress page caching system to make your site much faster and responsive. It works by caching Worpress pages and storing them in a static file for serving future requests directly from the file rather than loading and compiling the whole PHP code and then building the page from the database. WP-Cache allows to serve hundred of times more pages per second, and to reduce the response time from several tenths of seconds to less than a millisecond.

Get the plugin here: Ricardo Galli, de software libre - WP-Cache 2.0

Popularity: 5% [?]

Some excellent WordPress plugins I found recently - Breadcrumbs and better Links page management

I’m working on a new site relating to Gramm-Leach-Bliley Act compliance (it will replace the useless site that is currently up at grammleachblileyact.com) and was looking for breadcrumb functionality and a better way to manage outputting links from the Blogroll on the links.php page.

I had searched for a good WordPress breadcrumbs plugin a while ago, and the ones I found didn’t really impress me. I’m really happy with the one I ended up finding this time. It’s called Breadcrumb Navigation XT and it does exactly what I was looking for. I’ll be using this probably for any future needs when it comes to breadcrumbs and WordPress.

The second plugin that I found was related to fixing how WordPress currently outputs links using the default get_links_list() function used in most links.php template pages right now. I had used on the XyzAnt.com links page another WordPress function (wp_list_bookmarks()) that only works for WordPress 2.1 and higher, and is still undergoing active development / documentation. That function, however, only allows you to output the description, and doesn’t appear to include the functionality to show notes. Since there is a larger amount of allowable text for the notes field, and that is what I needed, I still needed to find (or write) a solution to outputting all links, ordered by category, displaying the notes field as well as link title, url, image, etc. This is the plugin that I found that does just this (found it after writing about 80% of the same functionality myself). It does just what I was looking for, shows all the categories that contain links and the links within each category.

Plugin author’s latest post about WordPress 2.1 support: Link Library now supports Wordpress 2.1

Popularity: 10% [?]

DiddleBug Extractor 2.1 - Palm DiddleBug image extractor script for OS X, Windows, Linux (Replaces Didcon 2.0)

DiddleBug Extractor 2.1

DiddleBug drawing - crow

Drawing pictures on your Palm

I use an excellent free Open Source program called DiddleBug on my Palm Treo 700p for doing small black and white drawings. The latest version of DiddleBug creates 320×320 pixel size drawings. These are referred to on their site as “high-res” pictures instead of the 160×160 pixel size drawings that older versions of the software created.

Getting DiddleBug pictures off your Palm

I used to use a nice converter on my Windows laptop called WindleBug but wanted to be able to just use my Mac laptop by itself instead.

The DiddleBug FAQ mentions using a Perl script called Didcon on Windows, Linux and OS X which hadn’t been updated yet to extract the new 320×320 pixel sized images. When I ran the Didcon script for the first time, it saved out a 160×160 graphic that had weird lines running throughout it, due to the fact that it wasn’t reading out the data for a 320×320 pixel sized graphic.

After hacking at it for a little while, including researching how to correctly indicate the pixel size of an image in a Windows bitmap in the header of the file, I managed to get a working script that correctly outputs a 320×320 .bmp file.

This is the modified script, and I’m also including a second script that you can double-click in the Finder to run the extraction process.

(more…)

Popularity: 11% [?]

Chickenfoot - Firefox extension to automate web tasks with Javascript in your browser

This looks pretty neato.

Chickenfoot is a Firefox extension that puts a programming environment in the browser’s sidebar so you can write scripts to manipulate web pages and automate web browsing. In Chickenfoot, scripts are written in a superset of Javascript that includes special functions specific to web tasks.

Check it out: Chickenfoot

(Via the Lifehacker RSS feed at RSS2.com)

Popularity: 3% [?]

Fixing mail.app’s IMAP date problem | MostlyGeek

Update: I’m now hosting this file here in the hopes that it can be useful to others since the original link doesn’t work anymore. Please note: I cannot provide ANY support for this. I didn’t write it. You should read through the options carefully before running this on your machine. That being said, it did work for me at the time, so hopefully it will work for you as well.

After copying an IMAP account from one server to another I ran into this same problem. The bash script that is supplied worked perfectly for me to fix the problem. They give example scripts for both BSD and Linux.

Fixing mail.app’s IMAP date problem

There is one last problem with mail.app that I finally got around to fixing today. When I upgraded to Tiger my IMAP accounts didn’t upgrade well so I deleted them and added them again. That fixed the connection and synchronization problems but introduced the IMAP Date problem.

The IMAP Date problem is the result of how mail.app figures out the Date Received time for an email. Rather than using the Date: header in the email it uses the time the file was written to the file system. This becomes a problem when files are copied to a new location on the server and the creation time of the file is changed. When the entire contents of a Maildir is copied to a new location this can cause all emails to display with the wrong date and time!

The solution is to change the time stamp of each email message that is wrong. The process is:

  1. Get the Date: header from the email message
  2. Compare it to the file system time stamp
  3. If they are different, change the time stamp to the date in the email

Here is the shell script that accomplishes this. All that needs to be done is to point it at a user’s Maildir and it will handle the rest. A word of warning, this script is likely far from perfect. I did run it on my own Maildir and it fixed about 16,000 emails in about 3 minutes.

Old link (broken): Fixing mail.app’s IMAP date problem | MostlyGeek

New link to download the script hosted here: fix_imap_time_for_apple_mail_app.sh

Here is the contents of the script:


#!/bin/sh
#
# Date : July 4th, 2005
# Author: Benson Wong
# tummytech@gmail.com
#
# This shell script corrects email messages where the file system
# date does not match the Date: header in the email.
#
# This will fix problems with mail clients like Apple's mail.app
# which uses the file system timestamp resulting in emails with the
# wrong file system timestamp to display the wrong received date
#
# This script has to be run by a user [root] with the
# necessary privileges to read/modify files in a user’s Maildir.
#
MDIR_PATH=”$1″
if [ $# -lt 1 ]
then
echo “Usage: $0 /path/to/user/Maildir”
exit 1
fi
if [ ! -d "$MDIR_PATH" ]
then
echo “Error: $MDIR_PATH does not exist”
echo “Usage: $0 /path/to/user/Maildir”
exit 1
fi
if [ ! -r "$MDIR_PATH" ]
then
echo “Error: $MDIR_PATH is not readable”
echo “Usage: $0 /path/to/user/Maildir”
exit 1
fi
if [ ! -w "$MDIR_PATH" ]
then
echo “Error: $MDIR_PATH is not writable”
echo “Usage: $0 /path/to/user/Maildir”
exit 1
fi
# set the internal field separator to the newline character
# instead of the default “”.
# This is required for handling filenames and directories with spaces
IFS=”

set -f
echo “start”
# Find all emails
for i in `find $MDIR_PATH -type f | \
egrep -v “(courierimap|maildirsize|maildirfolder)”`
do
EDATE=`awk ‘/^Date: [A-Za-z]*,/ {print $4,$3,$5,$6}’ “$i” | head -1`
if [ -z "$EDATE" ]
then
continue
fi
FDATE=`ls -l –time-style=long-iso “$i” | awk ‘{print $6,$7}’`
# Reformat the date for touch.
NDATE=`date -d “$EDATE” “+%Y%m%d%H%M”`
ODATE=`date -d “$FDATE” “+%Y%m%d%H%M”`
if [ "$NDATE" -eq "$ODATE" ]
then
# Skip it if the times are correct.
echo -n “_”
continue
fi
echo `basename $i` “from $ODATE to $NDATE”
touch -c -t “$NDATE” “$i”
done
echo “done”

Popularity: 4% [?]

bash script to copy all files in a directory and convert uppercase characters to lowercase

So, I recently found out that the version of PHPList that we were using on a client site (2.10.2) had a nasty bug in it where it would convert all URLs in a text version of an email message to lowercase. This bug is fixed in the latest version (2.10.3) but it left a number of subscribers complaining that the links in their email were broken.

I wrote this handy bash script to fix those links for emails that had already been sent out.

To use this script, follow these steps on your server command line. This is a bash script.

First, copy this code to your clipboard:


#!/bin/sh

# This script takes the contents of a directory and will make a copy
# of every file converting any uppercase characters to lowercase
# (Useful because PHPList had a bug where it converted URLs to
# lowercase in text-only mailing list messages and the links were
# therefore broken. This script will enable those links to work.)

for file in *
do
if [ -f "$file" ]; then
filelower=`echo $file | tr “[:upper:]” “[:lower:]“`
if [ -f "$filelower" ]; then
echo “You are trying to copy a file that has the same name as an existing file.”
echo “$filelower file was NOT copied.”
echo “”
else
if [ -d "filelower" ]; then
echo “You are trying to copy a file that has the same name as an existing directory - $filelower”
echo “$filelower file was NOT copied.”
echo “”
else
# not a file or directory. make a copy of the file
cp “$file” “$filelower”
fi
fi
fi
done

Next, you are going to create a bash script file.

$ vi cp_files_to_lowercase.sh

Press i and then paste in the code.

Press ESC then :wq to write the file and quit vi.

Next you are going to set the executable permission on the file.

$ chmod 700 cp_files_to_lowercase.sh

Next, change directory to the place you want to run the script on. In this case, we’ll change to the images directory.

$ cd images/

Let’s see what’s in the directory currently:

$ ls

$ Image1.jpg IMAGE2.jpg image3.jpg

Now run the script.

$ ../cp_files_to_lowercase.sh

The script will make a copy of any file that has an uppercase character in it and name it the same thing except all lowercase. It will tell you if the file already exists as a completely lowercase file (it won’t copy a file onto itself).

Now let’s see what it did:

$ ls

$ Image1.jpg image1.jpg IMAGE2.jpg image2.jpg image3.jpg

Now any URLs should work and any previous text-version emails that were sent out using the old version of PHPList should now have working links again.

DISCLAIMER: This script will copy files on your server. I am not responsible for any problems that this causes. I’ve tested this on my server, but you’d be wise to test what will happen first. If you add an echo in front of the cp command in the script you will see displayed what it would do without actually doing it.

Popularity: 8% [?]