Skip to content

Instantly share code, notes, and snippets.

View Nex-Otaku's full-sized avatar

Леонид Черненко Nex-Otaku

View GitHub Profile
@Nex-Otaku
Nex-Otaku / Daily-fucking-greate-advice.md
Last active May 17, 2023 10:01
Устанавливаем "ох..нный совет" на приветствие в консоли

Каждый раз открывая консоль получаем ох*нный совет

1. Устанавливаем httpie — аналог curl

https://httpie.io/

curl -SsL https://packages.httpie.io/deb/KEY.gpg | apt-key add -
curl -SsL -o /etc/apt/sources.list.d/httpie.list https://packages.httpie.io/deb/httpie.list
apt update
apt install httpie
@Nex-Otaku
Nex-Otaku / letsencrypt.conf
Created April 27, 2023 07:43
Snippets for Nginx. Should be placed in /etc/nginx/snippets
location ^~ /.well-known/acme-challenge/ {
allow all;
root /var/lib/letsencrypt/;
default_type "text/plain";
try_files $uri =404;
}
@Nex-Otaku
Nex-Otaku / xo-ast-parser.php
Created March 2, 2023 15:11
Вычисляем связи в PHP классе с помощью парсера Никиты Попова и визуализируем в Orb
<?php
require './../vendor/autoload.php';
use NexOtaku\MinimalFilesystem\Filesystem;
use PhpParser\ParserFactory;
use PhpParser\{Node, NodeTraverser, NodeVisitorAbstract};
class CallMap
{
@Nex-Otaku
Nex-Otaku / ModelMaker.php
Last active June 16, 2023 09:27
Model Maker for Laravel
<?php
namespace App\Module\ModelMaker;
use Illuminate\Console\Command;
use Illuminate\Console\Concerns\InteractsWithIO;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use NexOtaku\MinimalFilesystem\Filesystem;
use NunoMaduro\LaravelConsoleMenu\Menu;
@Nex-Otaku
Nex-Otaku / Xo.php
Last active March 2, 2023 19:22
Крестики-нолики
<?php
namespace App\Module\Demo\Xo;
use App\Module\Runtime\FilesystemRuntimeState;
use App\Module\Runtime\MemoryCachedRuntimeState;
use App\Module\Runtime\Types\StoredString;
class Xo
{
@Nex-Otaku
Nex-Otaku / Act.php
Created July 21, 2022 12:11
Пример сущности с необязательными полями
<?php
namespace App;
class Act
{
private int $id;
private string $title;
private ?\DateTimeInterface $signedAt;
@Nex-Otaku
Nex-Otaku / docker-compose.yml
Created May 11, 2022 11:28
Docker Compose configuration for a Laravel project with Invoker SSH access
version: '3'
services:
# PHP
yarko_php_service:
image: yarko_php_image
build:
context: .
dockerfile: ./docker/php/Dockerfile
container_name: yarko_php_container
@Nex-Otaku
Nex-Otaku / telegram-markdown.js
Last active October 12, 2021 20:04
Escape MarkdownV2 Telegram
// https://www.npmjs.com/package/telegramify-markdown
const telegramifyMarkdown = require('telegramify-markdown');
const escapeMarkdownV2 = (text) => {
// Функция telegramifyMarkdown не совсем корректно работает, глючит с форматом __Underlined__,
// поэтому обходим этот глюк с помощью замены "__" на "@@" и обратно.
const dogText = text.replace(/__/gi, '@@');
const lines = dogText.split('\n');
const percentText = lines.map(line => {
@Nex-Otaku
Nex-Otaku / SolidYiiComponent.php
Last active April 25, 2021 20:10
Custom component for use in Yii 2 application - independent from the framework
<?php
/**
We want to use our custom component e.g. Tracker with Dependecy Injection and all the nice features,
but make it totally independent of framework.
Make it SOLID )
It would be shame to extend our custom component from framework classes, because it would be a hard dependency from framework.
@Nex-Otaku
Nex-Otaku / ImageOptimizer.php
Created April 14, 2021 15:09
Оптимизируем изображения в Yii2
<?php
use yii\helpers\StringHelper;
class ImageOptimizerHelper
{
public static function optimize($path)
{
// Оптимизируем изображение с помощью расширения "ps/image-optimizer".
// Утилита сама определяет формат и выбирает подходящие настройки оптимизации.