Archive for December, 2009

Main Site Now iPhone Enabled

0

Have I pronounced my love for ASP.NET MVC yet? Well if I haven’t then let me do it now. I love you ASP.NET MVC! With very minimal effort, about 3 hours, I was able to create an iPhone version of the main site of Aqua Bird Consulting. I used JQTouch for the iPhone functionality, and used a new view engine to determine whether your coming in through an iPhone. Check out the pictures below. I’ll be pushing this nice feature out pretty soon. I still need to delve deeper into JQTouch, but I am confident that most ASP.NET MVC applications can be converted to an iPhone version with no effort at all.

photo photo 2photo 3

No Pain, No Gain? Part 2 : Tools

0

Some developers are elite, they only code in notepad. I on the other hand don’t fall into that category; I love my tools! This post is to recognize the importance of productivity tools and realizing the pain of living without them. A good carpenter could build your house with just a hammer and a handsaw, but we all know that is a completely insane undertaking. Approaching a development project is the same. Just like any other professional, developers should hone their tools.

The Tragedy

There are developers out there only using the basic Visual Studio IDE and what Microsoft provides to them out of the box. Although these developers are creating applications, they are probably feeling the pain in two places. You can code yourself into a corner when developing using drag and drop development. I am not going to say it is evil, because drag and drop certainly has a place, but it is intoxicating. Drag, Drag, Drag, Done! You’ve just created a application, but what happens when you need to step outside of the box of the visual studio designer? Many developers freeze and panic at this point, because there is no feature in their Visual Studio toolbox for that! The other problem with drag and drop, is that developers can get into brain-dead development. Like I said, it is intoxicating to drag a new feature onto your application, but does it really need to be there? Now I am picking on drag and drop, but there is another bigger tragedy. The tragedy is that these developers don’t explore the larger ecosystem of .NET. There is cool stuff happening outside of the realm of MSDN and Microsoft guidance.

The other issue I see is that many professional developers don’t have a proper development environment. What do I mean by development environment? To me there are minimal standards for a development environment: Source Control, Local Database Engine, External Text Editor, and Reflector. That’s it for a minimal productive development environment, if you are missing any of those then you are doing yourself an injustice.

The Remedy

So you are missing some of the things I mentioned above, but don’t fret I will give you a couple of tools that can fill those places and explain how they can ease your development life.

Reflector

USE THIS! You will be better for having done so. It disassembles any .Net assembly and shows you the code inside. I have progressed my skills exponentially by just reading other peoples code. At this point in my career I would say I read more code than I write. When you are scratching your head about why a call into a third party assembly is exploding, you can use reflector to see if the problem is yours or the third party.

Source Control

I personally have used Visual Source Safe, Team Foundation Server, CVN, and SVN. I currently love SVN because it allows me the facility to host a repository locally or use many of the FREE Subversion providers on the internet. I also have great Visual Studio integration with the free add-in Ankh-SVN. I’ve included the links to some SVN providers along with the link to Ankh-SVN below. Now you have no excuse to back up your tireless efforts in coding.

You’ll thank me when your machine blows up and you still have your code safely on the net. Your Welcome!

Database Engine

This isn’t so much an issue until development teams make it an issue. I’ve been part of development environments where there was one database that everyone developed against *cough* Oracle. What a freaking nightmare. Oracle released a developer version of their database, but the damage was already done. Developers yelling “You changed my data!” at each other, on the verge of fist fights. So as a rule of thumb, every developer should have a local instance of the database in their environment. If your database is “too complex” for that then you probably have bigger problems.

Use the appropriate engines for your project : SQL Server, Oracle, MySQL,, or SQLite.

External Text Editor

image

“I already have Visual Studio, who needs this?” Visual Studio is slow to load, especially with all those plug-ins (check out my load screen!). Visual Studio is also overkill when all you need to do is change a configuration setting or look at a text file.  Waiting for Visual Studio can seriously hamper your groove, and sometimes you just don’t have that luxury. In addition, sometimes your IDE is not available because your are on another machine. I personally like Notepad2. It is quick and it is portable. It also gives you nice syntax highlighting for XML and HTML.

