Skip to content

Instantly share code, notes, and snippets.

View james2doyle's full-sized avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / raycast.search-on-brave.sh
Last active May 6, 2022 19:02
Run a query on search.brave.com. Custom command for Raycast
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Search on Brave
# @raycast.mode compact
# @raycast.argument1 { "type": "text", "placeholder": "query", "percentEncoded": true }
# Optional parameters:
# @raycast.icon images/icon-brave.png
@james2doyle
james2doyle / PHP-Clips.json
Last active March 23, 2022 22:02
Nova 9 PHP Clips (completions, snippets) for common flow controls, variables, globals, functions, methods, documentation, and classes
{
"clips": [
{
"content": "/** @var ${1:class/type} ${2:description} */",
"name": "Var Documentation",
"scope": "editor",
"syntax": "php",
"trigger": "@var"
},
{
@james2doyle
james2doyle / Nova 9 Sublime Text Key Bindings.json
Last active April 14, 2022 16:05
Nova 9 key bindings that emulate the ones in Sublime Text
{
"extensionCommands" : {
"sublime-merge.blame" : {
"shortcut" : "alt-ctrl-b"
}
},
"menuItems" : {
"AddCursorsAtEndOfLine" : {
"shortcut" : "cmd-shift-l"
},
@james2doyle
james2doyle / raycast.random-lorem-ipsum.lua
Created January 26, 2022 18:45
Copy a random paragraph of Lorem Ipsum to clipboard. Extension for Raycast
#!/usr/bin/env lua
--[[
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Copy Random Lorem Ipsum
# @raycast.mode silent
# @raycast.packageName Developer Utilities
# Optional parameters:
@james2doyle
james2doyle / tailwind.config.ts
Last active January 15, 2022 21:38
An example of using the tailwind config with typescript
// npm i -D @types/tailwindcss
import type { TailwindConfig } from 'tailwindcss/tailwind-config';
import type DefaultTheme from 'tailwindcss/defaultTheme';
type Tailwind = TailwindConfig & { theme: { extend: typeof DefaultTheme } };
export default {
darkMode: 'class',
content: [
'./components/**/*.{js,vue,ts}',
@james2doyle
james2doyle / fastmod-use-responsible.sh
Created January 6, 2022 17:29
Use fastmod code replacement to update controller typehints to return Responsable interfaces instead of Response classes
fastmod -F '@return \Illuminate\Http\Response' '@return \Illuminate\Contracts\Support\Responsable' app/Http/Controllers
@james2doyle
james2doyle / json-in-sqlite.sql
Last active January 18, 2024 19:31
use SQLite to store JSON à la jsonb in PostgreSQL using virtual generated columns (https://www.sqlite.org/gencol.html)
CREATE TABLE t (
id integer PRIMARY KEY autoincrement,
data text
);
INSERT INTO my_objects (data) values('{"foo": "value", "bar": "other value"}'), ('{"foo": "baz", "bar": "qux"}');
ALTER TABLE my_objects ADD COLUMN foo text GENERATED always AS (json_extract(data, $.foo)) virtual;
SELECT * FROM my_objects;
@james2doyle
james2doyle / UserHttpSnapshotTest.php
Created November 23, 2021 17:29
Example usage of Laravels Spatie Snapshot testing package being used on a JsonResource output and a FormRequest rules array
<?php
namespace Tests\Snapshots;
use Illuminate\Http\Resources\Json\JsonResource;
use Spatie\Snapshots\MatchesSnapshots;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Models\User;
@james2doyle
james2doyle / axios.md.blade.php
Last active November 23, 2021 18:27
A Scribe partial for creating example requests using Axios. Place in resources/views/vendor/scribe/partials/example-requests/axios.md.blade.php
{{--
File: resources/views/vendor/scribe/partials/example-requests/axios.md.blade.php
--}}
@php
use Knuckles\Scribe\Tools\WritingUtils as u;
/** @var Knuckles\Camel\Output\OutputEndpointData $endpoint */
@endphp
```javascript
const instance = axios.create({
baseURL: '{{ rtrim($baseUrl, '/') }}',
@james2doyle
james2doyle / HasSlug.php
Last active December 16, 2021 16:56
A trait for Laravel (v8) that uses model events to set a slug field based on another field
<?php
namespace App\Traits;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
/**
* Handles the logic for settings slugs
*/