A Guide To ES6 Arrow Functions =>

One of many favourite things in ECMAScript 6 (aka ES6) is the newly added arrow functions. If you’re a Coffeescript user then the arrow function premise is not entirely new to you.

Essentially it allows you to create an anonymous function with the contextual value of “this” being the scope of the function being that of the outer function that the arrow function is being defined in. Nor does it expect you to use the keyword function

Still with me? Here is an example using the classic jQuery DOM ready shorthand.

$(() => {
    // jQuery document ready
});

Does this look familiar? No?

$(function() {
    // Document.ready
});

How about now?

As you can see the arrow function literally just creates an anonymous function without needing to write function() {} – while on the surface it might not appear to be that useful, but the amount of typing and scope headaches this will probably save you in your lifetime is quite a lot.

The benefit of arrow functions is especially useful when dealing with callbacks for functions such as; map, filter or anything else that uses a callback function. They are considerably easier to read and faster to type.

Magical context binding unicorn =>

If you’re familiar with how scoping works in Javascript, then you would have faced the dreaded buried context caveat of Javascript in which a function inside of another function means the outer scope cannot easily be accessed from the inner, unless you created a that variable or use bind.

Still confused what I am talking about? Let me show you the issue first hand.

    function letsDoSomething() {

        this.someVariable = "someValue";

        asyncFunction('fetchUsers', function() {
            // The value of "this" is different to that of the outer this
            // So the someVariable we defined above can't be accessed any more
        });
    }

The outer scope above is lost because of this newly introduced anonymous function on the callback of our async function. One of the existing solutions we might use is create a reference to the outer scope and call it that but it is a pretty hacky solution.

    function letsDoSomething() {

        this.someVariable = "someValue";

        // Create a reference to this outer scope
        var that = this;

        asyncFunction('fetchUsers', function(response) {
            // We can access the outer scope thanks to the that variable we created
            console.log(that.someVariable); // Will print someValue
        });
    }

For those who were aware of it and didn’t have to support IE8, we could use the less messy approach of bind

    function letsDoSomething() {

        this.someVariable = "someValue";

        asyncFunction('fetchUsers', function(response) {
            // We can access the outer scope thanks to the that variable we created
            console.log(this.someVariable); // Will print someValue
        }.bind(this));
    }

What we did with bind is we told the callback function to use our own supplied scope which is the outer this instead of creating an entirely new scope (silly anonymous function). While nicer, it still is a hack and bind has some performance issues to worry about.

So where am I going with this? Arrow functions by default will set the inner scope context to the outer scope context it was defined within. So lets rewrite the above example and use an arrow function instead to see the magic.

    function letsDoSomething() {

        this.someVariable = "someValue";

        asyncFunction('fetchUsers', (response) => {
            // We can access the outer scope thanks to the that variable we created
            console.log(this.someVariable); // Will print someValue
        });
    }

Much cleaner, wouldn’t you agree? We didn’t have to use bind or create a variable, or use call or apply and our context assumes the outer context within by default which in 99% of all use-cases is what you would want to happen.

Single line arrow functions () =>

When dealing with a single line arrow function, returns are implicit. This means that a one line equation (say checking if a number is greater than 5) will return by default.

Another example:

var arr = [1, 2, 3, 7, 8, 12, 15, 20];
arr.filter((val) => val > 5 );

If you try the above code out, you will get the following array returned; Array [ 7, 8, 12, 15, 20 ]

Breaking down the example for you, it might make more sense at first if you were to see it the traditional ES5 way.

var arr = [1, 2, 3, 7, 8, 12, 15, 20];

arr.filter(function(val) {
    return val > 5;
});

This is exactly the same as the arrow function example above, except we didn’t have to write function or return how good is that?

Multi line arrow functions () => {}

Exactly the same thing as single line arrow functions with exception of the return NOT being implicit. You can use the above example, but you will have to write return but still not have to worry about writing function

Last example (I promise)

