Skip to content

Instantly share code, notes, and snippets.

View cododel's full-sized avatar
💻

@cododelia cododel

💻
View GitHub Profile
@cododel
cododel / sql_to_seed.py
Created April 18, 2025 14:51
Convert "Sql INSERT INTO" to "Directus-Sync seed" file
import re
import json
import argparse
from typing import List, Dict, Any, Tuple, Optional
from pathlib import Path
def normalize_sql_content(sql_content: str) -> str:
"""
Normalize SQL content by:
1. Removing comments (--, /* */)
@cododel
cododel / README.md
Last active March 27, 2025 10:15
Update WooCommerce Attributes and Terms Slugs with Transliteration

Usage: Add this snippet to your WordPress theme's functions.php or a custom plugin to update WooCommerce attribute and term slugs.

Features:

  • Transliterate Cyrillic to Latin for attribute slugs (e.g., pa_цвет -> pa_cvet)
  • Update term slugs (e.g., красный -> krasnyj)
  • Preserve original attribute and term names
  • One-time execution with option check
  • Uses standard WooCommerce/WP functions with proper cache handling

Instructions:

@cododel
cododel / passgen.sh
Created December 24, 2024 10:05
Password Generator
#!/bin/bash
chars="abcdefghijklmnopqrstuvwxyz"
consonants='bcdfghjklmnpqrstvwxyz'
vowels='aeiou'
digits='0123456789'
special='()`~!@#$*-+={}[]:;,. ?/'
length=16
include_uppercase=false
@cododel
cododel / CommentSelector.js
Created October 30, 2024 12:37
JavaScript HTML Comment Selector class
class CommentSelector {
static comments = [];
static getAllCommentNodes() {
if (this.comments.length > 0) return this.comments;
const commentNodes = [];
const iterator = document.createNodeIterator(document, NodeFilter.SHOW_COMMENT, null, false);
let currentNode;
@cododel
cododel / Cell.php
Created October 27, 2024 15:44
PHP HTML Dom Static Builder
<?php
namespace App\Services\Table;
use App\Services\HTML\HTMLElement;
class Cell extends HTMLElement
{
public static function getTagName(): string
{
<?php
namespace App\Services\HTML\Modules\Tailwind;
trait InteractsWithTailwind
{
abstract public function class(string $class): static;
// Text utilities
@cododel
cododel / toCallable.ts
Created October 14, 2024 20:45
Helper to make class instance callable
type hasCallMethod = { call: (...args: any[]) => any };
export default function toCallable<T extends hasCallMethod>(instance: T) {
type argsType = Parameters<T["call"]>
const fn = (...args: argsType) => {
return instance.call(...args);
};
return new Proxy(fn.bind(instance), {
apply: (target, _thisArg, argsList: argsType) => target(...argsList),
@cododel
cododel / networkidle.js
Last active October 9, 2024 13:48
Network IDLE listener
function useNetworkidleEvents(){
let activeRequests = 0;
let idleTimeout = null;
// Функция для проверки состояния сети
function checkNetworkIdle() {
if (activeRequests === 0) {
idleTimeout = setTimeout(() => {
const event = new CustomEvent('network-idle');
window.dispatchEvent(event);
@cododel
cododel / PWCache.ts
Created August 11, 2024 00:53
managed request caching system for playwright with typescript
import type { Page, Response } from "playwright";
import fs from 'fs';
export class PWCache {
private readonly cacheDir = './.cache';
statistics: {
totalRequests: number;
totalCached: number;
totalNotCached: number;
};
@cododel
cododel / example.py
Created August 8, 2024 23:40
Async to Sync python with correct type definition
from sync_await import sync_await
class BookModel(BaseModel):
id: int
title: str
content: str
async def fetch_book(id: int) -> BookModel:
...