Sam Lesher » Code http://www.samlesher.com Fri, 07 May 2010 21:55:24 +0000 http://wordpress.org/?v=2.9.2 en hourly 1 Fix broken WordPress RSS in GoDaddy Free Hosting Accounts http://www.samlesher.com/code/fix-broken-wordpress-rss-in-godaddy-free-hosting-accounts http://www.samlesher.com/code/fix-broken-wordpress-rss-in-godaddy-free-hosting-accounts#comments Sat, 14 Feb 2009 18:10:11 +0000 Sam Lesher http://www.samlesher.com/?p=153 GoDaddy offers free ad-supported web hosting for any domain you register through them. The hosting is the same as their pay Linux Shared Hosting plans, except that they inject a banner advertisement into the top of every page.

I was able to manually install WordPress onto one of my sites that uses this free hosting, however I found that the WordPress RSS feed was broken. When you go to the default address for a Wordpress RSS feed (http://www.domain.com/feed), the page is addressed by a web browser with a mime type of ‘text/html’, even though it is actually an XML document. This results in the GoDaddy ad banner being injected into the XML document, thus invalidating the XML and breaking the RSS feed. Validators will give error messages like:

XML parsing error: :3:0: xml declaration not at start of external entity
Blank line before XML declaration
XML parsing error: <unknown>:199:7: not well-formed (invalid token)

I came up with a workaround that fixes this, here is a summary:
1. Install a plugin that changes the RSS feed paths
2. Write a script to download and cleanup the broken RSS XML files
3. Set up a cron job to update RSS twice an hour

1. Install a plugin that changes the RSS feed paths
Download and install the Feed Locations plugin. Once you enable it, you can access the settings for it in Admin by clicking Tools > Feed Locations. In the configuration screen, I set my feed locations for each feed type to these values:

RSS .92:  http://www.domain.com/rss/rss.xml
RDF (aka RSS 1.0):  http://www.domain.com/rss/rdf.xml
RSS 2.0:  http://www.domain.com/rss/feed.xml
Atom 0.3:  http://www.domain.com/rss/atom.xml
Comments RSS feed:  http://www.domain.com/rss/comments.xml

2. Write a script to download and cleanup the broken RSS XML files
Here is the script file I use to do the rss downloading and code cleanup. I call it ‘rssfeed.sh’. Modify BLOGADDRESS and FEEDPATH to the correct values for your hosting account:

#!/bin/sh
BLOGADDRESS=http://www.domain.com
FEEDPATH=/home/content/d/o/m/domain/html/rss

# NOTHING BELOW THIS LINE SHOULD NEED MODIFIED
# --------------------------------------------
FEEDFILE=${FEEDPATH}/feed.xml
RSSFILE=${FEEDPATH}/rss.xml
RDFFILE=${FEEDPATH}/rdf.xml
ATOMFILE=${FEEDPATH}/atom.xml
COMMENTSFILE=${FEEDPATH}/comments.xml
UBUNTUFILE=${FEEDPATH}/ubuntu.xml


# Remove existing FEEDFILE if it exists
if [ -f ${FEEDFILE} ];
then
   rm ${FEEDFILE}
fi
# Download broken FEEDFILE
wget -q ${BLOGADDRESS}/feed/ -O ${FEEDFILE}
# Remove blank line from beginning of file that breaks FEEDFILE
tail -n +2 ${FEEDFILE} > ${FEEDFILE}1
# Remove GoDaddy code injection from end of file that break FEEDFILE
head -n -2 ${FEEDFILE}1 > ${FEEDFILE}2
# Delete temp file
rm ${FEEDFILE}1
# Update feed url to use new feed.xml address
sed 's/\/feed\/\" rel=\"self\" type=\"application\/rss+xml\" \/>/\/rss\/feed.xml\" rel=\"self\" type=\"application\/rss+xml\" \/>/' ${FEEDFILE}2 >${FEEDFILE}
# Delete temp file
rm ${FEEDFILE}2


# Remove existing RSSFILE if it exists
if [ -f ${RSSFILE} ];
then
   rm ${RSSFILE}
fi
# Download broken RSSFILE
wget -q ${BLOGADDRESS}/feed/rss/ -O ${RSSFILE}
# Remove blank line from beginning of file that breaks RSSFILE
tail -n +2 ${RSSFILE} > ${RSSFILE}1
# Remove GoDaddy code injection from end of file that break RSSFILE
head -n -2 ${RSSFILE}1 > ${RSSFILE}
# Delete temp file
rm ${RSSFILE}1


# Remove existing RDFFILE if it exists
if [ -f ${RDFFILE} ];
then
   rm ${RDFFILE}
fi
# Download broken RDFFILE
wget -q ${BLOGADDRESS}/feed/rdf/ -O ${RDFFILE}
# Remove blank line from beginning of file that breaks RDFFILE
tail -n +2 ${RDFFILE} > ${RDFFILE}1
# Remove GoDaddy code injection from end of file that break RDFFILE
head -n -2 ${RDFFILE}1 > ${RDFFILE}
# Delete temp file
rm ${RDFFILE}1


# Remove existing ATOMFILE if it exists
if [ -f ${ATOMFILE} ];
then
   rm ${ATOMFILE}
fi
# Download broken ATOMFILE
wget -q ${BLOGADDRESS}/feed/atom/ -O ${ATOMFILE}
# Remove blank line from beginning of file that breaks ATOMFILE
tail -n +2 ${ATOMFILE} > ${ATOMFILE}1
# Remove GoDaddy code injection from end of file that break ATOMFILE
head -n -2 ${ATOMFILE}1 > ${ATOMFILE}2
# Delete temp file
rm ${ATOMFILE}1
# Update feed url to use new feed.xml address
sed 's/\/feed\/atom\/" \/>/\/rss\/atom.xml" \/>/' ${ATOMFILE}2 >${ATOMFILE}
# Delete temp file
rm ${ATOMFILE}2


# Remove existing COMMENTSFILE if it exists
if [ -f ${COMMENTSFILE} ];
then
   rm ${COMMENTSFILE}
fi
# Download broken COMMENTSFILE
wget -q ${BLOGADDRESS}/comments/feed/ -O ${COMMENTSFILE}
## Remove blank line from beginning of file that breaks COMMENTSFILE
tail -n +2 ${COMMENTSFILE} > ${COMMENTSFILE}1
# Remove GoDaddy code injection from end of file that break COMMENTSFILE
head -n -2 ${COMMENTSFILE}1 > ${COMMENTSFILE}2
# Delete temp file
rm ${COMMENTSFILE}1
# Update feed url to use new comments.xml address
sed 's/\/comments\/feed\/\" rel=\"self\" type=\"application\/rss+xml\" \/>/\/rss\/comments.xml\" rel=\"self\" type=\"application\/rss+xml\" \/>/' ${COMMENTSFILE}2 >${COMMENTSFILE}
# Delete temp file
rm ${COMMENTSFILE}2

In your webspace, create a directory called ’scripts’ and a directory called ‘rss’. Once you’ve created ‘rssfeed.sh’, upload it to the ’scripts’ directory. Make the file executable – you can do this with your FTP client by setting the permissions to 755, or you can do this in the file manager that GoDaddy provides.

3. Set up a cron job to update RSS twice an hour
Log into your GoDaddy hosting control panel:
http://www.godaddy.com
Click Hosting > My Hosting Accounts > Manage Accounts

Click Content > Cron Manager > Create Cron Job

Cron Job Title: Update Feed
Command: Browse to the /scripts/rssfeed.sh file that you created
Frequency: Hourly
Minute: x:00
Click Custom.
Checkmark “Run twice an hour”
Click Save.

Note – my cron job didn’t start working as scheduled right away, it took some time for the job to go into effect and start processing for me.

Once you complete all these steps you should have working RSS that updates every 30 minutes. Your main RSS feed address (RSS 2.0) will be http://www.domain.com/feed/feed.xml. You can test it by clicking the RSS icon that shows up in your Firefox address bar when you visit your blog.

Note – These instructions assume that the address for your blog is the root of your domain (http://www.domain.com/). Replace all instances of ‘domain.com’ with your actual web address. If you blog resides in a different directory, such as http://www.domain.com/blog/, you should adjust all paths accordingly (http://www.domain.com/blog/feed/feed.xml for example).

]]>
http://www.samlesher.com/code/fix-broken-wordpress-rss-in-godaddy-free-hosting-accounts/feed 19
Enable SHMConfig for Synaptics Touchpad on Ubuntu Intrepid Ibex 8.10 http://www.samlesher.com/code/enable-shmconfig-for-synaptics-touchpad-on-ubuntu-intrepid-ibex-810 http://www.samlesher.com/code/enable-shmconfig-for-synaptics-touchpad-on-ubuntu-intrepid-ibex-810#comments Sat, 01 Nov 2008 01:43:59 +0000 Sam Lesher http://www.samlesher.com/?p=105 Preferences > Mouse, click the “Touchpad” tab and uncheck “Enable Touchpad. The touchpad stays disabled, even through reboots. I’m leaving the original post [...]]]> ****EDIT****
These instructions are no longer needed for me. I don’t need to install Gsynaptics to disable my touchpad. I can now simply click System > Preferences > Mouse, click the “Touchpad” tab and uncheck “Enable Touchpad. The touchpad stays disabled, even through reboots. I’m leaving the original post here in case this doesn’t work on your system.

