Thursday 7 August 2014

Bootstrap Combobox templating issue

Just had to put a Combobox (http://en.wikipedia.org/wiki/Combo_box) on a Bootstrap site.  I've been playing with the bootstrap combobox plug in by Daniel Farrell (http://danielfarrell.com/).

You can find a demo at the github page - https://github.com/danielfarrell/bootstrap-combobox


I was trying to change the template slightly, but no matter what I did it ignored it.

Just found that you need to swap some of the arguments round in the constructor method if you're supplying options on start.

Basically, as seems common sense in hindsight, you need to move the line
this.$container = this.setup();
to be after the template 'option' declaration (which has to be a function returning a string, by the way).


Monday 28 July 2014

PHP Parse error: syntax error, unexpected '['

Encountered a strange PHP issue this morning when working on a client's server:

PHP Parse error:  syntax error, unexpected '['

The line in question was:

$intNumberOfChars = (int) substr(explode('(',$objField->DbDataType)[1],0,-1);



It turns out that PHP 5.3 and below (installed on the client's server) don't like to array dereference the result of a function or method call directly.  In essence, it means before PHP 5.4 you must use a temporary variable:

$arrTemporaryVariable = explode('(',$objField->DbDataType);
$intNumberOfChars = (int) substr($arrTemporaryVariable[1],0,-1);

I've never had this error before, so worth pointing out to people.  I'm amazed that the functionality has only been available since March 2012 (5.4's release date) as I use it all the time.


Thursday 17 July 2014

What is jQuery and Why Do Developers Love It?

This a post about something called jQuery and you probably have never heard of it if you don't build websites.

As some context, I've been programming for the web since 2000.  It's been a pretty rough ride at times, especially in the heady days when everything was achieved through a mix of standard PHP files, HTML and Macromedia Flash.  This saw you needing a plugin for your browser that took an age to download over dial-up and not much shorter if you were lucky enough to have early 256k 'broadband'.
But there's always been JavaScript, too.  A plucky little scripting programming language that's almost as old as the web, it was designed to allow user interactivity on web pages and in direct competition with Microsoft's Visual Basic Script.  In essence, JavaScript was a product of the Browser Wars of the mid-1990s; but without claiming a winner, I don't know anyone that uses VB Scripts anymore.  JavaScript allowed buttons to change when you clicked them, disable text boxes on forms and move items on the page depending on user input.  If you've ever encountered a little bit of text pop up telling you that your password isn't long enough or your email address isn't correct - you've probably been using JavaScript.
The problem that JavaScript faced, like many other web technologies both present and past, was one of cross-browser adoption and support.  Your browser (such as Internet Explorer, Google Chrome, Mozilla Firefox, Apple Safari) needs to support any language used on a given webpage.  There's a three main languages on many webpages today: HTML (HyperText Markup Language) describes the content of a page, CSS (Cascading StyleSheets) describe the look and design of a page and JavaScript controls the majority of the user interaction elements on a page.  All of these have had to fight for their place as the language for the job and have very good adoption nowadays as they've been standardised to describe how the browser should understand and implement their rules and instructions.  This has meant that you can reasonably expect any site to work in any browser.

JavaScript is a neat little language that is perfectly suited for the web.  Web development can be fast-paced, should be data-size efficient and genuinely do something useful.  This roughly can be translated as being experimental, lightweight and making things easier for users.  JavaScript can do all these things, but from a programmer's perspective it means a lot of lines of code and a lot of repetition.  A solution to this is home brewed libraries - that's a book of snippets of code that can be used as a recipe whenever you need to do things over and over.  So developers over time can build up a home brewed library with useful code snippets that make them faster at completing a task - they make a generalised library of snippets to do almost anything.  That was the situation on the web circa 2005.

One problem with generalised libraries in JavaScript is one of file size growing.  A browser needs to download the whole library when a page loads, so a large library can quickly grow to a megabyte or more.  If every developer has their own library, you need to download it if you haven't before.  This makes sites slow to load the first time, giving users a bad experience.  Browsers can cache a library so they remember they have that file and needn't download it every page load, but the problem remains for that first load.  So the solution is a ubiquitous library that every site uses such that you only need visit one site with that library and forever you have a copy of it for use on subsequent sites.  Voila, you've solved the problem.  For many years now, the Web has been using jQuery as this library.
The logo of jQuery has the strap line "write less, do more" and that's pretty much what's going on.  Before jQuery was released in 2005 programmers had to write the same lines over and over, precious development time given over to repetitious and tedious tasks which sap concentration and leads to mistakes.  jQuery takes these tedious tasks and makes shorthand available to cover a multitude of everyday things to free up development time so web developers can develop and build exciting and useful things.  Since many, many sites use it, it's never a problem to include it.  It's also grown up in a mobile-aware web, so there's a version with extensions written to better work with small touch screens.

What this means is that developers can throw something together to experiment, see how an idea might work with much less time cost to do so.  Developers can share other snippets based on this library to improve user experience or further shorten development time.  Sites can now do some really interactive things and allow users to better enjoy their visit.

Personally, time and again, jQuery surprises me with yet another feature that allows me to do something in a couple of minutes I thought would take a lot of code and a lot of time to write.

That's why I ♥ jQuery.

Sunday 15 June 2014

Weird graphics glitch OSX 10.9.3 on MacMini

Just had a mild panic when I switched on my Mac and displayed the desktop with very strange artefacts not dissimilar to a lower colour depth than necessary after updating OSX to 10.9.3

I wish I'd got a screen shot to aid recognition, but it may have not been relevant any way.  The areas that I now see that were problematic were predominantly white, and possibly even transparent or overlays.  It appeared on bitmaps, window chrome and the OSX Menu Bar and menu items when highlighted.  Essentially, it looked like a fog/glare or that anti-aliasing was incorrectly applied.  There was a few greens/purples punching through, too.  I've seen similar faults when a flatscreen monitor was dropped hard on a corner, but two at the same time?

I tried detaching both my monitors (one on HDMI, one on Thunderbolt) and cycling power on both monitors.  I tried using one at a time, but regardless of monitor/port combination, the glitch remained.

Had a Google about and noticed that 10.9.3, which I'd upgraded my Mavericks OS to the last time it was switched on, had a few users of older machines complaining of a similar but not the same glitch.  As I'm relatively new to the Mac OSX world, I sighed and thought I'd look into how to work around or try to ignore it until a fix is released.  I'd noticed that previous updates that involved graphics driver improvements had similar unintended problems for older hardware.

So only one thing left to try.  The IT Helpdesk standard "turn it off and on again".  It worked.  As silly as it sounds, it does work more often than I'd care to admit.  Hopefully this doesn't become a recurring fault.

I've tried looking for a screenshot of a similar glitch, but no one seems to have posted one - they seem to be much more broken than mine was.


Saturday 14 June 2014

Broadband Down

I've been dealing with Virgin Media to try and get a reliable internet connection at home.  I thought I'd put down a short resume of the trouble we have with their broadband.  I'll also post a review of their TV service too in the coming days as it is so full of niggles it's barely acceptable as a beta test version.

We've been customers for a number of years, with TV, phone and broadband, paying somewhere in the region of £80 per month.  We've got a number of gripes with the service, but predominantly, the main problem we have with the service is the broadband reliability.  It ranges from working perfectly and super fast to being none existent, you see.

We get a total drop out of signal to the router and we've had numerous and multiple engineers out to fix the issue. About eighteen months ago, it seemed fixed, one of the numerous engineers finally seemed to crack the problem.  It had something to do with the signal to noise ratio on our feed.  It seems Virgin broadband is very susceptible to fluctuations in the signal.  Whatever the engineer did, it didn't last.  About a month ago, it all started again.

So, as anyone unlucky enough to have to had reason to call Virgin Media will attest, I avoided calling 150 for as long as possible.  Finally, after it happened during Skype calls, trying to work on a server remotely and generally not being able to use any streaming service one night, we checked the service status page.  No reported faults. 

With a deep sigh, 150 is called and the endless loop of "are you on wireless?", followed by requests to restart the router begins. Being passed around, followed by promises that it's a temporary area fault that will resolve in X number of days. Not fobbed off by this, you explain that you know more about the fault than they do, and request to be passed to someone not reading from a script.  They promise a call will be made to you in the new day, which never happens.  Finally, your only option is being a pain in the arse on social media.

Fast forward a number of hoops jumped through, hours spent talking to them, and days waiting around for call backs that have a 66% chance of actually being made at current reckoning, we get a senior area engineer out. He arrives as advised (unusually from past experience - 12noon until 4pm included 6pm once) and does the usual triumvirate of new router (a different version this time), swapping the 'tap' we're fed from and a poke around with signal meters.  He can't see a fault and short of telling us the issue is in our heads, he leaves the set up and a resolution of "let's see if this fixes it".  No attenuator was fitted, swapped or fiddled with this time.  We're told to take a screen capture of the network status of the router when it goes down for aiding diagnosis.

I sit down today with internet radio on, after a few evenings of our Android phones reporting "unstable internet connection" but assumed they were just twitchy as they're relatively new.  My radio feed drops for a few seconds.  Annoying, but meh, could be wifi issues.  Drops again, this time long enough for me to see the device is trying to reconnect to the stream, but the wifi is at full signal.  Again, before I can grab my iPad, the device reconnects.  Next, it's down for a few seconds.  Okay, this is getting tedious.  I log my iPad into the router on the correct page to get a capture next time it happens.  I'm not left waiting for long.  It seems from my experience it actually happens every few minutes, for differing amounts of time.  Watching the status page, it's very common to happen and I only notice it drop when the radio cache is exhausted.  We've been watching YouTube and NetFlix all week since the engineer, but they're not live so can cache quite a lot of the stream.  Radio is a lot less cache happy by it's very nature, and so it's much more noticeable.  Luckily neither of us play online games and have been avoiding using our broadband for important Skypes and remote connections to servers.

So, I'm back at square one.  To be fair to Virgin Media this time, they are trying to fix the problem, but I did have to call, tweet and email a lot of people to get an engineer out.  I'll post updates as and when I get a resolution to the fault, but for now, I'll just have to live with musical statues FM.


Friday 6 June 2014

I hate TV

That is kind of a lie. I don't hate TV, I hate most of what is on it. It's not a semi-pompous "I'd rather read a book" or "I'd rather do something interactive", it's just I get bored of most television series or shows. I'm sure I'm not alone in this predicament. So I need your help if you're the same. I do like some TV, so I'll start here.

I loved seasons of the Scandinoir drama "The Bridge" and awaited each episode, I adored the BBC parody 2012 and the follow up W1A. I liked The Thick Of It and really enjoyed Sherlock and Luther was amazing. I watch Doctor Who and all the seasons of Star Trek. I liked ITV's Cracker back in the 1990s, recently watched like a fiend all the episodes of the sometimes difficult to follow French political drama "Spiral" and regularly end up watching other detective shows that are admittedly dated and poorly acted, like Taggart.

I've been recommended shows as "I know it'll be your thing" and ended up so, so bored of them after a few episodes. I'm not talking I dislike them per se, just I can't really be bothered making time to watch them, apathetic to them if you like. I've tried watching the stand out favourites people rave about Lost, 24 and Game of Thrones. All of them just annoy me by being so predictable or just so monotonous and, for a better way of putting it, long. I've watched hoping I'd get into it Battlestar Galactica and watched Firefly under some duress of my other half. I never caught on with Buffy, Angel or Xfiles back when I was younger, or really understand the appeal of many American made serials, even with British actors in them.

Like I say, I've had numerous series suggestions and I look into them and they just appear too daunting to attempt, combined with a complete lack of willing on my part as they seem so... magnolia. So boring. So monotonous. So expected, even or especially while they are attempting to be bombastic and novel. I think the "look at me, look at me" nature of them make me switch off. I want something to tease me in, almost surprise me that I've found it. Like Cracker, The Bridge or The Thick Of It.

I thought I'd found that with the BBC's recent series Happy Valley: it was acted okay, I enjoyed the overarching story but haven't watched past episode four. And yet I can't really say why. It should be up my street, it's based up north, police based and has some good actors in. But it's just a bit drawn out. The low key approach I was just hoping for back fired. It was too dull. I had a bad taste in my mouth from the first episode, but I listen to the voice inside that suggests this kind of attitude means I'll never enjoy anything new, so I continued and persevered for another three weeks and gave up.

This post is brought up after my other half just asked me to watch the Netflix original drama Orange Is The New Black. I have nothing really against it, but I can't be bothered watching it and paying attention. It would be okay as wallpaper TV, to have on while I did something more interesting, or perhaps snoozed on the couch. But that's not really watching TV, that's just having TV on. Similarly I couldn't really watch Fringe, I watched the odd episode but commitment to that much TV was beyond my patience so I left him to watch it whenever he liked and I dipped in and out of it. I didn't feel like I missed much story-wise and enjoyed the little of it I watched but I'm not tempted by more. I don't know how the story of Fringe ends, but I really don't care. I suppose I'll trip over the storyline on some page at some point or I'll find out by social osmosis, but I won't be tempted to watch it.

For the future however, I'm hoping I'll find out why I dislike series so much. I'm not after suggestions for series, I'm asking if anyone else is in the same boat when it comes to this. Could you please offer an explanation so I can at least understand how to try and enjoy series from the first episode. I just seem to dislike them from the start and then like a child sulk through them. Maybe there's no way through this and I should just take up a TV friendly hobby like knitting, doodling or snorting crack.


Monday 2 June 2014

What your coffee says about you

I've augmented something on twitter and added a few personal options.  Don't ask me for sugar in your coffee.