Skip to content

Instantly share code, notes, and snippets.

View DaniilVysotskiy's full-sized avatar

Daniil Vysotskiy DaniilVysotskiy

View GitHub Profile

Кунг-фу на клавиатуре. Искусство сочетать клавиши


Сочетания клавиш для тех, кто хочет войти в IT и не только.


Содержание

const createLogger = (backgroundColor, color) => {
const logger = (message, ...args) => {
if (logger.enabled === false) {
return;
}
console.groupCollapsed(
`%c${message}`,
`background-color: ${backgroundColor}; color: ${color}; padding: 2px 4px;`,
...args
@utlime
utlime / text-mask-cadastral-number.js
Last active November 21, 2024 13:39
Маска ввода для кадастрового номера (text-mask/cadastral-number)
TextMask.maskInput({
inputElement: document.querySelector("input[name = cadastral_number]"),
mask: function(rawValue) {
var mask = [/\d/, /\d/, ":", /\d/, /\d/, ":"];
var chunks = rawValue.replace(/\_/g, "").split(":");
var i;
for (i = 0; (!chunks[2] || i < chunks[2].length) && i < 7; i++) {
mask.push(/\d/);
}
@magnetikonline
magnetikonline / README.md
Last active January 29, 2024 23:26
An example of recursion with Promises - reading recursive directories.

An example of recursion with Promises

A pattern for recursion with Promises - in this example, walking a directory structure.

Function flow

  • readDirRecursive() is called with a starting directory and will itself return a Promise.
  • Internally readDir() is called and passed starting directory to read from.
  • A list of directory items is returned by getItemList() as a Promise, which in turn is chained to getItemListStat() to stat each item to determine if file or directory.
  • Finalised list then passed to processItemList():
@JKirchartz
JKirchartz / html5 notepad
Created November 26, 2011 03:28
simple html5 Notepad, saves in localStorage, but you can only have one note at a time.
<!DOCTYPE html>
<html><head><meta charset="UTF-8">
<title>HTML5 notepad app</title>
<meta charset="utf-8">
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<style>
html,body{background:#FCFCFC;color:#444;height:100%;width:100%;margin:0;padding:0;}
#notepad{height:98%;width:98%;padding:1%;font-size:100%;line-height:125%;font-family:san-serif}
::selection{background:#7D7}
::-moz-selection{background:#7D7}