Skip to content

Instantly share code, notes, and snippets.

View caendesilva's full-sized avatar
🎩
HydePHP.com

Caen De Silva caendesilva

🎩
HydePHP.com
View GitHub Profile
@caendesilva
caendesilva / .gitattributes
Created July 19, 2024 20:20
General .gitattributes file
* text=auto eol=lf
/tests export-ignore
/.github export-ignore
/.gitignore export-ignore
/.gitattributes export-ignore
/composer.lock export-ignore
/phpunit.xml export-ignore
// Best we've got
<h1>Frankenstein</h1>
<p role="doc-subtitle">Or: The Modern Prometheus</p>
// How about this? (Inspired by form label and input coupling)
<h1>
Frankenstein
<subhead>Or: The Modern Prometheus</subhead>
</h1>
@caendesilva
caendesilva / create-ai-model.php
Created July 13, 2024 20:09
Package all PHP source code files into a single file to use for AI contexting
<?php
function createCodeModel($directory, $outputFile): void
{
// Open the output file in append mode
$output = fopen($outputFile, 'a');
// Get all files in the current directory
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS),
@caendesilva
caendesilva / abstract.php
Created July 12, 2024 17:21
Personal AI commit message model generation
<?php
// SIMPLIFIED MODEL GENERATOR
$raw = trim(shell_exec('git log --pretty=format:"%s" --first-parent master'));
$lines = explode("\n", $raw);
$lines = filter_duplicates_keeping_first_matches($lines);
$lines = filter_lines_starting_with($lines, ['Merge', 'Revert', 'Reapply', 'Bump']);
@php($title = 'Authors')
@extends('hyde::layouts.app')
@section('content')
<main id="content" class="mx-auto max-w-7xl py-12 px-8">
<header class="lg:mb-12 xl:mb-16">
<h1 class="text-3xl text-left leading-10 tracking-tight font-extrabold sm:leading-none mb-8 md:mb-12 md:text-center lg:text-5xl text-gray-700 dark:text-gray-200">
Authors
</h1>
</header>
@caendesilva
caendesilva / compress_images.sh
Created June 25, 2024 14:43
Bash ImageMagick script to compress images in a directory named source to a directory called output
#!/bin/bash
# Ensure the output directory exists
mkdir -p output
# Iterate through all image files in the source directory
for image in source/*.{jpg,jpeg,png,gif}; do
if [[ -f "$image" ]]; then
# Get the filename without the directory path
filename=$(basename "$image")
@caendesilva
caendesilva / lint.yml
Created June 23, 2024 08:28
Simple YAML Linter/Validator Workflow for GitHub Actions
name: Validate YAML
on:
push:
pull_request:
jobs:
validate-yaml:
runs-on: ubuntu-latest
steps:
@caendesilva
caendesilva / app.css
Last active June 21, 2024 17:13
Simple and clean CSS styles for basic HTML layouts
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0;
padding: 0;
}
main {
max-width: 800px;
margin: 0 auto;
padding: 20px;
@caendesilva
caendesilva / configure-repository.yml
Created June 19, 2024 17:14
Configure a used repository template to respect export-ignored paths
# When using the Repository Template feature on GitHub, it does not follow the same rules as Composer create-project or ZIP downloads.
# For this reason, we have this script which will configure the repository the first time it is set up in order to normalize it.
name: Configure template repository
on:
# Run when branch is created (when the repository is generated from the template)
create:
# Only keep latest run of this workflow and cancel any previous runs
concurrency:
@caendesilva
caendesilva / simple-file-linter.php
Created June 15, 2024 15:29
A simple file linter written in PHP
<?php
declare(strict_types=1);
write('Running file Linter!', '32');
const PATTERN = '/src/*.php';
$files = glob(__DIR__ . '/' . ltrim(PATTERN, '/');
$exitCode = 0;