Skip to content

Instantly share code, notes, and snippets.

View sokil's full-sized avatar
🇺🇦
sapere aude

sokil

🇺🇦
sapere aude
View GitHub Profile
@sokil
sokil / mysqlLostConnection.md
Last active June 12, 2026 07:42
Mysql Server Has Gove Away
  • Error Code: 2013. Lost connection to MySQL server during query
  • Error Code: 2006. MySQL server has gone away
  • Error Code: 2003. Lost connection to backend server
  • The error code reported for MySQL server wait timeouts has been changed from 2006 to 4031 for MySQL server versions 8.0.24 and above.

Set global timeout:

mysql> SET GLOBAL wait_timeout=10;
@sokil
sokil / telegramBot.md
Last active June 10, 2026 21:45
Telegram Bot / Send message
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Php55\Rector\Class_\ClassConstantToSelfClassRector;
use Rector\Php70\Rector\FuncCall\MultiDirnameRector;
use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector;
use Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector;
use Rector\Php71\Rector\List_\ListToArrayDestructRector;
@sokil
sokil / README.md
Last active May 3, 2026 21:17
extract_cpp_hex_image.py

Command to create hex file:

xxd -i wallpaper.jpeg > wallpaper.h

Example:

extern const unsigned char wallpaper[];
@sokil
sokil / rush_pll_test.cpp
Created October 19, 2025 14:23
rush_pll_test.cpp
#include <cstdint>
#include <cstdio>
#define RUSH_REFERENCE_FREQ 50 // MHz
#define RUSH_INTERMEDIATE_FREQ 480 // MHz
#define RUSH_R_DIVIDER 1
#define RUSH_MOD 65536
#define RUSH_R_OUT_DIVIDER 1
#define FPFD (RUSH_REFERENCE_FREQ / RUSH_R_DIVIDER)
@sokil
sokil / elastic.http
Last active October 10, 2025 11:50
Elastic change index mapping
# get valid mapping and fix it
GET /test.activity_log_v1
# create new indewx with fixed mapping
PUT /test.activity_log_v2/
{
"mappings": {
"properties": {
"action": {
"type": "keyword"
@sokil
sokil / ELRS_Lora_SX1276_Pover_Levels.php
Last active July 3, 2025 08:01
ELRS Lora Pover Levels
<?php
$pattern = "| %12s | %12s | %12s | %-8s | %16s | %16s | %18s | %19s | \n";
echo sprintf(
$pattern,
'regPaConfig',
'regPaConfig',
'ELRS Power',
'paSelect',
@sokil
sokil / datetime.md
Last active November 5, 2024 16:01
date time and timestamp in MySQL

Difference

MySQL converts TIMESTAMP values from the current time zone to UTC for storage, and back from UTC to the current time zone for retrieval. This does not occur for other types such as DATETIME.

if server timezone changed, values of timestamp will be valid, because it stored as UTC, but values of datetime will change.

Timestamp

Timestamp stores values from 1970-01-01 00:00:00 UTC.

@sokil
sokil / README.md
Last active February 24, 2024 11:08
BetaFlight

Compile

Compile locally

make arm_sdk_install

Compile using Docker

@sokil
sokil / NginxUnitControl Api.sh
Last active February 24, 2024 11:00
Nginx Unit Control Api
# Set new
curl -XPUT --unix-socket /var/run/control.unit.sock http://localhost/config/applications/app/processes -d 100
# Read current
curl --unix-socket /var/run/control.unit.sock http://localhost/config/applications/app/processes