The Extras

Now what I mentioned above is just a minimum, but the extra tools make things better. Let’s look them over.

GhostDoc

I’d swear there was someone reading my code. This tool basically documents your code with a click. You need this if you do a lot of documentation in your code. It will literally save you thousands of commenting keystrokes.

ReSharper

A productivity tool like no other. My previous post explains it all. It is the difference between coding like the tortoise or the hare.

ORM – Object Relational Mappers

SQL is a powerful language, but I hate writing repetitive CRUD statements. An Object Relational Mapper is the way to go when designing a system. You can save hundreds of man hours not writing CRUD code and getting to what really matters. A nice introduction to Object Relational Mapping is Linq2SQL, check it out if you haven’t already.

Enterprise Library

Enterprise Library has been around for a long time and I love it. It is a set of proven industry practices packaged up for you nice and neatly. Don’t reinvent the wheel when you have a Ferrari waiting to pick you up.

In Summary

Tools are awesome, it is one of the greatest advantages we have over other development communities. You should also never get too comfortable with a tool set, because there is always something coming out that could serve you better. Tools are meant to help you do the job, they aren’t the job itself. If a tool doesn’t serve you well, then you should just avoid it and find something that works.

Attack of the Bots! – Stop Them With ReCAPTCHA in ASP.NET MVC

4

As developers sometimes we forget that there are bad people out there. Nefarious people waiting for you to mess up, just so they can exploit your weaknesses. One of the biggest problems with the internet today is the use of bots. If you have ever run a publicly open site like a blog, forum, or contact form then you know what I mean. You get flooded with junk that you didn’t even know existed. This can be a huge problem, because it essentially makes the data coming in hard if not impossible to sort. So how do you stop these advanced monsters from reeking havoc on your public facing site?

We first have to understand how they exploit your site. You probably have some kind of form on your site. It is there for anyone and everyone to use, just like you intended. You spent hours meticulously crafting this form with valid HTML and readable labels. There is your first problem. Bots traverse your page looking for FORM tags. Then they proceed to look for INPUT tags which match their criteria. If you use a popular CMS or Blogging engine then you are already at a disadvantage. These systems are known by bots and there are no surprises on how your system works. Then the bots proceeds to submit the form. All this occurs in a matter of nanoseconds. Remember computers are fast, even when they are evil. Now the bots have a choice, leave your defenseless site in search of another or proceed to submit your form mercilessly until your site collapses and your inbox is filled with worthless junk.

The popular solution to combating bots  has been CAPTCHA systems. CAPTCHA stands for “Completely Automated Public Turing test to tell Computers and Humans Apart.” It usually involves a challenge-response test. The most popular kind is to show scrambled words in an image, which can be seen below. Some CAPTCHA systems can also get very strange. I have seen one that shows you screenshots of cute fuzzy animals and asks you to pick the kitten. This really is a interesting subject and I suggest you read the Wikipedia page on CAPTCHA.

KCAPTCHA_with_crowded_symbols

Let’s get started in developing a solution. You might be thinking to yourself, “I don’t want to write a crazy CAPTCHA system.” Well you are in luck, there are several services on the internet that let you utilize their system. My favorite service is ReCAPTCHA. It offers both image based CAPTCHA tests along with audio tests for better accessibility. Let me show you what the final product will be like. I will be using the ASP.NET MVC sample project and modifying the registration page to add CAPTCHA checking. Dilled Fresno!?!? What the heck is that?

image

Step 1 – Getting Your ReCAPTCHA account.

Go to the ReCAPTCHA site and sign up for your keys. You will get a private key and and a public key. Copy these to notepad, you will need them.

Step 2 – Download the .Net Library for ReCAPTCHA

