Wednesday, May 9, 2007

Getting the Australian dictionary to work in OO

Here are the steps I took to get the Australian dictionary to work in OpenOffice 2.2 as installed by default in Ubuntu Feisty:

File->Wizzards->Install New Dictionaries

Chose the relevant dictionaries, wait some time for them to install. Restart OpenOffice

Tools->Options

Choose Language Settings->Writing Aids
Choose OpenOffice.org Hunspell Spell Checker
Click Edit
Choose the relevant Australian dictionary for each tool (spellcheck, hyphenation, thesaurus)
Click Close
Click OK

And it all works

Saturday, April 21, 2007

Dvico Remote with Knoppmyth R5E50

Set up latest (0.8.1 at the moment) lirc:
Download, decompress it
./setup
Choose USB->Dvico
Exit and run configure
make
make install
Make lirc run at boot
echo "/usr/sbin/lircd --driver=dvico --device=/dev/usb/hiddev0" > /etc/rc5.d/S20

I put this in my ~mythtv/.mythtv/lircrc


# lircrc.buzz.dvico-MCE-irxevent
# 2006-01-25, David Bussenschutt
# mailto:buzz at oska.com
# Save this file in ~/.lircrc
# 'man irxevent' for more info on format
# set the startup mode to nothing except jump to the dvico mode:
#
begin
flags = startup_mode
mode = dvico
end
#
#start dvico mode
begin dvico
begin
button = ok
prog = irxevent
# Middle button = on the diamond
config = Key Return CurrentWindow
end
begin
button = up
prog = irxevent
# This is the "up" on the central diamond
repeat = 3
config = Key Up CurrentWindow
end
begin
button = down
prog = irxevent
# This is the "down" on the central diamond
repeat = 3
config = Key Down CurrentWindow
end
begin
button = left
prog = irxevent
# This is the "left" on the central diamond
repeat = 3
config = Key Left CurrentWindow
end
begin
button = right
prog = irxevent
# This is the "right" on the central diamond
repeat = 3
config = Key Right CurrentWindow
end
begin
# magic button = to restart myth frontend...
button = setup
prog = irexec
repeat = 0
config = "pkill -9 mythfrontend ; sleep 2 ; mythfrontend"
end
begin
button = tv_onoff
prog = irxevent
#config = unused
end
begin
button = guide
prog = irxevent
# EPG:
config = Key M CurrentWindow
end
begin
button = dtv
prog = irxevent
#config = unused
end
begin
button = mp3
prog = irxevent
#config = unused
end
begin
button = dvd
prog = irxevent
#config = unused
end
begin
button = cpf
prog = irxevent
#config = unused
end
begin
button = back
prog = irxevent
config = Key Escape CurrentWindow
end
begin
button = more
prog = irxevent
# We'll use it for "Information"
config = Key I CurrentWindow
end
begin
button = dvd_menu
prog = irxevent
config = Key M CurrentWindow
end
begin
button = alt_tab
prog = irxevent
config = Key Alt-Tab CurrentWindow
end
begin
button = replay
prog = irxevent
# Use for backwards commercial skip
config = Key Q CurrentWindow
end
begin
button = skip
prog = irxevent
# Use for forward commercial skip
config = Key Z CurrentWindow
end
begin
button = start
prog = irxevent
#config = unused
end
begin
button = vol_up
prog = irxevent
# Use it as a volume key
repeat = 3
config = Key F10 CurrentWindow
end
begin
button = vol_down
prog = irxevent
# Use it as a volume key
repeat = 3
config = Key F11 CurrentWindow
end
begin
button = ch_up
prog = irxevent
# This is the "up" on the channel changer oval
repeat = 3
config = Key Up CurrentWindow
end
begin
button = ch_down
prog = irxevent
# This is the "down" on the channel changer oval
repeat = 3
config = Key Down CurrentWindow
end
begin
button = photo
prog = irxevent
config = Key P CurrentWindow
end
begin
button = live
prog = irxevent
#config = unused - set to livetv jump point?
end
begin
button = folder
prog = irxevent
#config = unused
end
begin
button = 1
prog = irxevent
config = Key 1 CurrentWindow
end
begin
button = 2
prog = irxevent
config = Key 2 CurrentWindow
end
begin
button = 3
prog = irxevent
config = Key 3 CurrentWindow
end
begin
button = 4
prog = irxevent
config = Key 4 CurrentWindow
end
begin
button = 5
prog = irxevent
config = Key 5 CurrentWindow
end
begin
button = 6
prog = irxevent
config = Key 6 CurrentWindow
end
begin
button = 7
prog = irxevent
config = Key 7 CurrentWindow
end
begin
button = 8
prog = irxevent
config = Key 8 CurrentWindow
end
begin
button = 9
prog = irxevent
config = Key 9 CurrentWindow
end
begin
button = 0
prog = irxevent
config = Key 0 CurrentWindow
end
begin
button = ratio
prog = irxevent
config = Key W CurrentWindow
end
begin
button = zoom
prog = irxevent
# Swap the PiP windows
config = Key N CurrentWindow
end
begin
button = rew
prog = irxevent
config = Key Left CurrentWindow
end
begin
button = playpause
prog = irxevent
config = Key P CurrentWindow
end
begin
button = ff
prog = irxevent
config = Key Right CurrentWindow
end
begin
button = mute
prog = irxevent
config = Key F9 CurrentWindow
end
begin
button = stop
prog = irxevent
# We'll use it for "Delete"
config = Key D CurrentWindow
end
begin
button = rec
prog = irxevent
config = Key R CurrentWindow
end
begin
button = power_onoff
prog = irxevent
#config = unused
end
end dvico
#
# Note the "repeat =" strings in the volume and channel.
# This means that if you hold down the key, every nth instance will be
# passed. This depends on your system, so you may want to increase or
# decrease this and see what happens. repeat = 1 is probably too
# fast.


