Sunday, October 31, 2010

Sending Identi.ca Countdown Messages

If you following me on Identi.ca you'll occasionally see some of my daily count down messages. For example right now I'm running a daily count down message to the Charleston Bar Camp. Here is my message from Sunday October 31, 2010: "13 days until BarCamp Charleston Sat Nov 13 2010 #barcampchs". I am also running a reverse countdown since my Nexus One mobile phone was sent off to repair. Here is that message as of October 31, 2010: "5 days since I sent my !NexusOne to @htc for repair. What is taking so long? !Android http://is.gd/gj3Mn".

I send these automated microblog messages by adding cron job entries that call a python script. I pass the python script two parameters the reference date in yyyymmdd format and the message to be sent.

Below is the cron job entries in my system as of this writing:

cron

# m h  dom mon dow   command
1       0       *       *       *       python /home/htplainf/Ubuntu\ One/scripts/dentcountdown.py 20101113 "BarCamp Charleston Sat Nov 13 2010 #barcampchs"
1       0       *       *       *       python /home/htplainf/Ubuntu\ One/scripts/dentcountdown.py 20101026 'I sent my !NexusOne to @htc for repair. What is taking so long? !Android http://is.gd/gj3Mn'
Below is the python script I wrote to send these countdown messages.

Python script


#!/usr/bin/python
# Python script to send a countdown message to Identi.ca 
#
# Pass a date in yyyymmdd format along with some text for your message. 
# Example: python dentcountdown.py 20100611 "SouthEast LinuxFest"


import sys
import httplib, urllib
from datetime import datetime, date, time
import base64

username = "YourUserNameGoesHere"
password = "YourSecretPasswordGoesHere"
date_format = "%Y%m%d"
today = datetime.today()
targetDate = datetime.strptime(sys.argv[1], date_format)
delta = targetDate - today
days = delta.days + 1

if days == -1: 
 verb = " day since " 
elif days == 1: 
 verb = " day until " 
elif days < 0: 
 verb = " days since " 
else: verb = " days until "
if days == 0:
 message = sys.argv[2] + " is today"
else: message = str(abs(days)) + verb + sys.argv[2]
params = urllib.urlencode({'status': message})
base64string = base64.encodestring('%s:%s' % (username, password))[:-1]
authorizationString = "Basic " + base64string
headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain", "Authorization" : authorizationString}
connection = httplib.HTTPConnection("identi.ca")
connection.request("POST", "/api/statuses/update.xml", params, headers)
response = connection.getresponse()
print response.status, response.reason 

Thursday, October 28, 2010

NETGEAR Powerline Ethernet Adapter vs CAT5e

I compared local area network bandwidth between the NETGEAR Powerline Ethernet Adapter model XAVB101 and CAT5e with gigabit Ethernet switches. I conducted 6 tests, 3 on each transmission medium. I used the commonly used network testing tool iperf. Bottom line: Pull CAT5e wire or better when feasible.

Below is a table of the bandwidth results.

CAT5ePowerline Ethernet
637 Mbits/sec73.4 Mbits/sec
629 Mbits/sec74.0 Mbits/sec
612 Mbits/sec74.5 Mbits/sec

My tests were conducted to favor the Powerline Ethernet adapter. I placed the two Powerline Ethernet adapters within 8 feet of each other in the same room. No extension cords were involved. The CAT5e circuit was a couple of hundred feet and include 2 Ethernet switches between the computers.

Here is the raw output from the iperf command:
Ethernet Over Power

htplainf@fe0:~$ iperf -c 192.168.1.5
------------------------------------------------------------
Client connecting to 192.168.1.5, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.6 port 34985 connected with 192.168.1.5 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.2 sec  88.9 MBytes  73.4 Mbits/sec
htplainf@fe0:~$ iperf -c 192.168.1.5
------------------------------------------------------------
Client connecting to 192.168.1.5, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.6 port 34986 connected with 192.168.1.5 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.1 sec  89.0 MBytes  74.0 Mbits/sec
htplainf@fe0:~$ iperf -c 192.168.1.5
------------------------------------------------------------
Client connecting to 192.168.1.5, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.6 port 34987 connected with 192.168.1.5 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.1 sec  90.2 MBytes  74.5 Mbits/sec



CAT5

htplainf@fe0:~$ iperf -c 192.168.1.5
------------------------------------------------------------
Client connecting to 192.168.1.5, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.6 port 41387 connected with 192.168.1.5 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec    760 MBytes    637 Mbits/sec
htplainf@fe0:~$ iperf -c 192.168.1.5
------------------------------------------------------------
Client connecting to 192.168.1.5, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.6 port 41388 connected with 192.168.1.5 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec    750 MBytes    629 Mbits/sec
htplainf@fe0:~$ iperf -c 192.168.1.5
------------------------------------------------------------
Client connecting to 192.168.1.5, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.6 port 41469 connected with 192.168.1.5 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec    729 MBytes    612 Mbits/sec
htplainf@fe0:~$ 


Here are the specs on the Ethernet adapter in the client computer. Notice it has negotiated at a gig with the Ethernet switch.

