Skip to content

Instantly share code, notes, and snippets.

@joelbutcher
joelbutcher / LaravelTailwindPaginator.vue
Created September 4, 2022 21:57
A Vue.js implemetation of the Laravel Paginator Links for Blade
<script setup>
import {computed} from 'vue';
defineEmits(['fetchData']);
const props = defineProps({
paginator: {
type: Object,
required: true,
default: {
@justin-schroeder
justin-schroeder / externalRedirect.ts
Created July 12, 2022 19:36
Perform an external redirect in Nuxt 3 router middleware
import { useNuxtApp } from '#app'
import { sendRedirect } from 'h3'
/**
* Performs an external redirect in a Nuxt3 route middleware. Once this Nuxt3
* pull request is merged, this function can be removed in favor of navigateTo:
*
* https://github.com/nuxt/framework/pull/5022
*
* @param url - An external url to redirect to
@ethanclevenger91
ethanclevenger91 / imagemagick-heic-forge-php-80-recipe.txt
Last active January 10, 2024 22:19
ImageMagick w/ HEIC support on Laravel Forge - Recipe (PHP 8.0)
# Minor tweaks from https://eplt.medium.com/5-minutes-to-install-imagemagick-with-heic-support-on-ubuntu-18-04-digitalocean-fe2d09dcef1
sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
apt-get update
apt-get -y install build-essential autoconf libtool git-core
apt-get -y build-dep imagemagick libmagickcore-dev libde265 libheif
cd /usr/src/
git clone https://github.com/strukturag/libde265.git
git clone https://github.com/strukturag/libheif.git
cd libde265/
./autogen.sh
@fridzema
fridzema / laravel-octane-on-forge.md
Last active May 8, 2024 06:32
Laravel octane(swoole) on forge / ubuntu server

Laravel

Configure octane laravel/octane

Server

PHP

Install swoole extension (place in corresponding .ini file(s)):

pecl install swoole
@Julien1138
Julien1138 / Editor.vue
Last active June 4, 2024 08:50
Tiptap collaboration server handles multiple document using namespaces and rooms
<template>
<div class="editor">
<template v-if="editor && !loading">
<div class="count">
{{ count }} {{ count === 1 ? 'user' : 'users' }} connected to {{ projectPath }}/{{ docName }}
</div>
<editor-content class="editor__content" :editor="editor" />
</template>
<em v-else>
Connecting to socket server …
@slava-vishnyakov
slava-vishnyakov / readme.md
Last active June 9, 2025 07:55
How to upload images with TipTap editor
  1. Create a file Image.js from the source below (it is almost a copy of Image.js from tiptap-extensions except that it has a constructor that accepts uploadFunc (function to be called with image being uploaded) and additional logic if(upload) { ... } else { ... previous base64 logic .. } in the new Plugin section.
import {Node, Plugin} from 'tiptap'
import {nodeInputRule} from 'tiptap-commands'

/**
 * Matches following attributes in Markdown-typed image: [, alt, src, title]
 *
@coltenkrauter
coltenkrauter / fix-wsl2-dns-resolution.md
Last active October 29, 2025 11:37
Fix DNS resolution in WSL2

Permanent WSL DNS Fix (WSL 2.2.1+)

If you're encountering ping github.com failing inside WSL with a Temporary failure in name resolution, you're not alone — this has been a long-standing issue, especially when using VPNs or corporate networks.

This issue is now fixed robustly with DNS tunneling, which preserves dynamic DNS behavior and avoids limitations like WSL’s former hard cap of 3 DNS servers in /etc/resolv.conf.

DNS tunneling is enabled by default in WSL version 2.2.1 and later, meaning that if you're still seeing DNS resolution issues, the first and most effective fix is simply to upgrade WSL. Upgrading WSL updates the WSL platform itself, but does not affect your installed Linux distributions, apps, or files.

To upgrade WSL, follow these steps,

@calibr
calibr / LevelDbPersistence.js
Created July 30, 2019 22:30
yjs v13(refactored) level db persistence
import level = require('level')
import * as encoding from 'lib0/dist/encoding'
import * as decoding from 'lib0/dist/decoding'
import * as syncProtocol from 'y-protocols/dist/sync.js'
import * as authProtocol from 'y-protocols/dist/auth.js'
import { createMutex } from 'lib0/dist/mutex.js'
const mux = createMutex()
function getEmptyEncodedStateVector() {
@a8dx
a8dx / US_State_Bounding_Boxes.csv
Created November 23, 2018 03:20
Bounding boxes for all US states and territories [NAD83]
STATEFP STUSPS NAME xmin ymin xmax ymax
1 01 AL Alabama -88.473227 30.223334 -84.88908 35.008028
2 02 AK Alaska -179.148909 51.214183 179.77847 71.365162
3 60 AS American Samoa -171.089874 -14.548699 -168.1433 -11.046934
4 04 AZ Arizona -114.81651 31.332177 -109.045223 37.00426
5 05 AR Arkansas -94.617919 33.004106 -89.644395 36.4996
6 06 CA California -124.409591 32.534156 -114.131211 42.009518
7 08 CO Colorado -109.060253 36.992426 -102.041524 41.003444
8 69 MP Commonwealth of the Northern Mariana Islands 144.886331 14.110472 146.064818 20.553802
9 09 CT Connecticut -73.727775 40.980144 -71.786994 42.050587
@bshishov
bshishov / forecasting_metrics.py
Last active October 31, 2025 02:26
Python Numpy functions for most common forecasting metrics
import numpy as np
EPSILON = 1e-10
def _error(actual: np.ndarray, predicted: np.ndarray):
""" Simple error """
return actual - predicted