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 blankLinesPattern = /^\s+$/gm; // the only regex that works fine | |
| const blankLinesRegex = new RegExp(blankLinesPattern); | |
| const data = `900,10,1,1,1,1,1,1,1,1,1,1 | |
| 100,2,1,1,1,2,1,2,1,1,1,1 | |
| `; | |
| var match; | |
| while (!!(match = blankLinesPattern.exec(data))) { |
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
| import { Subject, Observable, ConnectableObservable, from, interval } from 'rxjs'; | |
| import { multicast, refCount } from 'rxjs/operators'; | |
| // https://rxjs-dev.firebaseapp.com/guide/subject | |
| // { | |
| // console.log(`UNICAST VS MULTICAST`); | |
| // const subject = new Subject<number>(); | |
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 trimCanvas = (function() { | |
| function rowBlank(imageData, width, y) { | |
| for (var x = 0; x < width; ++x) { | |
| if (imageData.data[y * width * 4 + x * 4 + 3] !== 0) return false; | |
| } | |
| return true; | |
| } | |
| function columnBlank(imageData, width, x, top, bottom) { | |
| for (var y = top; y < bottom; ++y) { |
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
| // resolve after 500msec. | |
| of(null).pipe(delay(500)); | |
| // reject after 600msec. | |
| function makeRequest(timeToDelay) { | |
| return of('Request Complete!').pipe(delay(timeToDelay)); | |
| } | |
| return of(600) |
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 arr = [{name: 'Bill', age: 26}, {name: 'Sara', age: 42}, {name: 'Tom', age: 13}]; | |
| const namesArray = arr.map(({age, ...keepAttrs}) => keepAttrs); // removes `age` | |
| console.log(namesArray); |
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 getRejectedPromise() { | |
| const promise = new Promise((resolve, reject) => { | |
| reject('some error'); | |
| }); | |
| return promise; | |
| } | |
| let counter = 0; | |
| const interval = setInterval(() => { | |
| if (++counter > 10) clearInterval(interval); |
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
| interface Options { | |
| a?: string; | |
| b?: number; | |
| c?: Array<any> | |
| } | |
| const fullOptions = {a: 'a-full', b: 100, c: ['a-full', 100, null]}; | |
| const partialOptionsA = {a: 'a-1'}; | |
| const partialOptionsB = {b: 200}; | |
| const partialOptionsC = {c: ['a-2', 300, null]}; |
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
| let str = '123QWEqwe#$\\g/cm³' | |
| let result = str.replace(/[^A-Za-z0-9\p{No}]/g, ''); |
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
| btn - Button | |
| cb - CheckBox | |
| cbl - CheckBoxList | |
| dd - DropDownList | |
| hl - Hyperlink | |
| img - Image | |
| ib - ImageButton | |
| lbl - Label | |
| lnk - Link | |
| lbtn - LinkButton |
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
| 'use strict'; | |
| /** | |
| * isNumeric(n) returns a bool value | |
| * is "n" number or not | |
| * | |
| * @param {Number} n | |
| * @return {Bool} result | |
| */ | |
| function isNumeric(n) { |