Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.

2009/09/29

Perl Rocks

I keep meaning to blog on Perl, but I can't find anything new and useful to bring up. I just can't be a Perl iron man, it seems.

In lieu of content, I'll just say this:

Perl Rocks!

2009/09/25

Gizmo + GoogleVoice = Frustration



I'm a big fan of the idea of GoogleVoice, but I don't have a cell phone at the moment and work in a sub-basement anyway, so I want to use it with a computer phone. But I've been on this before.

What I have changed is Auto-Answer. I clicked that and tried again. I hear the voice, but I can't input the numbers. Go to about 8:35 on the YouTube video above and you'll see exactly won't come up.

Skype won't uninstall, so I'm reinstalling to deinstall. I hope that will help.

2009/09/23

Desperately Seeking Google Weather API Vocabulary

I work in a sub-basement. From about 9am to about 5pm, I don't see the sun. Great amounts of change can happen in that time, and I hate coming up for air without knowing what's up. So, great amounts of my programming come from trying to keep track of conditions. I send the weather info to local printers. I have a twitter feed. I have gravitated to using XML::DOM and Google's Weather API to give me the information. It's not too detailed, it's fast, and if Google's down, the Internet is down.

I have since found notify-send (mentioned here) and have found a set of weather icons that I like. And I'm working on getting the notifications look good.

My problem is that I'm not seeing a one-to-one mapping between the condition strings I'm getting from Google and the file names I'm getting from the icon sets. Nor are the image names listed in the XML.

So, I created a simple mapping of Condition strings to icon names.

sub config_icons {
my $path = '/home/jacoby/Pictures/weather_icons/' ;
my %config ;
$config{ 'Clear' } = $path . 'sunny.png' ;
$config{ 'Partly Cloudy' } = $path . 'cloudy1.png' ;
$config{ 'Mostly Cloudy' } = $path . 'cloudy3.png' ;
$config{ 'Cloudy' } = $path . 'cloudy5.png' ;
$config{ 'Overcast' } = $path . 'overcast.png' ;
$config{ 'Haze' } = $path . 'fog.png' ;
$config{ 'Fog' } = $path . 'fog.png' ;
$config{ 'ELSE' } = $path . 'dunno.png' ;
return \%config ;
}
This is a list of weather conditions that were observable in the American Midwest in summer and early fall, 2009. This is not the whole list of weather conditions.

What I am looking for today are the other ones, so I can finish this code and maybe send it out to you. Any help?

2009/09/16

The better way for Javascript

Previously, In the post Why People Hate Javascript, I spotlight an example where Firefox does one thing and Internet Explorer — I'll step out and say that Firefox does the right thing and IE does the wrong thing, but if there's doubt about which is correct in the language specification, that's a bad on the standards committee — and I was rightly, correctly informed that Javascript, through the DOM, had a means to get the information I needed without relying on the hated x.split(). Which I include below the cut.

$(function() {
var protocol = window.location.protocol ;
var hostname = window.location.hostname ;
var path = window.location.pathname ;
var query = window.location.search ;
var hash = window.location.hash ;
var url = protocol + '//' + host + path + query + hash ;
if ( host != hostname ) {
window.location.replace( url ) ;
}
} ) ;
The hostname you want to redirect to is placed at your discretion as var host, but I choose not to include it here. The only jQuery aspect to this is the wrapper, which makes this script run when the page is fully loaded. Which probably isn't strictly necessary. And this does work on both IE and FF.

2009/09/15

Compiling Rakudo on Ubuntu

During the last meeting of my local Perl Mongers group, our point person on Perl 6 stated that he couldn't get it to compile, he couldn't get it to compile 2 months ago, and if it can't compile, nobody's ever going to use it and it's dead.

I tweeted it, of course, and got a response.
@JacobyDave It works over here. Which instructions did you use? I use http://rakudo.org/how-to-ge...about 3 hours ago from Tweetie in reply to JacobyDave


So, of course, I had to try it.

jacoby@oz:~$ $ git clone git://github.com/rakudo/rakudo.git
bash: $: command not found


It seems I didn't have git installed.


