So, have you ever wasted a half hour coding while also driving yourself absolutely insane? Was it when you were playing with libxml-ruby and xpath?
Minutes ago I was coding up a xml-rpc webservice when I realized that I was unable to get the nodes that I was looking for with xpath.
As usual I searched google looking for other people having the same issue and nothing helpful came up. I knew I had to write this post when I sawthis.
So my response xml looked somthing like this:
response = <<-REMOTE_XML <?xml ...?> <rootNode xmlns="http://happythanksgiving.com/htgn"> <list> <item>hey</item> <item>there</item> </list> </rootNode> REMOTE_XML
My ruby was something like this:
document = XML::Parser.string(response).parse namespace = 'http://happythanksgiving.com/htgn' turkeys = document.find('/htgn:rootNode//item', namespace)
turkeys.sizewas always 0.
I the found out that I needed to add the namespace prefix to each element in the xpath find…. duhh!
document = XML::Parser.string(response).parse namespace = 'http://happythanksgiving.com/htgn' hotels = document.find('/htgn:rootNode//htgn:item', namespace)
Note the xpath ”/htgn:rootNode//item” changed to ”/htgn:rootNode//htgn:item” (added the namespace prefix)
Hope this helps some poor hacker or me next July when I forget and start searching google. 😉
A good friend of mine years ago used to use a command-line app called ytalk to show me around the bash shell (thanks Sione!). After a short while I stopped needing his help and so I stopped using ytalk. At work we really wanted to shell-share with remote team members who were unable to use the iChat screenshare because of OS and bandwidth limitations.
I remembered that ytalk was such a good tool for being able to see what someone else was doing in the shell and to show off your bash skills. I thought it was going to be easy to setup on Ubuntu, but as it turns out, although its still an available package, it is dead on install.
So…. here is what I ended up doing and I hope that if you do the same you will be ytalk’in in no time..
On ubuntu install ytalk:
sudo apt-get install ytalk
Change the default/broken inetd.comf configuration:
talk dgram udp wait nobody.tty /usr/sbin/in.talkd in.talkd ntalk dgram udp wait nobody.tty /usr/sbin/in.ntalkd in.ntalkd
talk dgram udp4 wait root /usr/sbin/in.talkd in.talkd ntalk dgram udp4 wait root /usr/sbin/in.ntalkd in.ntalkd
Note the “4” after the udp and the “nobody.tty” change to “root”
In the /etc/services file, make sure the following lines are in there:
paul@box:~$ sudo grep talk /etc/services talk 517/udp ntalk 518/udp
I didn’t have to change anything, but its a good idea to confirm things.
Initiating the chat:
You can do this in a couple of ways, the first and most obvious way is to coordinate with another person/user and ensure that the two of you are only logged in once to the same box ad then type.
paul@box:~$ ytalk fred
Or if your logged on more than once you can specify the tty in the request after finding out which one it is:
paul@box:~$ who fred pts/0 2009-11-06 10:50 (208.X.X.X) fred pts/2 2009-11-06 10:48 (208.X.X.X) paul pts/3 2009-11-06 14:02 (208.X.X.X)
More on that can be found here: http://manpages.ubuntu.com/manpages/intrepid/man1/ytalk.1.html
Thanks to euphemus for the breakthroughs!
Hope you find ytalk as useful and coolific as I do.