var arr = [1, 2, 3, 7, 8, 12, 15, 20];

arr.filter((val) => {
    return val > 5;
});

As you can see we had to write return and we used some curly braces as we would any normal function declaration. Pretty awesome, right?

ES6 support and transpilers

Okay, so at the moment (as of January 2015, for those in the future) support for ES6 is pretty fucking horrendous. Firefox supports a lot of the ES6 spec already, Chrome basically supports nothing (in the stable branch anyway) and the most surprising of all, Microsoft’s upcoming Spartan browser (aka renamed Internet Explorer) has the best ES6 support of them all and its only a technical preview.

So what I am trying to say is, even though most browsers don’t support ES6, through the use of a transpiler we can convert out ES6 code to ES5 compatible code for older browsers. My personal preference is 6to5, but Traceur is also pretty good as well.

Conclusion

Arrow functions => are awesome. They save us considerable time and effort and as developers, we are all aiming for that high efficiency mark, right? Eliminating room for error and in some cases, making our code more readable.

 

UK Immigration Reform Can’t Come Soon Enough

In 2013 I had my first experience with UK customs at Heathrow Airport. I had never been to the UK before, but my soon-to-be-wife has UK roots. Her parents immigrated over here 20 years ago and she has tonnes of family in the UK still.

We were visiting her nan and other family she has in the UK. A couple of aunts and uncles, her other nan as well. What actually sparked this post was this news story I read about a debate in UK parliament about making it easier for Australian and New Zealand’s to travel, work and live in the UK.

Basically everything it says is true. While those from the EU can fly in and out of the UK without really being questioned, when I flew over (keep in mind this is December 2013, so it was busy and Christmas), we were throughly interrogated by a customs officer obviously looking to catch someone so he can get his pat on the back.

“Where are you staying?”, “Why are you coming to the UK”, “How much money do you have?”, “What is the address of the place you are staying at?”, “What is the name of the person you are staying with?”, “Can I see your travel itinerary”, “Can I have the phone number of the person you are staying with?”, “Can I see your return ticket?”

Fortunately Marie and I went through together because I didn’t know all of those questions. I didn’t know where her nan lived, her phone number or even her nan’s full name. I had travelled a few places prior and I get they ask questions, but this was next level questioning and felt like he was trying to find anything however small to deny me and Marie entering… At Christmas of all times.

After flying 24 hours in total to get to Heathrow from Brisbane in economy class, the last thing I want to be is interrogated without a valid reason. Ask questions, but don’t treat Australians like criminals (even if we are all a bunch of convicts).

 

Transpiling Wars: 6to5 vs Traceur

While browsers play catchup with ES6 support and we wait for older browsers without ES6 support to fizzle out and die, we can actually start using ES6 today thanks to the work of Google’s Traceur or 6to5.

Whichever you choose for whatever reason, as long as the resulting code is ES5 compatible and your needs have been met, then really there is no competition between any transpiler except for perhaps the resulting code and various parts of the specification that are supported.

As a test, I transpiled code from the new SPA framework Aurelia which allows you to write using ES6 syntax. I ran it both through Tracer and 6to5 to see how things like speed and resulting generated code quality faired. This is by no means an in-depth analysis of the two, just a simple comparison test between output, support and speed.

The import lines in the original example were removed as the compilers would complain that they couldn’t find the files being requested (which is fair enough). I left them there for brevity.

Original code:

import {Router} from ‘aurelia-router’;

export class App {
static inject() { return [Router]; }
constructor(router) {
this.router = router;

this.router.configure(config => {
  config.title = 'Contacts';
  config.map([
    { route: '',              moduleId: 'no-selection',   title: 'Select'},
    { route: 'contacts/:id',  moduleId: 'contact-detail' }
  ]);
});

}

select(contact){
this.selectedId = contact.id;
this.router.navigate(‘contacts/’ + contact.id);
}
}