**** Original Post ****
In order to disable your Synaptics touchpad on previous releases of Ubuntu, you would set “SHMConfig” to “true” in xorg.conf and then install the program gsynaptics to disable/enable the touchpad.

The xorg.conf file is different in Intrepid Ibex, there is no section for the touchpad anymore. Now to enable SHMConfig you have to do it via HAL:

Edit this file:
/usr/share/hal/fdi/policy/20thirdparty/11-x11-synaptics.fdi

Find the section that starts with:
<match key="info.product" contains="Synaptics TouchPad">

And add this line to that section before :
<merge key="input.x11_options.SHMConfig" type="string">On</merge>

The file should end up looking something like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
  <device>
    <match key="info.capabilities" contains="input.touchpad">
      <match key="info.product" contains="Synaptics TouchPad">
        <merge key="input.x11_driver" type="string">synaptics</merge>
	<!-- Arbitrary options can be passed to the driver using
	     the input.x11_options property since xorg-server-1.5. -->
	<!-- EXAMPLE:
	<merge key="input.x11_options.LeftEdge" type="string">120</merge>
	-->
	<merge key="input.x11_options.SHMConfig" type="string">On</merge>
      </match>
      <match key="info.product" contains="AlpsPS/2 ALPS">
        <merge key="input.x11_driver" type="string">synaptics</merge>
      </match>
      <match key="info.product" contains="appletouch">
        <merge key="input.x11_driver" type="string">synaptics</merge>
      </match>
      <match key="info.product" contains="bcm5974">
        <merge key="input.x11_driver" type="string">synaptics</merge>
        <merge key="input.x11_options.LeftEdge" type="string">0</merge>
        <merge key="input.x11_options.RightEdge" type="string">1280</merge>
        <merge key="input.x11_options.TopEdge" type="string">0</merge>
        <merge key="input.x11_options.BottomEdge" type="string">800</merge>
        <merge key="input.x11_options.ClickFinger1" type="string">1</merge>
        <merge key="input.x11_options.ClickFinger2" type="string">3</merge>
        <merge key="input.x11_options.ClickFinger3" type="string">2</merge>
        <merge key="input.x11_options.HorizEdgeScroll" type="string">0</merge>
        <merge key="input.x11_options.VertEdgeScroll" type="string">0</merge>
        <merge key="input.x11_options.VertTwoFingerScroll" type="string">1</merge>
        <merge key="input.x11_options.HorizTwoFingerScroll" type="string">1</merge>
        <merge key="input.x11_options.HorizScrollDelta" type="string">0</merge>
        <merge key="input.x11_options.VertScrollDelta" type="string">40</merge>
        <merge key="input.x11_options.PressureMotionMinZ" type="string">10</merge>
        <merge key="input.x11_options.FingerLow" type="string">16</merge>
        <merge key="input.x11_options.FingerHigh" type="string">80</merge>
        <merge key="input.x11_options.FingerPress" type="string">256</merge>
        <merge key="input.x11_options.PalmDetect" type="string">0</merge>
        <merge key="input.x11_options.PalmMinWidth" type="string">10</merge>
        <merge key="input.x11_options.PalmMinZ" type="string">200</merge>
        <merge key="input.x11_options.MinSpeed" type="string">0.8</merge>
        <merge key="input.x11_options.MaxSpeed" type="string">1.2</merge>
        <merge key="input.x11_options.AccelFactor" type="string">0.10</merge>
        <merge key="input.x11_options.MaxTapMove" type="string">25</merge>
        <merge key="input.x11_options.MaxTapTime" type="string">223</merge>
        <merge key="input.x11_options.MaxDoubleTapTime" type="string">200</merge>
        <merge key="input.x11_options.TapButton1" type="string">0</merge>
        <merge key="input.x11_options.TapButton2" type="string">0</merge>
        <merge key="input.x11_options.TapButton3" type="string">0</merge>
        <merge key="input.x11_options.RTCornerButton" type="string">0</merge>
        <merge key="input.x11_options.RBCornerButton" type="string">0</merge>
        <merge key="input.x11_options.LTCornerButton" type="string">0</merge>
        <merge key="input.x11_options.LBCornerButton" type="string">0</merge>
      </match>
    </match>
  </device>
