Skip to content

Instantly share code, notes, and snippets.

View simonexmachina's full-sized avatar

Simon Wade simonexmachina

  • Melbourne, Australia
View GitHub Profile
@simonexmachina
simonexmachina / order-states.yaml
Last active August 29, 2015 14:11
Edits can be made here: http://code.stypi.com/aexmachina/order-states (but Stypi doesn't support YAML syntax)
root:
initialState: unpaid
actions:
- recomputeState() # throws Exception if 0 > paid || paid > total
# see comments on states below
- addItem(item) # then recomputeState
- payment(amount) # then recomputeState
- refund(amount[, transaction]) # then recomputeState
# if refunding line items then refund amount may be computed from
# adjustedTotal, and do we care what items a manual discount
@simonexmachina
simonexmachina / app.css.map
Created October 20, 2014 09:43
Source map example
{
"version": 3,
"file": "dashboard.css",
"sources": ["..\/..\/..\/app\/styles\/app.scss","..\/..\/..\/bower_components\/foundation\/scss\/foundation\/_functions.scss","..\/..\/static_compiler-tmp_dest_dir-cDHiEGco.tmp\/attic\/_variables.scss","..\/..\/static_compiler-tmp_dest_dir-cDHiEGco.tmp\/attic\/_foundation-settings.scss","..\/..\/..\/bower_components\/foundation\/scss\/foundation\/components\/_grid.scss","..\/..\/..\/bower_components\/foundation\/scss\/foundation\/components\/_accordion.scss","..\/..\/..\/bower_components\/foundation\/scss\/foundation\/components\/_alert-boxes.scss","..\/..\/..\/bower_components\/foundation\/scss\/foundation\/components\/_block-grid.scss","..\/..\/..\/bower_components\/foundation\/scss\/foundation\/components\/_buttons.scss","..\/..\/..\/bower_components\/foundation\/scss\/foundation\/components\/_dropdown.scss","..\/..\/..\/bower_components\/foundation\/scss\/foundation\/components\/_dropdown-buttons.scss","..\/..\/..\/bower_components\/foundation\/scss\/foundati
@simonexmachina
simonexmachina / README.md
Last active August 29, 2015 14:06
offlien-data readme

offline-data

A general-purpose, minimal solution for offline-first data access.

This module consists of two components for achieving offline capability, a DataCache for reads and an UpdateQueue for writes:

  • DataCache is a cache for HTTP (GET) data, backed by a PouchDB database that's continuously synced from a remote master database so that the cache contains all your data when you're offline.
  • UpdateQueue is a persistent queue for HTTP (POST and PUT) requests that will handle queing requests to the server and sending them when a connection becomes available.

DataCache

[email protected] node_modules/ember-cli/node_modules/bower/node_modules/junk
[email protected] node_modules/ember-cli/node_modules/bower/node_modules/stringify-object
[email protected] node_modules/ember-cli/node_modules/bower/node_modules/chalk/node_modules/supports-color
[email protected] node_modules/ember-cli/node_modules/bower/node_modules/update-notifier/node_modules/configstore/node_modules/object-assign
npm WARN unmet dependency /Users/simonwade/Temp/npm-test/node_modules/ember-cli/node_modules/bower/node_modules/bower-json requires graceful-fs@'~2.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
[email protected] node_modules/ember-cli/node_modules/bower/node_modules/bower-json/node_modules/intersect
[email protected] node_modules/ember-cli/node_modules/bower/node_modules/insight/node_modules/request/node_modules/http-signature/node_modules/assert-plus
npm WARN unmet dependency /Users/simonwade/Temp/npm-test/node_modules/ember-cli/node_mod
@simonexmachina
simonexmachina / changes.diff
Last active August 29, 2015 14:04
token-auth adapter
diff --git a/modules/token-auth/models/UserInterface.js b/modules/token-auth/models/UserInterface.js
index ff14924..39e88a1 100644
--- a/modules/token-auth/models/UserInterface.js
+++ b/modules/token-auth/models/UserInterface.js
@@ -44,3 +44,17 @@ UserInterface.findByUsername = function(username) {};
@return Promise A promise that yields an instance
*/
UserInterface.findById = function(id) {};
+
+/**
@simonexmachina
simonexmachina / instructions.md
Last active August 29, 2015 14:04
Instructions for using source maps with broccoli-sass

We're currently working on making this just work, but in the interim you can use the following instructions.

Source Maps

You can enable source maps by setting sourceMap: true in the options, but it's likely that your SASS source files aren't in the output tree (and hence are not available to your dev tools over HTTP), so you'll need to tell your dev tools where to find the source files:

Instructions for Chrome

### Keybase proof
I hereby claim:
* I am aexmachina on github.
* I am aexmachina (https://keybase.io/aexmachina) on keybase.
* I have a public key whose fingerprint is C99E 8EA3 9A10 90C7 5D71 6D67 D63F 6167 31A6 C4BD
To claim this, I am signing this object:
@simonexmachina
simonexmachina / file-upload.js
Created May 30, 2014 08:42
File uploads in Node.js
var multiparty = require('multiparty'),
mkdirp = require('mkdirp'),
path = require('path'),
fs = require('fs');
module.exports = function handleFileUpload(req, res, saveDir, cb) {
var form = new multiparty.Form();
mkdirp(saveDir, function(err) {
if (err) return cb(err);
form.parse(req, function(err, fields, files) {
@simonexmachina
simonexmachina / code.md
Created May 19, 2014 02:06
BaseController

OrganisationsController

This is a sketch of what we want:

var Proto = require('uberproto'),
    resource = require('express-resource');

// in controllers/organisations.js
module.exports = function(app) {
@simonexmachina
simonexmachina / post.md
Created May 8, 2014 23:17
JavaScript and Object Models

JavaScript and Object Models

A "choose your own adventure" story

JavaScript is has both object-oriented and functional heritage, thanks to its two parents: Scheme and Self.

It provides first class functions and makes it simple to compose these function objects into bundles of awesome. Even though I'm an OO "true believer" at heart, I find myself composing my code using functional concepts, and use the OO approach where there's a clear benefit or where I feel that it's the best way to communicate the interface.

Object-oriented software design is by no means the only way to do software design, but it's been an immensely successful model for a very long time now, and provides a clear and well-understood mental model for thinking and communicating about software. Lots of good ideas like encapsulation, delegation, traits and composition fit well into OO design.