Traceur generated code:
$traceurRuntime.ModuleStore.getAnonymousModule(function() {
"use strict";
var App = function App(router) {
this.router = router;
this.router.configure((function(config) {
config.title = 'Contacts';
config.map([{
route: '',
moduleId: 'no-selection',
title: 'Select'
}, {
route: 'contacts/:id',
moduleId: 'contact-detail'
}]);
}));
};
($traceurRuntime.createClass)(App, {select: function(contact) {
this.selectedId = contact.id;
this.router.navigate('contacts/' + contact.id);
}}, {inject: function() {
return [Router];
}});
return {get App() {
return App;
}};
});

6to5 generated code

var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };

//import {Router} from ‘aurelia-router’;

var App = exports.App = (function () {
function App(router) {
this.router = router;

    this.router.configure(function (config) {
        config.title = "Contacts";
        config.map([{ route: "", moduleId: "no-selection", title: "Select" }, { route: "contacts/:id", moduleId: "contact-detail" }]);
    });
}

_prototypeProperties(App, {
    inject: {
        value: function inject() {
            return [Router];
        },
        writable: true,
        enumerable: true,
        configurable: true
    }
}, {
    select: {
        value: function select(contact) {
            this.selectedId = contact.id;
            this.router.navigate("contacts/" + contact.id);
        },
        writable: true,
        enumerable: true,
        configurable: true
    }
});

return App;

})();
exports.__esModule = true;

More readable code

Winner: 6to5
While Tracer does an extremely great job at making ES6 code work on older browsers, it also comes at a cost of readability. The output of Traceur generated code looks nowhere near as readable as 6to5. In-fact, I found sometimes that Traceur takes what should be a pretty simple swap of ES6 methods for similar methods in ES5 and complicates everything ten-fold.

JSX support

Winner: 6to5
As React.js stays on course, dominating the front-end framework sea and leaving little to no survivors in its wake, the dominance of JSX continues to grow. An alternative JS/HTML like hybrid that is used for writing React.js components

At present, 6to5 is the only transpiler that supports JSX. Perhaps a small thing to consider when choosing a transpiler, but still great nonetheless as developers realise the potential of React.js and ditch traditional full-stack front-end frameworks. If you are working with React, this will probably be a deal-breaker for you.

ES6 specification support

No winner
Both Traceur and 6to5 seem to support all relevant facets of ES6. Now that it is in a code-freeze, there should be no reason that either transpiler supports more of the spec than the other. As pointed out above, 6to5 supports JSX, but that isn’t an ES6 specific thing.

Performance

No winner
Honestly, I found both Traceur and 6to5 to convert my code over to ES5 compatible code pretty quickly. There weren’t any noticeable differences between either when it came to waiting for the resulting code to be translated over.

Conclusion

It doesn’t matter what you choose, both will achieve the same thing. If support for JSX is a requirement for you, then you should go with 6to5. If resulting code quality is also important to you over function, then 6to5 ticks that box as well.

Either one you choose will work. Both are exceptionally clever transpilers, Google’s Traceur just takes the approach of making your code work in ES5 compatible browsers, 6to5 does the same thing, but the resulting code quality is arguably nicer and easier to decipher/learn from.

 

Writing In Markdown Can Make You a More Efficient Writer

Recently I switched my writing workflow for all of my blog posts to Markdown. I compose all my blog posts in Markdown, sync them with Dropbox and then publish them. In doing so, I have noticed the quality of my posts has increased, the frequency of which I write has increased and more importantly, witness an unprecedented amount of growth in blog traffic.

Why Markdown?

Writing in Markdown is so liberating, it is just text with a little sugar sprinkled over the top. Creating headings just means I have to write a # followed by text and bump up the number of # depending on the type of heading.

It strips away all of the complexity of writing, removing distraction and just letting you focus on the content. I know George RR Martin (guy who authors the Game of Thrones books) uses a computer running DOS with Wordstar 4.0 because he likes the simplicity and distraction free writing it affords him.

