Skip to content

Instantly share code, notes, and snippets.

View svagionitis's full-sized avatar

stavros vagionitis svagionitis

View GitHub Profile
@svagionitis
svagionitis / object_tracking.cpp
Last active February 10, 2022 15:28
Object tracking algorithms for OpenCV 4.5.5
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
// Examples from peopledetect.cpp and from https://learnopencv.com/object-tracking-using-opencv-cpp-python/
#include <opencv2/objdetect.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>
@svagionitis
svagionitis / git-fetch-all-dir-recursively.sh
Created September 8, 2021 06:44
Git fetch git repos in directories recursively
#!/bin/sh -eu
# Git fetch git repos in directories recursively
usage()
{
echo "Usage: $0 <directory>"
}
if [ -z "${1}" ]; then
usage
@svagionitis
svagionitis / webscraping-requests-beautifulsoup.py
Last active February 2, 2021 18:17
An example of webscraping in Python with requests an BeuatifulSoup
"""
An example of webscraping in Python with requests an BeuatifulSoup
Scraping lab test data from https://labtestsonline.org.uk/tests-index
This script will get a list of the lab tests from the above link and then get
more information for each test following the appropriate link. The web page stores
the data in Drupal 8. The lab tests are saved in JSON files.
"""
@svagionitis
svagionitis / backup-dir.sh
Created January 16, 2021 18:32
A script to backup a directory
#!/bin/sh -eu
# A script to backup a directory
usage() {
cat << EOF
Usage: $(basename "$0") [-d directory]
Where:
-d The directory to backup.
-h This help
@svagionitis
svagionitis / wget-mirror-website.sh
Last active March 14, 2024 08:27
A script to mirror a website using wget
#!/bin/sh -eu
# A script to mirror a website using wget
usage() {
cat << EOF
Usage: $(basename "$0") [-w website] [-u user_agent] [-b]
Where:
-w The website to mirror. The website will be like "https://example.com/"
-u The User agent to use. If no User agent is specified,
a Firefox default one is used.
@svagionitis
svagionitis / .gitignore
Last active January 11, 2021 16:58
A websocket proxy example in python
## https://github.com/github/gitignore/blob/master/Global/Vim.gitignore
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
@svagionitis
svagionitis / copy-wic-rootfs.sh
Created May 13, 2020 14:57
This script mounts the rootfs partition of a wic.xz image and copy the rootfs to a directory. The roofs partition is at partition 3.
#!/bin/sh -eu
# shellcheck shell=ash
# This script mounts the rootfs partition of a wic.xz image and copy the rootfs
# to a directory. The roofs partition is at partition 3.
if ! command -v losetup > /dev/null ; then
echo "ERROR: losetup is missing" >&2
exit 1
fi
@svagionitis
svagionitis / record-terminal-session.sh
Last active April 16, 2020 17:32
Record terminal sessions
# Create a log for the sessions
# Record terminal sessions.
# https://unix.stackexchange.com/questions/25639/how-to-automatically-record-all-your-terminal-sessions-with-script-utility
# https://www.2daygeek.com/automatically-record-all-users-terminal-sessions-activity-linux-script-command/
# TODO When changing tabs does not keep the directory
SESSION_LOGS_DIR="$HOME/.session_logs"
if [ ! -d "${SESSION_LOGS_DIR}" ]; then
mkdir -p "${SESSION_LOGS_DIR}"
fi
@svagionitis
svagionitis / stringify_newline.c
Created August 2, 2017 12:14
A function to stringify the newline character.
/** @brief Stringify the newline character of a string.
*
* In detail, the newline character, '\n' is not supported on
* json string, so it needs to split in two characters "\n".
*
* @param [in] src The string to stringify
* @return the stringified string on success<br>
* NULL otherwise
*
*/
@svagionitis
svagionitis / tpm-tools_build.sh
Created May 11, 2017 14:07
tpm-tools build script
#!/bin/sh -ex
mkdir -p sysroot
PREFIX_DIR=$(readlink -e sysroot)
mkdir -p $PREFIX_DIR/include
INCLUDE_DIR=$(readlink -e $PREFIX_DIR/include/)
mkdir -p $PREFIX_DIR/lib
LIB_DIR=$(readlink -e $PREFIX_DIR/lib/)
mkdir -p $LIB_DIR/pkgconfig
PKG_CONFIG_PATH=$(readlink -e $LIB_DIR/pkgconfig/)