jacoby@oz:~$ apt-cache git
E: Invalid operation git
jacoby@oz:~$ apt-cache search git | wc -l
502
jacoby@oz:~$ apt-cache search git | grep -i '^git'
git-core - fast, scalable, distributed revision control system
git-doc - fast, scalable, distributed revision control system (documentation)
gitk - fast, scalable, distributed revision control system (revision tree visualizer)
git - transitional dummy package which can be safely removed
git-arch - fast, scalable, distributed revision control system (arch interoperability)
git-buildpackage - Suite to help with Debian packages in Git repositories
git-cola - highly caffeinated git gui
git-cvs - fast, scalable, distributed revision control system (cvs interoperability)
git-daemon-run - fast, scalable, distributed revision control system (git-daemon service)
git-email - fast, scalable, distributed revision control system (email add-on)
git-gui - fast, scalable, distributed revision control system (GUI)
git-load-dirs - Import upstream archives into git
git-svn - fast, scalable, distributed revision control system (svn interoperability)
gitmagic - Guide about Git version control system
gitosis - git repository hosting application
gitpkg - helper scripts for maintaining packages with git
gitweb - fast, scalable, distributed revision control system (web interface)
jacoby@oz:~$ sudo apt-get install git gitmagic git-doc
[sudo] password for jacoby:
Reading package lists... Done
Building dependency tree
Reading state information... Done
git is already the newest version.
Suggested packages:
git-core git-arch git-cvs git-svn git-email gitk gitweb
The following NEW packages will be installed:
git-doc gitmagic
0 upgraded, 2 newly installed, 0 to remove and 8 not upgraded.
Need to get 1333kB of archives.
After this operation, 6136kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com jaunty/main git-doc 1:1.6.0.4-1ubuntu2 [1126kB]
Get:2 http://us.archive.ubuntu.com jaunty/universe gitmagic 20090101-1 [207kB]
Fetched 1333kB in 2s (587kB/s)
Selecting previously deselected package git-doc.
(Reading database ... 206981 files and directories currently installed.)
Unpacking git-doc (from .../git-doc_1%3a1.6.0.4-1ubuntu2_all.deb) ...
Selecting previously deselected package gitmagic.
Unpacking gitmagic (from .../gitmagic_20090101-1_all.deb) ...
Processing triggers for doc-base ...
Processing 1 added doc-base file(s)...
Registering documents with scrollkeeper...
Setting up git-doc (1:1.6.0.4-1ubuntu2) ...
Setting up gitmagic (20090101-1) ...

jacoby@oz:~$ $ git clone git://github.com/rakudo/rakudo.git
bash: $: command not found
jacoby@oz:~$ git clone git://github.com/rakudo/rakudo.git
The program 'git' is currently not installed. You can install it by typing:
sudo apt-get install git-core
bash: git: command not found
jacoby@oz:~$ sudo apt-get install git-core
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
git-arch git-cvs git-svn git-email git-daemon-run git-gui gitk gitweb
The following NEW packages will be installed:
git-core
0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.
Need to get 4322kB of archives.
After this operation, 8995kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com jaunty/main git-core 1:1.6.0.4-1ubuntu2 [4322kB]
Fetched 4322kB in 7s (599kB/s)
Selecting previously deselected package git-core.
(Reading database ... 207451 files and directories currently installed.)
Unpacking git-core (from .../git-core_1%3a1.6.0.4-1ubuntu2_i386.deb) ...
Processing triggers for man-db ...
Setting up git-core (1:1.6.0.4-1ubuntu2) ...
Setting up git-core (1:1.6.0.4-1ubuntu2) ...
jacoby@oz:~$ git clone git://github.com/rakudo/rakudo.git
Initialized empty Git repository in /home/jacoby/rakudo/.git/
github.com[0: 65.74.177.129]: errno=Connection timed out
fatal: unable to connect a socket (Connection timed out)
jacoby@oz:~$ jacoby@oz:~$


Needed to open up a hole in the firewall to allow git.


jacoby@oz:~$ git clone git://github.com/rakudo/rakudo.git
Initialized empty Git repository in /home/jacoby/rakudo/.git/
remote: Counting objects: 18798, done.
remote: Compressing objects: 100% (5049/5049), done.
remote: Total 18798 (delta 13754), reused 18345 (delta 13370)
Receiving objects: 100% (18798/18798), 2.49 MiB | 723 KiB/s, done.
Resolving deltas: 100% (13754/13754), done.

Creating Makefile ...
Cleaning up ...

You can now use 'make' to build Rakudo Perl.
After that, you can use 'make test' to run some local tests,
or 'make spectest' to check out (via svn) a copy of the Perl 6
official test suite and run its tests.

jacoby@oz:~/rakudo$ make
/home/jacoby/rakudo/parrot_install/bin/parrot /home/jacoby/rakudo/parrot_install/lib/1.6.0-devel/library/PGE/Perl6Grammar.pbc \
--output=src/gen_grammar.pir --encoding=utf8 \
src/parser/grammar.pg src/parser/grammar-oper.pg



jacoby@oz:~$ cat hello.pl
say 'hello' ;
jacoby@oz:~$ rakudo/parrot_install/bin/perl6 hello.pl
hello
jacoby@oz:~$


It compiles on my Jaunty Ubuntu box. I don't have a clue as to why it wouldn't compile on his Fedora box. And, at some point, I'll have to try it on Windows.

2009/09/11

Why People Hate Javascript, or Must Mean Chum

