Skip to content

Instantly share code, notes, and snippets.

#include <QApplication>
#include <QDebug>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QAction>
#include <QIcon>
#include <QThread>
#include <QObject>
#include <QFile>
#include <QIODevice>
#include <QCoreApplication>
#include <QUdpSocket>
#include <QObject>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QUdpSocket _s;
_s.bind( QHostAddress::LocalHost, 9000 );
#include <QObject>
#include <QCoreApplication>
#include <QUdpSocket>
#include <QTimer>
int main( int argc, char *argv[] )
{
QCoreApplication app( argc, argv );
QUdpSocket _s;
# Print progress on same line
(1..10).each do |i|
print "\rDownloaded: #{i} of 10"
sleep 1
end
puts
puts 'Rest of the logs here...'
@iamazeem
iamazeem / first_recurring_character.cpp
Created April 10, 2018 11:25
How to find first recurring character in a string
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <array>
#include <utility>
#include <algorithm>
#include <unordered_map>
// https://stackoverflow.com/a/55297349/7670262
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
int main()
{
const auto data = R"({ "Name": "45", "Path": "C:\file.json" })";
@iamazeem
iamazeem / self_delete.cpp
Created April 19, 2019 06:08
Qt: Run self-deleting .BAT file using QProcess (https://stackoverflow.com/a/51742823/7670262)
// https://stackoverflow.com/a/51742823/7670262
#include <QProcess>
int main()
{
QProcess process;
process.setProgram( "cmd.exe" );
process.setArguments( { "/C", R"(E:\deleteme.bat)" } );
process.setWorkingDirectory( R"(E:\)" );
// https://stackoverflow.com/a/55187379/7670262
#include <QDebug>
#include <QMap>
#include <QMapIterator>
#include <QString>
int main()
{
using InnerMap = QMap<int, QString>;
// https://stackoverflow.com/a/44558860/7670262
/*
Directory structure:
C:\Test
-- A
---- a.txt
-- B
---- b.tx
// https://stackoverflow.com/a/51889159/7670262
#include <iterator>
#include <iostream>
struct data
{
data() = default;
int num1 = 0;
int num2 = 0;