Skip to content

Instantly share code, notes, and snippets.

View james2doyle's full-sized avatar

James Doyle james2doyle

View GitHub Profile

Heading

Start a line with a hash character # to set a heading. Organize your remarks with subheadings by starting a line with additional hash characters, for example ####. Up to six levels of headings are supported.

Alternatively, on the line below the text, add any number of == characters for heading level 1 or -- characters for heading level 2.

Best practices: Markdown doesn't agree on how to handle a missing space between the number signs # and the heading name. For compatibility, always put a space between the number signs and the heading name.

@james2doyle
james2doyle / alert.blade.php
Created October 2, 2024 20:10
A simple alert Laravel Blade component that is styled with Tailwind and uses Alpine for the dismissal
<div {{ $attributes }} x-data="{ visible: true }" x-show="visible" x-cloak>
<div class="relative w-full overflow-hidden rounded-xl border border-red-600 bg-white text-slate-700 dark:bg-slate-900 dark:text-slate-300"
role="alert">
<div class="flex w-full items-center gap-2 bg-red-600/10 p-4">
<div class="rounded-full bg-red-600/15 p-1 text-red-600" aria-hidden="true">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="size-6"
aria-hidden="true">
<path fill-rule="evenodd"
d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16ZM8.28 7.22a.75.75 0 0 0-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 1 0 1.06 1.06L10 11.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L11.06 10l1.72-1.72a.75.75 0 0 0-1.06-1.06L10 8.94 8.28 7.22Z"
clip-rule="evenodd" />
@james2doyle
james2doyle / x-cloak.css
Created September 28, 2024 17:32
Trick with v-cloak in Vuejs but updated for Alpine and x-cloak. From https://medium.com/vuejs-tips/v-cloak-45a05da28dc4
[x-cloak],
[x-cloak]>* {
display: none !important;
}
[x-cloak]::before {
content: "loading\2026";
}
@james2doyle
james2doyle / MyErrorBoundary.tsx
Created September 17, 2024 16:51
A React Error Boundary that has some basic styling and functionality
'use client';
import { ErrorBoundary } from 'react-error-boundary';
import type { ErrorInfo } from 'react';
import type { ErrorBoundaryProps, FallbackProps } from 'react-error-boundary';
import { Button } from '@components/Button';
const logError = (error: Error, info: ErrorInfo) => {
console.error({ error, info });
@james2doyle
james2doyle / x-scrolled.js
Last active August 23, 2024 21:50
An Alpinejs plugin that lets you trigger an expression if the page is being scrolled up or down
// USAGE:
// x-data="{ direction: 'up' }" x-scrolled.up="direction = 'up'" x-scrolled.down="direction = 'down'"
Alpine.directive(
'scrolled',
(_, { modifiers, expression }, { evaluateLater, cleanup }) => {
const results = evaluateLater(expression);
let scrollPos = 0;
const handler = () => {
@james2doyle
james2doyle / Card.php
Created July 11, 2024 17:47
Merge attributes with props in a Laravel class component
<?php
namespace App\View\Components;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class Card extends Component
{
@james2doyle
james2doyle / opcache.ini
Created June 17, 2024 16:59
Control the jit in PHP with an opcache config
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=100M
opcache.jit=tracing
@james2doyle
james2doyle / 0000_01_01_000000_set_sqlite_extensions.php
Last active October 7, 2024 13:54
Use a Laravel migration to set some PRAGMA performance settings in Sqlite
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
<?php
/** @see https://twitter.com/AshAllenDesign/status/1786037324775633109 */
test('strict types are used everywhere')
->expect('App')
->toUseStrictTypes();
test('globals')
->expect(['dd', 'ddd', 'die', 'dump', 'ray', 'sleep'])
@james2doyle
james2doyle / example.ionapi
Created May 1, 2024 18:46
An example on how to get an oAuth2 token from the Mingle ION API for Infor Cloudsuite
{
"ti": "AAAABBBBCCCCDDDD_ZZZ",
"cn": "Example ION File",
"dt": "11",
"ci": "AAAABBBBCCCCDDDD_ZZZ~fioUStyk923dTK4y7iXdBwVjTBYEunBtd9GpEigvBf9",
"cs": "gkBdyWByfHiOwteD-vQn9jb7pudublgsI9kW4fiPhzsOi2lFKIttCzy5ofiiyMQqgSjpuS3GRDtMHbLbj_fexq",
"iu": "https://mingle-ionapi.inforcloudsuite.com",
"pu": "https://mingle-sso.inforcloudsuite.com:443/AAAABBBBCCCCDDDD_ZZZ/as/",
"oa": "authorization.oauth2",
"ot": "token.oauth2",