Friday, August 06, 2010

Annoy Smarx from Windows Phone 7

Annoy Smarx is a web app that Steve Marx showed in Windows Azure Firestarter event. It is a web app that once you clicked on an image, Steve’s notebook wallpaper would change to the selected image. It was a pretty cool demo cause it showed you a good practical sample of AppFabric ServiceBus.

Last week I started playing around with the new Windows Phone 7 SDK, and I faced the problem I do when I start something new, “what should I code”? I t has to be simple cause I’m new to this stuff (I’m no too familiar with silverlight either) but not too simple… I hate the “Hello World!” sample. So I thought maybe I can create a client for the AnnoySmarx sample and so I did.

I liked it cause it a simple project, yet it has many cool features, like downloading blobs from Azure Storage, using a ListBox to show the images, handling the double tap event on Windows Phone 7 (there’s no OnDoubleTap event, so it might be a little more complicated than you think), and calling a rest service on ServiceBus which is actually running on my computer.

You’ll find all the resources you need at Steve’s post and the code for this client here.

I recorded a video of the app running on the emulator…

pretty cool uh?!


Read Full Post

Wednesday, June 30, 2010

Introducing shelltwit

Some time ago I talked about a command line twitter client I was developing. Today I can proudly say it is finished… for now Smile
And I decided to upload the code to Codeplex GitHub for a few reasons. First of all it uses xAuth with .net with no extra library. Some may be asking “why would you want to do that if there are hundreds of libraries out there?”… well yeah but… no I don’t have an answer for that… I guess I just wanted to give it a try.
Also, while developing this tool I encountered some problems that some people does not ever find, specially people from English speaking countries. The problem appears when you want to twit say… “Peñarol Campeón!”. It took me a little while to discover the right encoding and as I said before, there’s not much written about it. (For more info take a look here)
And finally I wanted to share the code in case some soul out there wanted to give me a hand with the rest of the API. So far this tool only updates the status, but I’m also building a library (cleverly called shelltwitlib) where I’m intending to add every twitter API method.
As a bonus, if you use the shelltwitlib (since it works with xAuth) you’ll be able to have your tool displayed on your status like in the picture shown below.
Want more? integration is also available Smile


Read Full Post

Tuesday, June 22, 2010

HTTP Error 404.17 - Not Found

The requested content appears to be script and will not be served by the static file handler.

For some (unknown at the time) reason I had this error while trying to view a WCF service app in the web browser. I googled (and binged) around and there was many reasons for that message.

My problem was that my brand new computer came with Microsoft .net 3.0 installed but IIS was not active. So I installed IIS after the WCF support so the WCF mime types were not installed.

To get this working all I had to do is running the following command:

C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg -i

Hope it helps someone else.

Read Full Post

Monday, May 17, 2010

Encoding strings for the twitter API free icon set Some time ago, I started to work on shelltwit a command line twitter updater (it only updates your status), but I didn’t want to use any existing library because I wanted to learn how to work directly to twitter API.

I looked around for some examples, the Twitter API doc is not well updated or complete, so it is not easy to start coding right away, you need to read a lot first (I hate when that happens). I found a good sample from Shannon Whitley called Twitter xAuth with .net. I started up with that code but I found an issue with international characters, like á, é or ñ, which kept me from posting about #Peñarol. So I started to hunt the bug, looked around online, went to the Twitter API user group and found out that there are a lot of issues with international characters. I found people form Brazil, Russia and Japan complaining about it. Apparently most libraries were written by english speaking developers so very few encounter the issue.

Now I can happily say that found the issue so I thought about posting the solution here.

Encoded strings (your twitter status) must be made to UTF8 according to RFC3986 and there’s no native .net function that does that, so after some researching I came up with an algorithm that does exactly that. So I hope it helps some one else.

static string UNRESERVED_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~";

// see 'Try It Yourself' to see if this function is encoding well
//This should be encoded according to RFC3986
//I could not find any native .net function to achieve this
/// <summary>
Encodes a string according to RFC 3986
/// </summary>
/// <param name="value">
string to encode</param>
/// <returns></returns>
public static string EncodeString(string value)
StringBuilder sb = new StringBuilder();
foreach (char c in value)
if (UNRESERVED_CHARS.IndexOf(c) != -1)
byte[] encoded = Encoding.UTF8.GetBytes(new char[] { c });
for (int i = 0; i < encoded.Length; i++)
return sb.ToString();

Read Full Post

Monday, April 19, 2010

My Run 2.0 samples

annoysgomez Last week Run 2.0 took place in Montevideo and I had the privilege of working with Guadalupe Casuso (from Microsoft) and Luis Pandolfi (from Infocorp) on part of the Keynote, we talked about Windows Azure and if you ask me it was too short.