You will need to download the ReCAPTCHA .NET Library. Technically you don’t need this, you could write your own wrapper, but this makes it much easier. Go ahead and add this to your ASP.NET MVC project as a reference.

Step 3 – Implement the Client-Side

You want the ReCAPTCHA red box to show up on your site. So we are going to have to put some code in your view. ReCAPTCHA has already provided this code for for you. I have placed it below for faster access. Place this code within your Form tag, it is critical that you do so. Ok you are done. I also placed a ValidationMessage underneath the ReCAPTCHA code so that I could see my message.

                <script type="text/javascript"
                   src="http://api.recaptcha.net/challenge?k=<YOUR PUBLIC KEY>">
                </script>

                <noscript>
                   <iframe src="http://api.recaptcha.net/noscript?k=<YOUR PUBLIC KEY>"
                       height="300" width="500" frameborder="0"></iframe><br>
                   <textarea name="recaptcha_challenge_field" rows="3" cols="40">
                   </textarea>
                   <input type="hidden" name="recaptcha_response_field"
                       value="manual_challenge">
                </noscript>
                <%= Html.ValidationMessage("ReCaptcha") %>

Step 4 – Implement the Server-Side

When the form is submitted, there will be two extra inputs submitted to your controller action. The “recaptcha_response_field” value and the “recaptcha_challenge_field” value. We will be using these to verify that the user is really human. So for the code that performs the CAPTCHA.

 private bool PerformRecaptcha()
        {
            var validator = new RecaptchaValidator
                                {
                                    PrivateKey = "<YOUR PRIVATE KEY>",
                                    RemoteIP = Request.UserHostAddress,
                                    Response = Request.Form["recaptcha_response_field"],
                                    Challenge = Request.Form["recaptcha_challenge_field"]
                                };

            try
            {
                var validationResult = validator.Validate();

                if (validationResult.ErrorCode == "incorrect-captcha-sol")
                    ModelState.AddModelError("ReCaptcha", string.Format("Please retry the ReCaptcha portion again."));

                return validationResult.IsValid;
            }
            catch (Exception e)
            {
                ModelState.AddModelError("ReCaptcha", "an error occured with ReCaptcha please consult documentation.");
                return false;
            }
        }

RecaptchaValidator is from the assembly you referenced. Notice that we need to set the private key, and that we are getting the user’s I.P. address. We also set the fields that we got from the form. Now we just need to ask the service if everything is ok. The rest is trivial ASP.NET MVC code.

Conclusion

You can get ReCAPTCHA into your site in about 5 minutes, but it might take some time to perfect how you want it to integrate with you current scheme. For me, I don’t make a call to ReCAPTCHA if my model is not valid (see code below), this saves me an expensive and unnecessary internet call. I am also considering placing similar code in an ActionFilter, in the same fashion as ValidateAntiForgeryTokenAttribute. It should be pretty simple to do that.

 if (ModelState.IsValid && PerformRecaptcha())
   {
    ...
    }

So now you have the power to stop those evil bots and take bake your site. Hope this helps.

No Pain, No Gain? Part 1: Bugs

0

I recently listened to Jeremy Miller in the Alt.Net podcast, and I also watched the latest in the NHibernate series from TekPub. The common thread I see between both these things is the act of achievement in your own development life. Jeremy Miller talked about the state of Alt.Net and how he and others can further the cause of the movement. The main message I got was, get your house in order. Knowing who you are and what you do can go a long way in reducing the pain of development.

The TekPub series talks about NHibernate and integrating it into Rob Conery’s Kona project, but Oren Eine said something very interesting. NHibernate is a tool to keep you from doing the grunt work associated with a database. Which is exactly why I purchased the NHibernate series, I want to reduce the amount of time spent grunt working and optimize the time spent adding value.

This series of posts will be as much introspective as it is informative. I will look at things that cause me pain in my day to day development, and also explore methods to alleviate the pain (short of morphine shots).

