Skip to content

Instantly share code, notes, and snippets.

View inilim's full-sized avatar

inilim

View GitHub Profile
@inilim
inilim / InotifyEnum.php
Last active February 5, 2026 05:54
Enum for extension php "inotify"
<?php
enum InotifyEnum: int
{
case ACCESS = \IN_ACCESS;
case MODIFY = \IN_MODIFY;
case ATTRIB = \IN_ATTRIB;
case CLOSE_WRITE = \IN_CLOSE_WRITE;
case CLOSE_NOWRITE = \IN_CLOSE_NOWRITE;
case OPEN = \IN_OPEN;
@inilim
inilim / article-php-sqlite-and-fiber-an-unobvious-trick-to-save-memory.md
Last active February 5, 2026 03:00
[Article] PHP, SQLite and Fiber: An unobvious trick to save memory

PHP 8.1 introduced Fibers, and SQLite 3.38.0 added built-in json_tree support. What happens when you combine these two technologies with a custom PDO function? You get a quite exotic, yet efficient method for data processing with minimal memory overhead.

What's the Problem?

The standard json_decode in PHP works great until you encounter megabyte-sized files.

Streaming parsers exist, but they are often slower and more complex to use. Our approach is a "golden middle": simpler than streaming, yet more economical than json_decode.

The Core Idea

@inilim
inilim / statya-php-sqlite-i-fiber-neochevidnyy-tryuk-dlya-ekonomii-pamyati.md
Last active February 5, 2026 03:01
[Статья] PHP, SQLite и Fiber: Неочевидный трюк для экономии памяти

В PHP 8.1 появились файберы (Fibers), а в SQLite 3.38.0 — встроенная поддержка json_tree. Что будет, если объединить эти две технологии с кастомной функцией PDO? Получится весьма экзотический, но эффективный способ обработки данных с минимальным оверхедом по памяти.

В чем проблема?

Стандартный json_decode в PHP работает отлично, пока вы не сталкиваетесь с мегабайтными файлами.

Существуют стримовые парсеры, но они часто медленнее и сложнее в использовании. Наш подход — это "золотая середина": проще стриминга, но экономнее json_decode.

@inilim
inilim / tampermonkey.js
Created January 12, 2026 15:45
Twitch — hide dark overlay
// ==UserScript==
// @name Twitch — hide dark overlay
// @namespace http://tampermonkey.net/
// @version 1.0
// @description скрывает оверлей блокировщик
// @author You
// @match https://www.twitch.tv/*
// @grant none
// ==/UserScript==
@inilim
inilim / tampermonkey.js
Last active January 10, 2026 18:11
YouTube - скрыть старые видео | hide old videos
// ==UserScript==
// @name YouTube — скрыть старые видео
// @namespace http://tampermonkey.net/
// @version 1.3
// @description Скрывает видео старше 1 года
// @author You
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
@inilim
inilim / index.php
Created November 16, 2025 21:35
4.2# Парсинг LiveLib. Парсинг данных из файлов и занесение в БД. (PHP, Crawler, SqLite)
<?php
error_reporting(E_ALL);
set_time_limit(0);
date_default_timezone_set('Etc/GMT-3');
require_once __DIR__ . '/functions.php';
# Функции для работы с PDO SqLite
require_once __DIR__ . '/_INIL_connectLite.php';
require_once __DIR__ . '/vendor/autoload.php';
ini_set('memory_limit', '5024M');
timeRun();
@inilim
inilim / index.php
Last active November 16, 2025 21:34
4.1# Парсинг LiveLib. Сбор href в базу и сохранение html файлов. (PHP, Crawler, HTTPClient, SQLite)
<?php
error_reporting(E_ALL);
set_time_limit(0);
date_default_timezone_set('Etc/GMT-3');
require_once __DIR__ . '/functions.php';
# Функции для работы с PDO SqLite
require_once __DIR__ . '/_INIL_connectLite.php';
require_once __DIR__ . '/vendor/autoload.php';
ini_set('memory_limit', '5024M');
timeRun();