Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
#include <QString>
#include <QByteArray>
#include <QDebug>
#include <QFile>
#include <QCryptographicHash>
#include <botan/pkcs8.h>
#include <botan/hex.h>
#include <iostream>
#include <QString>
#include <QByteArray>
#include <QDebug>
#include <QFile>
#include <QCryptographicHash>
#include <botan/pkcs8.h>
#include <botan/hex.h>
QT += core
QT -= gui
CONFIG += c++11
TARGET = ws_test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
@NorbertFenk
NorbertFenk / generateIpFromInt.cpp
Created December 5, 2017 22:37
Simple funtion which can generate valid ip4 address from a simple int.
#include <QDebug>
QString generateIpFromInteger(quint32 ip)
{
QString ipString;
for (int i = 0; i < 4; ++i) {
ipString.insert(0, QString::number(ip & 0xff));
if (i < 3) {
@NorbertFenk
NorbertFenk / load_json_qt.cpp
Created January 22, 2018 13:58
Simple Qt based JSON file loading
QVariant loadJson(const QString &path)
{
QFile file(path);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
throw Exception(QStringLiteral("Could not open file"));
}
QByteArray input = file.readAll();
file.close();
#include <iostream>
#include <vector>
#include <algorithm>
#include <chrono>
#include <ratio>
// NOTE source: https://www.fluentcpp.com/2018/01/12/how-is-stdset_difference-implemented/
template<typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator mySetDifference(InputIterator1 first1, InputIterator1 last1,
@NorbertFenk
NorbertFenk / deleteFilesFromInput.sh
Created February 9, 2018 11:46
If you accidentally hit cmake before "cd build" and you really do not know how to "mass" checkout folders and files this will help a lot.
#!/bin/bash
# source: https://stackoverflow.com/questions/10929453/read-a-file-line-by-line-assigning-the-value-to-a-variable
while IFS='' read -r line || [[ -n "$line" ]]; do
rm -rf $line
done < "$1"
Download the requested version: https://github.com/google/googletest/releases
tar -xzvf <GTEST-FOLDER>.tar.gz
cd <UNZIPPED-FOLDER>
mkdir build
cd build
cmake -G"Unix Makefiles" .. # By default the CMake try to identify the system so the -G"Unix Makefiles" optionally
make install # If needed use super user previlige
@NorbertFenk
NorbertFenk / multiple-branch-rebase.sh
Last active April 7, 2018 18:10
Multiple branch rebase to a dedicated branch. Checkout the target branch and use the script.
#!/bin/bash
# checkout the target branch
# ./multiple-branch-rebase.sh <branch1> <branch2> ...
set -e
TARGET_BRANCH=$(git rev-parse --abbrev-ref HEAD)
for BRANCH in "$@"; do
@NorbertFenk
NorbertFenk / git bisect hands-on
Created May 25, 2018 11:41
Short example for the git bisect command.
https://git-scm.com/docs/git-bisect
https://dockyard.com/blog/2016/07/26/how-to-bisect-ember
example
cd <git directory>
git bisect start
git bisect bad // this command will assume the HEAD in this case
git bisect good <commit id of a good commit>
git bisect run ./<arbitrary scrip>
e.g.
```