Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# According to this documentation https://cloud.google.com/container-registry/docs/managing you can move images
# but the gcloud command with add tag option will handle only one tag at a time
# The "if while for" magic will handle multiple tags by retagging the same image.
# Supported input which is provided by the list-tags command:
# 0.2.63
# 0.2.60;0.2.61
# 0.2.59
@NorbertFenk
NorbertFenk / fork-cpp-example.cpp
Created July 25, 2018 08:20
Short program to show forking in C++ and how to create zombie process.
#include <iostream>
#include <unistd.h>
int main()
{
std::cout << "------ program started ------" << std::endl;
int counter = 0;
pid_t pid = fork();
@NorbertFenk
NorbertFenk / QtTestBenchmarkWithCMake.txt
Last active June 22, 2018 13:44
QtTest benchmark with CMake
https://stackoverflow.com/a/23560316/5789008
------------------ CMakeLists.txt ------------------
cmake_minimum_required(VERSION 3.9)
project(qt_perf_test_with_cmake)
enable_testing()
set(CMAKE_AUTOMOC ON)
@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.
```
@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
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 / 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"
#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 / 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();
@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) {