Michael Gunner

Michael Gunner

© 2015 Michael Gunner. All rights reserved.

Author Archives: Michael Gunner

  1. Have bold text on hover without affecting fluid widths

    Leave a Comment

    So there you have it, your lovely new navigation bar. The trouble is, you want the text to be bold on hover, but you also need your elements to be fluid with. This creates the problem of the buttons changing width when hovered on, because of the change in font weight.

    The way around this is to simulate our font weight with text shadow instead. Text shadow declarations do not affect the box model, so your elements won’t change in size when hovered on.

    To see an example of this working, click here to see a jsfiddle.

  2. Calculating distances between co-ordinates on Earth

    Leave a Comment

    If you’re working on a project that involves any sort of geolocation, distance plotting or such like – you’ll probably need to do this. But calculating a distance between A and B is not as straight forward as you’d think, primarily because Earth is not flat. Neither is it a perfect globe. Therefore, you need to take this into account when plotting distances between two points on Earth.

    We do this using something called the Haversine formula. This formula allows you to take two co-ordinates on a globe and plot the distance between them.
    a = sin^2(\delta \varphi /2) + cos(\varphi 1).cos(\varphi2).sin^2(\Delta\lambda /2)\\c = 2.atan2(\sqrt{a}, \sqrt{(1-a)})\\d = R.c

    φ is latitude, λ is longitude, R is earth’s radius (mean radius = 6,371km), note that angles need to be in radians to pass to trig functions!

    The main drawback of the Haversine formula is it assumes Earth is perfectly spherical, when really it’s not. In fact, Earth is slightly ellipsoidal, but even taking this into account the error deviation is at most 0.03%, so for most purposes the Haversine is accurate enough. It’s also worth baring in mind Haversine is “as the crow flies” – so it does not take into account hills, mountains, canyons etc that may actually add to the length of the distance.

    So how do we turn this formula into usable code? Using PHP, we take five variables. We need the latitude and longitude of point A and point B as well as Earth’s radius, which is 3959 miles.

    We input them into a function which converts the degree co-ordinates into formula-friendly radians, and then inputs them into the Haversine formula, exactly as you see it above.

    You should be able to drop this function into your project and use it for calculating distances between points on Earth. You can read more about Haversine here: http://www.movable-type.co.uk/scripts/latlong.html

  3. Input date-time on Chrome usability sucks

    1 Comment

    I’ve been waiting so long for date time input type implementation, and Chrome desktop has it. But frankly, the implementation is terrible, from the point of view of usability, as well as being pretty ugly.

    With the date field, you get three controls. Unfortunately, they’re all tiny and quite fiddly, and whilst the button to bring up the date picker is fairly self-explanatory, the up/down controls are a little more ambiguous. The function of the field is also not in line with traditional date pickers, when clicking the field you would expect the picker to appear, but it only appears when you click the drop down. This may mean many users simply never even realise it exists.

    The styling of it all is pretty ugly too, which surprises me. For example whilst the up/down controls have a gloss look consistent with other form controls in Chrome, the drop down button is a flat down arrow with no button styling at all. The date picker is the worst part, it’s far too small and has some strange styling, for example a blue border around each month.

    There’s also a button with a dot, who’s function is not immediately clear. It turns out clicking it puts into the field the current today’s date.

    The time field is also quite difficult to use, for example much like in the date field you have to manually move between each part (hours to minutes) either with your mouse or arrow keys. Granted there’s not really another way to handle this, but I would imagine most people will be switching between mouse and keyboard which makes it feel clunky.

    In my honest opinion, the usability of the date field would be massively improved if the date picker was larger and better styled, and displayed automatically when selecting the field. I also think the time field would work better if it also displayed a picker – perhaps one that works similar to those on mobile devices.


  4. It’s time to say goodbye to Internet Explorer 8.0

    1 Comment

    Your initial reaction to this is possibly a “whoa, you crazy fool!” But in all honesty, I think the time has come to drop support for IE8. By doing so, I’m following in the footsteps of many others, including the agency Zurb.

    But why? Simply because IE8 usage is dropping off very fast, and the trend is a downwards spiral. Last year, I dropped IE7 support when IE7 usage was hovering at about the same point IE8 usage is now. Now, IE7 is pretty much finished.

    A quick look at worldwide browser stats gives compelling evidence, IE8 usage is only three percentage points above IE10, which has doubled in just one month. By that trend, we can expect IE10 to have eclipsed IE8 usage within the next two months.

    Of course, you shouldn’t go purely on global stats, you should also look at the stats specific to your site. But those paint an even more damning picture, out of 1200 visits in the last month to our main website, only a meagre 84 were IE8. In comparison, about 300 visits were from mobile devices, making the case for responsive design more compelling and justified than ever.

    The time has therefore come in my mind to say goodbye to IE8. Hasta la vista, baby.

  5. Get your own Instagram web page

    Leave a Comment

    Purely just for fun, I’ve put up an Instagram app I made.

    This is a fun little page that grabs all your photos and arranges them on a grid. You can then re-arrange the photos by changing the filter you used in Instagram. It’s incredibly light weight – just 117kb.

    If you already have Instagram, setting up takes five minutes. Because this uses the JavaScript API, it is purely static, however please be aware that this means anyone that sees your code can see your access token. You may not want that. If anybody want’s to fork this and convert to PHP, feel free.

    It’s responsive, and on desktops you can enlarge the pictures. It uses Quicksand.js.

    Do what you want with it but if you do use it, show me. If you’re comfortable with the code you can change it, or if you think the code needs to change, change it.

    Fork on Github: https://github.com/bmike2013/minsta

    Working demo: http://michaelgunner.co.uk/laboratory/insta/

  6. Internet Explorer 10 Mobile/jQuery UI Touch Events conflict

    Leave a Comment

    Wondering why your lovely jQuery UI autocomplete isn’t working in IE10 Mobile? In fact, no jQueryUI widgets work properly out of the box with IE10 Mobile, or for that matter IE10 on Windows 8 when used on a touch device.

    The problem is that IE10s touch events conflict with jQuery UIs touch events. Handily, Microsoft have provided a very simple CSS declaration you can use to remove the inbuilt IE10 touch events, and therefore this removes the conflict and your UI widgets should all work.

    Stick the following in your stylesheet and it should fix the problem:

  7. Custom InfoBoxes for Google Maps API v3


    The default Google Maps infoboxes are all well and good – but you can’t style them. The infobox.js plugin however lets you do this. You can get the plugin here: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/examples.html

    So how do you use it? This assumes you’re using more than one marker on your map. If you’re only using a single marker, refer to the link above. The first thing you want to do is stick in the options code for the box.

    “boxText.style.cssText” defines our styling for the box. You could do this in your external CSS file if you prefer. The rest of the options should be fairly self-explanatory. As you’re plotting more than one marker, I’m assuming you’re using a loop. So you need to now incorporate your infobox into the loop.

    After you have defined your marker (e.g. “marker = new google.maps.Marker”) you’ll want to attach an event listener. This simply tells the browser what to do when the user clicks on the marker. So you want your infobox here.

    The “boxText.innerHTML” declaration simply defines what content is displayed inside each box. Because you’re looping through markers, you’ll want the correct content for each marker, not the same. Therefore, you should store your information in an array, in this case the array is called “markerinfo”. The “[i]” then simply increments which part of the array is used as the code loops.

    That should basically be it. Remember, this post is for Maps APIv3 code that involves looping through multiple markers. If you’re only displaying one marker, or you’re not looping, your code may need to be different.

  8. Dealing with my Psoriasis


    I think you can probably tell, this blog post isn’t going to be about websites.

    Three and a bit years ago I had a strep throat infection, which basically feels like a really bad sore throat. Unfortunately as a result of my sore throat, I developed Psoriasis. More specifically, the guttate variety. Guttate Psoriasis is different from the more common plaque psoriasis because instead of big patches of psoriasis, I get small spot-sized patches.

    The spread of psoriasis on my body was quite rapid and unfortunately I was misdiagnosed by two different doctors on two separate occasions which led to a delay in getting the treatment I needed which mean my condition was allowed to worsen much more than it should have. It also meant me spending a lot of money on useless prescriptions. I was also devastated to discover when I got the correct diagnosis that there is no cure for the condition and in all likelihood, I’d probably have it in some form for the rest of my life.

    I did however spend many weeks attending treatment at Brighton General Hospital, which was light therapy. Light therapy involves standing in a sort of tanning-booth for a short period of time twice weekly. Although it’s like a tanning booth the two shouldn’t be confused, tanning booths do not filter the UV rays they emit so are not effective and are also significantly more dangerous. However any exposure to UV radiation does carry risks. The great thing however was the therapy for me worked, and save for a couple of tiny bits I was cleared of my psoriasis. I then got on with my life.

    About 4 months ago however a minor relapse started coming on. I’m still dealing with this relapse which has affected the skin on my face, arms, and trunk area of my body. My current relapse is nowhere near as bad as my initial outbreak, so I’m feeling positive about getting rid of it. I have a second doctors appointment booked and I believe I’ll probably get another referral to see a specialist and that will possibly result in more light therapy.

    So how does psoriasis affect me?

    • Social life. If I’m having a bad day or having a flare up on my face, I become a recluse. I go to work but that will be it, at best I’ll go to a friends house and watch a movie. Psoriasis makes conducting a healthy and engaging social life incredibly difficult, frustrating and demeaning. Even if you do pluck up the courage to go out, often people will look at you and point out your skin. Even when it’s done with the kindest and best intentions, when I do manage to go out the house, I’m doing it to get away from my skin, not be reminded of it.
    • Comfort. When I have an outbreak, it makes me feel very uncomfortable. Basic tasks can become difficult, such as sleeping or having a shower – or even just walking.
    • Humiliation and complete loss of self-confidence. I spent a lot of my childhood feeling extremely crap about how I looked. I felt very ugly. Things improved for me when I hit my late teens and I started to feel really good about my looks. I had spent my whole life trying to be happy with my appearance, when psoriasis came along and completely destroyed any hope I had of achieving that. I don’t think I’m ugly anymore, but it’s very difficult to see yourself as attractive when you have the condition.
    • Relationships. Difficult enough for anyone, now imagine you have psoriasis and you can maybe get a feel for how difficult it is for me. I had a relationship last year with someone that didn’t care about my psoriasis which was great, but unfortunately it didn’t work out. Dating is really difficult because even if I manage to go on a date with someone, I have to confront that awkward moment when they turn up and they can see my condition. Many girls are not comfortable with the idea of dating a guy with psoriasis.
    • My personality. Psoriasis has made me an angry person. Most of the time, I channel my anger into positivity, by working hard and trying to do good things. Sometimes though, it makes me a complete tosser. There’s really no other way to put it. It can make me a very horrible and difficult person to talk to and live with. I can’t help this though and try to deal with my emotions as best I can.


    The important thing I have learned from having psoriasis is that it does not need to control your life and there are treatments out there that can and will work. If a treatment doesn’t work or loses effectiveness, just ask to try another. The good thing is every year many new treatments are being developed and gaining approval, so as time goes on there are going to be more and more options available to treat it which should hopefully mean the outlook is positive.

    I’m confident that seeing my doctor next week I’ll be able to get this current outbreak under control and hopefully get rid of it altogether, and then I can get on with my life. I’m also confident that any future outbreaks I have, I’ll be able to deal with them too. I have to accept that I will probably have psoriasis for the rest of my life, but I’ve also come to accept I can still lead a positive and happy life.

    I hope if you are reading this, you have learned a bit about psoriasis and it’s true effects and how horrible it can be to live with. So if you know anybody that suffers from it, keep it in mind and if they’re stressed or short tempered, give them a break, it is probably because of their skin. Don’t stare or ask stupid questions or treat them differently, be kind and understanding to their condition and be there for them as support and care.