Phil Leggetter logo

Phil Leggetter

Head of Developer Experience & Relations at Hookdeck

  • Home
  • Blog
  • AAARRRP
  • Realtime Web Guide
    • Realtime Web Technology Guide
    • History, Background, Benefits & Use Cases of Realtime
    • Fundamentals of the Realtime Web & Realtime Web Functionality
    • Choosing your Realtime Web App Tech Stack
    • Developer Tools
    • Realtime Hosted Service Latency Stats
    • Realtime Data Sources
    • Transport Mechanisms
  • About
    • Leggetter Family Tree
  • How I approach problem solving in code?

    23 Oct 2009

    Recently I was posed the following question: Write a piece of code that prints all odd integer numbers between 1 and 99 This really isn't a difficult question but it still requires some thought. When I'm posed with any question I like to break things down into their constituent parts. Here's the process I went through: Okay, so I'll define two variables for a start and end value and there's going to have to be a loop. [csharp]int startValue = 1; int endValue = 99; for(int i = startValue; i lt;= endValue; i++) { // work out if i is an odd number }[/csharp] Now, for the odd number detection. And... after a few umms and errrs ... I'm going to have to mod 2 ( %2 ) the current value of i to work out if the value is odd. More ... umms and errs. Okay, I've finally worked out that if something mod 2 is not equal to 0 it's clearly an odd number. This took me longer than it should have but never mind. Once I've detected if i is an odd number I'll then put the odd number into a list for use later. [csharp] int startValue = 1; int endValue = 99; IList int oddValues = new List lt;int gt;(); for(int i = startValue; i lt;= endValue; i++) { if(i%2 != 0) { oddValues.Add(i); } } [/csharp] Those of you that are good at these little puzzles, or just think this is way too easy, might already be screaming at me about one of the following: Why are you using a IList , why don't you just print the value? Odd numbers are always 2 apart so why aren't you just increment i by 2 using i+=2 ?

    Read more…

  • Response.Redirect in Windows Azure

    6 Oct 2009

    I've recently created an application called GetGravatar that allows you to update your Twitter profile picture with your Gravatar. Once I'd set up my Windows Azure custom domain name I decided I wanted the web address for this new service site to be without "www" as seems to be all the rage (to keep the web address short). So, I looked at doing a Response.Redirect to catch any attempts to access my domain with "www" in it. I'm very sure that there are better ways of doing this but I added the following to my Site.master file: if (Request.Url.ToString().StartsWith("http://www.")) { Response.StatusCode = (int)System.Net.HttpStatusCode.MovedPermanently; string responseUrl = Request.Url.ToString().Replace("http://www.", "http://"); Response.Redirect(responseUrl, true); } So, if somebody types in http://www.getgravatar.com (see it works) or anything with a "www." in the URL they will be redirected to a non-www page. However, the redirect seemed to go to the correct URL but with port 20000. I've no idea why this is so I had to add a special case in to remove the port. if (Request.Url.ToString().StartsWith("http://www.")) { Response.StatusCode = (int)System.Net.HttpStatusCode.MovedPermanently; string responseUrl = Request.Url.ToString().Replace("http://www.", "http://"); responseUrl = responseUrl.Replace(":20000", ""); Response.Redirect(responseUrl, true); } I've not read up to see if this is expected but I thought it was quite unexpected and may be of use to somebody else in the future.

    Read more…

  • Windows Azure - 503 Service Unavailable

    27 Aug 2009

    I finally got around to trying out ASP.NET MVC and while I was at it I thought I'd also give Windows Azure a whirl. Windows Azure doesn't support ASP.NET MVC out of the box but Jim over on MSDN Blogs has written up the details of how to get ASP.Net MVC Projects running on Windows Azure . Problem So, I followed the instruction from the blog and uploaded the package and configuration file, waited for the staging application to get into a runnable state, and clicked on the staging link... Windows Azure - 503 Service Unavailable Clearly not a good thing! In addition to this error I occasionally got a random network error or a full-on connection error reported by the browser. I tried googling for this error but there was nothing about this problem after deploying to the real Windows Azure hosting (the cloud). As far as I can tell there's no way of getting any debug information or logs to work out what's going wrong. Maybe this is something that Microsoft will add later on? Solution Then it struck me that I hadn't actually set up any kind of TableStorage on my Windows Azure hosting so I removed all mentions of storage and database connections from the MVC application. This included editing Web.config and removing the following. The section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" / section element. The connectionStrings element The membership element The authentication mode="Forms" element The profile element The roleManager element Update: I've found that without the authentication element I started getting the error below so you may want to instead replace it with : CCT: Role instances did not start within the time allowed. Please try again. If you continue to encounter this behavior please try shutting down the Development Fabric. I'm guessing that not all of these elements actually need to be removed but doing so resulted in the MVC ASP.NET application working in Windows Azure. Update 2: ServiceDefinition.csdef If you happen to get network timeouts or 404 network connection issues it's worth checking your ServiceDefinition.csdef to make sure that you've got port 80 configured. I noticed that mine had updated to port 8080 so obviously I couldn't access the staging site on port 80 like I was trying. If you do have the port set to something else other than port 80 you can use that port to access your application but the ServiceDefinition.csdef does have a comment in there telling you your application should be on port 80 so you are probably best to stick with that. !-- Must use port 80 for http and port 443 for https when running in the cloud -- InputEndpoint name="HttpIn" protocol="http" port="80" /

    Read more…

  • System.Security.SecurityException: That assembly does not allow partially trusted callers

    25 Aug 2009

    I was writing a Windows Azure ASP.NET MVC application and when making a call to a page I received the following exception: System.Security.SecurityException: That assembly does not allow partially trusted callers In my application I'm using Castle Windsor for dependency injection and when trying to resolve a service using: } IGravatar gravatar = MvcApplication.Container.Resolve IGravatar (); I received this message. To solve things I needed to update the WebRole element in the ServiceDefinitions.csdef file so that enableNativeCodeExecution is enabled. WebRole name="TwitterGravatarMVC" enableNativeCodeExecution="true" I found the solution , detailed above, on the Azure Services Platform Developer Centre forum .

    Read more…

  • Book review: Juggle! Rethink work, reclaim your life

    5 Aug 2009

    Many times in the past I've said or heard the term "work life balance". In job interviews, in chats with my line managers and work colleagues, or in conversation with friends and family. It tends to be used when anybody is talking about finding time for family, friends, entertainment and enjoyment outside of work. It also suggests that there is a dividing line between work and life that can be easily drawn and stepped over. Finally it suggests that we want that separation between work and life and that work doesn't fit into life; that it can't, and potentially shouldn't, be integrated. For some people this statement holds true. They don't want to do or think about work outside of their 9:00 to 5:30 job. There is a definite line to be drawn. For other people, such as Ian Sanders , work is enjoyable because he's working on things he's passionate about. Ian integrates work and life because he enjoys what he does and understands the benefits it provides. Many other people feel the same way and Ian interviews a select few in his book. In " Juggle! Rethink work, reclaim your life " Ian discusses the motivations behind his choice to live in the "scrambled up world of work" where he integrates work and life. He provides hints and tips on how he, and others including Gary Vaynerchuk (a personal favourite of mine), manage to "live the juggle life" and the benefits that this provides. Being a juggler certainly isn't all plain sailing and the book also covers valuable information on the challanges and extra responsibilities that you may face if you make take the plunge. Ian's first book, " LEAP!: Ditch Your Job, Start Your Own Business Set Yourself Free ", introduced some similar concepts to those covered in Juggle!. I actually read Juggle! before I read LEAP! and there is some crossover, but not enough to take anything away from either book. Juggle!, in contrast to the title of Ian's first book, even suggests you should consider staying with your current employer and suggests way of negotiating or fashioning a role and a lifestyle that suits you. Juggle! Rethink work, reclaim your life contains 198 pages packed with thought provoking content and discussion. The book is very accessible and contains short, informative and well structured sections and chapters. So much so I would almost class the book as a reference and I'll certainly be going back again to read through the a number of chapters or work my way though some of the great lists that Ian has compiled in the near future. Relevant links: Ian Sanders website Ian Sanders Blog Juggle! Rethink work, reclaim your life on Amazon.co.uk Ian's first book LEAP!: Ditch Your Job, Start Your Own Business Set Yourself Free on Amazon.co.uk

    Read more…

  • Wikipedia now has a definition for Real-Time Web

    9 Jul 2009

    A while ago a wrote a blog article called What is the real-time Web? . At this time (19/04/2009) even Wikipedia did not have a definition for what "real-time web" was. It does now . The definition is short and sweet: Real-time web is the concept of searching for and finding information online as it is produced. Advancements in web search technology coupled with growing use of social media enable online activities to be queried as they occur. A traditional web search crawls and indexes web pages periodically, returning results based on relevance to the search query. The real time web delivers the most popular topics recently discussed or posted by users. The content is often "soft" in that it is based on the social web - people's opinions, attitudes, thoughts and interests - as opposed to hard news or facts. At present there is no mention of the technology behind the real-time web. Nothing about Twitter and FriendFeed helping to form the definition. Do you agree with this definition? What web 2.0 platforms do you think have helped define what "real-time web" is? What technologies do you believe have pushed the "real-time web" into such prominence?

    Read more…

  • Running in Hertford

    4 Jul 2009

    My girlfriend was out at the Take That concert at Wembley so I was left on my own this Saturday afternoon. Not knowing what to do with myself as the evening approached I decided to go for a run. Normally I find running quite difficult. As I run my mind tends to concentrate on my breathing which puts me off the run. The difference today was that I went exploring.

    Read more…

  • Microsoft Bing.com round table thoughts

    1 Jul 2009

    A couple of days ago I blogged that I was going to attend a Microsoft bing round table . I've now attended and here are the key points and interesting facts that I took from the event. You can also search for meetbing on twitter for relevant tweets.

    Read more…

  • Bing.com round table

    27 Jun 2009

    On Monday between 19:00 and 21:00 I'm going to a Bing roundtable (round table) in London. The event is being organise by Colin Mercer and is described as: a small round-table event to discuss Bing and since we saw your recent tweet regarding comparative search results between Bing and Google, we thought that you might be interested in coming along. The idea would be to get your initial thoughts and you'll get an update on the future steps for Bing which are being developed specifically for the UK. During the session you’ll have the chance to talk with Microsoft representatives and other people from social media like yourself, who have expressed some early opinion.

    Read more…

  • The O2 Mobile Phone Upgrade saga concludes

    1 Jun 2009

    Conclusion I finally managed to get the O2 XDA Serra (HTC Touch Pro) but boy was it a hassle! (See Trying to upgrade my O2 mobile phone ) I had to start a new contract with O2 and lose my old one that I'd had since 2004. I now know that this means I've lost 5 years of loyalty bonus points (or similar). I only found this out when I tried to get my PAC for my old O2 contract and the "retention team" offered me 18 months free with 250 text messages and 75 minutes. Yes, FREE. Other problems along the way were: "You can't take an existing simplicity tariff number onto a new O2 online tariff" Paying for two contracts for a number of days whilst O2 muddle along O2 actually trying to get me to keep two mobile contracts. Why would I want two mobile phone contracts? I can only use one phone at a time! Plenty of mis-communication Numerous calls to and from O2 Customer Services No offer of a "sweetener" to say sorry although they did end up manually transferring my phone number after I threatened to cancel both contracts. When my 24 month contract is up I will do everything in my power to use an alternative mobile phone network. I now have my O2 XDA Serra (HTC Touch Pro) and I'm very happy with it. What I should have done I should have phoned up and tried to cancel my contract as soon as I was displeased with the service. I then would have been put straight through to the "retention team" at O2 who would have done everything within their power to keep me. This most probably would have included getting the XDA Serra (HTC Touch Pro) for a discounted price and getting a better general tarriff. You live and learn.

    Read more…

← Newer postsPage 15 of 19Older posts →

Get posts via email

Phil Leggetter

My name is Phil Leggetter. I'm Head of Developer Experience & Relations at Hookdeck, an Event Gateway for event-driven applications.

I'm a hands-on Developer Experience, Developer Relations, Developer Marketing, and PLG (Product-Led Growth) Leader and Advisor.

phil@leggetter.co.uk

© Phil Leggetter