Skip to content

Instantly share code, notes, and snippets.

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

Ostap Brehin osbre

🇺🇦
#StandWithUkraine
View GitHub Profile
<?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
@osbre
osbre / dropdown.blade.php
Last active March 24, 2025 16:46
Laravel Breeze HTML5 native dropdown component (no JavaScript). Remove any inner <button>'s when using.
@props(['align' => 'right', 'width' => '48', 'contentClasses' => 'py-1 bg-white'])
@php
$alignmentClasses = match ($align) {
'left' => 'ltr:origin-top-left rtl:origin-top-right start-0',
'top' => 'origin-top',
default => 'ltr:origin-top-right rtl:origin-top-left end-0',
};
$width = match ($width) {
language_server.diagnostic_ignore_codes:
- worse.docblock_missing_return_type
products = retry_on_failure(times: 2) do
account.client.products.all
rescue => e
account.refresh_token
raise e
end
private
def retry_on_failure(times: , &block)