About David Eedle

Geek, tech, programmer, business owner. Serial starter of things. Oh, and please don't call me Dave.

Now Internet Explorer won’t even confess to being Internet Explorer

liar

The bizarre world of Internet Explorer never ceases to amaze me. Today’s revelation – Internet Explorer 11 doesn’t even like to admit that it’s Internet Explorer.

When a web browser visits a web site, it identifies itself to the web site with a string of information that contains various elements that say to the web site “hey, I’m here, this is the type of web browser I am, my version, operating system”. It’s known as the user-agent string.

In the past the user-agent string for Internet Explorer would look something like this:

Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)

The ‘MSIE’ stands for Microsoft Internet Explorer, so pretty easy to work out which browser is visiting your web site.

Today I was wondering why I could not teach some web site code to recognise it was being visited by IE, did a little research and came up with this page of explanation from Microsoft.

Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko

What’s missing? The ‘MSIE’ of course!

If I was using Firefox, the string would say FIREFOX, like this:

MOZILLA/5.0 (MACINTOSH; INTEL MAC OS X 10.8; RV:26.0) GECKO/20100101 FIREFOX/26.0

Safari would say ‘SAFARI’, and Chrome would, well now there’s the rub, because Chrome can say CHROME as well as SAFARI:

MOZILLA/5.0 (MACINTOSH; INTEL MAC OS X 10_8_5) APPLEWEBKIT/537.36 (KHTML, LIKE GECKO) CHROME/32.0.1700.77 SAFARI/537.36

Remind me again why I got into this web development malarky?

Rare bouquet for Telstra, selling unlocked iPhone 5

iphone5

It’s rare I pay a compliment to Telstra, they’ve been the source of so much pain over the years, and their domination of the telecommunications market in Australia is akin to Godzilla in a childcare centre, but for once I must give them kudos.

I upgraded my trusty iPhone4 to the new (and very very good) iPhone5s the other day. A key issue for me was unlocking the phone – removing the lock that carriers put on handsets to make sure you can only use the phone on their network. I need my phone to be unlocked so I can swap to my USA SIM card when I’m in America.

In the past unlocking a phone has even incurred a charge – from memory a jaw-aching $100 or $150. But nowadays it’s free – just go to the Unlock page on the Telstra web site. And here’s the massively good and useful news “All iPhone 5 models are already unlocked. “. Nothing for me to do!

It’s one in the eye for telcos in the USA, where they persist selling phones locked to the carrier, with complicated rules about when you can unlock – for example, usually you need to own the handset outright – eg not be paying it off as part of a phone plan contract.

Hackers with a sense of humour, or at least a love of Chinese food

Screen Shot 2014-01-16 at 3.51.46 PM

A client asked me to check into a page on their web site that captures name and address registrations from users. The page is available to the public, and does not included a CAPTCHA. The form entries are saved into a database table, there were many entries clearly submitted by a bot over a period of time. Many of them had the address “3137 Laguna Street, San Francisco”, which presumably was just a piece of junk, the main prize was them adding a bunch of links off to dodgy web sites in a description field.

Out of idle curiosity I Googled the address. It’s a Chinese restaurant!

I bet the Syrian Electronic Army never leaves restaurant recommendations on the sites they attack 🙂

Smothered in the comforting embrace of our home wifi network

wifi_pyramid

The screams from the furthest reaches of the house are muted at first, then build to a crescendo, and finally various household members’ heads pop around my study door – “Daaaaadd, the internet’s not working!”. Yup, you can tell the wifi is down in our house. Without wanting to create a shopping list for our neighbourhood burglars, at any given time there are upwards of twenty or more devices connected to our wifi networking including computers, phones, iPads, Apple TVs and televisions. There isn’t a single thing connected via ethernet wires anymore, just lots of gadgets floating on the Boyd-Eedle internet cloud. And boy does the world come to an end when that cloud evaporates in a puff of vapour.

