Skip to content

Instantly share code, notes, and snippets.

View snellingio's full-sized avatar

Sam Snelling snellingio

View GitHub Profile
You are Cascade, a powerful agentic AI coding assistant designed by the Codeium engineering team: a world-class AI company based in Silicon Valley, California.
Exclusively available in Windsurf, the world's first agentic IDE, you operate on the revolutionary AI Flow paradigm, enabling you to work both independently and collaboratively with a USER.
You are pair programming with a USER to solve their coding task. The task may require creating a new codebase, modifying or debugging an existing codebase, or simply answering a question.
The USER will send you requests, which you must always prioritize addressing. Along with each USER request, we will attach additional metadata about their current state, such as what files they have open and where their cursor is.
This information may or may not be relevant to the coding task, it is up for you to decide.
The USER may specify important MEMORIES to guide your behavior. ALWAYS pay attention to these MEMORIES and follow them closely.
The USER's OS version is mac.
The U
@snellingio
snellingio / macro.php
Created August 29, 2023 18:37
Filament highlight search
<?php
// AppServiceProvider boot
Str::macro('highlight', function ($string, $search, $highlight = '<mark class="highlight">$1</mark>', $caseSensitive = false, $minHighlightLength = 1) {
$toSearch = explode(' ', $search);
$searchable = [];
foreach ($toSearch as $key => $val) {
if (strlen($val) < $minHighlightLength) {
continue;
<?php
namespace App\Http\Livewire;
use App\Models\User;
use Livewire\Component;
use Livewire\WithPagination;
class SearchComponent extends Component
{
<?php
use Vector;
use PHPUnit\Framework\Assert;
expect()->extend('toBeWithin', function (float $expected, float $tolerance): void {
$actual = $this->value;
Assert::assertGreaterThanOrEqual($expected - $tolerance, $actual, "Expected {$actual} to be within {$tolerance} of {$expected}");
Assert::assertLessThanOrEqual($expected + $tolerance, $actual, "Expected {$actual} to be within {$tolerance} of {$expected}");
<!DOCTYPE html>
<html lang="en">
<head>
<script type="module">
customElements.define('history-component', class extends HTMLElement {
connectedCallback() {
// get the history from localstorage, if it exists
// if the current route is the latest, do not add it to the history
// if the current route is not the latest, add it to the history
// if the history is longer than 5, remove the oldest
import { AssociativeArray } from '../php/types'
import array_key_exists from '../php/array_key_exists'
import is_callable from '../php/is_callable'
import is_string from '../php/is_string'
class Fluent {
private _attributes: AssociativeArray = {}
constructor(attributes: AssociativeArray = {}) {
Object.assign(this._attributes, attributes)
@snellingio
snellingio / component.html
Created January 17, 2022 18:20
Import Alpine components
<style>
[x-show="!open"] {
color: red;
}
[x-show="open"] {
color: green;
}
</style>
<template>
const plugin = require('tailwindcss/plugin')
module.exports = {
mode: 'jit',
purge: ['./resources/**/*.{js,vue,blade.php}'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
<?php
namespace App\Http\Livewire\Sections;
use Livewire\Component;
use Livewire\TemporaryUploadedFile;
use Livewire\WithFileUploads;
class Photo extends Component
{
<div class="pb-6">
<label for="state" class="w-full block font-semibold pb-1 md:pb-2 select-none text-black dark-mode:text-grey-050">
State
</label>
<div class="w-full block flex">
<div class="relative w-full">
<select class="border border-grey-100 bg-white outline-none px-3 rounded appearance-none outline-none w-full py-3 bg-white text-black focus:border-blue-500" id="state" name="state">