Skip to content

Instantly share code, notes, and snippets.

View AlexBaranowski's full-sized avatar

Aleksander Baranowski AlexBaranowski

View GitHub Profile
@AlexBaranowski
AlexBaranowski / huge_pages_pg_calc.sh
Created February 1, 2019 16:54
Simple script to calculate huge pages for PostgreSQL. Please note that this is baseline and require further tunning.
#!/usr/bin/env bash
[ -z "$PGDATA" ] && echo "PGDATA is not defined!" && exit 1
[ ! -e $PGDATA/postmaster.pid ] && echo "Cannot find $PGDATA/postmaster.pid is PostgreSQL server running?" && exit 1
PG_PID=$(head -1 $PGDATA/postmaster.pid)
PG_MEM_U=$(grep ^VmPeak /proc/$PG_PID/status | awk '{print $3}')
HP_MEM_U=$(grep ^Hugepagesize /proc/meminfo | awk '{print $3}')
[ "$PG_MEM_U" != "$HP_MEM_U" ] && echo "The units differ please calculate the Huge Pages manually" && exit 1
PG_MEM=$(grep ^VmPeak /proc/$PG_PID/status | awk '{print $2}')
HP_MEM=$(grep ^Hugepagesize /proc/meminfo | awk '{print $2}')
@AlexBaranowski
AlexBaranowski / simple_home_backup.sh
Last active October 31, 2019 16:00
Backup script
#!/usr/bin/env bash
# Author: Alex Baranowski
# This is trivial backup script
# Backup should be done on **different** physical disk, and as any other file can be moved &&|| replicated.
# Stop on the first error
set -e
[[ -v "$KEEP_DAYS" ]] || KEEP_DAYS=120
@AlexBaranowski
AlexBaranowski / remove_hdds.sh
Created October 30, 2019 09:02
Remove all virtualbox disks (hdds)
# Simple script that get UUIDs and remove virtualbox disk (hdds).
hdds=$(vboxmanage list hdds | grep '^UUID' | awk '{ print $2}')
for hd in $hdds; do vboxmanage closemedium disk $hd --delete; done
#!/bin/bash
# Author: Aleksander Baranowski
# License: MIT (https://choosealicense.com/licenses/mit/)
# This simple script looks for changed .sh file from the last git commit
# then run shellcheck on them.
# USAGE: shellcheck_ci repo_root_dir
# Exit codes:
# 98 - required command is not installed
# 1 - some file failed check
# simple script to remove all libvirt images
for i in $(sudo virsh vol-list --pool default | awk '{print $1}'); do sudo virsh vol-delete --pool default $i; done
@AlexBaranowski
AlexBaranowski / 00_README.md
Created May 25, 2020 09:54 — forked from alanivey/00_README.md
CentOS 8 AMIs for ARM64 and x86_64
#include <stdio.h>
#include "hello2.c"
void print_hello(){
printf("Hello, World!\n");
}
int main(){
print_hello();
print_pi();
return 0;
}
#include<stdio.h>
int main(){
int i, j;
for (i=0; i < 100000;i++){
for (j=0; j < 100000;j++){
}
}
printf("Finish!");
}
@AlexBaranowski
AlexBaranowski / loadavg.c
Last active November 4, 2020 17:08
loadavg.c
#include<sys/sysinfo.h>
#include<stdio.h>
// NOTE: FSHIFT might differ
#define FSHIFT 16
#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
#define LOAD_INT(x) ((x) >> FSHIFT)
#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
@AlexBaranowski
AlexBaranowski / nappo.py
Created January 4, 2022 12:01 — forked from omajid/nappo.py
nappo
#!/usr/bin/python3
# Copyright © 2021 Red Hat, Inc
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,