Let’s take a quick inventory: me glued to my machine working; my loving partner plugging away on her book; our eldest simultaneously communing with her six best friends on social media whilst researching a homework task; our middle child wreaking havoc with his closest mate on Grand Theft Auto, every move planned while chatting over Facetime on his iPad; and finally the youngest trawling through an apparently endless chain of Hi-5 videos on YouTube – she’s a big fan of the Spanish-dubbed ones. Personally I find it hilarious watching Charlie and Nathan mouth ‘Hello’ on screen but say ‘Hola’.

Earlier this month we took to the road and stayed a week and a half in a holiday rental up in the high country, near one of the ski resorts. There was a complete absence of mobile phone reception inside the house, although if you wandered up the back garden, stood on one foot, and held your phone at a 22.45 degree angle to the event horizon one bar of coverage was possible, just enough to send a text, barely enough to pull down email headers, and definitely nowhere near sufficient to enable a wifi hotspot.

When we first arrived the kids gave me the impression we had just detoured into the depths of Mount Doom. I took pleasure from previous visitors’ entries in the guest book bemoaning the absence of internet access, my favourite was annotated with the scrawled riposte from the house’s owner “get over it”. My sentiments exactly, although my inability to read and deal with email led to reserving a day on our return to connected civilisation to chew through and handle the 150 emails that had accumulated in my inbox.

On the bright side, I read six books in ten days; played board games with my children; sat down to a home cooked meal every night with more people than just myself for company at the dinner table; and our son who brought a couple of teen friends, embarked on a backyard cricket competition worthy of Wide World of Sports coverage. Consequently  nobody had a chance to exceed their mobile data cap, a frequent and unwelcome occurrence in chez Boyd-Eedle – damn expensive too, the phone companies have finally given up taking us to the cleaners on wired internet data and focussed their rheumy eyes on the next price gouging frontier – mobile.

Between our ADSL and cable internet connections we have I think around 700Gb of data a month available, and despite Netflix being the television channel of choice, we never exceed the limit, even with my Orange is the New Black marathons. Now the telco parasites have latched onto wireless data like those annoying little ball of fur terriers incessantly humping your trouser leg, impossible to shake them loose. So an $80 a month mobile plan mystically morphs into $200 because Telstra charges $15 for a 1Gb data pack which, if they charged the same rate for our ADSL and cable internet, would lead to a bill of $10,500 a month by my calculations.

Arriving home from our holiday my children delivered their best impression of a dehydrated man crawling through sand towards a desert oasis, or maybe more suitably in my childrens’ lexicon, Kim Kardashian scrabbling towards the last TV camera in the world, as their various gadgets booted up and they were once again smothered in the comforting embrace of our home wifi network.

Oh and did I mention the kicker – no television signal either in our Faraday cage holiday hideaway. Just videos and DVDs. Note to self: I never ever want to see Disney’s Cinderella ever again.

word-wrap: break-word CSS for long text options in drop down select lists

CSS+HTML

A quirk I ran across yesterday with CSS on a drop down list. The list is disabled and has a width fixed with CSS and is contained in a table cell. The selected option text is wider than the fixed width of the list.

<table class="grid_table_new">
  <tbody>
    <tr>
      <td><select style="width:130px;" disabled="disabled" >
          <option value="47" selected="selected">Traditur Preascep irruit. Sed now possum Non adamare te. Maneam</option>
        </select></td>
    </tr>
</table>

When viewed in the browser the list looks like as you would expect:

Screen Shot 2013-12-21 at 8.55.42 AM

Except someone showed me their screen, and it looked different:

Screen Shot 2013-12-21 at 9.00.08 AM

As you can see, the drop down has expanded vertically to display the entirety of the option text. I tested this page in a bunch of browsers and found this  was only happening in a couple of browsers:

  • Chrome (Win) – YES
  • FF (Win) – no
  • Safari (Win) – YES
  • IE11 – no
  • Chrome (Mac) – no
  • FF (Mac) – no
  • Safari (Mac) – no