Let’s start with the biggest area of pain, Bugs.

Bugs

No software developer likes to release code that has bugs in it, but bugs are an inevitable pain every developer will have to deal with. I personally have had my fair share of bugs, but I have always been able to resolve them quickly and effectively. The pain with dealing with bugs can come from two places: the act of trying to preemptively stop them, or the act of reacting.

Stopping Bugs

If you are anal about the code you write, then you probably employ some kind of testing methodology: Test Driven Development, Behavior Driven Development, Integration Testing. All These methods make sure your code works. The pain with using these methodologies is that they require a substantial amount of effort to implement. They require understanding and a time investment that some developers just don’t want to put in. I can’t say I blame anyone for not adopting a testing methodology, it takes discipline and dedication.

There are several test generating tools out there, but few really make the process any less painless. You usually are trading one set of pros and cons for another. The trick here is to build a system of developing tests regardless of tools you use. A system that is smaller in complexity is ideal. Test Driven Development has Red Green Development; a process where you get tests to fail then pass. A small but effective system of writing tests. A solid system can help bake practices in and make you more disciplined.

After understanding why I should write tests, I found that bugs in my code are melting away. It’s hard to make a test pass when all your assumptions are correct but the code isn’t. So am I saying that everyone should adopt a testing methodology? No I’m not, but I do recommend it to those developers who don’t like dealing with bugs later because it can substantially reduce those incidents.

So you’ve spent the time to write tests, but bugs still creep into your code. Time to panic! Aaaaah!

Fixing Bugs

I’ve seen this one too often. A bug is found and everyone goes into fire-drill mode. Managers hovering, programmers sweating, IT guys pushing continual updates. It is like watching a slow motion crash test. The problem usually get’s fixed, but not the best way. In addition, the fix usually introduces more bugs.

The solution here is to understand what is happening. Far too often, companies feel that panic mode is ok but it psychologically drains everyone involved. This can bring morale down and breed resentment amongst groups. Why didn’t the testers catch that major bug? How could the programmers have been so stupid? Why are the managers making me push a solution every 5 minutes? What happened to the order of things?

So how do you reduce this pain. Well I’ve experimented with a few options and found that sandboxing is the best course of action. A sandbox environment that is exactly like your production environment. This might seem obvious but the number one sin that most people commit is, they don’t respect the concept of those environment. A sandbox should be your first and only place you push code. Once you are happy, copy that exact environment over to production. There should never be any code directly pushed to production. Respect the structure you setup and it will help you, don’t respect it and it will come back to haunt you.

Beta environments are also a good way to reduce the pressure of critical bugs. Many application have employed this method with success. Create a clone of your web application/application that is strictly Beta. There is an implied agreement between you and your users that there are bugs and the experience might not be ideal. That way you won’t be surprised when a critical bug occurs, also your clients will hopefully understand why the application broke.

Conclusion

Bugs are a part of our development life. They are present and they will always be there. The best thing we can do is take an approach that makes it less painful in our development lives. Some developers are more comfortable writing tests to preemptively stomp bugs, while others thrive in the panicked environment of critical bugs. I personally feel that I don’t want to let bugs get out the door, so I test everything with a three pronged approach. Unit Testing, Integration Testing, and Quality Assurance. 

Open Flash Chart in ASP.NET MVC

10

If you’ve ever developed an application of any type, you know that the business function of that application is only half the story. Most business applications also have to take into mind that your business user is going to want reporting. As a developer I find reporting the most boring part of the development process, but it is becoming less and less painful for me as a developer to implement it into my applications. Within the last year Microsoft has released a charting addition to the .Net framework based on the Dundas charts package, but they only output static images. In most cases this is ok, but it doesn’t make for a very compelling experience. Open Flash Chart is one alternative to the .Net charting; it is interactive and dynamic, which can help you build those compelling interfaces that your clients look for. So the point of this walkthrough is to show you how to implement Open Flash Chart into your MVC application.

