Sign-up for my latest app's private beta at consolewriteline.com!

I'm thrilled to announce our latest venture, Doctype!

Doctype thumbnail

Doctype is a free question and answer site for web designers. You can get fast solutions to your CSS, HTML, web design and email design problems.

For each question, Doctype can generate screenshots of your design on any browser or email client. This makes it much easier for other people to see the problem and help you fix it.

Everything is editable, just like a wiki. This means answers are accurate, neat and up-to-date.

Check it out and email us with any feedback at hello@doctype.com.

.NET 3.5, C#

I recently had a need to find an available port for selenium, starting at the default of 4444. The code below checks to see if the port you're about to use is available, incrementing your port number to find the next free port if your first choice is in use.

This very simple method uses a global mutex to avoid a race condition when releasing a port.

Adapting it to use UDP is beyond what I need, but it'll be very easy to do - just replace ipGlobalProperties.GetActiveTcpListeners() with ipGlobalProperties.GetActiveUdpListeners();

/// <summary>
/// Provides static methods for operations 
/// commonly required when working with TCP ports
/// </summary>
public static class TcpPort
{
    private const string PortReleaseGuid = 
        "8875BD8E-4D5B-11DE-B2F4-691756D89593";

    /// <summary>
    /// Check if startPort is available, incrementing and
    /// checking again if it's in use until a free port is found
    /// </summary>
    /// <param name="startPort">The first port to check</param>
    /// <returns>The first available port</returns>
    public static int FindNextAvailablePort(int startPort)
    {
        int port = startPort;
        bool isAvailable = true;

        var mutex = new Mutex(false, 
            string.Concat("Global/", PortReleaseGuid));
        mutex.WaitOne();
        try
        {
            IPGlobalProperties ipGlobalProperties = 
                IPGlobalProperties.GetIPGlobalProperties();
            IPEndPoint[] endPoints = 
                ipGlobalProperties.GetActiveTcpListeners();

            do
            {
                if (!isAvailable)
                {
                    port++;
                    isAvailable = true;
                }

                foreach (IPEndPoint endPoint in endPoints)
                {
                    if (endPoint.Port != port) continue;
                    isAvailable = false;
                    break;
                }

            } while (!isAvailable && port < IPEndPoint.MaxPort);

            if (!isAvailable)
                throw new NoAvailablePortsInRangeException();

            return port;
        }
        finally
        {
            mutex.ReleaseMutex();
        }
    }
}

For usage examples, please see my integration tests:

[TestFixture]
public class TcpPortFixture
{
    [Test]
    public void FindNextAvailablePort()
    {
        Assert.That(TcpPort.FindNextAvailablePort(4444), 
            Is.EqualTo(4444));
    }

    [Test]
    public void FindNextAvailablePortInUse()
    {
        var tcpListener = 
            new TcpListener(IPAddress.Parse("127.0.0.1"), 4444);
        try
        {
            tcpListener.Start();
            Assert.That(TcpPort.FindNextAvailablePort(4444), 
                Is.EqualTo(4445));
        }
        finally
        {
            tcpListener.Stop();
        }
    }
}

Download: http://flare-browser.googlecode.com/files/Setup.msi (.msi, 2MB)

Forum Support: http://code.google.com/p/flare-browser/issues/list

Chat Support: Matt Brindley | Public Room

You can now download Flare 1.0 - the site-specific browser for 37signals' Campfire web app.

Flare lets you stay logged into a room in your Campfire account and notifies you of any new messages.

Features
  • Stay logged into your favourite Campfire room in the background - even between reboots.
  • Quickly switch between open rooms using Ctrl + the room number
  • Be notified of new messages with a preview.
  • Tray icon changes colour to show new messages have arrived (in case you miss the preview)
  • Request your password through the app if you've lost it.
  • Run multiple copies of Flare keeping you logged into many different rooms at once.

Instructions
  1. Make sure you've got .Net 2 installed, if not, get it here
  2. Click here to download and install Flare (.msi, 2MB)

Flare has been tested on Windows XP, Server 2003, Vista, Server 2008 and Windows 7.

How to use Flare
  1. After installation completes visit Start > All Programs > Flare
  2. If you've not used Flare before it will ask you for your account name, username and password.

    Flare settings


  3. Once Flare has logged into your account you'll see your campfire lobby, enter the room you want to and minimise the window. Flare will keep you logged into this room until you leave it.
    Flare Screenshot

  4. When new messages, pastes, files or users arrive you'll be notified with a semi-transparent message preview.
    Flare screenshot

  5. If you miss the preview, don't worry - Flare's icon will glow orange until you next view the window.
    Flare screenshot