htplainf@fe0:~$ sudo ethtool eth0
[sudo] password for htplainf: 
Settings for eth0:
 Supported ports: [ MII ]
 Supported link modes:   10baseT/Half 10baseT/Full 
                         100baseT/Half 100baseT/Full 
                         1000baseT/Full 
 Supports auto-negotiation: Yes
 Advertised link modes:  10baseT/Half 10baseT/Full 
                         100baseT/Half 100baseT/Full 
                         1000baseT/Full 
 Advertised pause frame use: No
 Advertised auto-negotiation: Yes
 Link partner advertised link modes:  Not reported
 Link partner advertised pause frame use: No
 Link partner advertised auto-negotiation: No
 Speed: 1000Mb/s
 Duplex: Full
 Port: MII
 PHYAD: 3
 Transceiver: external
 Auto-negotiation: on
 Supports Wake-on: g
 Wake-on: g
 Link detected: yes


Here are the specs on the Ethernet adapter in the client computer when connected to the Powerline adapter. Notice it has negotiated at 100Mb/s.

htplainf@fe0:~$ sudo ethtool eth0
Settings for eth0:
 Supported ports: [ MII ]
 Supported link modes:   10baseT/Half 10baseT/Full 
                         100baseT/Half 100baseT/Full 
                         1000baseT/Full 
 Supports auto-negotiation: Yes
 Advertised link modes:  10baseT/Half 10baseT/Full 
                         100baseT/Half 100baseT/Full 
                         1000baseT/Full 
 Advertised pause frame use: No
 Advertised auto-negotiation: Yes
 Link partner advertised link modes:  Not reported
 Link partner advertised pause frame use: No
 Link partner advertised auto-negotiation: No
 Speed: 100Mb/s
 Duplex: Full
 Port: MII
 PHYAD: 3
 Transceiver: external
 Auto-negotiation: on
 Supports Wake-on: g
 Wake-on: g
 Link detected: yes

Saturday, October 23, 2010

Android Harmony Remote with GoogleTV on a Nexus One

Below are screenshots of the Harmony Remote on an Android Nexus one. I'm using the app with a Logitech Revue GoogleTV set-top box. The app works great.










Thursday, October 21, 2010

Terminator at my Fingertips

I am big on keyboard shortcuts. For a couple of years now I've set Ctrl-Shift-o to start gnome-terminal. This works great. A little too great. I end up with a dozen gnome-terminal windows scattered across 4 workspaces. I decided to stop the madness. I installed Terminator and wrote the small bash script below. The script below will search for a Terminator session and if found bring it in to focus. If Terminator is not running it will start it.


#!/bin/bash 
if (wmctrl -l | grep Terminator); 
then 
 wmctrl -a Terminator; 
else
 terminator -T Terminator; 
fi 


If you are using Ubuntu like me you can use the following command to install Terminator and wmctrl.

sudo apt-get install terminator wmctrl

If you want to try this copy and paste the script to a file and make the file executable. Then use gconf-editor to set your keyboard shortcut to your script.

Wednesday, October 20, 2010

Identica Map - Real-Time Microblog Posts on a Google Map - Video Demo

Below is a YouTube video demonstration of http://IdenticaMap.com. This web app displays microblogging messages from Identi.ca in real-time on a Google Map. The frequency of messages are sped-up in the video for dramatic affect. The music is Fat Chance Lester's "The Plot To Save The World". Video with created with a combination of ffmpeg for screen capture and Blender for video editing on Ubuntu 10.04 Linux operating system.

Sunday, October 17, 2010

Identi.ca User Images

I created a Java servlet to create PNG images of Identi.ca users. You can use this utility on your website or gmail signature. The servlet looks up the user via the Identi.ca API. It uses the user's preferred background and foreground colors. The PNG image includes the user's name, avatar, latest notice and notice date.

The URL is: http://identicamap.com/utils/UserImageServlet?q=userNameGoesHere.

Here are a few examples:







Identi.ca Map

I created http://identicamap.com. This web app displays the Identi.ca public timeline on a Google Map with live updates.  The app is GWT based. The backend is running on Tomcat 6 in a Linode VPS. In a separate thread, the dents from Identi.ca are received and stored in a MySQL table. The GWT app queries the database periodically for new dents with location information and displays them on the map.

Saturday, October 9, 2010

Identi.ca Followers App - http://identicafollowers.com


The Identi.ca web interface requires you scroll through your followers in increments of 20 per page. I wanted a way to display them all on one page. I wrote http://identicafollowers.com to do just that. It uses OAuth to gain access to your Identi.ca followers feed without asking for your credentials. The app is a GWT app running on Tomcat. It is hosted on a Linode virtual private server.







Apache Directive to Prevent Cache of GWT nocache.js File

<LocationMatch (.*)nocache\.js$>
   Header Set Cache-Control "max-age=0, no-store"
</LocationMatch>

The Apache directive above will prevent the GWT nocache.js file from being cached. This is critical when you deploy new versions of your GWT apps. If the user does not get the latest version of your app, communication with the server will fail.