Skip to content

Instantly share code, notes, and snippets.

View kristianmandrup's full-sized avatar

Kristian Mandrup kristianmandrup

  • Freelancer
  • Copenhagen
View GitHub Profile
@kristianmandrup
kristianmandrup / aurelia-started.md
Last active February 22, 2017 16:15
Aurelia Getting started - walk through

Aurelia

Recipe

  • Install NVM
  • Install IO.js
  • Install global Node.js utility modules (gulp, jspm, yo)
  • Install RethinkDB
  • Install Koa.js
  • Install Aurelia generator
  • Create Aurelia app via generator
let testCall = async () => {
return await _.callApi(route + '/rate', 'POST', requests.rate);
}
test('route: components')
.that('POST component rating')
.will('add a rating to the component', async () => {
check.ratingAdded(testCall());
})
.will('NOT add a second rating to the component for the same user', async () => {
@kristianmandrup
kristianmandrup / dsl.js
Last active October 16, 2016 13:51
Improved Javascript testing DSL
require('babel-core/register');
require('babel-polyfill');
const chai = require('chai');
chai.should();
class Tester {
constructor(parent, text, opts) {
this.parent = parent;
this.text = text;

Artefact file structure

artefact.json
map.json
/view-models
/services
/ui
/preview
/fakes
@kristianmandrup
kristianmandrup / push-react.js
Last active September 15, 2016 08:59
Push.js used by Ratchet made more flexible in order to play well with React Virtual DOM strategy
/* ========================================================================
* Ratchet: push.js v2.0.2
* http://goratchet.com/components#push
* ========================================================================
* inspired by @defunkt's jquery.pjax.js
* Copyright 2014 Connor Sears
* Licensed under MIT (https://github.com/twbs/ratchet/blob/master/LICENSE)
* ======================================================================== */
/*
@kristianmandrup
kristianmandrup / app-alt.ts
Last active August 1, 2016 22:31
Indexable routes
// alternative way
ChildRouteLocator.prototype.convertInstructionToConfigurationUrl = (instruction) => {
};
Folder structure of app
app
models
decorators
- typically used to decorate a model with client side functionality
validators
- for validate middleware, one per model
routes
@kristianmandrup
kristianmandrup / React Reactive Component Styles.md
Last active March 31, 2016 14:28
Reactive Component Styles for React
export default Styles {
    constructor(props, state) {
        this.props = props;
        this.state = state;
        this.createGeneric()
    }

    generic() {
        return [];
@kristianmandrup
kristianmandrup / loader.md
Created November 23, 2013 09:13
App Loader

models/loader.ls

loads all files under models dir into app.Models namespace

models/validators/loader.ls

loads all files under validators dir into app.Model.Validator namespace

routes/validators/loader.ls

# namespaces.js
# Contains top level app namespaces
exports.do =
Models: {}
Controllers: {}
new-ns: (ns) ->
# split on "." and add recursively to self
var nsParts = namespace.split("."),