Skip to content

Instantly share code, notes, and snippets.

@ilzrv
ilzrv / domain.test.conf
Created September 12, 2023 06:41
A special version of PHP for a specific IP address via NGINX
upstream php_fpm_9000 {
server 127.0.0.1:9000;
}
upstream php_fpm_9001 {
server 127.0.0.1:9001;
}
server {
listen 80;
@ilzrv
ilzrv / crypto-aes-gcm.js
Created February 26, 2023 09:20
Example AES-GCM encode-decode with string key
// Sources:
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey
// https://github.com/mdn/dom-examples/blob/main/web-crypto/encrypt-decrypt/aes-gcm.js
// https://github.com/diafygi/webcrypto-examples#aes-gcm
let enc = new TextEncoder();
let dec = new TextDecoder();
(async function () {
additionalData = window.crypto.getRandomValues(new Uint8Array(32))
<?php
class LinkedList
{
private $head;
public function __construct()
{
$this->head = null;
@ilzrv
ilzrv / Pipe1.php
Last active April 7, 2024 00:49
Laravel Pipeline and Hub Example
<?php
class Pipe1
{
public function handle($passable, Closure $next)
{
$passable = ucfirst($passable);
return $next($passable);
}
@ilzrv
ilzrv / CheckoutData.php
Last active May 3, 2020 11:13
Data Transfer Object (DTO) in Laravel with PHP7.4 typed properties. Source: https://dev.to/zubairmohsin33/data-transfer-object-dto-in-laravel-with-php7-4-typed-properties-2hi9
<?php
class CheckoutData extends DataTransferObject
{
public int $checkout_id;
public Carbon $completed_at;
public static function fromRequest(Request $request){ ... }
@ilzrv
ilzrv / MySQL_5-7_macOS.md
Created November 3, 2019 12:47 — forked from robhrt7/MySQL_5-7_macOS.md
Install MySQL 5.7 on macOS using Homebrew

This is a fork of original gist https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e, with slight changes on pointing to 5.7 version branch, instead of 8 (latest default of MySQL in Hombrew).

Install MySQL 5.7 on macOS

This procedure explains how to install MySQL using Homebrew on macOS (Sierra 10.12 and up)

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.
@ilzrv
ilzrv / README.md
Created August 11, 2019 17:48 — forked from Alymosul/README.md
[Laravel] Seeding data in testing as part of the application build.

SeedDatabase trait along with SeedDatabaseState class gives your Laravel project the ability to seed the testing database once before running the full suite tests, which improves the speed of the tests than seeding the testing database before each test.

Also, it has the option to run custom seeders instead of the seeders that are called in the run() method of the DatabaseSeeder class you can achieve that as follows

...in the Testcase.php

public function setUp()

{

@ilzrv
ilzrv / encrypt.php
Created July 14, 2019 06:09
encrypt & decrypt data
<?php
if (! function_exists('encrypt_data')) {
/**
* Зашифровать значение,
* используя ключ
*
* @param $data
* @param $key

Naming Controllers

Controllers should be in singular case, no spacing between words, and end with "Controller".

Also, each word should be capitalised (i.e. BlogController, not blogcontroller).

For example: BlogController, AuthController, UserController.

Bad examples: UsersController (because it is in plural), Users (because it is missing the Controller suffix).