Skip to content

Instantly share code, notes, and snippets.

Avatar

stavros vagionitis svagionitis

View GitHub Profile
@svagionitis
svagionitis / git-fetch-all-dir-recursively.sh
Created Sep 8, 2021
Git fetch git repos in directories recursively
View git-fetch-all-dir-recursively.sh
#!/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 Feb 2, 2021
An example of webscraping in Python with requests an BeuatifulSoup
View webscraping-requests-beautifulsoup.py
"""
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 Jan 16, 2021
A script to backup a directory
View backup-dir.sh
#!/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 Jan 16, 2021
A script to mirror a website using wget
View wget-mirror-website.sh
#!/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 Jan 11, 2021
A websocket proxy example in python
View .gitignore
## 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
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.
View copy-wic-rootfs.sh
#!/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 Apr 16, 2020
Record terminal sessions
View record-terminal-session.sh
# 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 Aug 2, 2017
A function to stringify the newline character.
View stringify_newline.c
/** @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
tpm-tools build script
View tpm-tools_build.sh
#!/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/)
@svagionitis
svagionitis / Makefile
Last active Oct 16, 2020
This small utility shows how to use the `getifaddrs` and get information for network interfaces.
View Makefile
all: get-network-interfaces get-gateway-ip
get-network-interfaces: get-network-interfaces.c
gcc -o get-network-interfaces -ggdb -O1 -Wall -W -ansi -pedantic -std=gnu99 get-network-interfaces.c
get-gateway-ip: get-gateway-ip.c
gcc -o get-gateway-ip -ggdb -O1 -Wall -W -ansi -pedantic -std=gnu99 get-gateway-ip.c
clean:
rm -rf get-network-interfaces