Skip to content

Instantly share code, notes, and snippets.

View tswistak's full-sized avatar

Tomasz Świstak tswistak

View GitHub Profile
@tswistak
tswistak / diagram.js
Created June 12, 2018 09:06
GoJS tutorial part 2, listing 1
$(go.Node, 'Auto',
$(go.Shape,
'Circle', {
width: 100,
height: 100,
fill: 'white'
}),
$(go.Shape,
'Rectangle', {
portId: '',
@tswistak
tswistak / diagram.js
Last active June 13, 2018 12:28
GoJS tutorial part 2, listing 2
$(go.Node,
'Spot',
$(go.Shape, {
// ...
}),
$(go.Shape,
'Rectangle', {
portId: 'entry',
width: 20,
height: 20,
@tswistak
tswistak / diagram.js
Created June 12, 2018 09:07
GoJS tutorial part 2, listing 3
diagram.model = $(go.GraphLinksModel, {
linkFromPortIdProperty: 'fromPort',
linkToPortIdProperty: 'toPort',
nodeDataArray: [
// ...
],
linkDataArray: [
{from: 1, to: 2, toPort: 'entry'},
{from: 2, to: 3, fromPort: 'exit', toPort: 'entry'},
{from: 1, to: 3, toPort: 'entry'},
@tswistak
tswistak / index.html
Created June 18, 2018 09:02
GoJS tutorial part 3, listing 1
<div id="palette-content" style="height: 800px; width: 200px; display: inline-block; border: 1px solid black"></div>
<div id="diagram-content" style="height: 800px; width: calc(100% - 220px); display: inline-block; border: 1px solid black;"></div>
<script>
window.onload = function() {
diagram.initDiagram();
diagram.initPalette();
};
</script>
@tswistak
tswistak / diagram.js
Created June 18, 2018 09:04
GoJS tutorial part 3, listing 2
var initDiagram = function () {
diagram = $(go.Diagram,
'diagram-content', {
initialContentAlignment: go.Spot.Center,
allowDrop: true
});
// ...
}
var initPalette = function () {
palette = $(go.Palette, 'palette-content');
@tswistak
tswistak / diagram.js
Created June 18, 2018 09:04
GoJS tutorial part 3, listing 3
diagram.grid.visible = true;
diagram.toolManager.draggingTool.isGridSnapEnabled = true;
diagram.toolManager.draggingTool.gridSnapCellSize = new go.Size(50, 50);
@tswistak
tswistak / diagram.js
Created June 18, 2018 09:05
GoJS tutorial part 3, listing 4
diagram = $(go.Diagram,
'diagram-content', {
initialContentAlignment: go.Spot.Center,
allowDrop: true,
layout: $(go.LayeredDigraphLayout)
});
@tswistak
tswistak / tuples.ts
Created July 30, 2018 06:10
TypeScript 3.0, listing 1
type Triple = [string, number, boolean];
const a: Triple = ['a', 2, false];
@tswistak
tswistak / tuples.ts
Created July 30, 2018 06:10
TypeScript 3.0, listing 2
type StringAndNumbers = [string, ...number[]];
const b1: StringAndNumbers = ['a', 1, 2, 3];
const b2: StringAndNumbers = ['a'];
@tswistak
tswistak / tuples.ts
Created July 30, 2018 06:11
TypeScript 3.0, listing 3
type Strings = [...string];
type Empty = [];
const c1: Strings = ['a', 'b'];
const c2: Strings = [];
const c3: Empty = [];
const c4: Empty = ['a', 'b']; // invalid type