Because my posts are a combination of text, images and HTML, Markdown gives me the freedom to easily insert a link or a block of code without really having to write the opening and closing tags.

The pitfalls of Markdown

If you are using Markdown with WordPress, there is a pitfall that using a third-party writing tool like I do means you can’t easily insert images. So generally I will add in placeholders for images, write my article and then in WordPress insert the images as a final step.

Sometimes Markdown can be a little too simplistic, but for most peoples needs, it liberates you. I find Markdown allows me to write a 3,000 word article with relative ease because I can focus on the typing and not having to worry about opening and close hyperlink or paragraph tags.

Writing Markdown

Because Markdown is just plain text, you can write it using any program you want. I alternate between using Byword on Mac which is a great and affordable Markdown editor and at times I will use Sublime Text Editor to write Markdown as well. I have even used Google Keep to write a blog post in Markdown before. That is the beautiful thing, it is so simple, you can write it using any tool (existing or new).

Conclusion

These days we have our phones, social media, email and a tonne of other things that distract us to a varying degree preventing us from completely utilising our writing potential. When you strip things back, something beautiful happens. You see words more clearly, sentences are easier to read and the words just flow. We think we can multitask, but multitasking comes at a cost of efficiency and clarity.

While Markdown might not be for everyone, I find that because of it, I can easily write at least one blog post on a daily basis with minimal time investment (provided I have something to talk about). I have been known to write 4 or 5 blog posts a day. This increased writing intensity has done wonders for my SEO ranking and traffic.

If you want to learn Markdown or just understand it better, I highly recommend John Gruber’s excellent documentation on the syntax of Markdown which can be found here.

 

Aurelia vs AngularJS – Round One: FIGHT!

Things just got real in the front-end framework space. Durandal developer Rob Eisenberg and once upon a time short-term core Angular 2.0 developer has announced a new framework called Aurelia. A beautifully designed full-stack SPA framework with support for ECMAScript 6 syntax right out of the box and some clever design decisions.

Not only does it allow you to build applications using ES6, but it supports all forms of alternative abstraction syntax out of the box like TypeScript, AtScript and even CoffeeScript. Rob has plans to put out migration documentations detailing how to migrate from Angular 1.x, Angular 2.x and of course: Durandal. They are not currently available, but are on the roadmap as can be seen here.

The syntax

What we are seeing in Aurelia is undoubtedly the vision that Rob had for syntax in Angular 2.0. But due to internal politics and some resistance, Rob left because he realised Angular 2.0 was heading a direction that didn’t match the path he had in his own head (although he didn’t specifically state the reasons, this is the impression I and others got).

The way you bind to variables declared within your application class is absolutely beautiful and simple. No weird symbols or abstract naming, just similar syntax to what you can already find within Javascript itself.

Check out this example taken from the docs for binding to a variable:

<input type="text" value.bind="firstName">
<a href.bind="url">Aurelia</a>

Beautiful. But it gets better. You can explicitly specify the type of binding you are using, which effectively self-documents your HTML for other developers to easily be able to see if a value is being one-way or two-way binded.

Another example from the documentation showcasing the explicit syntax (in this case, two-way binding):

<markdown-editor value.two-way="markdown"></markdown-editor>

Sweet. Sweet. ES6

Being able to write web applications using ES6 is not a new thing. In-fact, there are solutions out there that allow you to write Angular applications using ES6. However, Aurelia takes things a step further and includes support for ES6 as well as a Gulpfile with customised build system for transpiling your ES6 down to ES5 compatible code. It makes me truly excited knowing that I can write an application using ES6 syntax and not have to worry about ES5 support because the included build system and configuration means I don’t have to research the best way to transpile my applications (nor do newcomers). This means you can just start writing code without having to worry about anything else.

Aurelia learning curve

Piggybacking off of the existing point, the decision to use ES6 class syntax and other spec features means the learning curve is considerably lesser than other frameworks. The biggest complaint in AngularJS is the steep learning curve, weird HTML abstraction syntax and way you actually define and configure an application.

