This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Snippets collected during development: made by myself or found on StackOverflow/GitHub. | |
| * Collection will grow in time. | |
| * Enjoy. | |
| */ | |
| // --- removing duplicates from an array --- | |
| [2, 4, 5, 2, 6, 4].filter((el, i, arr) => arr.indexOf(el) === i); | |
| [2, 4, 5, 2, 6, 4].reduce((acc, curr) => acc.includes(curr) ? acc : [...acc, curr], []); | |
| [2, 4, 5, 2, 6, 4].reduce((acc, curr) => acc.includes(curr) ? acc : acc.concat(curr), []); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Snippets collected during development: made by myself or found on StackOverflow/GitHub. | |
| * Collection will grow in time. | |
| * Enjoy. | |
| */ | |
| // --- running each function in an array --- | |
| const tab = [(a) => console.log(a), | |
| (a) => console.log(a+a), | |
| (a) => console.log(a-a)]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const a = undefined; | |
| // 1 | |
| if (typeof a === 'Function') a(); | |
| // 1 with jQuery | |
| if ($.isFunction(a)) a(); | |
| // same in Lodash -> _.isFunction | |
| // 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/gojs/1.8.12/go.js"></script> | |
| </head> | |
| <body> | |
| <div id="diagram-content" style="height: 800px; border: 1px solid black;"></div> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diagram = (function(){ | |
| var $ = go.GraphObject.make; | |
| var diagram; | |
| var initDiagram = function () { | |
| diagram = $(go.Diagram, | |
| 'diagram-content', { | |
| initialContentAlignment: go.Spot.Center | |
| }); | |
| } | |
| return { initDiagram }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diagram.model = $(go.GraphLinksModel, { | |
| nodeDataArray: [ | |
| {key: 1, category: 'first'}, | |
| {key: 2, category: 'second'}, | |
| {key: 3, category: 'second'}, | |
| {key: 4, category: 'third'} | |
| ], | |
| linkDataArray: [ | |
| {from: 1, to: 2}, | |
| {from: 2, to: 3}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diagram.nodeTemplate = $(go.Node, 'Auto', $(go.Shape, 'Circle')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diagram.nodeTemplate = $(go.Node, | |
| 'Auto', | |
| $(go.Shape, { | |
| geometryString: 'F M0 0 L100 0 Q150 50 100 100 L0 100 Q50 50 0 0z', | |
| fill: 'white', | |
| width: 100, | |
| height: 100 | |
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diagram.nodeTemplate = $(go.Node, | |
| 'Vertical', | |
| $(go.Shape, | |
| 'Rectangle', { | |
| width: 50, | |
| height: 50, | |
| strokeWidth: 0, | |
| fill: 'yellow', | |
| }), | |
| $(go.Shape, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var getTemplates = function () { | |
| return [{ | |
| category: 'first', | |
| template: $(go.Node, 'Auto', $(go.Shape, 'Circle')) | |
| }, { | |
| category: 'second', | |
| template: $(go.Node, | |
| 'Auto', | |
| $(go.Shape, { | |
| // ... |
OlderNewer