classDiagram
class DataLayer{
+Map<key:String, AbstractDataSet> DataSet
}
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
| function sum(a: number, b: number): number { | |
| return a + b; | |
| } | |
| function ded(a: number, b: number): string { | |
| return (a * b).toFixed(2); | |
| } | |
| type CF = (...args: any[]) => any; | |
| type LastFnReturnType<T extends any[]> = ReturnType<T[0]>; |
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
| // recursive | |
| function tick(cnt = 0, duration=1000, callback:(cnt:number)=>void ){ | |
| if(cnt <= 0) return; | |
| setTimeout(() => { | |
| callback(cnt); | |
| tick(--cnt, duration, callback); | |
| }, duration); | |
| } | |
| // async |
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
| function ampm224(s) { | |
| const ampm = s.substr(-2) === 'PM'; | |
| const [hh, mm, ss] = s.split(':').map(x => parseInt(x, 10) ); | |
| const HH = ampm ? hh%12 + 12 : hh%12 | |
| return [HH, mm, ss] | |
| .map( x => x.toString().padStart(2, '0') ) | |
| .join(':') | |
| } | |
| //['12:00:00AM','12:00:00PM','07:10:00PM'].map( timeConversion ) | |
| //["00:00:00", "12:00:00", "19:10:00"] |
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
| function HammingDistance(a, b){ | |
| var HD = 0; | |
| var n = (a ^ b); | |
| // console.log(a.toString(2)); | |
| // console.log(b.toString(2)); | |
| // console.log(n.toString(2)); | |
| while(n){ | |
| HD = HD + n % 2; | |
| n = n >> 1; | |
| } |
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
| /* | |
| Sort array and set items from def at the beginning | |
| WORKS CORRECTLY FOR UNIQ ARRAYS ONLY! | |
| */ | |
| const x = ['a','s','d','f','g','j','h','k','p']; // desired order | |
| const y = ['a','h','f','y','d','q','p','k']; // what we have | |
| const z1 = y.concat().sort( (a,b) => x.indexOf(a) - x.indexOf(b)); |
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
| for (var i = 0; i < 10; i++) { | |
| var element = document.createElement('button'); | |
| element.innerHTML = '#' + i; | |
| document.body.appendChild(element); | |
| element.onclick = function(){ | |
| console.log(i); | |
| } | |
| } |
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
| boolSort: function(a, b, dt, sign){ | |
| return (!!a^0 - !!b^0) * sign; | |
| }, |
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 fontSZ = '14px' | |
| var nl = document.querySelectorAll('*'); | |
| var szs = {}; | |
| for(var i = 0; i < nl.length; i++){ | |
| var tagName = nl.item(i).tagName; | |
| if( (tagName !='SCRIPT') && (tagName != 'LINK') && (tagName != 'STYLE') ){ | |
| var sz = window.getComputedStyle(nl.item(i))['fontSize']; | |
| if(sz === fontSZ){ |
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
| function flatten(a){ | |
| return a.reduce(function(p, c){ | |
| if(Array.isArray(c)) { | |
| return p.concat(flattern(c)); | |
| } else { | |
| return p.concat(c); | |
| } | |
| }, []); | |
| } |