This file contains 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
/** | |
* Code snippet for students ^^ | |
* Tarnavsky used this function to find t^-1 from prime number t and m. | |
* Usage: var tMinusOne = getRevT(m, t); | |
* Test case 1: getRevT(121, 5) === 97 | |
* Test case 2: getRevT(9, 7) === 13 | |
*/ | |
function getRevT (m, t) { | |
function stage (a, b) { | |
var r = a % b, q = Math.floor(a/b); |
This file contains 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
/** | |
* Returns the cell of the table by given (x;y) coordinates considering colSpan and rowSpan of the cells. | |
* @param {HTMLElement} table - HTML table | |
* @param {number} x - X position in table matrix | |
* @param {number} y - Y position in table matrix | |
* @returns {HTMLElement|null} | |
*/ | |
var getTableCell = function (table, x, y) { | |
var m = [], row, cell, xx, tx, ty, xxx, yyy; | |
for(yyy = 0; yyy < table.rows.length; yyy++) { |
This file contains 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
/* | |
Pure CSS solution for centering content always on middle center of parent relative block. | |
*/ | |
.central { | |
position: absolute; | |
left: 0; | |
top: 0; | |
width: 100%; | |
height: 100%; |
This file contains 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
/** | |
* Converts any date to "DD.MM.YYYY, hh:mm:ss" string. | |
* Workaround for NodeJS Date.toLocaleString implementation. | |
* | |
* @param {Date} date - Date to format. | |
* @returns {string} - Formatted date string. | |
*/ | |
var formatDate = function (date) { | |
return date.toISOString().replace(/(\d+)\-(\d+)\-(\d+)T\s?([^\.]*)\..*/, "$3.$2.$1, $4"); | |
}; |
This file contains 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 breaks code for parts with span tags and according styles, but skips &*; html-symbol combinations and tag <br> | |
* | |
* @param string | |
* String to parse. | |
* @returns {string} | |
* Parsed string. | |
*/ | |
this.highlightHTML = function(string) { | |
return string.replace(/(\/\*.*?(?=\*\/)\*\/)|([0-9]+\.?[0-9]+?)|(((<|&|&#)|(\^%?)|\/|\${0,3}|#{0,2}|%|\.|(\.\.))?[A-Za-z0-9]+[;>]?)|[{}\]\[\(\)!_'\\#\?\+\-\*\/=<>,]|("[^"]*")/g, |
NewerOlder