Monday, 28 July 2014
PHP Parse error: syntax error, unexpected '['
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?
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'.
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.
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
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
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
Wednesday, 28 May 2014
Where is my driverless car, Google?
I'm a person who mistrusts corporations. They work with the premise that they exist to make profit, and in economics terms, that means the purchaser gets a worse deal. If a producer of a primary product (raw materials) adds profit, then a manufacturer makes things and adds profit, then a retailer adds profit, the end consumer is paying the profit margins of three companies. This isn't inherently bad if each is adding value.
The hardest one to argue for is the retailer. In essence, they buy finished goods, put them on shelves and allow you to purchase them. Their added value is choice and convenience; perhaps after sales or maybe even advice presale. However, if we think of a market like the supermarkets, this does point to the only areas of value added are choice and convenience. I won't go all Veblen or Marx on you here, that's for another post, but I thought I'd make my standpoint clear from the start.
Google have announced today they're making driverless cars, and I immediately loved the idea. It's like Sci-Fi and I want one now. I don't understand people who reckon that they enjoy driving. It's brain numbing monotony and repetition, I only look forward to driving now as I am an odd ball who is wise enough to drive an automatic transmission vehicle (I can drive a manual car, I did for many years) as I see no one manually cranks their cars to start or manually adjusts the choke to change fuel air mix when starting.
This last thing is probably lost on most people born after 1980, cars used to have a knob to pull out when you started it, on the steering column. It changed the fuel air mix and as you drove and the car engine got hotter, you pushed it back in. My first car (C registration Vauxhall Nova) had one and on cold, wet mornings, they were a nightmare: push it back in too early and the car would splutter and stall. Mine had a spring that pulled it gradually back in and if you got to traffic lights before it was hot, the car just conked out, kangaroo style. So I augmented it with a wooden clothes peg that I clipped on to hold it out.
Anyway, Google's car sounds awesome. Yes, it'll make taxi drivers redundant for car owners who have a drink, but that was said about email - apparently email would make Royal Mail bankrupt, but of course it was their pension scheme, not the universal postage costs to blame there. In the end it takes us away from doing something we'd rather not do and gives us more time to do things we'd rather do. So instead of paying attention to the back of a truck on a winding country road, we can admire the gorgeous views to our side.
This is where my unease comes in usually with companies. I mistrust them but Google seem to give us toys and gadgets we like. This can be said of many firms, but for me Google's approach is something special. Yes, they have a monopoly on search. Inherently that's a bad thing, but while I could use another service just as easily, I find myself not doing. The reason? Their search is better. A monopoly based on a better product is something to knock from its pedestal, and no one seems to be able to no matter how much Microsoft throw at the problem, so I'm comfortable with it.
I end up with the same conclusion whatever Google does (some specific examples omitted): they make something I'd actually use, they make the best of breed and they give it out on an advertising funded model or use the data to better understand you. I wish Tivo actually did this, but it seems to always tell me I'd love stuff on channel 5 or something with James Corden in. With a slight unease, I accept Google's products much more readily than other corporation's products simply due to them using science, maths and software engineering to make better and better things.
It's going to be a long time until they're on the road, but the Google car is a step forward and perhaps the battle to make them legal will make them better still. I look forward to driving one. Hang on, don't I mean riding one?