While ES6 syntax and features are still foreign to many front-end developers, those with experience working with a language like Java or PHP will notice some similarities and pick up things very quickly. The documentation as it stands is exceptional. It is clear, relatively concise and arguably easier to follow than Angular’s nightmare of a documentation that even stumps the professionals every once in a while. The decision to use ES6 and the great documentation will lure a lot of developers intimidated by Angular’s syntax and lacking documentation over to Aurelia.

Keep in mind that as ES6 becomes more widely supported, more and more of these SPA frameworks will support ES6 syntax and eventually all frameworks will. Aurelia is the first of the bigger frameworks to support ES6 syntax out-of-the-box (there are frameworks that support it, just lesser known ones), but presumably the new Angular will support the syntax as will others in the coming months. At this stage in the game ES6 support is an advantage, but it won’t be an advantage forever or for long. It might just be enough to lure developers over early before the likes of Angular ship their own new version which could be just what Aurelia needs to get ahead.

Templating in Aurelia

The templating system in Aurelia actually utilises the W3C HTML Imports specification for importing HTML templates and logic. As such you write what is relatively straightforward HTML, but you can also easily include other HTML files and everything is contained with opening and closing template tags.

An example of importing using the Aurelia template engine taken from the documentation:

<template>
  <import from='./nav-bar'></import>

  <nav-bar router.bind="router"></nav-bar>

  <div class="page-host">
    <router-view></router-view>
  </div>
</template>

As you can see, importing a nav bar component is done by using a HTML like tag called import. No need to use DIV’s and weird attributes like import or aurelia-import or like you might be familiar with in Angular ng-include. The templating aspect of Aurelia while just requiring less syntactic sugar, is definitely easier to write and more inline with the standards set forth.

Dependency Injection and kittens

When it comes to dependency injection in Aurelia, it is simply a matter of defining a static method that returns what you want to be injected into the application, then referencing it on the constructor of your defined class.

An example of dependency injection taken from the Aurelia documentation:

import {HttpClient} from 'aurelia-http-client';

export class CustomerDetail{
    static inject() { return [HttpClient]; }
    constructor(http){
        this.http = http;
    }
}

Aurelia vs Durandal

While I am not clear on the intentions of Rob, I believe the intention is for existing Durandal users to migrate to Aurelia. As I mentioned earlier, there are guides coming detailing how to migrate from existing frameworks to Aurelia (one of those being Durandal). However, the plans are to keep maintaining Durandal 2.x for the foreseeable future.

I have no doubt that some of the concepts from Durandal made their way into Aurelia, but it appears that Aurelia is very much its own thing independent of Durandal. In-fact, what we see in Aurelia is a glimpse of what Angular 2.0 could have been had Rob had his voice heard a little more (but we’ll wait and see how Angular 2.0 turns out). The syntax, the excellent support for ES6 and supplied Gulpfile for building back to ES5, it is the perfect package for easy out-of-the-box development allowing you to focus on the code and less time working out how you want to configure your build system (something I have done a bit for Angular, as I try and find a combination that works well).

One of the biggest differences is out-of-the-box Aurelia supports native ES6 class syntax for defining a module. Whereas in Durandal, you define a class as an AMD module as underlying module support is provided by RequireJS which works really well, but the syntax doesn’t look as nice in my opinion. Having said that, ES6 class syntax and AMD syntax are not really that far away from one another to easily port Durandal code to Aurelia.

There are literally too many great things to say about Aurelia and I haven’t even fully immersed myself into it just yet. I have already started playing around with it and I like what I see thus far. Of course it will take a bit of time before people start encountering caveats and other issues in the framework, but provided the community rallies behind Aurelia, I think it has a great chance at becoming a dominant player in the SPA framework war.