image

Step 1 – Download the Open Flash Chart package

Obviously you’ll need Open Flash Chart, you can download it from the Official Open Flash Chart. When you download it there is going to be a lot of files, but don’t worry about it I’ll tell you which ones you need.

Step 2 – Import The Files You Need

You are going to need two files at a minimum. There is a .Net library in the package but I’ll show you, you don’t need it. The first file is the open-flash-chart.swf. This file is the major component of the open flash chart package. I transferred this file directly into my content folder in my ASP.NET MVC project.

image

image

The next file you’ll need is the swfobject.js file, this will make placing your charts on the page much cleaner and simpler. Transfer this file into your scripts folder.

image

image

Step 3 – Integrating Open Flash Chart into your View

There are a couple things that I do to get Open Flash Chart into my view. I first modify my master page and add a new ContentPlaceHolder called “Scripts”. This allows me to inject custom scripts per view if necessary. My head tag in the master page looks like the following.

<head runat="server">
    <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
    <link href="/Content/Site.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/swfobject.js" type="text/javascript"></script>
    <asp:ContentPlaceHolder ID="Scripts" runat="server" />
</head>

The next step is to inject the Chart into the page. The following code does that.

<asp:Content ContentPlaceHolderID="Scripts" runat="server">
    <script type="text/javascript">
        swfobject.embedSWF(
              "/Content/open-flash-chart.swf", "my_chart", "550", "200",
              "9.0.0", "expressInstall.swf",
              { "data-file": "Home/GetData" }
              );
    </script>
</asp:Content>
 

Notice what is done here. You first point to the open-flash-chart.swf in your content folder. Next you specify the div you would like to inject the chart into. Thirdly, you specify the size. Right after that is about the flash version and the install if your client is missing flash on their machine. Lastly, the most important thing, the location of your data. Notice that it points to a controller action. I’ll show you how to code that next.

Step 4 – Data, Data, Data

A chart wouldn’t be a chart without data. This is where we will leverage the power of the newest .Net frameworks with anonymous types. Open Flash Chart uses JSON objects to create you chart, but we don’t want to spend hours creating a library or adding references to assemblies we don’t need. So I went ahead and created an action relating to the one seen above. The code looks like this.


        public JsonResult GetData()
        {
            var data = new
            {
                title = new { text = "Many data lines", style = "{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}" },
                y_legend = new { text = "Open Flash Chart", style = "{color: #736AFF; font-size: 12px;}" },
                elements = new object[] {
                        new { type = "bar", alpha = 0.5, colour = "#9933CC", text = "Page views", values = new []   {9,6,7,9,5,7,6,9,7}},
                        new { type = "bar", alpha = 0.5, colour = "#CC9933", text = "Page views 2", values =  new [] {6,7,9,5,7,6,9,7,3}}
                },
                x_axis = new { stroke = 1, tick_height = 10, colour = "#d000d0", grid_colour = "#00ff00",
                    labels = new {
                        labels = new[] { "January", "February", "March", "April", "May", "June", "July", "August", "Spetember" }
                    }
                },
                y_axis = new { stroke = 4, tick_length = 3, colour = "#d000d0",  grid_colour = "#00ff00", offset = 0, max = 20 }
            };

            var result = Json(data);

            // Allow Open Flash Chart to
            // make request for data through GET
            result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;

            return result;
        }

There are two catches here. The first catch is that Open Flash Chart has some properties that have a dash in them, like “font-size”. The other problem is that Open Flash Chart does a GET Request for all data, that is why I have the funky code at the bottom of the action. Don’t forget to look at the Open Flash Chart documentation to get an idea of what you need to get your chart looking like you want it to.

Conclusion

So there you have it. Now you have integrated Open Flash Chart with the addition of two files and a new action. I love how easy it is to use this project in an Asp.net application. Look into the Open Flash Chart package, because I’m sure there are more and better ways to implement this charting package into your applications.

