Skip to content

Instantly share code, notes, and snippets.

<html>
<head>
<style>
.box-that-changes-color {
height: 1rem;
width: 1rem;
background: red;
}
@media (min-width: 768px) {
import {Controller} from '@hotwired/stimulus'
import {Editor} from "@tiptap/core"
import {Mention} from "@tiptap/extension-mention";
import StarterKit from "@tiptap/starter-kit"
export default class extends Controller {
static targets = ['input', 'suggestions']
connect() {
this.editor = new Editor({
<?php
namespace Tests\SetupTraits;
trait SetupTraits
{
protected function setUpTraits()
{
$this->setupAdditionalTraits(
parent::setUpTraits()
<?php
protected function invalidJson($request, ValidationException $exception)
{
return response()->json([
'message' => $exception->getMessage(),
'errors' => Collection::make($exception->errors())->mapWithKeys(function ($value, $key) {
return [Str::camel($key) => $value];
}),
], $exception->status);
@jaggy
jaggy / HigherOrderIfProxy.php
Last active January 14, 2020 19:57
An exercise of implementing a higher order if.
<?php
namespace App;
use Illuminate\Support\Traits\ForwardsCalls;
class HigherOrderIfProxy
{
use ForwardsCalls;
<?php
use Illuminate\Database\Eloquent\Builder;
protected function registerWhereLikeMacro()
{
Builder::macro('whereLike', function ($attributes, $searchTerm = null) {
$this->where(function (Builder $query) use ($attributes, $searchTerm) {
foreach (array_wrap($attributes) as $attribute) {
$query->when(
<?php
namespace App;
trait Tappable
{
public function tap($callback)
{
return tap($this, $callback);
}
<?php
namespace App;
trait HasPersonName
{
public function getNameAttribute($name)
{
return new PersonName($name);
FROM elixir:latest
RUN mix local.hex --force
RUN mix local.rebar --force
RUN mix archive.install https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez --force
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get update && apt-get install -y postgresql-client inotify-tools nodejs
RUN mkdir /app
@jaggy
jaggy / phpv
Last active December 19, 2017 23:27
*sh snippet for switching PHP versions.
function phpv() {
brew unlink php$(php -v | head -n1 | grep -o -E '\d\.\d' | tr -d '.')
brew link php$1
valet restart
}