Skip to content

Instantly share code, notes, and snippets.

@mausvt
mausvt / worker.hpp
Last active January 8, 2023 12:19
KDAB thread worker wrapper
class Worker public QObject
{ Q_OBJECT
public:
Worker() {
// create timer, socket, etc.
m_thread.reset(new QThread); // no parent
moveToThread(m_thread.get());
m_thread->start();
}
~Worker() {
@mausvt
mausvt / sha256_file.py
Created December 22, 2020 17:45 — forked from eas604/sha256_file.py
sha256 file checksum function in python
def sha256_file(file_path, chunk_size=65336):
"""
Get the sha 256 checksum of a file.
:param file_path: path to file
:type file_path: unicode or str
:param chunk_size: number of bytes to read in each iteration. Must be > 0.
:type chunk_size: int
:return: sha 256 checksum of file
:rtype : str
"""
@mausvt
mausvt / HowToOTG.md
Created September 7, 2019 21:16 — forked from gbaman/HowToOTG.md
Simple guide for setting up OTG modes on the Raspberry Pi Zero

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int

@mausvt
mausvt / gramain.cpp
Created June 28, 2018 11:48
Графопостроитель gl+glut
#include <GL/glut.h>
#include <iostream>
#include <math.h>
#include <string>
#include <fstream>
#include <vector>
int count = 0; // Размер масива У,Х
float* X; // масив для хранение х-ов
float* Y; // масив для хранения у-ов
@mausvt
mausvt / comm.cpp
Last active August 29, 2015 14:11
Ugly mess uv_tcp_connect do not give callback
#include <iostream>
#include <assert.h>
//#include <netdb.h>
#include <errno.h>
#include <QList>
#include "comm.h"
#include "uiconf.h"
using namespace std;
UDPthread::UDPthread(QList<UiElement*> *elements, int port)