Update: SSL support has now been added. If your account uses SSL, make sure you check the "Use SSL" checkbox when entering your account name, username and password.

Update: I've released Flare under the GNU GPL. More details at: http://code.google.com/p/flare-browser/

I've put together a "coming soon" page for http://consolewriteline.com/ that includes a form to sign up for beta notifications.

If you'd like to get involved and try consolewriteline out first, enter your email address in the signup form or email me at matt@mattbrindley.com.

Thanks!

This is part 3 of Building a web app. You can find part 1 here.

I want to pitch the idea to a few, carefully selected developers to get their feedback. I thought a mock-up could help to explain the idea, and add a little weight to the proposal.

Design is not my forte, but I also appreciate how important good UI design is. Rather than spending a disproportionate amount of time on the design, I've decided to approach the design of my app in two stages:

  1. Purchase a clean, simple and easy to amend template that I can bend to fit my app.
  2. If the idea is well received, I can hire a designer to pay some further attention to the UI.

I have no doubts that an excellent UI designer will make a big difference to the product's success, but I just need a mock and something to use during testing right now.

Turns out there's a lot of ugly templates out there! Luckily I've found something clean for $59 that I think I can change to suit.

View image

After some tweaking, I have my first mock, ready to begin pitching the idea:

View image

I'm a little nervous now. I've only invested 2 evenings and $147 so far, but I'm growing increasingly attached to ConsoleWriteLine and tomorrow's job is to pitch the idea to a few developers to get their take on it.

I hope they like it, but if they don't, I'm prepared to write the idea off.

There'll be a small wait before the next post while I wait for replies.

This is part 2 of Building a web app. You can find part 1 here.

First I went hunting for a name. I wanted something techy and specific to my audience (.net developers). One idea was something you use in temporary apps while experimenting with a part of the framework you're not familiar with:

Console.WriteLine("Result: {0}", result);

Some developers use Debug.WriteLine, Trace.WriteLine or custom logging implementations, but after a cursory glance over StackOverflow and Bytes, most examples seem to use Console.WriteLine.

I've decided to start with Console.WriteLine and the domain name consolewriteline.com, I can always change it later.

With idea, product and domain name under my belt, and with motivation at an all time high, I'm all set for tomorrow evening's task: design a mock up.

Read Building a web app - Part 3: Designing a mock up.

I've been sitting on an idea for months and I'm still excited about it.

I think there's potential in an online version of the MSDN library docs that allows you to edit, build and run example code in your browser. A kind of prepared scratch-pad. This solves a problem that I've been referring to as ConsoleApplication99 syndrome.

I'm going to document building the service in a series of articles, I'm doing this because:

  1. As I'll be working on this alongside my main job, sharing progress with you should help keep me motivated and focused. I'm not going to out-right promise stuff, but I know I'll feel more obligated.
  2. Silly decisions will stand out. If I have to justify my decisions with you, I'm far less likely to spend hours on things that don't matter to *you* - the reader and potential user.
  3. Money. I'll be spending some in place of spending extra time. Justifying expenses openly will be an interesting (and useful) exercise.
  4. Your feedback will help shape the project.

I've started investigating the feasibility of the project and have made some conclusions:

  • The service will use an API called MTPS to fetch MSDN Library content.
  • Republishing this content is within Microsoft's terms of use.
  • Security issues will be addressed with cloud computing (Litmus has 400 instances with Amazon EC2, so I'm familiar with it).

When I have specifics, I'll share them properly. Right now I'm just keeping an eye out for show-stoppers.

Read Building a web app - Part 2: Naming it.

Contact Me

If you'd like to get in touch, contact me on +447944 353544 or matt@mattbrindley.com

products

Litmus

Litmus makes compatibility testing easier for web pages and email newsletters.

ThinkFold

Online outlining, for groups. Collaborate in realtime with colleagues!

Delicious Presentation Creator

20 slides from your Delicious feed, 20 seconds each.

Flare

A site-specific browser for 37Signals' Campfire chat app, bring Campfire to your desktop.

CSSVista

Edit your CSS code live in both Internet Explorer and Firefox simultaneously.