Skip to content

Instantly share code, notes, and snippets.

View AlexBaranowski's full-sized avatar

Aleksander Baranowski AlexBaranowski

View GitHub Profile
@AlexBaranowski
AlexBaranowski / remove_all_github_repos.py
Created May 31, 2023 08:06
Removes ALL GitHub repositories for selected organization. Requires Access Token (provided by env variable GH_TOKEN) with admin right/delete repositories rights. Scripts uses python requests and os module only.
import requests
import os
GH_TOKEN = os.environ['GH_TOKEN']
GH_HEADERS = {"Accept": "application/vnd.github+json",
"Authorization": f"Bearer {GH_TOKEN}",
"X-GitHub-Api-Version": "2022-11-28"}
ORG_NAME = "TODO-FIXME-YOUR-ORG-NAME"
REPO_SET=set()
@AlexBaranowski
AlexBaranowski / check-x86_64-microarch.sh
Created October 4, 2022 08:53
Checking the x86_64 microarchitecture
#!/usr/bin/env bash
# Author: Alex Baranowski
# License: MIT
set -e
# we only need first flag line for the cpu
cpu_flags=$(grep '^flags\b' /proc/cpuinfo | head -n 1)
echo -e "supported cpu flags:\n$cpu_flags"
@AlexBaranowski
AlexBaranowski / migrate-to-centos-vault.sh
Created February 14, 2022 13:25
This trivial script migrate CentOS 8 repos to CentOS 8 vault repos
#!/usr/bin/env bash
cat > /etc/yum.repos.d/CentOS-Linux-AppStream.repo << EOF
# CentOS-Linux-AppStream.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are geographically
# close to the client. You should use this for CentOS updates unless you are
# manually picking other mirrors.
#
# If the mirrorlist does not work for you, you can try the commented out
@AlexBaranowski
AlexBaranowski / swap-check.sh
Created January 18, 2022 16:06
Simple script to check how many swaps can your Linux run.
#!/usr/bin/env bash
# Author: Alex Baranowski
# License: MIT
# Max swap files tester
# magic number: 33 -> in theory 32 swap file on Linux can be used 33 = 32+1
echo "Deactivating all swaps that are used"
sudo swapoff -a
@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,
@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)
#include<stdio.h>
int main(){
int i, j;
for (i=0; i < 100000;i++){
for (j=0; j < 100000;j++){
}
}
printf("Finish!");
}
#include <stdio.h>
#include "hello2.c"
void print_hello(){
printf("Hello, World!\n");
}
int main(){
print_hello();
print_pi();
return 0;
}
@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
# 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