Skip to content

Instantly share code, notes, and snippets.

View osbre's full-sized avatar
🇺🇦
#StandWithUkraine

Ostap Brehin osbre

🇺🇦
#StandWithUkraine
View GitHub Profile
---
globs: **/*.php
alwaysApply: false
---
- Do not use `auth()` helper or `Auth` facade, instead always retrieve the user either from the Request (`$request->user()`) or via `#[CurrentUser]` attribute (`use Illuminate\Container\Attributes\CurrentUser;`). Prop-drill it down the methods instead of calling `Auth` or `auth`.
- Do not add comments because code is already self-explanatory.
- Do not assign ids manually like `Post::create(['user_id' => Auth::id()`, instead call relationship method on the parental model like `$user->posts()->create()`.
@osbre
osbre / movie-for-old-tv.bat
Last active November 29, 2025 14:48
ffmpeg command to make video compatible with old Hitachi TV from 2000s.
@echo off
for %%f in (*.mkv *.mp4 *.mov *.avi *.webm) do (
ffmpeg.exe -i "%%f" ^
-c:v mpeg2video -q:v 4 -maxrate 8000k -bufsize 1835k ^
-c:a mp2 -b:a 192k ^
"%%~nf.mpg"
)
@osbre
osbre / vite.config.mjs
Last active August 4, 2025 09:50
todo: debug why @inertiajs/vue3 resolver does not work
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import tailwindcss from '@tailwindcss/vite'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { VueUseComponentsResolver, VueUseDirectiveResolver } from 'unplugin-vue-components/resolvers'
export default defineConfig({
server: {
@osbre
osbre / spa-for-mpa.html
Last active September 2, 2025 20:03
Like hx-boost or Tuborlinks. Just 3.2 kB minified+gzipped. Optional `data-no-morph`
<script
src="https://unpkg.com/idiomorph@0.7.3/dist/idiomorph.min.js"
integrity="sha256-incz+t+g09rlM/2ASDxkCIUiHJNFjBcRyUB5dQj0ZmI="
crossorigin="anonymous"
></script>
<script>
const morphTo = async (url, opts = {}) => {
const res = await fetch(url, { headers: { 'X-Requested-With': 'Idiomorph' }, ...opts });
const text = await res.text();
const html = new DOMParser().parseFromString(text, 'text/html');
<?php
namespace App\Models\Concepts;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
/** @mixin Model */
trait HasUUID
{
@osbre
osbre / SB Requisite.ask
Created June 2, 2025 23:36
brightness 177%
<?xml version="1.0" encoding="UTF-8"?>
<Ableton MajorVersion="5" MinorVersion="12.0_12049" SchemaChangeCount="7" Creator="Ableton Live 12.0.5d1" Revision="4daa12474c52194070371c09a9a78dc600078aec">
<Theme>
<ControlForeground Value="#18110a" />
<TextDisabled Value="#776b61" />
<ControlDisabled Value="#f3f0ef" />
<MeterBackground Value="#2b2219" />
<SurfaceHighlight Value="#c3bab4" />
<SurfaceArea Value="#776b61" />
<Desktop Value="#8b7f76" />
<?php
namespace Illuminate\Tests\View\Blade;
class BladeUseTest extends AbstractBladeTestCase
{
public function testUseStatementsAreCompiled()
{
$expected = "Foo <?php use \SomeNamespace\SomeClass as Foo; ?> bar";

Use namespaces and PHP 8 callable syntax. Prefer functions over classes, composition over inheritance.

Example: namespace MyProject; add_filter('tiny_mce_plugins', remove_emoji_dns_prefetch(...));

This is a file within a theme, Inc. Complete the task now and use the latest features, if applicable. We don't use Gutenberg and rely on the classic editor/tinymce.

@osbre
osbre / svg-upload-support.php
Created April 16, 2025 20:07
WordPress / ClassicPress plugin to enable SVG uploads for admins.
<?php
/**
* Plugin Name: SVG Upload Support
* Description: Allows SVG uploads for admins only.
* Version: 1.0
* Author: Ostap Brehin
* Author URI: https://ostapbrehin.com
*/
add_filter('upload_mimes', function ($mimes) {
@osbre
osbre / php-and-composer.sh
Last active April 12, 2025 04:57
A script to install PHP 8.4 and Composer on Debian/Ubuntu servers.
#!/bin/bash
# Update and install necessary packages
sudo apt update
sudo apt install -y lsb-release apt-transport-https ca-certificates curl
# Add Ondřej Surý's PHP repository
curl -fsSL https://packages.sury.org/php/README.txt | sudo bash -
# Install PHP 8.4 and required extensions for Laravel