I work with a web front-end to a genomics database. This is what pays my bills. We recently moved the URL from one associated with my university to a dot.org. We decided to push all users coming into the .edu address to the .org address. Easy javascript, I thought. I had finished something and decided to test it with IE, which I never use. "The only legitimate use for Internet Explorer is to download Firefox", as I always say.

But in IE, I got bouunced to some weird, wrong URL. So, I added some debug code to figure out what's going on.



Here's the code that generated this, with dyked-out relocation code.


$(function() {
var u = $( document ).attr('URL') ;
var v = u.split( /\//g )[2] ;
var w = u.split( /\//g ) ;

if ( v != host ) {
w[2] = host ;
x = w.join('/') ;
alert( u + '\n' + v + '\n' + w + '\n' + x + '\n') ;
// window.location.replace( x ) ;
}

} ) ;




u is the URL. Both the same.

v should be the host, which is the problem. A url looks like this: protocol://host/path/?querystring, where path could contain many slashes. Split on slashes,
protocol should be the first element, or element [0]. Element [1] should be blank. Element [2] should be host.

But it just isn't.

w is an array, made from the URL and joined with a comma for display purposes. The alert from Firefox says http,,host,path, showing a blank element 1, as it should be. The alert from IE says http,host,path. Evidently, it thinks the regular expression was variable.split( /\/+/g ),which matches and splits on one or more slash, rather than variable.split( /\//g ), which matches and splits on one and only one slash.

There is a scene in Cabin Boy where Chris Eliot, a candidate for upper-class twit of the year, tells the existing cabin boy (Andy Richter) that he wants some fancy soup for dinner. The cabin boy walks off and decides "He must mean chum". Chum is rotting fish guts. Microsoft decided that I must have meant chum.


2009/09/08

Flawed Perl

Take my Weather Notification on the Printer script and add the notify-send program which connects to Gnome's OSD setup and you can get some pretty cool stuff.

Except, it seems, something doesn't like Unicode.



At first, I thought the problem was on notify-send, but 1) remembering what had gone on with my twitter weather script (@PurdueWeather) and 2) testing with direct use of Unicode made me decide that it's Perl's fault.

And there are many solutions.

It strikes me that there should be something along the lines of use Unicode ; that, with one line, tells Perl you're using Unicode strings. I'm sure there's a Unicode module, and I'm reasonably sure that's not what it does.

Anyway, code for using notify-send and the Google Weather API to tell you what's going on with the atmosphere is under the cut. For my next trick, I will add images.


#!/usr/bin/perl

# $Id: hpsetdisp.pl 11 2006-03-22 01:21:03Z yaakov $

# hpsetdisp.pl
# Connects to a JetDirect equipped HP printer and uses
# HP's control language to set the ready message on the
# LCD display. Takes an IP address and message on the
# command line. My favorite message is "INSERT COIN".
# Keep in mind the limitations of the display when composing
# your clever verbiage.
#
# THIS PROGRAM IS PROVIDED WITH NO WARRANTY OF ANY KIND EXPRESSED OR IMPLIED
# THE AUTHOR CANNOT BE RESPONSIBLE FOR THE EFFECTS OF THIS PROGRAM
# IF YOU ARE UNCERTAIN ABOUT THE ADVISABILITY OF USING IT, DO NOT!
#
# Yaakov (http://kovaya.com/ )
#
# Modified by Garrett Hoofman
# 10/18/2007
# http://www.visionsofafar.com

# Modified by David Jacoby
# 12/10/2008
# http://varlogrant.blogspot.com/

# Modified by David Jacoby, using notify-send and tweaking Unicode
# 09/08/2008
# http://varlogrant.blogspot.com/

use strict ;
use warnings ;
use 5.010 ;
use Getopt::Long ;
use IO::Interactive qw{ interactive } ;
use IO::Socket ;
use XML::DOM ;
use Data::Dumper ;
use subs qw{ get_weather notify } ;

my $zip = '' ;
my $forc = 'F' ;
my $interactive = '' ;
my $degree = '°' ; #the unicode, straight
$degree = "\x{00b0}" ; #the unicode, specified
my $rdymsg = "Ready" ;

GetOptions(
'zipcode=s' => \$zip ,
'forc=s' => \$forc ,
) ;

if ( $forc eq 'c' || $forc eq 'C' ) { $forc = 'C' }
else { $forc = 'F' }

$zip !~ /\d/ and exit 0 ;
my $weather = get_weather ;
notify $weather ;

exit ;

########## ########## ########## ########## ########## ########## ##########
sub get_weather {
my $rdymsg ;
my $parser = XML::DOM::Parser->new() ;
my $file = 'http://www.google.com/ig/api?weather=XXXXX&hl=en' ;
#my $zip = shift ;
$zip =~ s{(\d{5})}{}mx ;
$zip = $1 ;
$file =~ s/XXXXX/$zip/mx ;
my $doc = $parser->parsefile( $file ) ;
my $city =
$doc->getElementsByTagName( 'city' )->item( 0 )->getAttribute('data') ;
my $curr_temp ;
if ( $forc eq 'C' ) {
$curr_temp =
$doc->getElementsByTagName( 'temp_c' )->item( 0 )->getAttribute('data') ;
}
else {
$curr_temp =
$doc->getElementsByTagName( 'temp_f' )->item( 0 )->getAttribute('data') ;
}
my $curr_cond =
$doc->getElementsByTagName( 'condition' )->item( 0 )->getAttribute('data') ;

my @output ;
push @output , qq{Conditions for $city} ;
push @output , qq{ $curr_temp$degree $forc, $curr_cond } ;
return join "\n" , @output ;
}
########## ########## ########## ########## ########## ########## ##########

########## ########## ########## ########## ########## ########## ##########
sub notify {
my $notify = '/usr/bin/notify-send' ;
my $weather = shift ;
say qq{ $notify $weather } ;
$weather = join q{'} , '' , $weather , '' ;
qx{ $notify $weather } ;
return ;
}
########## ########## ########## ########## ########## ########## ##########

2009/09/02

People share the gift of gab between themselves

I am a Google Voice user, and I have been since it's been GrandCentral. I use it because voice mail connecting to email is an obviously good thing, transcribing your voice mail is a really good thing and the dial-in voice mail interface is an obvious dog. Also, I work in a sub-basement where cell phone signals do not reach. If I want to know that people are trying to get ahold of me, I had better have a voicemail service that uses email.

But that just means that I can hear the voice mail. What if I want to answer?

Lifehacker has a post on using Gizmo to do just that. They make it sound so simple. Set up Gizmo. Tell Google Voice you have a Gizmo Phone. Have Google Voice confirm your Gizmo number. Then you're golden.

Unless you're not.

Here is my entirely unhelpful order of events.
  • Tell Google Voice I want to verify my Gizmo phone.
  • My computer rings.
  • Time passes.
  • Google Voice gives up.
  • Gizmo's soft phone pops up to tell me I have a missed call.
I have tried Skype and it has ... kinda worked. The problem is, nobody I know uses Skype. On second thought, the problems are and they are nobody uses Skype, and if I'm being cheap (and I am) I'm not going to pay for SkypeIn.

It might be something simple and stupid. My current cannot-be-checked-at-work theory about my wife's laptop is that it's a permissions error. I'll work it out and see.

Oz never gave nothin' to the Tin Man...

Tinman is the name of my Compaq Mini netbook. Twiki* is the name I gave to my wife's netbook, which is an EeePC. Both, at this point, run Windows XP. Yeah, I'm the big Linux guy, but as a web developer, I find it useful to have a machine running Internet Explorer that I can test against.

We got the Mini with a deal with Sprint. We get the card Bill Kurtis has been pushing, which would allow someone to use the Internet when far away from wireless access points, using the Sprint cell network for data. It also provides good and useful GPS information like location and speed and the way to the closest Sprint store. I got a netbook out of the deal (yay) but I live in a house with Wi-Fi and work in a dank sub-basement with Wi-Fi and sufficient network cables. I don't find the need to check email much when I'm not either at work or at home. However, K spends her day running around a lot. It therefore makes reasonable sense for her to use it. So she asked me if she could have it.



Let me cut to the end, of the story, just for a moment. The dingus, once set up, is set up. You have to reinstall the interface software, sure, but anything you plug it into should be able to quickly get online, because by plugging it in you've done all you have to do to log onto the network.

Unless you have some sort of problem with your USB. Which Twiki seems to have.

* In the beginning of the Mystery Science Theater take on Catalina Caper, Joel has the bots say their prayers, even for Twiki. My eldest asked "Who is Twiki?" This is the description I gave.

There was a show in the late 70s and early 80s called Buck Rogers. There was a character whose name I don't recall, who was a hyperintelligent computer which takes the form of a of a blinged-out hubcap. Being a hubcab, that character cannot move, so there's Twiki, who looks like a cartoon seven-year-old with a bowl cut frozen in carbonite, who wears the blinged hubcap like Flavor Flav wears a clock.

This caused my son to laugh out loud.


I know the time, boieee

The installer comes with the Sprint card, and I have installed it four times. I have talked to the Sprint helpdesk. I have tried this process on three (3) computers ( Twiki, Tinman and Maria, named after the evil Maria from Metropolis ) and the problem comes up only on Twiki. Yeah, I have other Windows machines I can test against, sure. But the take-away seems that there's something wrong with K's machine.

Just had a thought. K might not be running as Admin. In general, that's good, but if she is, she can't install the drivers in the protected places and thus can't get networking going. I thought she was running with Admin privs, but I do not recall. Still, that's worth a look. ETA I checked, and she's running as Admin. It isn't that.