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 / 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 / telegramBot.md
Last active May 15, 2025 08:31
Telegram Bot / Send message
@sokil
sokil / mysqlLostConnection.md
Last active November 5, 2024 20:11
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

Set global timeout:

mysql> SET GLOBAL wait_timeout=10;
@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
@sokil
sokil / SignalHandler.php
Last active January 26, 2024 15:07
Handle signals by dispatcher or ticks
<?php
class SignalHandler
{
/**
* @var bool
*/
private $isRunning;
/**
@sokil
sokil / delete_insert_deadlock.sql
Last active November 28, 2023 13:11
select for update deadlock
## Connection 1
1. begin
3. delete from table where id = 1;
5. insert into table values (1);
## Connection 2
2. begin