Boogey Down with SQLite – SQLite Administrator

0

I have always been a big fan of in-memory / file system databases. Why you ask? Well it’s because as a developer it offers a low learning curve and it’s easy to integrate into any project. As a person that pays for webhosting, I can save between 10 – 30 dollars a month on database expenses, especially if the database in question is never going to be that large. That is between $120 – $360 a year, that’s no chump change.

SQLite is a software library that implements a self-contained, serverless, zero-configuration,transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain.

SQLite Homepage

SQLite is the champion of small databases. It is used by Adobe, Apple, Bloomberg, Mozilla, and other companies. There is one small drawback (no pun intended). It can be difficult to manage without the right tools. That is where SQLite Administrator comes in. This tool is amazing, and it gives you a similar experience to SQL Server Management Studio. You can manage your database like a pro with all the nice IDE candy. Check out the screenshots below.

So if you are a web developer getting ready to code up your next site, make sure you think about SQLite. It allows you to give your clients a rich data driven experience without the overhead costs of an expensive service based database, and feel comfortable knowing that you can manage that database with SQLite Administrator.

main

errorpos

edit_table

edit_data

Aqua Bird Consulting Site Up!

0

Well I’ve had this done for a while, but here at Aqua Bird Consulting we are going through some procedures that didn’t allow us to publish our site. Today we decided it would be a good time to do so. Go check it out. From a user stand-point, there is a lot of information about what we do here at Aqua Bird Consulting. Through the nerd’s eye view, the web site was built using Asp.Net MVC 1, JQuery and a lot of other cool stuff under the covers. I can say I’m proud of the work done on the site. If you don’t have time to head over right now, just look at some of the screenshots below.

image image

Zeep Mobile – SMS Gateways

0

A good application is ubiquitous, it is everywhere you need it and never in your way. That is probably why applications like Twitter and Facebook have been so successful. So how do you add more of that ubiqutous goodness into your applications? SMS of course! Text messaging is a powerful tool for many people. I text more than I talk, and I think that is becoming the status quo.  That in mind, I have been looking for a good SMS gateway provider so that I can give texting capabilities to my clients. I still haven’t stumbled on the best solution, but there is one worth talking about: Zeep Mobile.

Zeep Mobile is a Free SMS Gateway for use without any limitations, but there is a catch. The catch is with each message you send  your users, a small text based ad will be placed in your at the end of the message. If you don’t want ads, you can pay for an ad free service. So I signed up for the beta and decided to figure out how well it works.

Step 1 – Sign Up For Beta

Go to the Zeep Mobile site and sign up for the Beta, you should get an invitation almost instantly. This is a Beta, so I didn’t expect everything to work or have a super refined service.

Step 2 – Understanding the Flow

You can’t start sending messages to anyone you want. This is a subscription based system. So you have to follow these steps to get started.

  1. Create  an application key within Zeep Mobile
  2. Copy a provided HTML Snippet onto your site
  3. Sign up through the provided widget with a valid number or test number (provided by Zeep Mobile).
  4. Confirm on that number that you want text messages from said application.
  5. The Application is now ready to send that number text messages.

Step 3 – Following Their API

Zeep Mobile is a REST based API, which means all your interactions will be facilitated through the HTTP protocol; mainly posting your data to them. Also, their authorization scheme is based on a secret key and hashing your content along with the current date of the request. See the diagram below.

authentification_step_2

In addition to sending text messages, Zeep Mobile can make calls to an endpoint of yours and pass you data. This is so your application can store and maintain the latest users. I’ll show you how to send text messages to Zeep, but I won’t show the callback because that is trivial to implement once I show you how to call Zeep Mobile.

Creating Your Zeep Authorization Token

Zeep Mobile requires you have your authorization token in the header. It follows the following format.

Zeep [API Key]:[HMAC+SHA1 Encoded Canonical]