</deviceinfo>

Reboot, and you should now be able to disable the touchpad with gsynaptics.
Note, System > Preferences > Mouse also has a section for touchpad, so disable it there as well.

]]>
http://www.samlesher.com/code/enable-shmconfig-for-synaptics-touchpad-on-ubuntu-intrepid-ibex-810/feed 7
Wordpress plugin to display Twitter status via Ping.fm http://www.samlesher.com/code/wordpress-plugin-to-display-twitter-status-via-pingfm http://www.samlesher.com/code/wordpress-plugin-to-display-twitter-status-via-pingfm#comments Sat, 06 Sep 2008 23:54:33 +0000 Sam Lesher http://www.samlesher.com/?p=73 I have just finished writing my first Wordpress plugin – a widget to display a status update via Ping.fm:

Ping.fm is a simple service that makes updating your social networks a snap. You can use AIM, GTalk, iGoogle, Windows Live Messenger, Yahoo! Messenger, WAP, iPhone/iPod Touch, SMS or E-mail to let Ping.fm relay your message to a multitude of social networking sites. This plugin lets you use Ping.fm to add your status to your Wordpress Blog’s sidebar via Ping.fm’s “Custom URL” integration.

== Installation ==

* Extract archive
* Upload entire ‘pingfm_status’ directory to ‘wordpress/wp-content/plugins’
— do not remove files from directory, upload the directory with all files in it
* At http://ping.fm create a Custom URL to update the following address:

http://url_to_your_wordpress_installation/wp-content/plugins/pingfm_status/pingfm_post.php

* Enable the plugin in your Wordpress admin section
* Add pingfm widget to your sidebar, set the Title

== Notes ==

If you notice that the timezone is incorrect on the timestamps that appear in your updates,
you can change it in ‘/wp-content/plugins/pingfm_status/pingfm_post.php’. I have included
some notes in that file.

Here is a link to the plugin in the Wordpress Plugin Directory.

]]>
http://www.samlesher.com/code/wordpress-plugin-to-display-twitter-status-via-pingfm/feed 14