Skip to content

Instantly share code, notes, and snippets.

View mosolovsa's full-sized avatar
🐈

Mosolov Sergey mosolovsa

🐈
View GitHub Profile
@mosolovsa
mosolovsa / mount_qcow2.md
Created May 3, 2024 06:35 — forked from shamil/mount_qcow2.md
How to mount a qcow2 disk image

How to mount a qcow2 disk image

This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.

Step 1 - Enable NBD on the Host

modprobe nbd max_part=8
@mosolovsa
mosolovsa / main.cpp
Created August 10, 2023 14:05
Virtual table for predefined set of custom protocol request handlers to make possible store request structures as POD and dispatching to handler via request type
#include <iostream>
#include <cassert>
using RequestHandler = void (*)(void);
struct RequestHandlers {
static constexpr size_t MAX_REQ_TYPE_CNT = 255;
enum EFlags {
IsExisting = 0x01,
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from PySide2.QtCore import QTimer, QObject, SIGNAL
from PySide2.QtGui import QResizeEvent
from PySide2.QtWidgets import QApplication, QWidget, QLabel, QMainWindow
from PySide2.QtSvg import QSvgWidget
import sys
class AppWindow(QMainWindow):
def __init__(self, parent=None):
super(AppWindow, self).__init__(parent)
sudo apt install autoconf build-essential bison flex git texinfo help2man gawk libtool libncurses5-dev python3-dev python3-distutils
git clone http://github.com/crosstool-ng/crosstool-ng
cd crosstool-ng
./bootstrap
./configure --enable-local
DEFCONFIG=samples/.../crosstool.config ./ct-ng defconfig
./ct-ng build
@mosolovsa
mosolovsa / main.py
Created July 1, 2021 22:06
manual duplex printing chunk generate
import os.path
from PyPDF2 import PdfFileReader, PdfFileWriter
# chunk_size, path = sys.argv[1], sys.argv[2]
chunk_size, path = 50, '/home/serg/print/auto/fluent.pdf' # '/home/serg/Documents/sicp.pdf'
pdf = PdfFileReader(str(path))
cnt = pdf.getNumPages()
ranges = [range(i, i+chunk_size) for i in range(0, cnt, chunk_size)]
@mosolovsa
mosolovsa / main.dart
Created May 20, 2021 10:07
Custom flutter navigation widget
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
void main() {
runApp(StartupApplication());
}
enum Page { screenDashboard, screenProfile, screenSearch }
#include <iostream>
#include <memory>
#include <cxxabi.h> // <-- gcc header
template <typename type> std::unique_ptr<const char*> type_name(const type *addr)
{ return std::make_unique<const char *>(abi::__cxa_demangle(typeid(*addr).name(), 0, 0, NULL)); }
template<typename T> struct MyTest {
MyTest(T _data) : data(_data) { }
@mosolovsa
mosolovsa / main.cpp
Created November 6, 2020 09:12
noway for virtuals
#include <iostream>
template <typename T> constexpr
void print_type() {
std::cerr << __PRETTY_FUNCTION__ << std::endl;
}
enum ETypes {
type1,
type2
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <fcntl.h>
#include <malloc.h>