Skip to content

Instantly share code, notes, and snippets.

View Oleksandr-Moik's full-sized avatar

Oleksandr Moik Oleksandr-Moik

View GitHub Profile
@Oleksandr-Moik
Oleksandr-Moik / declension helpers.php
Last active December 17, 2024 20:57
Declension helpers
<?php
if (!function_exists('declension_key')) {
/** Translation based declension function */
function declension_key(int $number, string $key, ?string $locale = null): string
{
$locale = $locale ?: app()->getLocale();
$words = trans('declensions.' . $key, [], $locale);
<?php
use Illuminate\Support\Facades\File;
function generateUniquePathName(string $filePath): string
{
$path = File::dirname($filePath);
$name = File::name($filePath);
$extension = File::extension($filePath);
@Oleksandr-Moik
Oleksandr-Moik / UnitTest.php
Created May 19, 2024 21:53
Extract the YouTube Video ID from a URL in PHP (Larave, test suite on Pest)
<?php
it('extracts video ID from YouTube URLs', function ($url, $expectedId) {
expect(get_youtube_video_id($url))->toBe($expectedId);
})->with([
['https://youtu.be/dQw4w9WgXcQ', 'dQw4w9WgXcQ'],
['https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'dQw4w9WgXcQ'],
['http://youtube.com/v/dQw4w9WgXcQ', 'dQw4w9WgXcQ'],
['https://www.youtube.com/embed/dQw4w9WgXcQ', 'dQw4w9WgXcQ'],
['https://www.youtube.com/shorts/dQw4w9WgXcQ', 'dQw4w9WgXcQ'],
@Oleksandr-Moik
Oleksandr-Moik / postman.md
Created August 24, 2023 19:59
Posman utils

set default header for api requests

write in pre-requrest/prepare

pm.request.addHeader('Accept: application/json')

automaticaly set api token to variables

PhpStorm, Laravel IDEA plugin, ide.json (v1) configuration file for package jeroennoten/laravel-adminlte. Place in the root of your project. Hints for components and types from a package.

ide.json

{
  "$schema": "http://laravel-ide.com/schema/laravel-ide-v1.json",
  "completion": {
  },
  "view": {

Laravel

Run Locally

Clone the project

  git clone <project_url>

My collection of shell aliases

Common

alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

alias mkdir='mkdir -p'