Skip to content

Instantly share code, notes, and snippets.

View nikitaeverywhere's full-sized avatar
🇺🇦
Just build it!

Nikita Savchenko nikitaeverywhere

🇺🇦
Just build it!
View GitHub Profile
/*
* This CSS describes the basics of trick to make CSS-only navigation.
* This type of navigation uses #anchors to switch pages.
* In this CSS anchor #page-main as well as empty anchor (#) describes the main page.
* Valid markup for this example:
* <div class="pages">
* <div class="page"> Page content 1 </div>
* <div class="page"> Page content 2 </div>
* </div>
*/
@nikitaeverywhere
nikitaeverywhere / getTableCell.js
Last active October 15, 2019 18:59
JavaScript function that returns the cell of the table by given coordinates considering colSpan and rowSpan of the cells.
/**
* 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++) {
@nikitaeverywhere
nikitaeverywhere / central.css
Last active August 29, 2015 14:20
Pure CSS solution for centering content always on middle center of parent relative block.
/*
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%;
@nikitaeverywhere
nikitaeverywhere / formatDate.js
Last active August 29, 2015 14:14
NodeJS date formatting function (appeared because NodeJS is not using the system locale and Date.toLocaleString gives unexpected result)
/**
* 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");
};
@nikitaeverywhere
nikitaeverywhere / gist:6310513
Last active December 21, 2015 13:09
SuperRegular expression for breaking Caché code to lexical parts. It can be improved! Supports ##class, $Method/$Var, $$MyMethod, $$$Macro, ^Global, ..ClassMethod, %SystemClass, "strings", 016175, {[()]}.
/**
* 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,