Showing posts with label Projects. Show all posts
Showing posts with label Projects. Show all posts

Saturday, 14 November 2009

Twitpic from the Command Line in Linux

I've just put together a short script for automatically taking a webcam pic then uploading it to Twitter.

Yes, I know what you're thinking, no I don't know why either. I had help from other places that I found through googling. Here it is in case you want to try it out:

#!/bin/bash

# Script to automate posting of webcam images to twitpic

IMGDIR="/location_to_save_webcam_pics"
STAMP=`date +%m%d%Y_%s`
IMG="$IMGDIR/"webcam_""$STAMP".jpeg"
USERNAME="twitter_username"
PASSWORD="twitter_password" # Don't forget to escape special chars with "\"
MESSAGE="Webcam snapshot, `date`"

# Take picture from webcam
TAKE=`streamer -o $IMG`
echo "$TAKE"

# Upload to twitpic using curl
curl -F "username=$USERNAME" -F "password=$PASSWORD" -F "message=$MESSAGE" -F media=@"$IMG" http://twitpic.com/api/uploadAndPost

I really need to find a way to post code on blogger. The next step is that this script can be added to a cron job and made to feed random pics at intervals.

I'm now trying to think what other interesting things I can send to twitter from Ubuntu?

Thursday, 29 October 2009

Firefox Ubiquity and Geocache GC Code search

I really like Mozilla's new Ubiquity extension for firefox.

It's like having a command line for the web. I can't see too many users adopting it as the command line is too scary for most casual and Windows users (even though, ironically, it's easier to use).

However, since it's an open platform I thought I'd have a go at my first firefox extension. I'm not a software developer and outside of building MS Access DBs in my youth, I haven't really done much development. So although it's pretty basic, I'm quite proud actually!

But I did manage to come up with small command for searching geocaching.com via coord.info.

Subscribe to it here: http://gist.github.com/234537

I'd welcome anyone who would wish to extend it as I'm not really hot on javascript.

Hopefully it will provide some use to a few geocachers maybe.

Edited 14/11/09: Accidentally deleted the first gist. Added new link.

Sunday, 18 October 2009

GSAK and GPSBabel

I run Ubuntu and predictably there's a derth of support for Geocaching on Linux based systems. It's not that there isn't open source alternatives - it's just that they're not quite designed for caching.

A truly great piece of shareware for Geocaching on Windows is GSAK, but there is no official Linux version and after 21 days you get a nag screen unless you pony up for the registered version. So imagine my surprise to find that GSAK relies upon an open source technology called GPSBabel to do the actual leg-work of exporting data to your device from your OS.

Basically GSAK is the glossy database that goes over the top - and it is a fine tool don't get me wrong. Anyway I found a way to make GSAK work on Linux, by replacing the gpsbabel.exe file with an executable script named "gpsbabel.exe". The original info I got from the GSAK forum provided by alancurry.

alancurry's script didn't work exactly, I had to make some tweaks:
#!/bin/bash
case "$1" in
-i)
gpsbabel -i garmin -f usb:0 -o gpx -F "$HOME/.wine/drive_c/Program Files/gsak/Temp/babel.gpx"
exit 0
;;
-N)
gpsbabel -N -i xcsv,style="$HOME/.wine/drive_c/Program Files/gsak/GSAK.STL" -f "$HOME/.wine/drive_c/windows/profiles/{username}/Application Data/gsak/babel.txt" -vs -o garmin -F usb:
exit 0
;;
*)
;;
esac
I then saved this script as "gpsbabel.txt" in "$HOME/.wine/drive_c/Program Files/gsak/".

Right now, after using it for 100+ days I'm getting bothered by the nag screen ('The GSAK Spouse'), but I'm not going to pay and register it and there are a few reasons for this:
  • The developer appears to have no intention of supporting Linux.
  • Since it's buggy under wine (crashes often) I only use it to load PQs and export them to my GPSmap 60CSx, I don't save the data - I usually wipe it and start over each week.
So now I'm thinking of finding a quicker way to access the GPX file from the command line, order it like GSAK does and then export directly without having to load up a buggy, nagging GSAK UI.

If I find a way to make it work, maybe I'll post it as an open source project and invite others to contribute. I'll need to if I was to try and build a GUI since I know nothing of GUI development.