Skip to content

Instantly share code, notes, and snippets.

@Toliak
Toliak / RESEARCH.md
Last active November 7, 2024 11:45
Huawei Matebook D16 RLEF-X NVMe Laptop Disk is read-only after sleep problem research and fix

I have bought laptop Huawei Matebook D16 RLEF-X. Tried to use Arch Linux and encountered with the problem:

  1. Turn on the suspend mode (sudo systemctl suspend)
  2. Close the laptop lid
  3. Wait a few minutes
  4. Open the laptop back
  5. Use mount to see that the disk is read-only. Moreover, it determines like read-only, however, it is just broken. No zsh history, no executables, no way to poweroff without power button long-press.
@Toliak
Toliak / shame.py
Last active February 14, 2023 10:16
Python runtime bytecode patch example
import functools
import struct
import types
import dis
def _patch_code(code: types.CodeType):
# Call function with 0 arguments
function_call_bytearray = bytearray(dis.opmap['CALL_FUNCTION'].to_bytes(1, byteorder='little') + b'\x00')
@Toliak
Toliak / caveats.lua
Last active February 4, 2021 09:31
MTASA has some interesting caveats with NPC damage synchronization and processLineOfSight function
SERVER_SIDE = guiGetScreenSize == nil
CLIENT_SIDE = guiGetScreenSize ~= nil
---------------
-- LIFECYCLE --
---------------
if SERVER_SIDE then
addEventHandler('onResourceStart', resourceRoot, function()
@Toliak
Toliak / Guide.md
Last active November 19, 2023 10:12
Пошаговая инструкция по сборке и тестированию

CMakeLists.txt

Прописывается основная информация для сборки через CMake.

cmake_minimum_required(VERSION 3.4)    # Минимальная версия CMake

set(CMAKE_CXX_STANDARD 17)             # Стандарт C++
set(CMAKE_CXX_STANDARD_REQUIRED ON)    # Обязательность установки указанного стандарта (если OFF (по умолчанию), то воспринимается как совет)
@Toliak
Toliak / touchpad.md
Last active November 8, 2023 09:01
Фичи для тачпада

Настройка touchpad'а на Manjaro

Данный апгрейд позволит вам использовать touchpad для переключения рабочих столов, окон и для подобных действий

Добавление группы

sudo gpasswd -a $USER input
@Toliak
Toliak / .bashrc
Created June 19, 2019 13:24
Useful aliases for arch linux
alias ll="ls -la"
alias pac="sudo pacman --noconfirm"
alias yao="yaourt --noconfirm"
alias give-me-upgrade="sudo pacman --noconfirm -Syyuu && yaourt --noconfirm -Syyuua"
alias give-me-ssh="ssh-add $(ls ~/.ssh | egrep "^([^\.]+)$" | grep -v known_hosts)"
@Toliak
Toliak / encodeString-filesize-fix.lua
Last active February 22, 2020 15:29
MTA encodeString filesize fix
local KEY = "sampletext"
addEventHandler("onResourceStart", resourceRoot, function()
-- ENCODE
local file = File.open("test.txt")
local raw = file:read(file.size)
file:close()
local len = #raw
local lent = {}
@Toliak
Toliak / vk-read.js
Last active June 17, 2018 17:13
Reads last VK message or amount of messages
function vk_read(token, id) {
if (!typeof(token) === "string") throw "TypeError: Expected string at 1 argument";
if (!typeof(id) === "number") throw "TypeError: Expected number at 2 argument";
// Упрощение AJAX запроса
let ajax = function(method, url, data) {
let xhr = new XMLHttpRequest();
// формируем запрос
let send = "";
@Toliak
Toliak / downloader.js
Created June 11, 2018 11:26
Download files from `/url/${from}` to `/url/${to}`
function downloader (from = 1, to = 5, url) {
if (typeof(url) !== "string") throw;
const INTERVAL = 250; // Интервал между запросами
window.g_timer_timestamp = Date.now();
window.g_counter = from; // Счетчик
window.g_aviable = true; // Если прошлый файл не скачался, новое скачивание не начинается
let f = function() {
window.g_aviable = false; // Блокируем