Reboot and go :)

Friday, February 16, 2007

Script to get a lot of eBay user ids

To get enough user ids to use for my feedback script I made this perl script:

#!/usr/bin/perl

use LWP::Simple;

$url = "http://search.ebay.com.au/_W0QQfrtsZ0";
$_=get($url);
$number_of_uids = $ARGV[0];
#$number_of_uids = 1000;

do
{
while($_=~m/<h3 class=\"ens fontnormal\"><a href=\"(http:\/\/cgi\.ebay[^\"]*)\"/g)
{
$counter++;
#print "$counter: $1\n";
$item_page = $1;
$uid = get_uid($item_page);
$userids{$uid}++;
}
if($_=~m/<span class=\"next\"><a href=\"([^\"]*)/g)
{
$_=get("http://search.ebay.com.au" . $1);
}
else
{
print "Can't find & get next page of items\n";
}
}while (scalar(keys(%userids))<$number_of_uids);

foreach $uid (keys %userids)
{
print "$uid\n";
}

sub get_uid
{
my $page=shift;
$item_data=get($page);
if($item_data=~m/http:\/\/myworld\.ebay\.com\.au\/([^\/]*)/g)
{
$this_uid = $1;
}
else
{
print "Can't find user id on page $page\n";
}
$this_uid;
}

Wednesday, January 10, 2007

Get Linux/Unix command lines for Windows

Sometimes the windows command line just isn't good enough, and instead of dir you want ls, or you want to count the number of lines in a file with a wc -l or grep for something. Cygwin is great and all, but it is a bit of overkill for most of my situations. UnxUtils.zip contains all of the above and more, and all the tools are accessible from the windows command line!

The official site's download link is down at the time of posting, but I have found a number of unofficial mirrors:

ftp://81.30.199.66/pub/windows/unixutils/UnxUtils.zip
ftp://ftp.ufanet.ru/pub/windows/unixutils/UnxUtils.zip
ftp://193.40.239.25/pub/windows/msutils/UnxUtils.zip
ftp://194.226.230.170/pub/windows/devel/UnxUtils.zip
http://www.mirrorservice.org/sites/ftp.locustworld.com/UnxUtils.zip

Once you have downloaded and unzipped into a directory you need to add them to your windows path, so that when you type ls your computer knows where to find it.

  • Right click "My Computer" then click properties
  • In the "System Properties" window click the advanced tab
  • Click the "Environment Variables" button
  • Click the "PATH" variable and click edit
  • Add a semicolon to the end of the "Variable value" field and then type in the location you unzipped UnxUtils.zip to followed by \usr\local\wbin
To test your new utilities open up a command prompt (you can find it hiding in Start->Programs->Accessories->Command Prompt) and try one out! The standard UnxUtils contains the following tools:

(this list generated by typing ls *.exe | sed -e "s/\.exe//g" > utils.txt from within the wbin directory - from a windows command prompt!)


agrep
ansi2knr
basename
bc
bison
bunzip2
bzip2
bzip2recover
cat
chgrp
chmod
chown
cksum
cmp
comm
compress
cp
csplit
cut
date
dc
dd
df
diff
diff3
dircolors
dirname
du
echo
egrep
env
expand
expr
factor
fgrep
find
flex
fmt
fold
fsplit

gawk
gclip
gplay
grep
gsar
gunzip
gzip
head
id
indent
install
join
jwhois
less
lesskey
ln
logname
ls
m4
make
makedepend
makemsg
man
md5sum
mkdir
mkfifo
mknod
mv
mvdir
nl
od
paste
patch
pathchk
pclip
pr
printenv
printf
pwd


recode
rm
rman
rmdir
sdiff
sed
seq
shar
sleep
sort
split
stego
su
sum
sync
tac
tail
tar
tee
test
touch
tr
type
uname
unexpand
uniq
unrar
unshar
unzip
uudecode
uuencode
wc
wget
which
whoami
xargs
yes
zcat
zip

Tuesday, January 9, 2007

Run X11 Applications Remotely

Sometimes you want to run a graphical application on a Linux box that is headless, but you don't want to go to the bother of connecting up a keyboard, mouse and monitor. The Linux graphics system X11 is great for this as it doesn't care where you are, as long as it is knows where to connect and is authorised to do so. Here is how I run X11 applications locally on Mac OSX or Linux:

First off, I start the X server. On OSX that means installing and running the application; on Linux I'm usually already in a graphical mode so it is already running. On the local computer (the one I'm sitting at) I run:

$ xauth list
Ari.local/unix:0 MIT-MAGIC-COOKIE-1 7b246eec9fc9d493fc009dd4ea2b8b8a
10.0.0.9:0 MIT-MAGIC-COOKIE-1 7b246eec9fc9d493fc009dd4ea2b8b8a
localhost:0 MIT-MAGIC-COOKIE-1 7b246eec9fc9d493fc009dd4ea2b8b8a

The line in the middle is the one of interest; it is the inet domain line. Copy that line. On the remote computer (via ssh) I run

$ export DISPLAY=10.0.0.9:0
$ xauth add 10.0.0.9:0 MIT-MAGIC-COOKIE-1 7b246eec9fc9d493fc009dd4ea2b8b8a

That second line is mostly a copy-paste job. Once all this has been configured, X11 should now run lovely.

Saturday, January 6, 2007

Get the total $ amount of an ebay user's sales, broken up into positive and negative feedback

A while back I had a thought that maybe there were people on eBay who were selling lots of $1 items fairly and ripping people off on a few $1000 items - and maintaining 99%+ positive feedback. To test this theory I wrote this perl script, which trawls the feedback of the user you specify and tells you how many $ of positive, negative and neutral feedback a user has. To try it, copy and paste the code below into a file called dollarfeedback.pl and run it by typing ./dollarfeedback.pl userid eg. ./dollarfeedback.pl phillsebayid

#!/usr/bin/perl

use LWP::Simple;

print "Ebay \$ feedback calculator\n";
$uid = $ARGV[0];
$max_items = 500;
print "Username = $uid\n";
$items_counted = 0;

do
{
$found=0;
$page++;
$url = "http://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedbackFromBuyers&userid=$uid&items=200&page=$page";

print "Getting $url\n";

$_=get($url);

s/@/x/g;
s/\^/x/g;
s/~/x/g;
s/\*/x/g;
s/\"Positive feedback rating\"/@/g;
s/\"Negative feedback rating\"/\^/g;
s/\"Neutral feedback rating\"/~/g;
s/\ViewItem&item=/*/g;

while($_=~m/[^\^@~]*([@\^~])[^\*]*\*([0-9]*)/gs && items_counted<$max_items) { $found=1; $item_number=$2; $feedback_type=$1; $item_price=&get_price($item_number); if($item_price == -1) { next; } $dollar_feedback{$feedback_type}+=$item_price; $item_feedback{$feedback_type}++; $items_counted++; print "$uid : Item $items_counted : Item number $item_number : Price $item_price : Feedback $feedback_type\n"; } $_=~m/Positive Feedback:[^0-9]*([0-9]*)/g; $eBay_feedback_percent = $1; }while(m/>Next<\/a>/g &&amp; $found==1);# && items_counted<$max_items); if($items_counted==0) { print "No items for $uid\n"; } else { $percentage_positive_feedback_dollar = ($dollar_feedback{"@"} * 100 / ($dollar_feedback{"@"} + $dollar_feedback{"^"} + $dollar_feedback{"~"})); $percentage_positive_feedback_item = ($item_feedback{"@"} * 100 / ($item_feedback{"@"} + $item_feedback{"^"} + $item_feedback{"~"})); print "User: $uid, eBay Positive Feedback Rating: $eBay_feedback_percent%\n"; print "Items sold that are still on record: $items_counted\n"; print "Positive feedback total: " . $item_feedback{"@"} . " items totalling " . $dollar_feedback{"@"} . " dollars\n"; print "Negative feedback total: " . $item_feedback{"^"} . " items totalling " . $dollar_feedback{"^"} . " dollars\n"; print "Neutral feedback total: " . $item_feedback{"~"} . " items totalling " . $dollar_feedback{"~"} . " dollars\n"; print "Positive feedback % in terms of items: " . $percentage_positive_feedback_item . "%\n"; print "Positive feedback % in terms of dollars: " .$percentage_positive_feedback_dollar . "%\n"; open (OUTFILE, ">>datafile.csv");

print OUTFILE "$uid,$eBay_feedback_percent,$items_counted," . $item_feedback{"@"} . "," . $dollar_feedback{"@"} . "," .
$item_feedback{"^"} . "," . $dollar_feedback{"^"} . "," . $item_feedback{"~"} . "," . $dollar_feedback{"~"} . "," .
$percentage_positive_feedback_item . "," . $percentage_positive_feedback_dollar . "\n";
close OUTFILE;
}

sub get_price
{
my $item=shift;
$item_data=get("http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=$item");
$price=-1;
if($item_data=~m/\"DetailsCurrentBidValue\"><b>AU \$([0-9\.]*)/g)
{
$price=$1;
}
elsif($item_data=~m/\"Buy It Now\"/g && $item_data=~/<\/span><\/td><b>AU \$([0-9\.]*)/g)
{
$price=$1;
}
$price;
}



My apologies in advance for my less than spectacular Perl code (and blogger killing my formatting!), but it does the job :) Please let me know if you like it, and any cool dirt you dig up with it.


Update: I'm doing some experiments with this code on my other blog Tech Sleuth. Come see what dirt I dig up!

View any page through the Google Cache

This is great for when a page isn't loading or has just changed and you want the old version. To view any page via the Google Cache, drag the following link to your toolbar


View in Google Cache

Or make a new bookmark with the following text as the location:

javascript:location.href = 'http://google.com/search?q=cache:' + document.location.href;

To use the new bookmarklet, just click on it when you are on a page and you will view the cached copy instead. This is great when the page is loading slowly or has changed recently and you want to view the old one.