After the keynote I talked to some people who told me the session was great, but most of them already knew about Azure, so I guess I never know how good/clear was for someone new to the Windows Azure Platform (if you’re in this category please send me a line). One thing Guadalupe told us, and I guess she was right, is that there’s no point of showing something you can’t use yet… it’s like showing a kid a candy. I don’t know, but one thing I do know is that we could have use the entire conference to talk about Azure :)

On my part of the session I had to show something on ServiceBus so I showed Steve Marx’s AnnoySmarx sample. I changed a few thing from the listener, one thread would never end unless you close the cmd window, and added a few messages for demoing purposes. The sample is pretty cool cause it let you change the wallpaper of my computer by clicking the images from an online web page (in this case hosted on Windows Azure). For my sample I deployed the web app at and people from the audience would get online and click on the images while on the main screen you could see the wallpaper of my notebook changing. I was pretty cool and showed how you can get servicebus up & running with a little extra work from what you do to host regular WCF services.

Another tool I used is Windows Azure Storage Explorer which I built myself to browse and manage items from a Storage Account. I recently uploaded the source code to codeplex, the project is here.

Read Full Post

Wednesday, March 24, 2010

Goodbye trim()

I’ve been playing a bit the the RC version of the .net framework 4 and already found a new cool method.

Until now when I wanted to check for a valid string I had to use the following code:

if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text.Trim()))
    throw newArgumentNullException("text", "text is not valid");

And I had to do that because a string containing nothing but white spaces was not valid and if you called the Trim() method on a null string you’ll get a NullReferenceException, you know the message… (“Object reference not set to an instance of an object.”)

So, the new cool method I found is a static method from string called IsNullOrWhiteSpace. the name pretty much says it all, except that the real name should be IsNullOrEmptyOrWhiteSpaces ;)

Instead of writing the code shown above, where you could easily forget the second condition, now you can have the same behavior in one single sentence:

if (string.IsNullOrWhiteSpace(text))
    throw newArgumentNullException("text", "text is not valid");

Read Full Post

Tuesday, March 09, 2010

New features to the Azure Web Storage Explorer

On the first version you could only manage blobs, upload, delete and download them. Now I added the same functionality for Queues and Tables.
I found a pretty cool way of showing unstructured data from the Azure tables from a gridview control. How? with my good old friends the DataSets :)
I also updated the source code so you can download the source files from the version that it’s right now running on the Azure platform.
Go to to see the application running and here to download the source code.
Feedback is always welcome!

Edit: url is now

Read Full Post

Monday, January 25, 2010

YATC (yet another twitter client)

image My twitter followers have probably realize by now that I’ve been playing around with the Twitter API. I’ve been trying out the API and I created a command line tool to update my twitter status.
I tried lots of clients but it is still a pain in the a*s to go to a different application or web browser to update my status.
I have a command line window open all the time so now I’ll be easier to update my status. In case you want to give it a try you can download it from here. The use is real simple, just type twit <your status> and that’s it. If it is the first time you run it it’ll ask you for your twitter credentials.

Edit: as of today (Jan 28th, 2010) twit has integration. Just type your status with a url and twit will post the short version of it. Yes! I like playing with web APIs.
As always, this bits have the “works on my machine” warranty :)

Read Full Post

Monday, January 18, 2010

Moving from basicHttpBinding to customBinding

We’ve been having a few issues with some users that cannot authenticate to Genexus Server. Logging the server side, thanks to SvcConfigEditor, I found that the probles had nothing to do with the user credentials themselves but with some WCF configuration that prevent packages “from the future” to reach the server.

How did that happen, and most important, how do I change it?  It happened because of daylight saving (global warming is everywhere). WCF has a under the hood feature that prevents your server to be reached by packages with a timestamp away 5 minutes (default value) from the server’s time (taken to UTC). Apparently, not everybody has its computer set up correctly with the correct date/time setting, so when one of them changed (the client or the server) the server would not validate the client.

So, how do you change that with your existante basicHttpBinding? you can’t! :( What you have to do is creating a customBinding and modify the maxClockSkew attribute of the security tag. And how do you do that? Well, lucky us there’s a tool that does that for us. It’s called WcfBindingBox (hopefully will stay there for a while) and you simply paste your current binding configuration and when you click ‘Convert to CustomBinding!’ well… it does just that!

After using that new config on my dev server I had the following error while authenticating:

“A supporting token that satisfies parameters 'System.ServiceModel.Security.Tokens.UserNameSecurityTokenParameters:
InclusionMode: AlwaysToRecipient
ReferenceStyle: Internal
RequireDerivedKeys: False' and attachment mode 'SignedEncrypted' was not provided.”

And the problem was exactly what the message says (unbelievable). All I did to fix it was creating an instance of the UserNameSecurityTokenParameters class, configure the properties mentioned on the message and add it to my TransportSecurityBindingElement.

I lost a whole with this so I hope it will be useful to someone else.

Read Full Post