Skip to content

Instantly share code, notes, and snippets.

View calebporzio's full-sized avatar

Caleb Porzio calebporzio

View GitHub Profile

It's time to swap out these placeholders on the new Livewire landing page. Show some love!

(Please reply with a brief testimonial, name, and twitter handle)

image

import { reactive } from '@vue/reactivity'
function switchboard(value) {
let lookup = {}
let current
let get = () => current
let set = (newValue) => {
<?php
function memoize($target) {
static $memo = new WeakMap;
return new class ($target, $memo) {
function __construct(
protected $target,
protected &$memo,
) {}

Help me solve morphdom woes in Livewire

Blade "@if" statements can sometimes cause problems in Livewire.

I can eliminate those problems if I can inject markers around those conditional block like so:

@if (...)
    <div>foo</div>
@endif
<html>
<script src="/basic/canvas.js"></script>
<script src="/basic/ml.js"></script>
<div style="border: 1px solid black; width: 100px; height: 100px;">
<canvas width="200" height="200" id="points" style="position: absolute; width: 100px; height: 100px"></canvas>
<canvas width="200" height="200" id="line" style="position: absolute; width: 100px; height: 100px"></canvas>
</div>
<script>
<script data-turbo-eval="false">
document.addEventListener('turbo:before-render', () => {
let permanents = document.querySelectorAll('[data-turbo-permanent]')
let undos = Array.from(permanents).map(el => {
el._x_ignore = true
return () => {
delete el._x_ignore
}
function benchmark(times, callbacks) {
let result = {}
Object.entries(callbacks).forEach(([key, value]) => {
let thing = {}
let start = performance.now()
for (let index = 0; index < times; index++) {
value()
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tailwindcss/ui@latest/dist/tailwind-ui.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.min.js" defer></script>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@0.7.4/dist/tailwind.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.min.js" defer></script>
@calebporzio
calebporzio / karabiner_vim_mode.json
Created March 27, 2020 18:13
A backup of the ideal vim mode karabiner plugin
{
"title": "Caleb's Vim Mode",
"author": "Caleb Porzio(calebporzio.com)",
"rules": [
{
"description": "Vim Mode [D as Trigger Key]",
"manipulators": [
{
"from": {
"key_code": "d",