Skip to content

Instantly share code, notes, and snippets.

View sustr4's full-sized avatar

Zdeněk Šustr sustr4

View GitHub Profile
@sustr4
sustr4 / stactolls-env.sh
Created May 30, 2024 14:39
stactolls-env.sh
sudo apt-get update; sudo apt-get -y dist-upgrade
sudo apt-get -y install git python3 python3-pip python3-venv
git clone https://github.com/CESNET/DHuSTools.git
python3 -m venv ~/s1
~/s1/bin/pip3 install stactools-sentinel1
~/s1/bin/pip3 install requests
@sustr4
sustr4 / resto-id.sh
Created May 3, 2023 15:15
Translation of Resto function toUUID() into BASH
toUUID() {
NSTR=$'\x92\x70\x80\x59\x20\x77\x45\xa3\xa4\xf3\x1e\xb4\x28\x78\x9c\xff'
HASH=`printf "${NSTR}$1" | sha1sum`
printf "%08s-%04s-5%03s-%01x%03s-%12s\n" ${HASH:0:8} ${HASH:8:4} ${HASH:13:3} $(( ( 0x${HASH:16:1} & 3 ) | 8 )) ${HASH:17:3} ${HASH:20:12}
}
@sustr4
sustr4 / docker-deb10
Last active June 15, 2021 19:47
Succession of commands to install docker on Buster
#!/bin/bash
sudo echo nameserver 8.8.8.8 > /etc/resolvconf/resolv.conf.d/base
sudo service systemd-resolved restart
sudo apt-get update
sudo apt-get install -y curl gnupg apt-transport-https ca-certificates lsb-release imagemagick vim unzip
wget -q -O - https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
@sustr4
sustr4 / Makefile
Created April 8, 2020 11:31
Copernicus coverage heatmap
all:
gnuplot -c heatmap2d.gnu
@sustr4
sustr4 / gist:10f334fa58c22907ec6bc6c97f827469
Last active February 25, 2020 12:20
Replicate Travis-ci
export BUILDID="build-14688"
export INSTANCE="travisci/ci-sardonyx:packer-1576238197-60d50014"
sudo docker run --name $BUILDID -dit $INSTANCE /sbin/init
sudo docker exec -it $BUILDID bash -l
su - travis
@sustr4
sustr4 / create_VOMSes.sh
Last active June 1, 2017 10:59
create_VOMSes.sh
#For SL6:
rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum -y install yum-priorities
rpm -ivh http://repository.egi.eu/sw/production/umd/3/sl6/x86_64/updates/umd-release-3.14.4-1.el6.noarch.rpm
yum install -y mysql-server voms-admin-server voms-admin-client emi-voms-mysql ca-policy-egi-core
/etc/init.d/mysqld start
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('[Edited]');"
mysql --user=root --password=[Edited] -e "create database voms_training_egi_eu"
@sustr4
sustr4 / yaml2csv.rb
Created December 2, 2015 09:54
Convert hierarchical YAML from Clouditor to sequential CSV for further processing in spreadsheets. Each run segment on a separate line.
require 'yaml'
data = YAML.load_file("vm_records_export.yml")
puts "id,user,group,name,memory,vcpu,cpu,hostname,start_time,end_time,host_info.vcpu,host_info.memory,host_info.model"
data.each { |rec|
rec["runtime"].each { |runtime|
puts "#{rec["id"]},#{rec["user"]},#{rec["group"]},#{rec["name"]},#{rec["memory"]},#{rec["vcpu"]},#{rec["cpu"]},#{runtime["hostname"]},#{runtime["start_time"]},#{runtime["end_time"]},#{runtime["host_info"]["vcpu"]},#{runtime["host_info"]["memory"]},#{runtime["host_info"]["model"]}"
@sustr4
sustr4 / yaml2usage.rb
Created December 2, 2015 09:37
Add-up week-by-week usage of resources, based on YAML exported from Clouditor.
require 'yaml'
data = YAML.load_file("vm_records_export.yml")
# 1 Jan 2014: 1388534400
# 1 Jan 2015: 1420070400
# 1 week: 604800
weeks = Array.new(54, 0.0)
@sustr4
sustr4 / yaml2totals.rb
Created December 2, 2015 09:32
Generate temporal sequence from clouditor exports. Totals are recalculated for each second whence at least one change occurred.
require 'yaml'
data = YAML.load_file("vm_records_export.yml")
cpu_timeline = Hash.new
mem_timeline = Hash.new
now = Time.now.to_i
data.each { |rec|
@sustr4
sustr4 / voms-install-SL6.sh
Last active September 24, 2015 15:13
Install VOMS and create a testing VO
#!/bin/sh
#INSTALL EPEL, UMD and VOMS
rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh http://repository.egi.eu/sw/production/umd/3/sl6/x86_64/updates/umd-release-3.0.1-1.el6.noarch.rpm
yum install -y voms-server yum-priorities voms-admin-client voms-admin-server mysql-server voms-mysql-plugin xml-commons-apis
service mysqld start
/usr/bin/mysqladmin -u root password [Edited];