Skip to content

Instantly share code, notes, and snippets.

View vladkrasovsky's full-sized avatar
🇺🇦

Vlad Krasovsky vladkrasovsky

🇺🇦
  • Uman, Ukraine
View GitHub Profile
@vladkrasovsky
vladkrasovsky / consoleColors.js
Created February 11, 2023 11:30 — forked from abritinthebay/consoleColors.js
The various escape codes you can use to color output to StdOut from Node JS
// Colors reference
// You can use the following as so:
// console.log(colorCode, data);
// console.log(`${colorCode}some colorful text string${resetCode} rest of string in normal color`);
//
// ... and so on.
export const reset = "\x1b[0m"
export const bright = "\x1b[1m"
export const dim = "\x1b[2m"
@vladkrasovsky
vladkrasovsky / randomDarkColor.js
Created November 27, 2022 21:18 — forked from chak10/randomDarkColor.js
Javascript Random Dark Color
function randDarkColor() {
var lum = -0.25;
var hex = String('#' + Math.random().toString(16).slice(2, 8).toUpperCase()).replace(/[^0-9a-f]/gi, '');
if (hex.length < 6) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
var rgb = "#",
c, i;
for (i = 0; i < 3; i++) {
c = parseInt(hex.substr(i * 2, 2), 16);
@vladkrasovsky
vladkrasovsky / gist:0a433cd3f4928d4985aea207b31d7d03
Created July 2, 2022 19:46 — forked from igorpronin/gist:d1cdea867adc091668e78e5a6eba0a00
Как делать код-ревью, статья понравилась
https://toster.ru/q/276441
Отсюда, есть и другие рекомендации от др авторов.
Я когда делаю Code Review критерии следующие:
* Безопасность:
- Каждый аргумент метода простого типа должен проверяться на тип в случае его проксирования и на граничные значения в случае обработки. Чуть что не так - бросается исключение. Если метод с кучкой аргументов на 80% состоит из поверки из аргументов - это вполне норм))
- Никаких trigger_error, только исключения.
- Исключения ДОЛЖНЫ быть человеко-понятны, всякие "Something went wrong" можно отдавать пользователю, но в лог должно попасть исключение со стектрейсом и человеко-понятным описанием, что же там пошло не так.
- Каждый аргумент (объект) метода должен быть с тайпхинтингом на этот его класс, или интерфейс.
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid",
@vladkrasovsky
vladkrasovsky / .bash_aliases
Created February 8, 2022 21:47 — forked from helderco/.bash_aliases
Docker aliases
# Add to /etc/hosts
# 127.0.0.1 localhost docker.local db mail
alias docker-host="echo docker.local"
alias drun="docker run -it --rm"
# Docker Compose
alias dc="docker-compose"
@vladkrasovsky
vladkrasovsky / acfmap.js
Created February 12, 2021 09:22 — forked from anonymous/acfmap.js
Google maps api with advanced custom fields
(function($) {
/*
* render_map
*
* This function will render a Google Map onto the selected jQuery element
*
* @type function
* @date 8/11/2013
* @since 4.3.0
@vladkrasovsky
vladkrasovsky / ua-cities.json
Created February 10, 2021 18:05 — forked from alex-oleshkevich/ua-cities.json
Города Украины
[
{
"name": "Украина",
"regions": [
{
"name": "Автономная Республика Крым",
"cities": [
{
"name": "Алупка",
"lat": "44.4197222",
@vladkrasovsky
vladkrasovsky / webstoemp-gulpfile.js
Created February 1, 2019 07:34 — forked from jeromecoupe/webstoemp-gulpfile.js
Gulp 4 sample gulpfile.js. For a full explanation, have a look at https://www.webstoemp.com/blog/switching-to-gulp4/
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
@vladkrasovsky
vladkrasovsky / eyebrowser.jquery.js
Created April 16, 2018 08:00 — forked from gary-rafferty/eyebrowser.jquery.js
Quick jquery plugin to check navigator.userAgent string
(function($){
function getInternetExplorerVersion() {
var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer') {
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
@vladkrasovsky
vladkrasovsky / gh-pages-deploy.md
Created March 24, 2018 09:28 — forked from belohlavek/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. Here's how to do it:

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore (or skip and force-add afterwards).