Skip to content

Instantly share code, notes, and snippets.

View OrelSokolov's full-sized avatar
🎯
Focusing

Oleg Orlov OrelSokolov

🎯
Focusing
View GitHub Profile
@OrelSokolov
OrelSokolov / FAST_CRYSTAL_ROADMAP.md
Last active October 16, 2026 10:02
FAST_CRYSTAL_ROADMAP.md

FAST_CRYSTAL_ROADMAP — догнать C в горячих циклах

Почему Crystal медленнее C (на примере brotli.cr и freetype.cr)

Порты brotli и freetype на Crystal — это код в C-стиле: предаллоцированные буферы, индексы вместо указателей, unsafe_fetch, uninitialized, @[AlwaysInline] (сотни вхождений). Аллокаций в горячем пути ноль, GC молчит. И всё равно на hot loops остаётся типичный разрыв в 15–40% до C. Языковых средств, которые C даёт из коробки, в Crystal просто нет — и дело не в GC и не в «медленном рантайме», а в четырёх конкретных

@OrelSokolov
OrelSokolov / fix.md
Last active October 11, 2026 20:36
Xiaomi Redmi notebook Ubuntu YMTC PC300 (DRAM-less NVMe, `1e49:1033`) freezes Linux suspend/resume

Fix: YMTC PC300 (DRAM-less NVMe, 1e49:1033) freezes Linux suspend/resume

TL;DR

On an s2idle-only Meteor Lake laptop, suspend hung ~50% of the time with a black screen and required a hard reset. The culprit was not the GPU driver — it was the SSD: the YMTC PC300 NVMe drive stops completing I/O when its PCIe link is allowed to enter deep ASPM states (L1/L1.1/L1.2) around sleep transitions.

Fix — disable link power management for the drive + drive-side APST:

@OrelSokolov
OrelSokolov / macos_qemu_performance_guide.md
Created May 29, 2026 13:47
1920x1080 60FPS performance guide for QEMU KVM MacOS without passthrough

1920x1080@60fps without GPU passthrough

Tested on: QEMU 9.2.1, macOS Guest (Big Sur – Sequoia), Host OS: Ubuntu 24.04 / GNOME (X11)
Display: vmware-svga (no GPU passthrough)
Note: In macOS System Information (About This Mac) you will still see 3–7 MB of Video Memory regardless of QEMU settings. This is expected and not a problem. The vgamem_mb parameter does not affect the macOS driver or framebuffer performance — do not chase this dead end.> Resolution: 1920×1080


Core Principle

@OrelSokolov
OrelSokolov / nopanic.rs
Created December 3, 2025 14:04
Deny any panic methods in crate
//! NoPanic - Complete set of rules to forbid panics and dangerous constructs
//!
//! This file contains crate-level attributes to forbid compilation
//! with methods that can cause panics or unsafe operations.
//!
//! Include at the beginning of main.rs via: include!("nopanic.rs");
// ============================================================================
// FORBID PANIC METHODS (deny - compilation error)
// ============================================================================
@OrelSokolov
OrelSokolov / dxvk.conf
Last active March 28, 2022 08:46
Armored Warfare Проект Армата DXVK конфиг для увеличения FPS
# DXVK Project: https://github.com/doitsujin/dxvk
#
#
# Override PCI vendor and device IDs reported to the application. Can
# cause the app to adjust behaviour depending on the selected values.
#
# Supported values: Any four-digit hex number.
# dxgi.customDeviceId = 0000
dxgi.customVendorId = 10de
class Buffer
attr_reader :buffer, :overflows
def initialize(&block)
@limitation_criteria = block
@buffer = []
@overflows = 0
end
def set_action(&block)
# Something like Rails helper, but with short M instead of Million
def short_number_to_human(n)
postfix = { 1 => "", 10**3 => "K", 10**6 => "M", 10**9 => "B"}
key = postfix.keys.select{|k| n/k.to_f >= 1}.max
"#{(n/key.to_f).round}#{postfix[key]}"
end

Problem is after installation from official site postgresql was not found:

locate bin/psql

Then we got /Library/PostgreSQL/10/bin/psql. Add this to PATH variable in .profile

export PATH=/Library/PostgreSQL/10/bin:$PATH

Problem:

No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***

Try this:

@OrelSokolov
OrelSokolov / 1.rb
Created August 12, 2015 17:40
test
require_relative 'helpers/handle_errors'
require 'ostruct'
require 'phone'
class ParsedStore < OpenStruct
include HandleErrorsHelper
def initialize(*args)
super(*args)