Skip to content

Instantly share code, notes, and snippets.

View HassanZahirnia's full-sized avatar
🌸

Hassan Zahirnia HassanZahirnia

🌸
View GitHub Profile
@innocenzi
innocenzi / RoutesTest.php
Created September 20, 2022 15:35
No closure route assertion
<?php
use Illuminate\Routing\Route;
use Illuminate\Routing\Router;
test('basic feature test', function () {
$routes = collect(app(Router::class)->getRoutes()->getRoutes())
->filter(fn (Route $route) => ! isVendorRoute($route));
foreach ($routes as $route) {
@pascalbaljet
pascalbaljet / SwapOctaneServer.php
Last active July 8, 2024 18:12
Blue-green deployment with Laravel Octane
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Console\Concerns\CallsCommands;
use Illuminate\Support\Facades\Http;
use Laravel\Forge\Forge;
use Laravel\Forge\Resources\Daemon;
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Tightenco\Ziggy\Ziggy;
class GenerateRoutesCommand extends Command
{
export default defineConfig({
plugins: [
laravel(['resources/js/app.js']),
{
name: 'ziggy',
enforce: 'post',
handleHotUpdate({ server, file }) {
if (file.includes('/routes/') && file.endsWith('.php')) {
exec('php artisan ziggy:generate', (error, stdout) => error === null && console.log(` > Ziggy routes generated!`))
}
@innocenzi
innocenzi / some-page.vue
Last active June 24, 2022 13:14
Dealing with cached visits with Inertia
<script setup lang="ts">
import { useBackForward } from '@/scripts/use-back-forward'
const { reloadOnBackForward } = useBackForward()
// When the page component is loaded, if it's a visit made with the "back" or "forward"
// browser functionality, the page will reload. You can optionally pass options to Inertia.
reloadOnBackForward({
only: ['quotations'],
})
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
/**
* Generates a JSON file with all translations.
@innocenzi
innocenzi / README.md
Last active November 21, 2022 13:41
Vite + Inertia SSR

package.json:

{
  "scripts": {
    "dev": "vite",
    "dev:server": "node public/build/server/server.js",
    "build": "vite build",
    "build:server": "vite build --outDir ./public/build/server --ssr ./resources/scripts/inertia/server.ts"
  }
}
@innocenzi
innocenzi / GenerateI18n.php
Last active July 18, 2022 18:18
VITL translations
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
/**
* Generates a JSON file with all translations.
@samselikoff
samselikoff / tailwind.config.js
Created April 16, 2021 15:57
Firefox plugin for Tailwind CSS. Add styles that target Firefox browser only.
const plugin = require("tailwindcss/plugin");
module.exports = {
mode: "jit",
purge: {
content: ["./src/**/*.{js,ts,jsx,tsx,mdx,vue}"],
},
theme: { extend: {} },
variants: {},
plugins: [