Angular Attack 2016 Post Mortem
(This is an opinion-based article an in no way reflects the views of Platform45)
This weekend, a few colleagues and I got together and participated in the first annual Angular Attack, a 48 virtual programming competition, in which we built an app using Angular 2.0. Our app, "espy", is a status board with the aim of aggregating data over multiple software development projects and displaying it on a screen with shiny graphs. We got pretty far with our app, and I'm personally very impressed with what the team managed to achieve in such a short amount of time using a brand new framework that none of us had really had much experience in.
Achievement unlocked! Check out my quick-and-dirty WebSocket/WebGL game here.
This weekend, I achieved a number of goals I have had for myself as a developer.
First and foremost, I wrote a real-time network-enabled multiplayer game. This is something I've always wanted to do. Earlier multiplayer games I wrote were keyboard-sharing and/or hotseat games. My first network-enabled game was a turn-based TCP battleships game I wrote for a second year university project. Later, I made an attempt at a real-time networked game (using TCP and then UDP), which was an abysmal failure. This weekend I decided to use WebSockets and it turned out great.
The Whys and Woes.
There has to be a reason (or multiple) why I decided to abandon my previous, working, blogging platform (Octopress) for a custom, built-from-scratch one.
From time to time I find myself needing to test some method that deals with the file system. It's a tricky business, and there are a number of ways to go about it. Here, I'll go through a few I've looked at in the past and sum up how I feel about them.
1. Stubbing the File System
As with any interaction with the outside world, one would naturally just stub the whole thing out, or at least the bits of it that you use.
Given this method:
Ruby has a couple of random selection functions, including
Array#shuffle. I thought I'd compare their performance, for interest's sake.
rand function by default returns a randomly-generated floating point number between 0.0 and 1.0. The
Array#sample method returns a random element from the array it is called on. The
Array#shuffle method shuffles the array's contents and is notoriously slow for random selection purposes. I'm throwing it in here just to demonstrate how slow it actually performs.
The proposed methods being benchmarked are
- Good old rand:
(rand * (N-M)).to_i + M
- Rand with integer:
rand(N-M) + M
- Rand with range:
- Sample from range:
- Sample from array:
a = (M...N).to_a...
- Shuffle and first:
a = (M...N).to_a...
This last weekend I created a github project, picked the autogenerated name, and proceeded to create Furry Dangerzone.
Three and a half hours after getting familiar with Gosu I had a playable game. 24 hours later I had a polished game. ~48 hours later I had an optimsed, somewhat bug-free game. Since then I've been improving it here and there.
It's flappy-bird-esque: space to jump, don't touch the stars or the edges.
Today I was listening to music on my mac at work, and wondered if there was a way to adjust iTunes volume with a shortcut key. Turns out there isn't one unless iTunes is in focus, and iTunes is generally not in focus.
So what's the reason for this? No particular reason, but I did figure out a way, and I thought I'd share it.
I grabbed some code from Doug who has iTunes-related AppleScripts on his website. I then proceeded to plonk the code into a couple of Automater services. The two scripts are as follows:
Check out my literate programming implementation called WEBdown.
In my three years of studying computer science, I think Donald Knuth was mentioned by a lecturer approximately once. Seeing as he is one the greatest (if not the greatest) figures in the world of computer science and software engineering today, I find this somewhat sad. He has only really influenced the stundents indirectly through the mandatory use of LaTeX that was introduced in third year and forced from honours level onwards. Still, I hardly think more than a handful of us even know the origins of LaTeX. Most of the students actively despise it, preferring to use Microsoft Word or Adobe InDesign, for which they are punished. Anyways this post isn't a rant about LaTeX, but rather about something far less known and far more interesting (in my opinion). It's about something I stumbled upon last week called Literate Programming.
Pretty much anybody who knows anything about web design these days ought to know what responsive web design is (I'm pretty new to the game and I know what it is). For those who don't know what responsive web design is, it's where you design a website in such a way that it automatically adjusts the layout based on the size of the surface it is drawn on. The idea is that the website will be fit for phone, tablet and desktop without having to redirect to a special "m.example.com" for mobile users.
To test responsiveness of a website, you don't have to break open your phone (although you could, and an easy way to do so would be to use my "brilliant" QR-This app). Rather, you can simply drag your browser window into the size of a phone screen and watch the magic happen.
The first webapp that I shall consider "completed", is this silly little thing that uses antiquated technology to do something for which there are already much better and more useful applications. The antiquated technology I am referring to is the ever-present QR Code. The something I'm doing with it is providing a means to easily transfer URLs from your computer to your phone. The app I created is called QR This!
Since I recently switched from Chrome to Safari (since the new Safari is less memory intensive), I found myself unable to simply access my tabs from my Android phone. This is quite a feature loss, and might just pull me back to using Chrome, but for now I needed some way of getting URLs accross without typing the whole thing in again or emailing them to myself. At the time Googling "Online QR code generator" got me websites that allowed me to insert any text and convert it into a QR code, which i could then snap with my phone's built-in scanner.