Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Ryan Chandler ryangjchandler

💭
I may be slow to respond.
View GitHub Profile
@ryangjchandler
ryangjchandler / index.ts
Created September 16, 2021 13:21
Typescript Optional<T> type (Rust-esque)
View index.ts
type Option<T> = Some<T> | None<T>;
interface Optional<T> {
unwrap(): T;
unwrapOr(or: T): T;
isSome(): boolean;
isNone(): boolean;
}
class Some<T> implements Optional<T> {
@ryangjchandler
ryangjchandler / README.md
Last active November 4, 2022 16:32
Raycast - Laravel Documentation
View README.md

Raycast - Laravel Documentation

This script command provides a quick way of searching the Laravel documentation.

It accepts a query and will open the first result in your default browser.

Installation

  1. Begin by creating a ~/.config/raycast/scripts folder if you don't already have one.
@ryangjchandler
ryangjchandler / README.md
Last active September 14, 2021 22:35
Tailwind Palette to CSS Variables
View README.md

Tailwind Shades to CSS Variables

This script can be used to generate a set of CSS variables from a Tailwind shades object.

Overview

Let's say you have the following JavaScript object. You might have generated such an object on a site such as Tailwind Shades.

{
View example.html
<div x-data="example()">
<template x-for="(item, i) in items" :key="i">
<div x-bind="props(i)"></div>
</template>
</div>
<script>
const example = () => ({
current: 0,
items: [1, 2, 3],
props: (i) => ({
View PostModelEvents.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
class Post extends Model
{
public static function boot()
View class.eu
// module name shoild follow folders, like PSR-4
module controllers
import "http" exposing Request, Response
export class HelloController {
exposed function handle(req Request, res Response) {
return res.send("Hello")
}
View class.eu
// module name shoild follow folders, like PSR-4
module controllers
import "http" exposing Request, Response
export class HelloController {
exposed function handle(req Request, res Response) {
return res.send("Hello")
}
View hello.eu
import "http" exposing HttpServer, Request, Response
function main() {
HttpServer.get("/", func (req Request, res Response) => {
return res.Send("Hello!")
})
HttpServer.listen(8080)
}