Skip to content

Instantly share code, notes, and snippets.

View khromov's full-sized avatar
🍡

Stanislav Khromov khromov

🍡
View GitHub Profile
@khromov
khromov / async_report.md
Last active November 24, 2026 01:44
svelte vs svelte-lite async

What dropping async saved

Svelte's scheduler is built around experimental.async. State changes are grouped into batches that each hold their own view of the state, so that several can be pending at once, be rebased on each other, or be thrown away. Every app ships that machinery, whether or not it uses async. svelte-lite does not support async in the browser, so its scheduler is synchronous, and the machinery is gone.

Compared here: Svelte 5.59.1 at [90ad4e8][svelte] and svelte-lite at [70bb7c0][lite].

@khromov
khromov / README.md
Last active April 27, 2025 23:20
llms.txt file for htmx
@khromov
khromov / bundle-size.yaml
Last active January 3, 2025 21:58
GitHub Actions Bundle size comparison
name: 'Bundle Size Comparison'
on:
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
@khromov
khromov / service-worker.ts
Created April 10, 2023 21:17
SvelteKit service worker example
/// <reference types="@sveltejs/kit" />
/// <reference no-default-lib="true"/>
/// <reference lib="esnext" />
/// <reference lib="webworker" />
// https://kit.svelte.dev/docs/service-workers#type-safety
const sw = self as unknown as ServiceWorkerGlobalScope;
import { build, files, version } from '$service-worker';
@khromov
khromov / focused.ts
Last active February 19, 2023 20:20
Svelte window focused action
// Example: <div use:focused={(e) => console.log('Focused, event:', e)}>
export default function focused(node: HTMLElement, callback: Function) {
const handleFocusEvents = (event: Event) => {
callback(event)
};
window.addEventListener('online', handleFocusEvents);
window.addEventListener('focus', handleFocusEvents);
@khromov
khromov / .dockerignore
Last active January 11, 2023 20:04
SvelteKit staged build Dockerfile
node_modules
README.md
.svelte-kit
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
.env*.local
.env.local
.env
@khromov
khromov / README.md
Last active January 3, 2023 02:53
DiceBear avatars for WordPress
@khromov
khromov / plugin.php
Created September 17, 2022 21:37
Gutenberg block templates with Advanced Custom Fields
<?php
/*
Plugin Name: Plugin
Version: 1.0
*/
add_action('acf/init', function() {
// Check function exists.
if( function_exists('acf_register_block_type') ) {
@khromov
khromov / tampermonkey-script.js
Last active August 12, 2022 12:48
Tampermonkey: Find driving slot Trafikverket
// ==UserScript==
// @name Find slot
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Book a Förarprov with the place and type (manual/auto) that you want, then go to Boka Prov > Personbil B > Bokade Prov > Press the edit icon for the existing test. Enable the script and reload the page. The script will look for a better time in the same configuration of auto/manual and location.
// @author You
// @match https://fp.trafikverket.se/boka/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=trafikverket.se
// @require https://cdnjs.cloudflare.com/ajax/libs/ion-sound/3.0.7/js/ion.sound.min.js
// @grant none
@khromov
khromov / gutenberg-locked-template.php
Created June 9, 2022 23:41
WordPress Gutenberg - Add a locked template to a post type
<?php
add_action('init', function() {
// For which posts type
$post_type_object = get_post_type_object( 'post' );
// Which allowed blocks
$post_type_object->template = [
['core/heading', ['level' => '5', 'content' => 'Default value']],
['core/paragraph'],
['core/image'],