A path for quickly becoming productive with Node.js

If you’re an experienced web developer, and you want to learn Node.js and be somewhat productive with your time, here’s an easy path to begin with.

I’ll assume you know raw JavaScript and a little raw Node. Enough JavaScript to be familiar with the DOM, anonymous functions, and callbacks. You dont have to know React or anything of the sort.

First up, Learn enough to recognise the new syntaxes in ES2016, along with promises, arrow functions, generators and async await. You don’t have to be good at them; just be able to know how to read them.

Now learn enough Node and NPM to start a vanilla Express server and realise how much work it would be to write a whole fully featured web application in it.

Now quit jQuery, cold turkey.

If you come from using a Rails-like framework such as Rails, Django or Laravel, the though of scouring NPM for all the packages you’ll need, you’ll be wanting someone to make opinionated decisions about the right packages for the job for you. May I suggest Adonis.js. It comes with all the MVC, Authentication and ActiveRecord stuff you’re used to, along with loads of other good stuff too. You’ll have a good reason to learn about Generators, Promises and async await here.

Resist the urge to jQuery.

If you want to write your front end as a single page application (SPA), to run in front of your API, you could use what you’re familiar with, or you can start afresh with Vue.js because it has the gentlest learning curve of any of the mainline frameworks, all the best stuff from the other frameworks, and you don’t even have to learn a bundled/compiler if you don’t need it.

Vue is easy to learn, easy to adopt, and you’re never forced into complicating things too early. Go at your own pace, and eventually you’ll learn about components, which will change everything. Get started with Vue’s single file components and never look back.

With Vue, you don’t need a router out of the box, until you know you do. You also don’t need state storage until you know you do.

You want to write a universal app, or use Material design you can do that when you want. Heck, you can even bring in JSX if you’re feeling that. And you dont have to add any of these packages to your project, until you need it, and in any order.

tl;dr: Learn enough JS and Node to spot new JS language constructs, starting with Adonis will give you a reason to learn the new stuff while giving you an easier path to success.

Disagree? Got a easier, faster path to productivity and learning all this crazy JS? Chime in below, or hit me up: @Glutnix on Twitter.

My Day at WellyCon 2016

WellyCon is New Zealand’s premiere board gaming convention. Hundreds of avid gamers come together, bust out their cardboard cartons and plastic meeple and play board games with each other for two days straight, some even playing into early Sunday morning before returning the next day.

Discovery

I had never been to WellyCon before, but others had told me about it a few years ago. Only three weeks before the event, I saw it advertised in the ComicCon New Zealand flyer. Apparently all the big NZ geek events were running on the same weekend: Queen’s Birthday weekend.

The bigger, more well-known geek event, also running Queen’s Birthday weekend was Armageddon Expo, the annual entertainment and pop culture event. I’ve been to Armageddon many times (even cosplaying as Gordon Freeman and Axe Cop), but found it less and less to my liking, as it focussed on cartoons, television and cinema, and less about video games and board games.

I asked my lovely wife for the privilege of going to just the Saturday of WellyCon, leaving her with our daughter. Lucky is the man whose wife lets him go to WellyCon without her!

A Community Mindset

Because I was going by myself, I wondered how games got started at WellyCon. It turns out that there’s a very large game library at WellyCon. It’s full of games brought along by other attendees and left to be played by others. You can rustle up a group, choose a game, claim a table, set up and start playing.

I wasn’t expecting to know many people there, and I wasn’t going as part of a group, so I decided to only join games looking for extra players. As it turns out, they have these big signs you can put on your table to make it easy for players like me to find your table.

Turning Up

There was plenty of parking at Wellington Girls in Thorndon, if you knew where to find it. I circled around before I found the tiny WellyCon sign leading in to the parking field.

Once through the door, I walked around the busy atrium, admiring the magnificent stack of board games, and spotting one of the signs, and jumping into a game of Star Wars Carcassonne.

Star Wars Carcassonne is a lighter version of the original Carcassonne where cities are asteroid fields, roads are trade routes, no farms (space is empty) and cloisters are planets, and a fun planet-conquering mechanic which lets you roll battle dice to steal them. None of us had played this variant, and one of us had never played a Carcassonne. We read the rules, and learned how to play, and enjoyed ourselves very much. And I won, which is nice.

Family Jewels

Half-way through the first game, I got a text message from Adrianne, one of the organisers of WellyCon informing me that I had won a spot prize. After my game, I went to claim my prize.

Choosing from almost 90 prizes, I selected a set of plastic gems and gold nuggets for playing Splendor with. They are beautiful and decadent, and must add a further tactile experience to the game. I should not that at this point, I have played a lot of Splendor on my mobile phone, but did not own a physical copy of Splendor.

Much Game. Very Lose. Wow.

I ended up playing Shadows over Camelot with the same two people (Caleb and Fiona) and two other people. The traitor won by sabotaging too many quests, then falsely accusing another player to end the game. We didn’t complete a single quest. Fun game though!

After publically not collecting my lunch, and then correcting, and consuming it, I played a game of Splendor with some older gamers (not revealing my gem stash), and was thoroughly trounced. I got locked out of the ruby market, losing a lot of tempo in the process. I did, however, remind all those players that you can reserve a face-down card from any of the three stocks.

Trading Post

