Skip to content

Instantly share code, notes, and snippets.

@agmcleod
agmcleod / melonjs-ecs.md
Last active April 10, 2017 02:14
MelonJS ECS Proposal

Melonjs ECS proposal

After working with unity a fair bit, I've come to appreciate the modular code base. Components have an expected api, and provide a single thing to the parent object or entity.

The problems with the current setup.

  • It can be hard to know what objects you need. Renderable/Sprite/Animation Sheet
  • Entity is the only thing that has physics, defaults to an animation sheet.
  • Sprite is the only thing that provides scale and rotation, plus subclasses
@agmcleod
agmcleod / .eslintrc
Last active August 29, 2015 14:26
React/JSX/ES6 setup.
{
"ecmaFeatures": {
"arrowFunctions": true,
"blockBindings": false,
"classes": true,
"forOf": true,
"jsx": true,
"modules": true,
"objectLiteralShorthandMethods": true
},
@agmcleod
agmcleod / gist:62b702269f2f18aeece5
Created April 13, 2015 15:49
State name to abbreviation ruby hash map
states = { "Alaska" => "AK",
"Alabama" => "AL",
"Arkansas" => "AR",
"American Samoa" => "AS",
"Arizona" => "AZ",
"California" => "CA",
"Colorado" => "CO",
"Connecticut" => "CT",
"District of Columbia" => "DC",
"Delaware" => "DE",
# config valid only for current version of Capistrano
lock '3.3.5'
set :application, 'desert'
set :repo_url, 'git@github.com:agmcleod/dune.git'
set :assets_roles, [:web, :app]
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
class DataSource {
createSchema () {
var connection = this.getConnection();
this.transaction(connection).then((tx) => {
tx.executeSql("CREATE TABLE IF NOT EXISTS interactions (id integer PRIMARY KEY, start_date varchar(50), end_date varchar(50), first_name varchar(100), last_name varchar(100), email varchar(150))");
}).catch(() => {
console.log("Could not create table");
});
}
<platform name="ios">
<!-- iOS 8.0+ -->
<!-- iPhone 6 Plus -->
<icon src="res/ios/Icon-60@3x.png" width="180" height="180" />
<!-- iOS 7.0+ -->
<!-- iPhone / iPod Touch -->
<icon src="res/ios/Icon-60.png" width="60" height="60" />
<icon src="res/ios/Icon-60@2x.png" width="120" height="120" />
<!-- iPad -->
<icon src="res/ios/Icon-76.png" width="76" height="76" />
@agmcleod
agmcleod / angular.html
Last active August 29, 2015 14:16
Dynamic list
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, maximum-scale=1.0" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
<div ng-app="myapp">
@agmcleod
agmcleod / test.js
Created October 29, 2014 12:56
Testing cocoon js RAF
var me = {};
(function () {
/**
* Convert first character of a string to uppercase, if it's a letter.
* @ignore
* @function
* @name capitalize
* @param {String} str Input string.
* @return {String} String with first letter made uppercase.
//
// BarcodeViewController.m
// HSTestApp
//
// Created by McLeod, Aaron on 2014-08-14.
// Copyright (c) 2014 McLeod, Aaron. All rights reserved.
//
#import "BarcodeViewController.h"
#import "HTMLViewHelper.h"
if (me.video.isCanvas()) {
var context = renderer.getContext();
context.strokeStyle = "red";
context.lineWidth = 2;
context.strokeRect(x, y, width, height);
}
else {
renderer.setColor("red");
renderer.strokeRect(x, y, width, height);
}