Skip to content

Instantly share code, notes, and snippets.

View mtoso's full-sized avatar

Mattia Toso mtoso

View GitHub Profile
@mtoso
mtoso / machine.js
Last active September 30, 2019 03:09
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@mtoso
mtoso / Dummy.js
Last active May 7, 2019 23:52
webpack-render-module
var constructor = function(params) {
RenderModule.call(this, constructor, params);
};
constructor.FX2RenderModuleName = 'Dummy';
constructor.init = function() {
return RenderModule.init(Utils.resolveUrl('./render.js'), constructor);
};
@mtoso
mtoso / test.js
Last active October 2, 2021 11:16
Unit Test Template
import test from 'tape';
// For each unit test you write,
// answer these questions:
test('What component aspect are you testing?', assert => {
const actual = 'What is the actual output?';
const expected = 'What is the expected output?';
assert.equal(actual, expected,
'What should the feature do?');
@mtoso
mtoso / package.json
Created September 16, 2015 16:20
Node ES6 scripts
"scripts": {
"lint": "eslint source",
"clean": "rm -rf build/* && mkdir build/public && mkdir build/server && mkdir build/client",
"build-server": "babel -d build/server source/server -s",
"build-client": "browserify source/client/index.js -t babelify --outfile build/client/bundle.js",
"build": "npm run clean && npm run build-server && npm build-client"
}
@mtoso
mtoso / speedtest
Last active August 29, 2015 14:23
A simple javascript class for speed testing
var SpeedTest = function(testImplement,testParams,repetitions){
this.testImplement = testImplement;
this.testParams = testParams;
this.repetitions = repetitions || 10000;
this.average = 0;
};
SpeedTest.prototype = {
startTest: function(){
if( this.testImplement( this.testParams ) === false ){