Being a nice guy, the following code to do that is directly below. One note, before you pass the message into the method below, make sure to Url Encode the string. This can be done by using the HttpUtility class. I’ve also provided extension methods to do this.

        public string GetZeepAuthorization(string message, DateTime date)
        {
            // product HTTP Date
            var httpDate = date.ToString("r");
            string canonicalString = ApiKey + httpDate + message;

            // Compute the Base64 HMACSHA1 value
            HMACSHA1 hmacsha1 = new HMACSHA1(SecretAccessKey.ToByteArray());

            // Compute the hash of the input file.
            byte[] hashValue = hmacsha1.ComputeHash(canonicalString.ToByteArray());

            string b64Mac = hashValue.ToBase64String();
            return string.Format("Zeep {0}:{1}", ApiKey, b64Mac);
        }
 public static class Extensions
    {
        public static byte[] ToByteArray(this string input)
        {
            UTF8Encoding encoding = new UTF8Encoding();
            return encoding.GetBytes(input);
        }

        public static string ToBase64String(this byte[] input)
        {
            return Convert.ToBase64String(input);
        }

        public static string ToUrlEncoded(this string input)
        {
            return HttpUtility.UrlEncode(input, Encoding.UTF8);
        }
    }

Posting Your Text Message

You have two options here: Send a message to a particular user or send the message to everyone. The code below shows you how to send to everyone, but this code is easily adapted to send to a single user. The quirk below is that you have to set the date on your request or Zeep will complain. Zeep uses the date to calculate the hash on their side, if the date is missing then you can’t get your request through. Read the documentation on Zeep Mobile for more detailed information.

  public string SendZeepMessage(string message, string authorization, DateTime date)
        {
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(BlastMessage);

            request.Date = date;
            request.Method = "POST";
            request.Headers.Add("Authorization", authorization);
            request.ContentType = "application/x-www-form-urlencoded";

            // send the Post
            var messageBytes = message.ToByteArray();
            request.ContentLength = messageBytes.Length;

            using (var os = request.GetRequestStream())
                os.Write(messageBytes, 0, messageBytes.Length);

            try
            { // get the response
                WebResponse webResponse = request.GetResponse();

                using (var stream = new StreamReader(webResponse.GetResponseStream()))
                    return stream.ReadToEnd().Trim();
            }
            catch (WebException wex)
            {
                // This exception will be raised if the server didn't return 200 - OK
                // Try to retrieve more information about the network error
                using (HttpWebResponse errorResponse = (HttpWebResponse)wex.Response)
                {
                    // get descriptive message
                    using (StreamReader sr = new StreamReader(errorResponse.GetResponseStream()))
                        return sr.ReadToEnd().Trim();
                }
            }
        }

That’s all the code you need to start sending text messages to subscribers. Now all you need to do is write a way to handle callbacks, possibly through an HttpHandler, ASP.NET Web Form Page, or ASP.NET MVC.

Get Your Message (err… Sorta)

At the time I wrote this code, everything was working fine on Zeep Mobile but something must have broken on their side. How can I be certain it is on their side and not my code? Well messages are getting through. This means that hash on my messages are being calculated and are successful on Zeep Mobile’s side, but the messages coming through are blank. Hopefully this is just a small hiccup in the Beta. Below you will see the test phone that Zeep Mobile Provides.

image

Step 4 – Thoughts About Zeep Mobile

It is definitely a winning idea, but it is still in beta. As you saw above things are still being worked out with the API and the API lacks a lot of the calls needed to really make it something great. Essentially the API was designed to facilitate text messaging, but has left out  administration features that would allow you to manage your subscribers. The good side to that lack of functionality is that you could code it yourself due to the nature of the callback service Zeep Mobile provides. Essentially, Zeep Mobile is saying that they want to facilitate communication between you and your subscribers, but doing anything more is up to you.

Zeep Mobile is worth checking out and trying, but as of right now I would look for a stronger SMS Gateway Provider for any serious application. The downside to using other SMS Gateway providers is that they are expensive. If anybody knows any good ones please let me know, because I am always interested.

