Skip to content

Instantly share code, notes, and snippets.

View Tymek's full-sized avatar

Tymoteusz Czech Tymek

View GitHub Profile
version: '3'
services:
mysql:
image: docker.io/bitnami/mysql:8.0
volumes:
- ./mysql_data:/bitnami/mysql
environment:
- ALLOW_EMPTY_PASSWORD=yes
- MYSQL_USER=bn_wordpress
- MYSQL_DATABASE=bitnami_wordpress
@Tymek
Tymek / gist:170c5e6f14f580c069a0d1bc71419095
Created January 16, 2023 19:13
ZSH - list colors for p10k (powerlevel10k)
for i in {0..255}; do print -Pn ' '%K{$i} %k%F{$i}${(l:3::0:)i}%f ' ' ${${(M)$((i%6)):#3}:+$'\n'}; done
type CacheType<T> = {
has: (key: string) => boolean;
get: (key: string) => T | undefined;
set: (key: string, result: T, now?: number) => void;
clear?: () => void;
};
const createCache = <T>(maxAge = 60_000): CacheType<T> => {
const values = new Map<string, T>();
const expiry = new Map<string, number>();
@Tymek
Tymek / imgsize.ts
Created August 21, 2024 17:20
ts image size handler
import http from 'node:http'
import https from 'node:https'
import sizeOf from 'image-size'
const MAX_REDIRECTS = Number.parseInt(
process.env.IMGMETA_MAX_REDIRECTS || '10',
10,
)
const ALLOWED_DOMAINS = process.env.IMGMETA_ALLOWED_DOMAINS || '*'
const TIMEOUT =
@Tymek
Tymek / indexed.ts
Last active September 16, 2024 19:15
TS type with indexed object and version property
// TypeScript type for an object with 1 property that is required but different then other properties
type Todo = { id: string; text: string; done: boolean }
type Table = Array<Record<string, unknown>>
type Schema = (
| {
[key: string]: Table
}
@Tymek
Tymek / console.js
Created February 12, 2025 13:41
Visually checking font-size on the page.
(() => {
document.querySelectorAll('*').forEach(el => {
const hasDirectText = Array.from(el.childNodes).some(
node => node.nodeType === Node.TEXT_NODE && node.textContent.trim().length > 0
)
if (hasDirectText) {
const size = window.getComputedStyle(el).fontSize
if (size === '16px') {
el.style.backgroundColor = 'red'
} else if (size === '15px') {
const viewer = new Cesium.Viewer("cesiumContainer", { shouldAnimate: true });
viewer.scene.globe.enableLighting = true;
// Distance threshold in meters for label visibility
const LABEL_VISIBILITY_DISTANCE = 5000000;
const updateLabelVisibility = () => {
const cameraPosition = viewer.camera.position;
const entities = viewer.entities.values;