As other more dominant and less framework like contenders such as Mitrhil and React.js go down the path of concentrating on performance over syntax or features, it will be interesting to see where the likes of Aurelia ends up within the existing ecosystem of frameworks and libraries in the next year or so.

As uncertainty remains around just what Angular 2.0 will look like, Aurelia has just entered the race as a VERY worthy contender for the SPA crown. Can we just hurry up and standardise on a front-end framework already? I think I speak on behalf of most developers when I say it can be tiring to have to continually learn the new flavour-of-the-week front-end framework. Things show no signs of slowing down just yet, I am keeping up, but would love to be able to breathe for a little while before I need to learn another MV* framework.

I will be doing a more detailed write-up shortly on Aurelia as I delve into its underlying complexities and see where it shines and where it epically fails (as the youth of today say). Perhaps even a comparison between AngularJS 1.x, React.js and other frameworks.

Try it out by reading up on Aurelia here and getting started with the code. Jump in.

Are you excited about Aurelia and if so, what parts excite you and what parts don’t?

 

What Is The Appeal of Triple J’s Hottest 100 Countdown?

Call me un-Australian, a non-conforming individual, a meta-hipster or what you will, but I just don’t see the appeal of the Triple J Hottest 100. A countdown which somehow seems to seduce both hipsters and true-blue Aussie bogans into not only participating in the voting process but also tuning into the radio station for an entire day.

A favourite past-time of many who like to celebrate Australia day with a few cold ones, an assorted selection of traditional BBQ meats (sausages, steak and chicken) and a radio tuned to Triple J in the background as people comment on songs being played so far and what will be in the top 20, top 10 and top 3.

All the while I try and hide the fact that most of the music does not appeal to me nor do I really care who makes it into the top 10 or the countdown itself. When asked for my predictions, I casually steer the conversation into a new direction, people have luckily had a few drinks, so nobody notices my verbal sleight-of-hand.

Maybe I am not in the majority, perhaps I have a problem and a deep underlying sense of disdain for the Hottest 100 tradition that has been engrained into the Australian backbone for over 25 years since hitting the scene in 1988. Maybe I am just not cool enough to like or want to participate in the Hottest 100?

Democracy is great and the Hottest 100 is a musical form of democracy, citizens vote to elect the musical constituents they deem to be the worthy of mass Australian media acclaim for a day or two after the countdown is done and then we go about our normal lives for another year.

Then there is the controversy around getting Taylor Swift into the countdown in the form of the horrible “#Tay4Hottest100″ social media shit storm. Ultimately Swift was excluded from the countdown, but ironically Bruno Mars (an artist who gets tonnes of airplay on the more commercial stations) is somehow an exception?

Don’t get me started on the inclusion of other relatively big name acts like; Sia, Lorde, Vance Joy (Taylor Swift even covered one of his damn songs and hand-picked him as a supporting act for her Australian tour), Kendrick Lamar, Jack White and the more laughable inclusion of one of the biggest rock bands out there: Foo Fighters.

I don’t like Taylor Swift’s music any more than most people with decent music taste do, but the exclusion of her from the countdown because she is “too mainstream” is just elitist bullshit, especially when the likes of Foo Fighters who are definitely not a struggling Indie rock band from Melbourne make it onto the list.

I was proud to see The Amity Affliction make it into the countdown, they’re a great Australian band who encompass a strong DIY ethic that has finally paid off for them. The countdown is great exposure for a band like The Amity Affliction looking for a new fan or perhaps to help bolster their merchandise and CD sales if only temporarily.

Sadly, most of the music just isn’t for me. There is a severe lack of variety within the Hottest 100, looking back at the earlier years you had great artists like Nirvana, Joy Division, Pearl Jam, Faith No More and other iconic nineties bands making it into the countdown, intertwined with pop and hip-hop. The countdown used to be pretty diverse and had something for everyone.

