Skip to content

Instantly share code, notes, and snippets.

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

Ostap Brehin osbre

🇺🇦
#StandWithUkraine
View GitHub Profile
@osbre
osbre / spa-for-mpa.html
Created July 20, 2025 19:54
Like hx-boost or Tuborlinks. Just 3.2 kB minified+gzipped. Optional `data-no-morph`
<script src="https://unpkg.com/[email protected]"></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');
Idiomorph.morph(document.body, html.body, { restoreFocus: true });
};
addEventListener('click', e => {
<?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
@osbre
osbre / install-franken.sh
Created April 12, 2025 04:36
A script to install FrankenPHP on Debian/Ubuntu servers.
#!/bin/bash
set -e
if ! apt -q install jq; then
echo "FAIL"
exit 1
fi
wget -q "https://github.com/dunglas/frankenphp/releases/download/$(wget -q -O- 'https://api.github.com/repos/dunglas/frankenphp/releases/latest' | jq -r '.tag_name')/frankenphp-linux-$(uname -m)"
@osbre
osbre / 1.md
Last active April 9, 2025 23:51

Forum Title:
Laravel bootstrap takes 200ms — what's the fix?


Jeen:
Hey, quick question — my Laravel bootstrap takes 200ms. What do people usually use to speed that up? RoadRunner?

Ivan Mykhavko:
OpenServer 😄

@osbre
osbre / controller.ex
Last active March 27, 2025 15:43
Phoenix controller template without use of Contexts
defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Controller do
use <%= inspect context.web_module %>, :controller
alias <%= inspect schema.module %>
alias <%= inspect context.base_module %>.Repo
def index(conn, _params) do
<%= schema.plural %> = Repo.all(<%= inspect schema.alias %>)
render(conn, :index, <%= schema.collection %>: <%= schema.plural %>)
end