Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Jamie Balfour'sPersonal blog

I'm happy to announce after the latest feedback on ZPE, that you can now use the C style increment on a for loop:

ZenLang
for($i = 0; $i < 10; $i++)
    print($i)
end for

Of course, since ZPE has been designed for ease of use, users can still use the original style of incrementing or decrementing in for loops:

ZenLang
for($i = 0, $i < 10, 1)
    print($i)
end for
zenlang
zpe
zengin
for
loops

I spend a lot more of my time developing the front end than the back end of my website since the back end is pretty damn flawless as it is. I say this because I was originally more of a back end web developer - and I probably say this to many peoples' suprise but it's actually true that I still am. I prefer working on the front end sure, but the back end is really where I am more talented.

Effectively combining the front and back end is about ensuring that the back end stuff works with the front end stuff, but your front end needs may be quite high. For instance, iterating 1000 records on your local database is not going to be too demanding, but getting them from an external website and then generating the HTML for these then adds quite a bit more work. What if you are collecting the latest from your Twitter account (like I do) and placing it on the website and applying regexps all over the content? This is quite demanding. So I spent a lot of time reviewing literature on this exact problem and it seems it actually is a problem, albeit easy to fix.

Our PHP function may return us a HTML result when we get our Tweets back from Twitter's API, and we know that the Twitter feed is only going to update when we update it, so why don't we just throw the HTML result into a text or HTML file? This solution then means that we have to manually update (delete the file) the website when we update Twitter. Not ideal.

The solution, check the modification date of our cached file. If it is more than 24 hours old, delete it. The PHP function will no longer see the file and instead of getting a cached version it will refresh it with a new request to Twitter. Still not perfect though since we've got to delete the file.

The final solution, the PHP file checks if the file exists, if it does checks the modification date and if it's over 24 hours old it gets the latest data from Twitter and updates the file with that data and returns it.

There you have the description of a very simple PHP caching system. 

Posted in Web Development
cache
php
script
js
website

In the last few days I've been focusing a lot of my time on software development rather than my usual web development. As a result ZPE has received more of my time than my website. This changed again today when I decided to work on it again.

Today I brought back the Facebook commenting system to my website, replacing my long lasted Disqus comment system. As a result of this, I am also including this in BalfBlog 2.1 instead of Disqus. The main benefit is now users no longer have to enter an individual post to comment on it (for the main blog mode, not introduction mode).

The DISQUS_SHORTNAME and the related settings are no longer required since Facebook does not need users to login. 

On my website side of things again, I have been focused on ensuring the OpenGraph content is up to date on my website. You should see that it is now pretty concise and works effectively every time and as a result sharing looks much better with Facebook.

Posted in Website news
website
update
july
2016
og
image

Today I graduated! This is the happiest day of my life and I'm so very proud of what I have achieved to this day!

Back in 1997, when I was aged 6, I got my first computer. I quickly learned the ins and outs of it and was very into writing my own stuff and really enjoyed writing stories. As I was using my computer more and more I took an interest in how it works. By age 9, I was very interested in computer hardware and how they worked.

In my first year at high school, I realised that I was really good at working with computers and people were coming to me for computer help more and more (including my teachers). It was then that I decided I want to do something related to computers. I always knew I wanted to go to university so I put two and two together and in 2009 I applied to several universities to study computer science with Heriot-Watt being my top choice. I was accepted and my course began in 2012. 

My time at Heriot-Watt university has had its ups and downs and I've needed support from time to time. At Heriot-Watt support is always there for those who ask. I had a friendly bunch of lecturers who were always on your side and there to help. 

I'd like to thank everyone who has helped me at Heriot-Watt but I'd like to specifically thank a few people including Lorriane Vallance, Dr Tessa Berg, Dr Helen Hastie, Professor Rob Pooley, Professor Andrew Ireland, Dr Fiona McNeill, Dr Jenny Coady, Dr Santiago Chumbe and Professor Greg Michaelson. I'd also like to thank Professor Judy Robertson and Dr Sandy Louchart for their support in my first to third years, who have since moved to other universities. 

I'd also like to thank my friends and classmates, particularly Jonathan, Merlin, Mark and Sharang who stuck with me through thick and thin in the last year, as without them I would not be celebrating this day.

Posted in Life
graduation
heriot-watt
heriot
watt
university
bsc
hons
honours

Helvetica returns! And on this occasion, I am not talking about you Calum Cormack. 

As I have been conducting feedback surveys on my website to select visitors for the last few days I have discovered that many do not like the Open Sans font since it is too light to read. I also felt like this from time to time and have considered the change to the slightly heavier Mac favourite font, Helvetica. 

Helvetica was once the default font on OS X (soon to be macOS) but Apple dropped it for the San Francisco font in both iOS 9 and OS X 10.11. I also once used Helvetica as my default font but dropped it for the sake of cross-platform support and have switched font on my website quite a lot since then. I am hoping that Helvetica will be staying, I will be running a trial run of this for four weeks from today. If I get more positive remarks about the font on the website I will retain it. 

As the result of the information from some feedback I received, Roboto has become the new site font - the third attempt at a font from Google Fonts.
Posted in Website news
helvetica
arial
sans

As you are maybe aware, Microsoft announced Project Scorpio at E3 a few days back; a second iteration of the Xbox One with more power and capabilities of 4K video output that will also includes 4K games. However, some of us will be disappointed Microsoft is making games specifically for the new console.

My brother used to argue that the Xbox is great because all you do is press a single switch and it's on in a few seconds and because it didn't need upgrading every four or so years. In direct comparison to my 2011 and 2013 PCs, the time for the Xbox One start up is actually about 3 or 4 seconds longer than them. So this argument is now void. The argument about upgrading has also become invalid due to Scorpio