This years countdown which was playing in the background at a BBQ gathering I was relatively sober at, I noticed most of it was either indie rock or electronic music (there was a bit of dubstep and dance in there). With exception of bands like The Amity Affliction, the countdown was relatively uninspiring for me, but others seemed to enjoy it. Don’t get me started on The Hilltop Hoods, I struggle to contain my animal like rage when I hear that Cosby Sweater song playing.

Perhaps I have a problem of being too un-Australian. Maybe I should get involved and leave my music elitism out of this. After all, it is only an event that rolls around once per year that manages to galvanise the misled youth and XXXX drinking tradies into actually participating in something.

Maybe I should focus less on the countdown and just chill? Perhaps I just need to accept the fact that I am not cool enough to like any of the music or recognise 99% of the artists on the countdown. I should just stick with what I know and contain my music opinions out of fear of being perceived as some kind of music snob who hates Australia.

Then there is this Chet Faker guy. Not only was one of his tracks chosen for the number #1 spot on the countdown, but he also seemed to have a few others in the top 10 as well. Apparently people really like Chet, or perhaps they are hypnotised by his mighty hipster beard where he likes to keep his pet budgie Nelson, hidden away from customs in an elaborate maze of facial hair.

I tried getting into his music and I think he has a pretty good voice, but all of his music seems to sound the same to me. Either way, he has done incredibly well for himself: so good for him. There seemed to be a little controversy at the BBQ I attended where the gathering-goers were split 50/50 about his inclusion in the top 10 and taking out the number 1 spot.

I’ll just stick to my self-curated Spotify playlists laden with copious amounts of blues, non-Australian hip-hop, metal and likeable non-radio rock. You can have your Hottest 100 and if it makes you happy participating in the Australian tradition of caring what gets played in the countdown, then do what makes you happy and don’t let people like me tell you otherwise. I’ll happily consume beer and eat fine cuts of meat.

TL;DR – I don’t like the Triple J Hottest 100, nor most most of the artists or music that finds its way onto the list year after year.

 

GTA V Online: Easy 10k Money Glitch

During my relatively small amounts of down time I sometimes like to unwind with a beer, a few friends and play a game of GTA V on my PS4 (which largely collects dust). Because I do not get to play that often, I have resorted to finding ways to shortcut the process of getting money and XP.

In my travels I discovered a money glitch which nets you a nice little profit and works as of January 26th, 2015. To my knowledge it works on all platforms (last-gen and current-gen).

The beautiful thing about this glitch is that it currently skips the almost one hour waiting period.

Step 1: Buy a Rat-Loader for $6,000 from southernsanandreassuperautos.com
Step 2: Go into a Los Santos Customs
Step 3: Scroll through the suspension list and make sure the default suspension is selected.
Step 4: The “Sad Trombone” horn is now free to select from the horns menu. Select it and then equip it to the vehicle.
Step 5: You can now sell the car for $16,000 which should net you a nice $10,000 profit.
Step 6: Repeat the previous steps to keep netting yourself a tidy profit. Considerably faster than doing missions and less time consuming. This also bypasses the wait-time because purchasing cars via the in-game internet has no time restriction like off the street vehicles.

 

Keeping Getting Calls From (02) 8015 7641?

Without fail, every single day I get multiple calls from the number 02 8015 7641 for the last week or so. They keep trying to call, yet don’t seem to leave a message on my voicemail. I keep putting off answering the call after some Googling seems to indicate that it is some kind of scam or competition.

So, after being constantly hassled day-after-day I tried calling the number back with my caller ID on private. I tried a few times and I kept getting this pre-recorded message in an English accent that said: “All of our agents are currently busy, please stay on the line, your call is important to us and will be answered shortly” – then it hangs up on you. Weirdly enough, the number doesn’t even ring which leads me to believe it is some kind of automated spam/scam.

When they called back next, I answered the phone this time around. After waiting a minute or so, I was put through to an operator.

The company is called Winning Choice and basically they are calling about entering into a competition to win some large sum of money. I asked them why they kept calling me multiple times a day and not leaving a voicemail and the lady didn’t have an explanation.