I had brought with me a selection of my least played games, hoping to trade them for slightly better games. WellyCon hosts a trading corner, where you can leave your games on a silent auction or for sale. I missed the (seemingly non-existent) face to face trading session at 12:30, but put all my games in a box marked “Offers” and waited for calls. Maybe not a great strategy, but I did get a call or two, settling one deal that day.

For the Hoard

Splendor board game box art

I finally got a copy to go with the plastic gems I won

Walking around I spotted a demo table with Cheeky Parrot Games showing off their Kickstarter card game Hoard, which I had already seen online. I sat down and played a full game with Tim Kings-Lynne, one of the game’s designers, and Julia Schiller, Director of Cheeky Parrot Games. They’re lovely people, and maybe they let me beat them at their own game. I got to talking to Tim and his exploits on the Miramar Peninsula working at Weta Digital, how the game has developed, and thoroughly enjoyed myself for a good while there.

After this I hung out with my old buddy Chris and Mel for a while, catching up on old games and old times. He also convinced me to put my games on silent auction. We then sat down and they introduced me to Codenames. Being the code master is hard! We played three games before I had to leave for the night and rejoin my family.

Last Dash for Cash

Before I left, I closed a trade! I traded a copy of Power Grid along with the China/Korea map expansion for $40. And on the way out, I passed by the Cerberus Games booth and spotted a copy of Splendor that had not been there all day, which I swiftly secured and took home.

I thoroughly enjoyed myself that day. Playing five different games, most of which I had never played before. I made new friends, won prizes, sold games at auction, caught up with old friends, and bought a game I have wanted for a while.

You should go to WellyCon!

Will I return for WellyCon 10 next year? ABSOLUTELY. My wife is supremely sore she missed out.

Should you? If you have enjoy learning and playing new and interesting board games, Definitely! And I learned there is a Mini-WellyCon coming up, maybe Labour Weekend? See you there?

Adding data to every view safely in Laravel 5.1

In Laravel 5.1, it’s really easy to share data with every view. Every page of your site might need the currently logged in user, or the footer needs that phone number or those opening hours from your database.

The Laravel 5.1 documentation’s approach to sharing data with every view works for most circumstances, but I recently learned of a case where it breaks things: running artisan.

The problem

The documented approach to sharing data with all views tells us to add code to AppServiceProvider->boot():

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        view()->share('key', 'value');
    }
}

This approach is fine, for certain values.

view()->share('siteName', 'Banana Bill's Boat Boutique');
````

Literal values won't be a problem.

```php
view()->share('currentUser', Auth::user());

Here, if someone’s logged in, Auth:user() will be an instance of the User model. If not, it’ll be null. No problem here either.

view()->share('openingHours', OpeningHours::currentHours());

Here’s our problem. We’re asking the OpeningHours model to get the current opening hours. And most of the time, this will work. However, if you haven’t run your migrations yet, your pages will give you an SQL error saying the opening_hours table is missing.

And so you get the hint and run your migrations to create the table. php artisan migrate

…and you get the same error. You say to the computer “I’m trying to make the table right now! Lay off!”. But no dice, you continue to get the same error.

The issue here is that everything in AppServiceProvider->boot() runs even when you run artisan commands. It’s not normally an issue, but if you’re a new developer installing a project on your dev machine for the first time, this could really throw you.

The solution

Create a new service provider and have that create a View Composer for us instead.

In the example above, we’d comment out our share command, and we’ll get the use of artisan back:

php artisan make:provider ViewComposerServiceProvider

This will create /app/Providers/ViewComposerServiceProvider.php

Add the new service provider to /config/app.php‘s providers array:

    'providers' => [
        ...
        App\Providers\RouteServiceProvider::class,
        ...
    ]

And then in ViewComposerServiceProvider->boot() create a view composer:

    public function boot()
    {
        View::composer('*', function($view)
        {
            $view->with('openingHours', OpeningHours::currentHours());
        });
    }

ViewComposerServiceProvider->boot() will still be called when you invoke artisan, but OpeningHours::currentHours() will only be called when you a view is created. Now your app won’t break during a first time deployment. Hooray!

TL;DR view()->share() with models works great until your database isn’t there. Use view composers instead.

Cave Story has Masterful Level Design

[youtube https://www.youtube.com/watch?v=c_0sjTBzCW0]

No doubt about it, Cave Story is one of the best games ever made.

This video is pretty spoiler-heavy, so if you’ve not played Cave Story, there’s a freeware version that’s been ported to almost everything, and if you want it on Steam, Nintendo 3DS, or other shops, you can pay for it too. The freeware version along with the fan translation is still the best choice though.

Pink Heaven out, Kero Blaster on Oct 11

Studio Pixel, infamous for indie smash hit Cave Story, released Pink Heaven for PC. It looks like it features the pink office lady from Pink Hour, the demo prologue game to Kero Blaster, an innovative frog-themed platform shooter.

Pink Heaven - Studio Pixel

Kero Blaster is an excellent game, extremely fun and rewarding, and doesn’t artificially lengthen playtime. For those who still couldn’t get enough, a New Game+ mode made it harder.

The iOS version of Pink Heaven will be released on October 11. Pixel is also giving Kero Blaster an update on the same day, adding ZANGYOU MODE (‘Overtime’ Mode). 

Because of the update, Studio Pixel is bumping the prices of the game up a buck or two, so go get the game while you still can!


Japanese ad informing of Kero Blaster price increase on Windows and iPhone