Write Your Own Haikus and Win an Xbox 360 and TV

0

haikuhttps://www.r2haiku.com/

Aqua Bird Consulting also has a artsy side, but we also really want that TV and Xbox 360 Elite. Here are our two Haikus, vote for them and if we win you are welcome to come play with us on our new TV and Xbox. You could also write your own Haikus. A haiku is a poem with 17 syllables and three lines. The first line has 5 syllables, the second 7 syllables, and the third 5 again. It doesn’t have to rhyme.

Haiku # 1

This Server is Zen
Processing In Harmony
Now Relax Forever

Haiku # 2

This is an easy choice
no fuss, no muss, no hassle
Get back to your life

Coding With My Voice

0

I was exploring some screen casting software the other day and I noticed that Windows 7 has speech recognition. It probably was there in Vista, but I never really played around with it. I wondered how easy it would be to program a “hello world” program while keeping mouse and keyboard strokes to a minimum. I started by starting my voice recognition on my instance of Windows 7 machine.

image image

The next step is to announce to my computer to start Microsoft visual studio 2010. That command is “Open Microsoft Visual Studio 2010”

This is where it goes down hill for me. Visual Studio 2010 doesn’t have voice support for actions. I tried to say something like “File > New> New Project” but Voice recognition just ignored me. The second approach was to remember what the shortcut was to start a new project. Since I know it, I said to my computer “Control Shift N.” Soon after, I was presented with the New Project dialog. Another painful experience. I had to tab my way to a new project, and tabbing with your voice is not fun. Below is a play by play of my tabs.

image

Not exactly fun. The next step was to get into the code. I cheated here and had to click into my code. After some painful, painful, painful yelling at my computer I got this code. It took me about 10 minutes of backspacing, and fixing things to get a simple application.

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World");
            Console.Read();
        }
    }

So you might be thinking, why would anybody do this?

Well I started thinking about scenarios where programmers could leverage their voice to program. Before we know where we want to go, we have to know where we are. Obviously we are not very far when it comes to programming with your voice. Below are some things that need to change for developers to start programming with their voices.

Context Switching

Programming languages are created to crudely mimic human language. A phrase could mean two different things to a word processing application and a development environment. Theoretically, when I enter Visual Studio my voice context should be switched to a developer context. This means that voice recognition is listening for different keywords to perform functions. Below are some examples of actions that could be present in a developer context.

  • “Add New Class”
  • “Add New Project”
  • “Lambda x comma s executes s equals x”  (x,s) => s = x
  • “Console Write Line String Hello World End String”
  • “Select Current Method”
  • “Select Class”
  • “Rename Function/Class/variable”
  • “Comment Above Line  ….”

In addition to knowing actions in this context, the voice recognition could know you programming preference and make appropriate decisions for you. This is primarily for casing variables, functions, and classes. When you say “Calculator Service,” The voice recognition should know that you mean CalculatorService.

Programming Language Hooks

The voice recognition software should be able to recognize keywords and namespaces of the programming language you are using. So if you say a class name, the voice recognition software should know if you are creating a new class or talking about an existing class. This approach could be achieved two ways: create an API that the voice recognition can call in an IDE, or create a dictionary that you could place into a location for the voice recognition. Either way, you are building an API to allow developers to extend the voice recognition for their particular programming language.

Fingers-Voice Hybrid

Right now you are able to type while you talk to your computer. I would expect that you could do the same when programming with your voice. Some things just might be faster using your fingers.

Conclusion

These are the first step to voice recognition for developers, they are obviously large steps to take. Clearly the current voice recognition in Windows is made to server the greater population of users, who are interested in word processing, email, and chat applications. It would be great if you could take the voice recognition in Windows and specialize it to be used with Visual Studio and other IDEs to boost the efficiency of developers. Microsoft, I hope you are listening.

Go to Top