Blog

Travel map – countries visited

I’ve been looking for a good countries visited map for quite some time. There’s something satisfying about painting the world red (or in this case, orange), and something humbling about seeing massive chunks of the planet untouched. So since we’re approaching April and I’m getting the inevitable itchy feet again, I’ve gone hunting.

Up until now, World66 had seemed my only option. But in the Age of Google, posting images for this sort of thing seems a bit of a letdown. Fortunately 29travels have just the thing with their Google Map version.

Pretty cool but it’s a shame there doesn’t seem to be an option to edit the map. But, a quick look at the iframe source, and you can see it’s pretty easy to hack in any new countries as you visit. Providing you know the right country codes of course.

http://www.29travels.com/getmap.php?j=ALATBACYCZDEESFRGBHRISITMKMTMENLPLSITRUSVAVN&c=cc41c9f2&w=575&h=300

That query string is a long list of 2-digit country codes. So, if you know the code for the country you want to add, just adding it to the string will provide all the highlighting you need. For example Australia = AU

http://www.29travels.com/getmap.php?j=ALATBACYCZDEESFRGBHRISITMKMTMENLPLSITRUSVAVNAU&c=cc41c9f2&w=575&h=300

Who wants to package this up into a WordPress plugin for me? 🙂

Getting document reports from Amazon Seller Central SOAP services (C#)

Developing against the Amazon API becomes a lot more straightforward with being able to get at the errors with your XML documents. Validating against the XSDs is only part of the solution, but even downloading reports can be tricky. Trouble is, the documentation from Amazon is a very closed & private sort of affair – sometimes out of date and sometimes very sparse. Perhaps they should think about a wiki 🙂

Getting at your reports consists of two parts, firstly – use the Document ID (long) you got from posting the XML in the first place.

[codesyntax lang=”csharp”]public DocumentProcessingInfo DocumentStatus(long DocumentID)
{
//Setup the service interface, set the URL of the service
//and add our credentials.
merchantinterfacedime myAmazon =
new merchantinterfacedime();
myAmazon.Url = ConfigurationManager.AppSettings[“URL”];
myAmazon.Credentials =
new NetworkCredential(
ConfigurationManager.AppSettings[“UserName”],
ConfigurationManager.AppSettings[“Password”]);

//Setup our merchant details.
Merchant myMerchant = new Merchant();
myMerchant.merchantIdentifier =
ConfigurationManager.AppSettings[“MerchantIdentifier”];
myMerchant.merchantName =
ConfigurationManager.AppSettings[“MerchantName”];

//Send it all off to Amazon.
DocumentProcessingInfo myStatus =
myAmazon.getDocumentProcessingStatus(
myMerchant, DocumentID);

//Return the status of the document.
return myStatus;
}[/codesyntax]

This will give you the status of your upload, as well as whether it’s complete or not. It also gives you another document ID, which you can use to get at your much-needed reports.

[codesyntax lang=”csharp”]public string GetDocument(string id) {

StringBuilder report = new StringBuilder();

merchantinterfacedime myAmazon =
new merchantinterfacedime();
myAmazon.Url = ConfigurationManager.AppSettings[“URL”];

myAmazon.Credentials =
new NetworkCredential(
ConfigurationManager.AppSettings[“UserName”],
ConfigurationManager.AppSettings[“Password”]);

//Setup our merchant details.
Merchant myMerchant = new Merchant();
myMerchant.merchantIdentifier =
ConfigurationManager.AppSettings[“MerchantIdentifier”];
myMerchant.merchantName =
ConfigurationManager.AppSettings[“MerchantName”];

ReferencedBinary incomingDoc = new ReferencedBinary();
// the seven-digit string is the document ID number
myAmazon.getDocument(myMerchant, id, out incomingDoc);
IEnumerator enumer = myAmazon.ResponseSoapContext.Attachments.GetEnumerator();
while (enumer.MoveNext())
{
// Print the document to standard out
Attachment downloadedDoc = enumer.Current as Attachment;
StreamReader r = new StreamReader(downloadedDoc.Stream);
report.Append(r.ReadToEnd());
}
return report.ToString();
}[/codesyntax]

And tying it all together:

[codesyntax lang=”csharp”]long amazonId = #######
string report = GetDocument(DocumentStatus(amazonId).processingReport.documentID);[/codesyntax]

Your report will be in XML, and give you any validation errors that might be preventing your feed from working properly, as well as some very helpful status on the number of items processed. How did you ever live without it?

There are some chain emails you just can’t ignore

album-cover

John Casimir, Prince of Anhalt-Dessau: Speech is more than eloquence. In stores soon.

We’ve all seen them. Forward this mail or die.  Forward to 50 friends and fall in love tomorrow.  Fill out these 7,000 questions and forward to all your friends.

Well I stumbled across this one on Facebook, and couldn’t stop myself as soon as I hit the Wikipedia entry.

CREATE YOUR FIRST ALBUM COVER

Here are the rules:

1 – Go to Wikipedia. Hit “random”
or click http://en.wikipedia.org/wiki/Special:Random
The first random Wikipedia article you get is the name of your band.

2 – Go to Quotations Page and select “random quotations”
or click http://www.quotationspage.com/random.php3
The last four or five words of the very last quote on the page is the title of your first album.

3 – Go to Flickr and click on “explore the last seven days”
or click http://www.flickr.com/explore/interesting/7days
Third picture, no matter what it is, will be your album cover.

4 – Use Photoshop or similar to put it all together.

Ladies and gentleman, I give you the latest album from John Casimir, Prince of Anhalt-Dessau. Speech is more than eloquence.

Code highlighting, and the magic of LINQ

I’ve had a small block of code in my drafts folder for quite some time now, just looking for an excuse to publish it.  I’ve been using LINQ a lot in the past 6 months, and it’s one of the recent additions to the language that’s made me think twice before using PHP or Perl for my own projects (despite the existence of PHPLinq).

HIM: LINQ’s like pringles
ME: only makes sense after drugs?
HIM: once you pop you can’t stop

But I didn’t really want to write a full post on LINQ.  It seemed dull.  It’d been done before.  It’s old news.

So I picked up the WP-SynHighlight extension for WordPress.  Which gives some rather cool code-highlighting through GeSHi.

So here’s some highlighted stylised C# LINQ demonstrating how simple it is to combine LINQ to SQL with LINQ to XML data sources.
[codesyntax lang=”csharp”]var answers = (from a in poll.Descendants(“AnswerSet”).Descendants(“Answer”)
join aCount in dbVotes
on a.Attribute(“id”).Value equals aCount.AnswerId.ToString() into aJoined
from o in aJoined.DefaultIfEmpty()
select new {
id = a.Attribute(“id”).Value,
percentage = ((o == null ? 0 : o.VotesCount) / dbVotes.Sum(b => b.VotesCount.GetValueOrDefault()) * 100),
count = o == null ? 0 : o.VotesCount, text = a.Value
});
[/codesyntax]

Now if only Microsoft would release LINQ to XSD out of preview.

Twitter your Gallery 2

Seems everyone is talking about Twitter nowadays.  The Hudson River picture launched it into the media world as the best news source on the planet, and Obama‘s adoption of the tool has given America the same pleasure that Britain experienced when our Prime Minister, Stephen Fry starting getting ‘back in touch with the people’, in October 2008.

The Hudson River picture wouldn’t have been possible without the non-affiliated TwitPic – which never truly got the recognition it deserved.  Without it, the infamous picture would have only been a 140 character description, and nobody will have noticed or cared.  Still, that’s the nature of buzzwords I guess.  If they don’t cause a buzz, they’re just words.

Anyway, TwitPic is yet another disparate service like Flickr, Panoramio or Facebook that’s had me tempted away from uploading some of my photos to Gallery2 / Blakepics.  With Facebook, I’ve integrated my own application there; Panoramio and Flickr, stolen the best parts of each.

And now with a hack to the tagging module in Gallery 2 I can emulate all I want from TwitPic as well, and tuck another service onto the shelf at the back at the cupboard.  So as usual, I thought I’d share.

What it is…

  • Tweet any photos on Gallery just by adding the tag ‘twitter’ to your photo.
  • Automatically takes the photos title as your Tweet text.
  • Processes all URLs through TinyURL, giving you a warm and fuzzy Tiny URL

What it isn’t…

  • A seamless Gallery2 module.  There’s some hacking to do.
  • Multi-user.  If you share your Gallery, there’s some more work to do.

If you make improvements in these areas or any others – please let me know 🙂

Requirements

Things you need to do

  1. Download my Twitter Tags class
  2. Unzip to the root of your Gallery installation
  3. Edit /modules/tags/classes/TwitterTag.class with your twitter username/pass, and Gallery URL.
  4. Edit /modules/tags/classes/TagsHelper.class
    1. Add this just above the line ‘class TagsHelper’
      GalleryCoreApi::requireOnce('modules/tags/classes/TwitterTag.class');
    2. Then just above
      return TagsHelper::assignTagById($itemId, $tagId);
      Add
      TwitterTag::Tweet($itemId, $tagId);
  5. Tag any photos you want to appear on Twitter with ‘twitter’.

The Devil’s Footprints in the Snow

You may have heard about the total devastation that hit Britain on February 2nd, 2009.  I already feel behind the curve as I write this on a wind-up battery-powered laptop, dividing the last tin of baked beans out between myself and the family upstairs.

Transport ground to a halt because we weren’t as prepared as Canada.  Businesses across the country, even in The Great Capital lost billions as a fifth of the workforce abandoned brave attempts to struggle into the office, shovelling coal into the engines attempting to push their way through snow drifts up and down the country.  Some even had to revert to working from home, costing the economy further millions as I.T. support staff were pulled from vacations all over the world to keep VPNs and email systems up and running.

Bendy buses were left abandoned across London as people struggled to climb atop double deckers after a growing number of reports of minor avalanches around Hampstead Heath. Ferry services from Greenwich were suspended after hundreds of commuters were lodged firmly in ice for over 6 hours without food or water, and even the time-honoured horse and carriage struggled to get all 27 of the City of London’s remaining employees into work on time.

Boris Johnson was on hand to help anyone local school children “from the borough” build snowmen in any way he could.  “The Snowman was invented in England, you know”, he quipped in an earlier statement today.  Meanwhile, the Canadian army is said to have been put on high alert to help Britain in any way they could, whilst President Obama was quoted as saying “why can’t you be more like Chicago?”

Three of the major supermarkets have closed 80% of their stores nationwide, and do not expect supplies to return to the cities any time soon.  With more snow expected before Saturday, they are said to be preparing armed forces from Sweden to prevent the tragic events in Shropshire happening elsewhere.

Then again, it’s just a bit of snow.  Lighten up 🙂

Statistical New Years Resolutions on Blakepics

Last year, like the year before that, I made a resolution to caption 35% of the photos on Blakepics (up from 20%). There were 4,040 photos added over the past year, and approx. 25% of all photos are now captioned. So I didn’t reach my goal. 1,344 photos were captioned, and if it weren’t for all those new ones it’d be standing at 30%.

Fortunately, BBC News have now deemed New Years Resolutions to be bad for your health.  So like bread, second-hand smoke, guilt and vitamins, I’ve given them up.

But I thought to myself, “I’ve been captioning loads of photos every week”.  I did.  “I bet it’s the rest of those free-loaders not pulling their weight”.  So I’ve given the Caption Status page on Blakepics a much-needed overhaul.  If you’re logged in, you’ll now see how you’re doing with captioning your own photos – and even if you’re not, you can see a member list with how many photos everyone’s captioned, as well as click-through to a list of them all.

Turns out I was wrong.  A lot of those free-loaders are doing a better job than me.  In fact, whilst 25.01% of total photos are captioned – 25.04% of my own photos are captioned.  Since most of them on there are mine, I guess I shouldn’t be surprised.

So it seems as though I can’t prove everything with statistics.  Not if that something is how successful my 2008 Resolution has been.

Happy New Year Everyone!

Vietnam Photo Story

The end of my Vietnam trip has come and gone, so here’s the inevitable photo story from my time away. The pictures come from all over Vietnam from Hanoi down to Ho Chi Minh (or Saigon, if you prefer). Facebook users will probably need to click through to the original article link to see the video.

The rest of the photos, including the ones in the video above are on Blakepics, where you can also find a full quality version of this video. The music for this one in case you’re interested, is “Easier to Lie” by Aqualung, inspired by a recent episode of Lead Balloon.

The Road to Saigon

Yesterday afternoon I boarded the bus at Da Nang to Saigon. Taking around 16 hours – it’s the longest bus ride I’ve ever taken, the previous contender being the 8-10 hour trips around Turkey. Well, there’s an achievement.

It’s difficult killing 16 hours, especially once the battery runs out on the music/life-giving iPAQ. So here’s another set of notes like the last one, since Andrew liked the format so much 😉

Ho Chi Minh trail was closed due to landslides. Minh took me down about 20 metres of it, and past the sign so he still fulfilled the contract we made out previously.

Saigon was renamed Ho Chi Minh city after the war, an effort to crush the spirit of the people. The further south you get, the more people call it Saigon. Nobody told the people.

Likewise, prices are quoted in US Dollars a lot more here. Every time I ask “how much is that in Dong?”, they look impatiently at me, like I want to pay with snakeskins.

Food is important in Vietnam. During the 16 hour journey we all stopped for inclusive sit-down meals together twice. Rice, fish, meat, vegetables, all shared with strangers around 3 large tables. It beats National Express hands down.

Ignoring the motorbike drivers is the best policy. No more cheerful “No, thank you”, but a determined dive into heavy traffic as they run after you screaming “Where you phhhrrooom?” will stop all but the most determined.

Ceiling geckos will not eat you in the night. Unproven, but a reassuring initial trial.

All of the street restaurants have small plastic garden furniture for tables and chairs… I haven’t found a single place at that sells it.

I still find it strange whenever I visit an ancient site that’s under-construction. I’m sure the scaffolding is just for restoration or support … But you can never be sure.

It’s perfectly safe if your hotel room’s ceiling is held up by cellotape. I hope.

$12/night hotel rooms in Saigon are not opulent luxury.

As always, send to all you mates – and you’ll find eternal happiness, etc.

The Vietnam War. There was only ever one of them

Minh

Minh

You might have noticed I’ve not really mentioned The War. It’s a defining point of Vietnam’s history of the last century, and ultimately brought about the unification of the country as a whole for the first time since the French colonisation in the 1850s. So after great efforts to ignore it, as I head into the south of Vietnam, it’s time to catch up. My guide Minh was an officer in The War, and as promised gave me the background I needed for this post. I wanted something more personable than the history books, and Minh was invaluable in providing me with both.

Ho Chi Minh, or Uncle Ho was the founding member of the French communist party, and believed in Vietnam for the Vietnamese. He was respected by everyone both in the north and south and is still considered to be a great man by everyone I’ve met. After World War I, France were trying to reduce the resources it was committing to its colonies, and the Indochinese Communist Party was formed, at a time when unemployment and poverty were at their highest. Not unsurprisingly.the Vietnamese welcomed the idea of change with open arms. The new Vietnam looked a lot more attractive than the mess they were in at the moment.

World War II hit, and provided Ho Chi Minh with the opportunity he had been waiting for. It demonstrated the weakness of their colonial masters, and saw the Japanese taking control of coal mines, rice fields and military installations. The Japanese were running high on “Asia for the Asians”, but this wasn’t enough for Ho Chi Minh, who wanted to give his country back to his people. Hiroshima, and the Japanese surrender kicked off the August Revolution, and the Democratic Republic of Vietnam was established in Hanoi ruling North Vietnam.

“Who do you think the war was between?”, Minh asked me. “Russia and America”, I replied. “Yes, the communists and capitalists. Vietnam was just symbol, as Iraq is now.” He doesn’t consider it a civil war between the north and south, but two superpowers fighting it out in his country. America had been supporting the French war in Indochina since 1950. In 1955, they began funding the training of Diem’s army in the south. America believed that if Vietnam fell to communism, the entire region would follow – something they were very keen to avoid. Not least because of what it would mean for US access to trade routes, raw materials and markets. I was already drawing plenty of cynical parallels with Iraq.

In August 1964, America stopped providing just money and properly entered the war. At this time, Minh was attending university, he was given the choice to fight, or to carry on with his education. He chose, like many others to fight for his country. Being born and living in the south, he fought on the side of the Americans. It had nothing to do with belief, he tells me – simply where you were. By 1973, the Americans and the south were defeated. Giving power to the communist rule from Hanoi.

It wasn’t the end of the hardships for Minh and many like him. He was sent to a re-education camp because he fought on the losing side. This was a labour camp, and conditions unpleasant. It all depends on position in the war, rank, and what you did. But the length of time in the camps was different for everyone. If he had been forced to spend 3 years, he would have been automatically allowed to go to America when he left. Minh speaks with disappointment that he was only there for two years, and not eligible. “Would you still go now?” I ask him. “Of course”.

Once released, he’s not allowed to move city without prior government approval and forced to report to the police station every week. Minh still feels a bitterness towards having to give his every movement in detail. At the end of the two years, the police interviewed his neighbours to find out if he has changed, and has become a good person. Because of this, he says it’s very difficult to trust anyone, even now. Your neighbour, your friend could be reporting you to the police, or to your enemy. He’s still wary of the north, not that there is recognisable danger. But history has proven that there could be.

I ask the inevitable, “What do you see for the future? For Vietnam? For your children?” He sees both as the same. Minh endeavours to set a good example for his two sons. “Every day, we sit and we eat together as a family. Sometimes they are busy, they are grown up – family of their own. So sometimes once a week.” He believes the future relies on two things, education and experience. He uses these times with his family for education. “Experience,” he explains “they must learn that for themselves.”

Minh looks to the west for his countries future. He believes Vietnam has a lot to learn from America and Europe. “What do you think of the collapse of the world economy? Does it affect you?” Minh starts laughing hard, a long throaty laugh that spreads slowly across his face. “Financial crisis”, he chuckles. Minh doesn’t appear worried.