Skip to content

Instantly share code, notes, and snippets.

@marina-mosti
marina-mosti / useEmptySlotCheck.js
Last active April 23, 2024 09:40
Vue 3 check for slot with no content
import { ref, computed, onBeforeUpdate, Comment, Fragment, Text, useSlots } from 'vue'
// Adapted from https://github.com/vuejs/vue-next/blob/ca17162e377e0a0bf3fae9d92d0fdcb32084a9fe/packages/runtime-core/src/helpers/renderSlot.ts#L77
// Demo: https://play.vuejs.org/#eNqVVm1P3EYQ/iuDU+UOdNiEa0NBHE2gRE1bJVWg/RJH1Z49PhvstbW7PkDX+++d2bV9vmCIggTa3Xl7ZuaZMSvvbVX5yxq9E+9URyqrDGg0dXUWyqyoSmXgoiwqSFRZwMgP+MLqo068AoXJBEp5jkmp8O8qFgYnUGu8ykujYd3YOqNQRqXUBgq9gBlbjke/ZTuj3Y3ElItFbm1JYbwLszMKEUpgE38p8hrpfXP+BWSd53AC1k8o16E8DVwilAJdDBZVTpDoBnDK+O0JYLWyKNZk4R46VXghRYFnaXYabFvb9K1busxrY0oJb6I8i25nobcBHnpnF/wIBZ4GTo2Mes68iWc0pZtkC/9Gl5KKv2KfoRdRgCxH9bEyGZUj9E7ASlgm8ry8+92+GVXjpH2PUoxuB95v9D2/hd5fCjWqJYZeJzNCLZCAsvjy6gPe07kTFmVc56T9jPAT6jKvGaNTO69lTLB7ehbte8uRTC6u9eW9QanbpBgoa66tfugRO7i2T6W+gTv1p9aOOk1VbOnI7N1ulWYCcRu5M6jJFoKehM9b3aXrMP2/j9+N0RX7uCwq88BKF9ygboQGZL3BYHSaGN76H9NoOMkKCK0z0hOIMckkxi2G2VDIsXVmZ2sb/riZK64HOy9z9PNyMXbl3oRxM7YdzL2xJjle0283btSPARBEcOrO88WkNhYozQTeKbFwp2ti3aPdEeztUeA9+BUNqoIgabhL0aSoQNjKQaYdfCD38A/th+k
@FrankFang
FrankFang / svgsprites.ts
Last active January 7, 2024 09:13
A Vite plugin for generating svg sprites
import path from 'path'
import fs from 'fs'
import store from 'svgstore'
import { optimize } from 'svgo'
import type { Plugin, ViteDevServer } from 'vite'
interface Options {
id?: string
inputFolder?: string
inline?: boolean
@pazguille
pazguille / partytown.html
Last active April 9, 2024 18:19
Use Partytown 🎉 without frameworks
<!doctype html>
<html lang="es-AR">
<head>
<meta charset="utf-8" />
<meta name="HandheldFriendly" content="True" />
<link rel="preconnect" href="https://www.dolarsi.com" />
</head>
<body>
<script type="text/partytown">
window.dataLayer = window.dataLayer || [];
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<!-- Partytown config -->
<script>
partytown = {
debug: true,
@johnfmorton
johnfmorton / proxy-for-partytown.php
Last active March 29, 2024 12:31
Simple proxy with php for use with Partytown
<?php
/**
* About this script:
* This proxy was built with PartyTown.js in mind. https://github.com/BuilderIO/partytown
* Partytown is a lazy-loaded library to help relocate resource intensive scripts into a
* web worker, and off of the main thread.
* Many third-party scripts already provide the correct CORS headers, but not all do.
* For services that do not add the correct headers, then a reverse proxy to another domain must be used in order to provide the CORS headers.
* see: https://github.com/BuilderIO/partytown/wiki/Proxying-Requests
@ostark
ostark / NoFields.php
Created February 10, 2021 21:09
lightweight entry queries without custom fields
<?php
namespace modules;
class NoFields extends \craft\services\Fields
{
public function getAllFields($context = null): array
{
return [];
}
@sanderson
sanderson / boxfile.yml
Created April 7, 2017 15:50
Changes to CraftCMS for Nanobox
run.config:
engine: php
engine.config:
runtime: php-7.0
document_root: public
webserver: apache
extensions:
- ctype
- pdo
- pdo_mysql
@timkelty
timkelty / default.vcl
Last active October 16, 2017 15:29
VCL 4.0 (Load Balanced, SSL termination, ESI, sticky sessions, PURGE, BAN, some specifics for Craft CMS)
vcl 4.0;
import std;
import directors;
import cookie;
import header;
backend web01 {
.host = "web01.myserver.com";
.port = "80";
<?php
$db = Yii::$app->db;
$sql = $db->queryBuilder->batchInsert($table, $fields, $rows);
$db->createCommand($sql . ' ON DUPLICATE KEY UPDATE')->execute();
@khalwat
khalwat / BradsForMen.conf
Last active January 1, 2020 01:10
How to avoid .htaccess completely, and put your rewrite rules for Craft CMS in an Apache .conf file
# Using .htaccess is something you should avoid if at all possible, due to performance concerns:
# https://httpd.apache.org/docs/current/howto/htaccess.html
# Here's how to implement the rewrite rules for CraftCMS in an Apache .conf file; the key
# part is the "## Removes index.php from Craft URLs ##" section; the rest is provided
# just for context. Enjoy - andrew@nystudio107.com
<VirtualHost *:80>
ServerName BradsForMen.com
ServerAlias *.BradsForMen.com
DocumentRoot /var/www/BradsForMen/public