The explanation why they don’t leave a voicemail message is quite clear: they know you won’t call them back if they say they’re calling about a competition that involves a survey.

They wanted to send me through a link to a survey to win some money. I just hung up on them as the lady sounded like she was in an Indian call centre reading off of a script, almost robotic like, but definitely a real person. I was nice to her, but if they try calling again, I won’t be so nice next time.

 

Using The HTML5 Page Visibility API… For fun and profit

With HTML5 came a plethora of useful API’s and added methods, one of those which didn’t really get as much visibility (ha, get it?) was the Page Visibility API.

What is the Page Visibility API?

The clue is in the name. It allows you to determine if a page is visible (a tab is focused or window being shown). Historically we haven’t really been able to reliably determine if a visitor is looking at a page and as such, can cause issues when media is being played.

The API is smart enough to work with both tabs and windows. It can accurately tell you if a user is focused and looking at your page. Especially handy if you have two side-by-side windows but focused on another and want to know if you’re site is legitimately and actually being viewed.

When should I use it?

The easiest use-case is when playing audio or video. If a user switches to another tab, you can pause any audio or video that might be currently playing. This not only makes for a better experience for users, it also prevents battery being wasted on devices and saves CPU as well.

There are other non-obvious uses as well. If you have any kind of looping animation (another CPU expense) you can pause or stop the animation when the user isn’t looking (after all, is there a point to a running animation if nobody can see it?).

How to use the Page Visiblity API?

Compared to other features in the HTML5 spec, the Page Visibility API is easy to use. After adding an event listener, it has two methods you can use. You most likely will only be using the method document.hidden which returns true or false if the page is in-view or not. The other method document.visibilityState tells you exactly why it is or is not in view with values; visible, hidden, prerender and unloaded. You can read up on each method value here.

HTML:

<audio id="audioPlayer" controls>
    <source src="song.ogg" type="audio/ogg">
    <source src="song.mp3" type="audio/mpeg">
</audio>

Javascript:

var audioPlayer = document.getElementById("audioPlayer");

document.addEventListener("visibilitychange", function() {
    if (document.hidden) {     
        audioPlayer.pause();  
    } else {
        audioPlayer.play();   
    } 
});

Page Visibility API Support

Surprisingly, the Page Visibility API is well supported and mostly free of vendor prefixes (except for Android). It is supported in IE10 and up, and on every modern browser (except Opera Mini, but who cares about Opera Mini anyway?).

 

Candy Crush: Soda Saga (Refill Life Glitch)

Yes, I play the new Candy Crush: Soda Saga game (don’t judge me), it passes the time while waiting for my bus and train ride home. In doing so I discovered a nifty little glitch in the game that allows you to get unlimited lives.

The process is a little involved, but I thought I would share it. This isn’t a Candy Crush hack, this is merely a glitch in how the game checks for lives sent to you by a Facebook friend.

  1. You need to have Facebook connected to the game.
  2. You need at least one Facebook friend who plays the game and can/will send you a life when you run out.
  3. Once a friend (or friends) send you a life, don’t accept it right away.
  4. Disconnect completely from wifi and cellular internet (the easiest way is putting your phone into flight mode).
  5. Make sure the game is completely closed, but you have the pending life/lives ready to accept in the game.
  6. Open the game and accept the life (then go into a game and spend it by attempting a level). Once you run out of lives again, simply close the game down completely, ensuring you are still in flight mode and then open it back up. Provided that this little glitch is still working when you read this, you should be able to accept the lives from your Facebook friends again.

There is a funny story about how I discovered this little glitch. When I was in the US recently I took over my Australian Galaxy S4, but the screen shattered one night when I was playing air hockey at an arcade. So I had to buy a new phone, I found a used Galaxy S4 Active and used it in the US. However upon return home, the phone doesn’t work with Australian 4G (on Telstra anyway), so I only have internet when connected via wifi and not when I am out and about.

 
Real Time Analytics