Skip to content

Instantly share code, notes, and snippets.

View predaytor's full-sized avatar
🍁
it's perfect

Dmytro Pushkarchuk predaytor

🍁
it's perfect
View GitHub Profile
@isaumya
isaumya / wpcspc_device_based_cache_cf_worker_template.js
Last active May 10, 2025 18:46
Custom Cloudflare Worker Code for Device Based Caching - WP Cloudflare Super Page Cache Plugin
/**
* Worker Name: WPCSPC - Device based Cache
* Description: This worker is responsible for caching the requests based on the device type
* Based on Default Worker Version: 2.8.0
* Version: 2.1.0
* @link: https://wordpress.org/plugins/wp-cloudflare-page-cache/
* @link: https://wordpress.org/support/topic/mobile-page-theme-and-cloudflare-caching-plugin-integration/
* @author: Saumya Majumder
*/
// Default cookie prefixes for cache bypassing
@erangaeb
erangaeb / minikube
Last active November 14, 2023 17:37
configure memory and cpu
# by default minikube alloca 2 cpus and 2 gb memory
minikube start
# delete existing minikube instance and allocate more memory/cpu on start up
minikube stop
minikube delete
minikube start --memory 8192 --cpus 4
>> 🔥 Creating hyperkit VM (CPUs=4, Memory=8192MB, Disk=20000MB)
# keep existing minikube instance and allocate more memory/cpu
@erangaeb
erangaeb / minikube
Created November 7, 2021 10:33
configure docker0 bridge
# the default docker0 bridge inside minikube
minikube ssh
ifconfig
>> output
docker0 Link encap:Ethernet HWaddr 02:42:E1:6D:15:33
inet addr:172.17.0.1 Bcast:172.17.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:311191 errors:0 dropped:0 overruns:0 frame:0
TX packets:307842 errors:0 dropped:0 overruns:0 carrier:0
@juancsr
juancsr / mac-docker-withot-docker-destop.md
Last active November 11, 2025 18:32
Use docker in mac without docker-
@mattiaz9
mattiaz9 / blurhashDataURL.ts
Last active October 29, 2025 01:56
Convert blurhash to a base64 DataURL string (no canvas or node-canvas)
import { decode } from "blurhash"
export function blurHashToDataURL(hash: string | undefined): string | undefined {
if (!hash) return undefined
const pixels = decode(hash, 32, 32)
const dataURL = parsePixels(pixels, 32, 32)
return dataURL
}
import { useSignal, signal, effect } from '@preact/signals';
import { useLayoutEffect, useMemo, useRef } from 'preact/hooks';
/** @template T @typedef {T extends (infer U)[] ? U : never} Items */
/** @param {{ v, k?, f }} props */
const Item = ({ v, k, f }) => f(v, k);
/**
* Like signal.value.map(fn), but doesn't re-render.
@marvinhagemeister
marvinhagemeister / bind-plugin.ts
Last active June 8, 2025 06:48
Preact Signals `bind:value`
import { options } from "preact";
import { Signal } from "@preact/signals";
// Add `bind:value` to JSX types
declare global {
namespace preact.createElement.JSX {
interface HTMLAttributes {
"bind:value"?: Signal<string | string[] | number | undefined>;
}
}
@richardscarrott
richardscarrott / worker.ts
Last active February 8, 2026 09:50
Cloudflare Workers / Pages `stale-while-revalidate`
import { parse } from 'cache-control-parser';
export default {
async fetch(request: Request, env: {}, ctx: ExecutionContext): Promise<Response> {
try {
const cache = await caches.default;
const cachedResponse = await cache.match(request);
if (cachedResponse) {
console.log('Cache: HIT');
if (shouldRevalidate(cachedResponse)) {
@rphlmr
rphlmr / protect-routes.ts
Last active November 26, 2024 00:24
Protected routes middleware with HonoJS with Remix-Hono
import { getSession, session } from "remix-hono/session";
import { pathToRegexp } from "path-to-regexp";
/**
* Add protected routes middleware
*
*/
app.use(
protect({
@samselikoff
samselikoff / settings.json
Last active February 20, 2025 15:40
Tweaked Dracula theme for VSCode
{
"diffEditor.renderSideBySide": true,
"editor.fontSize": 14,
"editor.lineHeight": 22,
"editor.tabSize": 2,
"editor.matchBrackets": "never",
"editor.cursorBlinking": "solid",
"editor.selectionHighlight": false,
"editor.occurrencesHighlight": "off",
"editor.scrollbar.horizontal": "hidden",