After a significant amount of poking around in a large amount of CSS I finally tracked it down to this piece of CSS:

table.grid_table_new td, table.grid_table_new th {
	word-wrap: break-word;
}

word-wrap has been around for a while but from what I can tell is not officially applicable to options in a select list, it’s designed to help when formatting blocks of text on a page, and has now been renamed to overflow-wrap, which now seems to be supported by current browsers. I tried swapping the existing property to overflow-wrap – same outcomes though.

It seems this is a quirk of Chrome and Safari on Windows (note, NOT on Mac). And given it’s impossible to specific that my customers should use one of those browsers clearly we need an alternative solution to cope with these long text options. Thankfully JQuery gives us choices, such as this plugin.

Happy 10th bloggy birthday to me

cake

I noticed today it’s coming up for 10 years since my first ever blog post – and it was an apology!

Well I set this Blog up many months ago just to see how it all worked. Then promptly ignored it for ages. But I’ve had a resergence of interest, particularly because I keep seeing things I want to make comment on, or make note of. My daytime job involves me in online publishing of paid subscription content, focussing on people working in the arts and entertainment industry. As part of that I’m the webmaster and main programmer for a number of large content-rich sites, and I also write an occasional column published on one of the sites, highlighting issues revolving around technology and the internet in the arts industry.

The two main sites my company publishes are Arts Hub Australia and Arts Hub UK. My column is called ‘Click to Start’. Behind the scenes I program, generally large, web sites specialising in content management and publishing, subscriber management and email distribution.

I posted this on 26 November 2003, what feels like a lifetime ago – indeed it is, our youngest child was born in 2006, so my blog is three years older than her.

367 posts and 10 years later I am not sure I am any more enlightened. Just older and greyer, whilst a little like Dorian Gray and thanks to WordPress’ continual improvement the blog looks better and better.

puTTY SSH connections dropping when on wifi instead of ethernet

04082-fart-putty

I use puTTY to create SSH tunnel connections to servers, and usually have the connection up all day. Recently I’ve been plagued with puTTY losing the connection every 15 or 20 minutes – all because I moved to wifi instead of a wired connection. It’s because I bought a new MacBook Pro, which doesn’t have a standard ethernet port, a small fact I didn’t realise so I didn’t buy an adaptor. Plus my family was probably becoming a little bored with the blue network cable hanging down the stairs from our cable router to my study – makes the place look untidy.

I already had keep alives configured in puTTY:

Screen Shot 2013-11-06 at 9.19.46 AM

After some research I came across this post ‘Why Windows 7 / PuTTY drop TCP connections even on very brief outages?‘ which seemed to mirror my own experience to some extent.

I took a look at my Windows registry, and did not see the TcpMaxDataRetransmissions parameter, so added it in with a value of 15 (the superuser post suggests 15, the linked FAQ on the puTTY web site says 10).

2013-11-06_09-22-55

With this change my connection remained up for a couple of hours, and then died, a darn sight better than the previous habit of dropping a couple of times every hour – except this time puTTY doesn’t report the connection as dropped, it looks fine, I just can’t reach anything at the other end of the tunnel.

I decided to fiddle with the puTTY keepalive, and changed it from 30 seconds to 15 seconds, over the past day or two I’m seeing 3 or 4 hours uptime. Interestingly, I only notice when I try to connect to a server and receive a timeout message, previously puTTY would say it was disconnected, now it seems to think the session is still current.

All in all good progress. When I have some time I’ll play with the configuration some more. I haven’t even got to looking at whether there is a setting on my  wifi router that might be to blame.

Send file data via JSON from REST API and open as download file in browser (with Classic ASP/JQuery)

Pet project challenge of the day. I have a REST API that delivers a JSON response, and I want it to include file data, so the browser at the client end can download the file. In real world what I’m doing is offering a link to the user to export some data to an XLS and download to their desktop.

