Skip to content

Instantly share code, notes, and snippets.

View jesustorresdev's full-sized avatar

Jesús Torres jesustorresdev

View GitHub Profile
@jesustorresdev
jesustorresdev / Powershell-vs-Bash-para-usuarios-de-Linux.md
Last active June 25, 2023 21:28
Comparación de comandos en Bash y PowerShell.
@jesustorresdev
jesustorresdev / base64.h
Last active March 28, 2023 21:27 — forked from tomykaira/Base64.h
C++20 constexpr single header base64 decode/encoder.
#ifndef _MACARON_BASE64_H_
#define _MACARON_BASE64_H_
/**
* The MIT License (MIT)
* Copyright (c) 2016 tomykaira
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@jesustorresdev
jesustorresdev / kdiff3_files.desktop
Created April 6, 2018 14:12
Desktop entry to add a desktop action to compare text files with KDiff3. Have to be saved in "~/.local/share/kservices5/ServiceMenus"
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
MimeType=text/*;
Actions=diffFiles;
X-KDE-AuthorizeAction=shell_access
[Desktop Action diffFiles]
Name=Compare Files
Name[es]=Comparar archivos
MyWindow::MyWindow(QWidget *parent)
{
// ...
finiteBuffer_ = new FiniteBuffer(20);
FrameProcessingThread frameProcessingThread(finiteBuffer_);
frameProcessingThread.start();
// ...
}
QImage FiniteBuffer::extractFrame()
{
// Bloquear el cerrojo. Es lo mismo que hacer manualmente:
// mutex_.lock()
QMutexLocker lock(&mutex);
// El código del productor a partir de este punto no se
// ejecutará si el productor ha bloqueado el cerrojo
// primero.
class FrameProcessingThread : public QThread
{
Q_OBJECT
public:
FrameProcessingThread(FiniteBuffer* buffer,
QObject *parent = 0)
: QThread(parent), buffer_(buffer)
{}
void FiniteBuffer::insertFrame(const QImage& frame)
{
// Bloquear el cerrojo. Es lo mismo que hacer manualmente:
// mutex_.lock()
QMutexLocker lock(&mutex);
// El código del productor a partir de este punto no se
// ejecutará si el consumidor ha bloqueado el cerrojo
// primero.
void MyWindow::on_video_updated(const QRect& rect)
{
finiteBuffer_->insertFrame(movie_->currentImage());
}
class FiniteBuffer : public QObject
{
Q_OBJECT
public:
FiniteBuffer(int size);
~FiniteBuffer();
// Métodos de inserción y extracción para el productor y el
// consumidor, respectivamente.
class MyThread : public QThread
{
Q_OBJECT
protected:
void run();
};
void MyThread::run()
{