Thought for the Dazed

I've had to give up that Distance Learning course as I was having trouble seeing the teacher.

Flickr
www.flickr.com
RobMiles' items Go to RobMiles' photostream
Twitter
C# Yellow Book

Search entire site

Entries by Rob (3094)

Wednesday
Jun182008

Indiana Jones and the Kingdom of the Crystal Skull

2592031503

Tonight we went to see the latest (and probably last) Indiana Jones movie. It felt like this is one of those films that you are obliged to go and see and so we went and did our duty. At the end of the day I reckoned that it was a proper Indiana Jones movie (but then again I watched some of the originals recently and formed the same opinion about them).

Much has been made made about the directors' determination to use "real" special effects rather than the inferior computer generated ones. This approach seems to have extended into making the CGI effects that they did use look rubbish, one or two sequences would have looked bad in a computer game. And some of the model work was so obviously a model that they didn't need to add a trademark camera wobble to give the game away as they panned over it. But they did.

And for a movie produced by seasoned professionals the continuity was very bad. I'm not very good at noticing things. Just ask number one wife after she has had her hair done. But even I spotted the way that the sauce bottles mysteriously stood themselves back up again in the diner scene.  All this served to detract a bit from the lush locations and expansive musical score.

At the end of the day, as I always say, "If you don't like what it says on the tin, don't open the tin". This was always going to be a big, dumb, action movie with one or two good set pieces. I don't think anyone has a right to ask for anything else. If that is what you want, you'll love it. Like I did.

Tuesday
Jun172008

Discussion of Video Gaming

If you want a detailed, and really good, discussion of Video Games, what they are and where they are going, you should take a look here.

Monday
Jun162008

Loading Web Pages

I don't usually put up techie pages with code in them, but today I present something that I think might be useful and I've not found anywhere else. It is part of my RSS reader for the XNA display program, and it solves a couple of problems that you might hit. My feed reader needs to read feeds that are on a password protected site, and it also needs to read feeds that are compressed. This method does both:

private StringBuilder readWebPage(
    string url,
    string username,
    string password,
    string domain)
{
    // used to build entire input
    StringBuilder sb = new StringBuilder();

    // used on each read operation
    byte[] buf = new byte[8192];

    try
    {
        // prepare the web page we will be asking for
        HttpWebRequest request = 
            (HttpWebRequest)WebRequest.Create(url);

        if (username.Length > 0)
        {
            request.Proxy = null;
            NetworkCredential credential = 
               new NetworkCredential(username,
                                     password,
                                     domain);
            request.Credentials = credential;
        }

        // execute the request
        HttpWebResponse response =
            (HttpWebResponse)request.GetResponse();

        // we will read data via the response stream
        Stream resStream;
        Stream inputStream =
            response.GetResponseStream();

        // Might have a compressed stream coming back

        switch (response.ContentEncoding)
        {
            case "gzip":
                resStream =
                   new GZipStream(inputStream, 
                          CompressionMode.Decompress);
                break;
            case "":
                resStream = inputStream;
                break;
            default :
                debugOutput.PutMessageLine(
                    "Invalid content encoding: " +
                    response.ContentEncoding + " in: "
                    + url);
                return null;
        }

        string tempString = null;
        int count = 0;

        do
        {
            // fill the buffer with data
            count = resStream.Read(buf, 0, buf.Length);

            // make sure we read some data
            if (count != 0)
            {
              // translate from bytes to ASCII text
              tempString = 
                Encoding.ASCII.GetString(buf,0,count);

              // continue building the string
              sb.Append(tempString);
            }
        }
        while (count > 0); // any more data to read?

        return sb;
    }
    catch (System.Net.WebException w)
    {
        debugOutput.PutMessageLine(w.Message);
        return null;
    }
    catch (System.Net.ProtocolViolationException p)
    {
        debugOutput.PutMessageLine(p.Message);
        return null;
    }
    catch (Exception e)
    {
        debugOutput.PutMessageLine(e.Message);
        return null;
    }
}

This is not very elegant code, but it does work. I've pulled it straight out of the program and so there are a few things you need to know. I have a class called debugOutput which I use to send messages to the user. You either need to create one of your own, or remove those lines. If you need to use a username and password you need to add those to the call, otherwise you can leave those fields as empty strings.

Sunday
Jun152008

Question of Communication

Do fed-up radio operators talk with each other using Morose Code?

Saturday
Jun142008

Mending Headphones with McDonald's Straws

I got some Ultimate Ears headphones a while back. They sound wonderful. However, they have a little problem which has been causing me grief recently. They use an "in ear" design, with a tight fitting plug which goes inside your ear so that all the sound comes your way. Nothing wrong with that, until the plug bit starts to come off and stay in your ear when you try to remove the phones. I think this is caused by the rubber stretching slightly and becoming slack on the fitting. Whatever causes it, I don't like it as it then leaves me picking bits out of my ear canal, which doesn't look very cool.

Anyhoo, I've fixed the problem by the use of some drinking straws from McDonalds. I've put them around the outside of the rubber sleeve that goes over the headphone bit. This stops the sleeve from stretching quite so far, and makes it fit really tightly. I don't think it is the kind of thing you can get the Nobel prize for, but it works for me.

2577991277

Earpiece with straw power

Oh, and while we are in a McDonalds mood, don't the drink lids look a lot like faces?

2578823268

Scary face or coffee cup cover? You decide.