Today I found out the rss feed that I wrote for the infobot to work out the current time was broken. Basically, the script goes off to timeanddate.com and looks at the tables on there to work out what time it is the world (since it's easier than working it out yourself - especially when countries keep updating their laws about what time zone they're going to be in and when they're going to daylight saving.) The script as read should have been able to parse the string, but we were getting all these "Tor"s in our output.
Of course, "Tor" is Swedish for "Thu".
Yep. The webserver was looking at the accepted languages and if there was no header it was sending back a sweedish version. So what I was seeing with my browser (that was sending those headers) wasn't the same as what LWP was getting. It never used to do this - to be honest, we English speakers of the world are too lazy, we just assume if we don't specify these kinds of things we're going to get English back.
An additon of:
# all those need to have the english headers now
# or time and date will send us the times in sweedish. bork bork bork
WORLD->header("Accept-Language" => "en");
US->header("Accept-Language" => "en");
EUROPE->header("Accept-Language" => "en");
and everything works again.
~/bindirectory in the hope that someone else might find it interesting. I was too busy at the time to share mine, so I thought I'd post it here.
My all time killer script is the one that Tom Insam came up with after we discussed the problem for a while. Basically, we do all our work on a development server and we can ssh and samba mount the device. When I'm working locally on my laptop I can edit any file by typing
"ec $filename" and it loads in my local editor (a Carbonized Emacs.) I wanted the same thing when I'm sshed in to the development box.
So Tom came up with the idea of writing a script that starts another ssh session to the dev box and tails a file on the dev machine. The ec script on the dev machine writes to the end of the file instead of starting a process. The local end of the new ssh tunnel gets the filename and then spawns a local process to edit the file with my local editor over samba. Sweet! Completely transparent.
Of course it's more complicated than that. Whole YAML data structures get written to the file, so in theory at a later date I can extend the script to do something more useful. And I no longer run it as a shell script, I've got a CamelBones application written that runs the script and tails the output.
I know it's a simple idea, but the simple ideas are normally the best. It means I don't have to use a X11 forwarded editor from the dev server (eeek) nor do I have to have a seperate terminal for editing (running locally in the directory mounted via samba) and executing code (running remotely over ssh) on the dev server.
Let's see, what have I been doing with my days?
I've listened to many talks. The ones that stick out are the talk on WxPerl (short summary: It may be the best tool for the job but it's not a good enough tool to use if that's not what you need the tool to do,) Spreadsheet::WriteExcel (soon: charts!) Unicode (databases are fun,) and Usenet Gems (substr in lvalue context can be odd.) There were also gazillions (well, twenty) lightning talks I watched and they were all really interesting.
I gave three talks. The one talk I knew I was giving before I got there was on bundling. I then found out from Geoff I'd had a lightning talk accepted (on Perl and UTF8) and I ended up padding out the end of the WWW Smackdown talk session with an hour from my CPAN Modules talk (in the process of I drunk half a litre of water and still had a dry throat by the end.) I think they all went well in the end, and considering I wasn't expecting to give so many before I arrived, I think I did okay.
Of course the best thing about YAPC is the chance to meet up with people who I don't get to see that often. In addition to many of London.pm who don't make it to every social meet, there was Birmingham, Paris and Stockholm Perl Mongers in full effect. If I spend time listing all the people who I got to speak to - only briefly - I'd be here all evening. In the end I got my mini-axkit-bof. And I sat in many a scary conversation (including Tim Bunce on the problems with utf8 and databases which has given me quite a bit to think about.)
What have I been doing with my evenings? We boozed the Tuesday night at the crown, on Wednesday I went for sushi and then headed home early (and ended up hacking automatic unicode handing into Spreadsheet::WriteExcel,) and on Thursday we all headed off to the odyssey centre where we split off and ran around doing all kinds of mad things (I had tapas, played air hockey, watched people bowl, play pool and shoot zombies, and of course went to one of the bars.) I tried to stay out of the Crown too much, and almost succeeded most of the time. And Friday night? I'm sitting in the airport watching planes land and writing this (wireless++).
All in all it was a great conference, it had it's highs and it's lows. But in the end Karen, Marty, and all the orange clad helping crew did an excellent job. Now all I have to do is sit down and go though my notes and work out all the interesting titbits I've learnt so I can write them up here.
So, I'm just going throught things I need for YAPC::Europe, sorting my life out. This mainly involves not losing my passport again (since I have no other photo id - that and Erena would kill me,) buying Roobios tea to take with me (so I don't have to hunt for health shops in Belfast) and backing up my laptops (which I do every time I go away, and was really grateful I did when my old laptop hard disk died on the way back from Amsterdam in 2001.)
Still to do; Charge Laptop Batteries. Pick up camera cable. Don't lose plane tickets (paper...how quaint.) Update slides. Put multiple copies of slides on both laptops.
So, who do I want to meet? I'm going to scare matts by tracking him down and making him look at the Axkit / TT stuff and ask him how I do caching. I'd like to have another game of cards with the Belfast lot. And there's numerous other people I should bump into. Let me know here (or on my wiki page) if you want to meet up.
The lightning article's essentially on Test::DoubleEncodedEntities, but it's really about automatically detecting the errors that you can't normally see when you're working because even though they're obvious you're so focused on what you're doing you totally miss them. The theme was extended in the first talk on "dumb errors" I presented last night.
That talk moved onto talk about my new module Test::utf8 that I released last night. It's a testing tool for dealing with utf8, and along with testing if perl has encoded something utf8 or not, and if the string will fit in ascii or latin-1 it has some rather nifty tests that help catch when things go wrong. It's got a
is_valid_string test that can test if a string that is marked as utf8 contains valid utf8. And it's got a test that (taking a leaf out of Test::DoubleEncodedEntities) can tell you if you've double utf8 encoded your string or not (or forgotten to flag it as utf8 somehow.) There's a new version of the module on it's way to CPAN as I type this following the feedback I got last night - it was pointed out that the name
is_dodgy_utf8 was confusing (as it was testing it isn't dodgy utf8) and has been changed to
The second talk I did was the start of my campaign to get London.pm involved in the phalax project. It was reasonably well received and got a few laughs. We'll have to wait to see if we get any converts.
Aside from my own talks, the other talks were pretty cool too. Alex's live demo of his music editor which he talked about in his recent perl.com article was really quite cool and much more impressive than I thought it would be. He really can produce quite cool tracks just by typing code.
Tom's preview of his upcoming talk at YAPC was quite fun, and I think once he makes the modifications we've suggested to him it'll be a really good talk.
Simon gave a final "What I've been hacking on" which was a wonderful, if brutally honest, talk about what he's been doing and what stage he's at. He was unashamed in both pushing the new programing ideas he's been working on - extensions to maypole he's been developing while creating new applications to make it even more flexible - and pointing out that he never completes anything (and thanking Simon Wistow for completing everything he'd started.) We're going to miss Simon now he's going away.
That's enough journaling for now. And under no circumstances should I mention the variation of "Drink while you think" that was proposed in the pub last night where you use CPAN modules rather than famous people.
// Read all available data and converting it to a string
NSData *data = [fh availableData];
NSString *str = [NSString stringWithData:data];
My code (in Perl:)
my $data = $outhandle->availableData;
my $string = NSString->stringWithData($data);
Exception raised during posting of notification. Ignored. exception: *** -[NSConcreteFileHandle availableData]: Invalid argument
Bah. Everything hates me.
It'd be nice to automatically test for that. So I wrote a Test::DoubleEncodedEntities to do just that. Winging it's way to a CPAN mirror near you as I type.
This week when I have not been staring intently at internal Fotango code I have been rewriting the documentation and fixing some of the bugs in Data::Structure::Util. Later version in Fotango's Open Source svn. It'll have to wait for Pierre to get back off of holiday before I can convince him to release it to CPAN.
It didn't exactly go to plan
Also, just to kick us when we're down some utter b*$!ard stole Melin's bag from the sushi place we went to recover in. The utter f%&k. We didn't even see how the little s*!t could have got past us.
Apart from all that, not a bad evening. *sigh*
My next step is to beef up the test suite - the whole things runs out of an Apache::Test environment - so I can check that you can catch all the errors in the right place.
I've also been cargo culting like crazy with SubEthaFari which is a little mac xcode project that you build and shove in the right place in your ~/Library and through some crazy method swizzling (Object-C symbol replacing) it causes Safari to open it's source in SubEthaEdit rather than it's own source code viewer. This would be great, apart from two things. One, I can't use SubEthaEdit at work without either breaching the license terms or paying for it. Secondly, it's not emacs or vi.