I messed around with this for a while. Carriage of the file data seemed simple – at the REST end encode it to base64 and stick that into the JSON. The problem lies at the client end. I have JQuery calling the REST, and dealing with the response. How then to get the base64 out of the JSON and contrive to offer it as a File Save As situation?

Finally here’s what I came up with, it was sparked by something I saw on StackOverflow, although I cannot lay my hands on the post right now:

At the REST, encode the XLS file text to base64, and return the base64 in the JSON as a text element

On the client, I have an ASP script that acts as the controller, it receives requests from the pages (eg JQuery calls this page), then it calls the remote REST, and returns the response back to JQuery. Obviously cross-browser rules means my JQuery can only call URLs on the same domain, and my REST is not. So this script acts as the transporter for the calls. It’s even called Frank.

On the page I have a form with a hidden field, JQuery puts the base64 file data into that hidden field, then submits the form to another page.

<form id="base64Form" action="openFileToBrowser.asp" method="post" name="base64Form">
<input id="base64data" type="hidden" name="base64data" value="" />
<input id="fileName" type="hidden" name="fileName" value="responses.xls" />
</form>

This new page grabs the file data, decodes it from base64 back to text, sets the content headers to XLS etc. And hey presto, the user gets a File Save As dialog. Here’s the code on that page:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Option Explicit%>
<% response.expires = 0 %>
<!--#include virtual="/includes/hex_sha1_base64.asp" -->
<%
	dim base64data
	base64data=request.form("base64data")
	if base64data<>"" then
	Response.ContentType = "application/vnd.ms-excel"
	Response.AddHeader "Content-Disposition", "attachment; filename="&request.form("fileName")
	response.write Base64_Decode(base64data)
	response.Flush()
	end if
%>

The base64 encode/decode routine I’m using is part of the very handy hex_sha1_base64.asp file which I also use for other encryption and encoding tasks (for example I use it for encryption as part of talking to OAUTH based APIs).

I haven’t tested this in all browsers yet, be interesting to see if kicks up problems with IE etc.

nvarchar(max) doesn’t work on Azure SQL with Classic ASP

stress

This is one of those completely obtuse issues that one hits from time to time – nvarchar(max) fields behave oddly on Microsoft Azure SQL – yet it all works fine on SQL Server 2008 on my local machine.

I battled this for an hour before finally simultaneously figuring out that trying to return data from an nvarchar(max) column via Classic ASP on Azure yields a blank value (or weird binary garbage); and falling over someone else who’s had exactly the same problem recently.

It’s fine to have a table with nvarchar(max) in Azure. I can push data into it, I can see the data via SSMS, but returning via ASP – nada.

I’m returning the data via a UDF, so I altered the table definition returned from the function so the column is nvarchar(4000). My function grabs the data from the (max) column and sticks it into the output column without trouble, and the function returns values fine, don’t even need a CAST.

It’s frustrating because I’m anticipating these columns to hold large blocks of text, and now I’m size restricted.

I haven’t had time to explore whether messing with the connection strings might do the trick.

Clean up double line spacing in Dreamweaver code

Adobe_Dreamweaver_CS6_Icon

I work across Mac and Windows, with Dreamweaver running on my Mac, and code that sometimes will be hosted on Windows Servers and sometimes not. So I often run into the problem of erratic line spacing. If I have code saved on my Mac HDD (as opposed to my Windows VM), push it up to a Windows Server, then pull it down again, I sometimes wind up with the code double spaced when I open the file again in Dreamweaver.

I finally tracked down a quick solution to clean up these pages, with grateful thanks to this page: Permanently Remove Double Space in Dreamweaver Code View.

Do a search and replace:

  • Search for: [\r\n]{2,}
  • Replace with: \n

Make sure you have the Use Regular Expressions option checked.

Of course, it’s also good to make sure you have the Line Beak Type set correctly under Dreamweaver’s Preferences, but I’ve found that doesn’t really help when you are working cross-platform.