Another argument was the lack of exclusive and fresh games on PC, but I think Steam has since taken care of this. And a lot of Xbox exclusives such as Titanfall have since come to PC. Microsoft also announced that many new 'exclusives' would now come to PC too.

So really, what is the difference between the Xbox One and your gaming PC?

The Xbox One is an x86 based machine, running Windows under the hood, and games at less than 1080p. So it's the same architecture as your PC. Why would you really bother with a system that doesn't do half of what your gaming PC can do? 

The controller, right? I do admit the controller for the Xbox One is amazing (it's why I chose it over the PS4). But wait, what's that you say? You can use your controller with your PC?! Indeed. This is a crucial point to me, since there are games that I would rather play with a controller such as GTA V, but then there are other games I'd still rather have my WASD key combination for.

So now the Xbox One will be a PC you cannot upgrade yourself but will need to update by buying a new one every few years, am I right? Well this is what Scorpio makes it look like. 

So give me one argument for why an Xbox One is better than a PC. I really am having a hard time trying to figure out why I bought an Xbox One, since I've not enjoyed many of the games I own so far. 

Please note, this post is not a criticism of the Xbox One, more of it's upgrade strategy.  

Posted in Gaming
xbox
one
scorpio
pc
gaming
future
console
games

WWDC is getting less exciting as the innovation begins to get less innovative. I'm personally no longer shaken by the new releases of iOS since version 7, which was the last real iOS that I could say was exciting. Since then Apple's software releases have become less exciting and certainly don't hold the same level of innovation.

Anyway, WWDC last night was the moment Apple dropped the name OS X and named it macOS. So now, my Mac will no longer run on OS X but on macOS. The new version will be known by the name macOS Sierra. I'm happy to say the inclusion of Siri is something that I am excited about. This is something OS X should have had a long time ago.

iOS 10 is opening up to developers and third-party apps more and more. First off, Siri is being given an SDK and opened to developers so that apps can take advantage of the power of Siri. Third party developers such as WhatsApp will have more power over the iOS device too.

The most interesting part however was with tvOS. I feel that Apple has made a few crucial updates such as the new dark mode, which you may think is not crucial but let me tell you, it is. There was also the addition of the new single-sign on option for different apps stream through cable TV. 

Overall, WWDC 2016 was very lackluster and one of the least interesting WWDCs of all time. A lot of this is down to the fact that Apple have run out of fresh innovation since they've already implemented most of the important features of our smartphones - all they do now is move things around.

Posted in Apple Corporation
wwdc
apple
2016
exciting
macOS
iOS
tvOS
10.12
10
watchOS

WWDC

Today is the day. WWDC 2016. Have you thought much about what we might expect?

One of the main things that I am expecting is Apple finally dropping OS X and naming it macOS (stylised exactly like that). Doing this would make macOS feel right at home with iOS, tvOS and watchOS.

Of course, iOS 10 is expected and OS X 10.12 (or macOS 10.12). Apple will probably also announce tvOS 2 and watchOS 3. Also, there may be a few more watch straps announced today. With macOS 10.12 I am expecting that Apple will finally bring Siri to us Mac users.

Anyway, that's my thoughts. Let me know what you think below.

Posted in Apple Corporation
wwdc
apple
2016
exciting

My blog all about BalfBlog, which was formerly the BalfBlog blog has been renamed my Project blog. This blog will no longer focus solely on BalfBlog, but it will now discuss all of my projects.

On that subject, whilst ZPE is one of my main projects, it will not really be discussed too much on this blog since there is a dedicated blog on the zenlang.net website. I think it would be wise for me to keep submitting there rather than at both places.

Posted in Miscellaneous
project
blog
jamie
balfour

It's considered pretty bad practice to use a class selector in CSS as a single instance, for instance, you would not choose to the name the main_container element .main_container, would you? Or would you?

Well actually, I was thinking about this today, and I've come to the conclusion that yes, maybe you would. That's because of the DOM buzz word specificity.

Any CSS developer who has been using it for a while will know that the ID selector (#) is more powerful than the class selector (.), but do you know how much more powerful it is? Well 10 times to be exact. For more information on this, read the linked article.

It's important to note that throwing in an ID selector makes it very difficult to overwrite, so using one is not always the best way to achieve something. For instance, say you wanted all the anchor elements inside your main body section to be displayed with a style where you've got the code such as:

HTML
<div id="main_container">
    <a>Test</a>
    <a class="tester">Test</a>
</div>
<div id="sidebar">
    <a class="tester">Test</a>
</div>
</div>

The anchors could simply be selected using the #main_container a selection. But this means, according to specificity rules, that the anchor would have 101 points (100 + 1), meaning overwriting this anchor with a class is not easy and would require the ID at all costs. Now you want to style the links with the class tester too, but across the whole site. So we have two choices, either rewrite the page so that the body has an ID too, or, create a selector like #main_container a.tester, #sidebar a.tester.

Both of these solutions are inadequate.

The single use class

Let's rewrite the HTML and CSS. Add the class singleton to the main_container:

HTML
<div id="main_container" class="singleton">
    <a>Test</a>
    <a class="tester">Test</a>
</div>
<div id="sidebar">
    <a class="tester">Test</a>
</div>
</div>

Now our selection can be much weaker, albeit less specific (but since singleton will only occur once and only once we do not care). We can now select using .singleton a. We have reduced the specificity to 11 (10 + 1). To overwrite it, we can now just use a.tester since this also has a specificity of 11 (1 + 10). However, this will only work if it is placed in the CSS file after the reference to the original tag (i.e. after the .singleton a). 

So there you have it, a way to use the class selector as a single instance effectively.

Powered by DASH 2.0