Skip to content

Instantly share code, notes, and snippets.

View vladkrasovsky's full-sized avatar
🇺🇦

Vlad Krasovsky vladkrasovsky

🇺🇦
  • Uman, Ukraine
View GitHub Profile
@meeglos
meeglos / Fix PHP validation executable
Created September 28, 2021 16:30
VS Code PHP validation executable Laravel Sail
- In VS Code settings, search for settings.json:
"php.validate.executablePath": "/usr/local/bin/php"
- Edit the file:
sudo nano /usr/local/bin/php
Paste the code:
path=$(printf '%s\n' "${PWD##*/}")
command="docker exec ${path}_laravel.test_1 php "$@""
echo "Running php on docker ${path}_laravel.test_1"
$command
@yidas
yidas / js-nl2br-br2nl.md
Last active November 26, 2024 15:05
JavaScript nl2br & br2nl functions

JavaScript nl2br & br2nl functions

The exchange of new line & br HTML tag could refer to PHP - nl2br() function, which uses to inserts HTML line breaks before all newlines in a string.

These JavaScript functions consider whether to use insert or replace to handle the swap.

nl2br

@jeromecoupe
jeromecoupe / webstoemp-gulpfile.js
Last active April 11, 2025 08:17
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");
@igancev
igancev / deployer.php
Created December 21, 2017 09:34
deployer-yii2-advanced
<?php
namespace Deployer;
require 'recipe/yii2-app-advanced.php';
/*
* Configuration
*/
set('bin/php', '/opt/php70/bin/php');
@anschaef
anschaef / bootstrap-4-sass-mixins-cheat-sheet.scss
Last active April 12, 2024 08:49
Bootstrap 4 Sass Mixins [Cheat sheet with examples]
/* -------------------------------------------------------------------------- */
// All Bootstrap 4 Sass Mixins [Cheat sheet]
// Updated to Bootstrap v4.5.x
// @author https://anschaef.de
// @see https://github.com/twbs/bootstrap/tree/master/scss/mixins
/* -------------------------------------------------------------------------- */
/*
// ########################################################################## */
// New cheat sheet for Bootstrap 5:
@vishin-pavel
vishin-pavel / yii2 autocomplete with id
Created May 19, 2017 07:32
Автокоплит инпут для Yii2 с возмоностью использовать Id вместо значения
<?php
//http://stackoverflow.com/questions/25708344/yii2-autocomplete-save-the-id-instead-of-value
use yii\web\JsExpression;
use yii\jui\AutoComplete;
$data = Company::find()
->select(['name as value', 'name as label','c_id as id'])
->asArray()
->all();
@abritinthebay
abritinthebay / consoleColors.js
Last active April 2, 2025 07:34
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"
@igorpronin
igorpronin / gist:d1cdea867adc091668e78e5a6eba0a00
Last active January 29, 2025 12:26
Как делать код-ревью, статья понравилась
https://toster.ru/q/276441
Отсюда, есть и другие рекомендации от др авторов.
Я когда делаю Code Review критерии следующие:
* Безопасность:
- Каждый аргумент метода простого типа должен проверяться на тип в случае его проксирования и на граничные значения в случае обработки. Чуть что не так - бросается исключение. Если метод с кучкой аргументов на 80% состоит из поверки из аргументов - это вполне норм))
- Никаких trigger_error, только исключения.
- Исключения ДОЛЖНЫ быть человеко-понятны, всякие "Something went wrong" можно отдавать пользователю, но в лог должно попасть исключение со стектрейсом и человеко-понятным описанием, что же там пошло не так.
- Каждый аргумент (объект) метода должен быть с тайпхинтингом на этот его класс, или интерфейс.
@mikedamoiseau
mikedamoiseau / backup-db.sh
Last active November 27, 2022 07:23
Script to backup a MySQL database and send the dump by email and/or scp
#!/bin/bash
# ----------------------------------
# DEFINED - Global variables
# ----------------------------------
# defined temporary folder
DBBACKUP="dbbackup"
# database configure