Skip to content

Instantly share code, notes, and snippets.

View kwk's full-sized avatar

Konrad Kleine kwk

View GitHub Profile
@kwk
kwk / command.sh
Created May 22, 2023 15:19
Get list of builder admins for buildbot
curl -sL https://lab.llvm.org/buildbot/api/v2/workers > workers.json
curl -sL https://lab.llvm.org/buildbot/api/v2/builders > builders.json
cat builders.json | jq '.builders[] | {(.builderid|tostring): .name}' | jq '{"builders": (reduce inputs as $in (.; . + $in))}' > builders_lut.json
jq -s '.[0] * .[1]' builders_lut.json workers.json > joined.json
cat joined.json | jq '.builders as $builders | .workers[] | {"workername": .name, "admin": (""+.workerinfo.admin|tostring), "builders": $builders[.configured_on[].builderid | tostring]}' | jq -s > temp.json
cat temp.json | jq 'group_by(.admin)[] | {"admin": ("" + .[0].admin), "builders": [.[] | .builders] | sort | unique}' | jq -s
@kwk
kwk / Containerfile
Last active July 21, 2023 12:57
Runnning the llvm-test-suite with PGO optimized and plain LLVM in Fedora Rawhide
FROM fedora:rawhide
LABEL description="Test compilers with llvm-test-suite"
USER root
WORKDIR /root
# Install deps to run test-suite
RUN dnf install -y \
cmake \
fedora-packager \
@kwk
kwk / main.cpp
Created May 4, 2023 21:15
getNumDisplayWidth
#include <cstdio>
#include <cmath>
#include <array>
static unsigned getNumDisplayWidth(unsigned N) {
if (N < 10)
return 1;
if (N < 100)
return 2;
if (N < 1000)
@kwk
kwk / mermaid.md
Created April 28, 2023 12:14
Embed image in marmaid sequence diagram
sequenceDiagram
autonumber

actor alice as Alice

box Github.com
participant gh as Github.com Website
participant ghapi as Github.com API
end
@kwk
kwk / CMakeLists.txt
Last active April 20, 2023 19:03
Dynamic macro overriding
cmake_minimum_required(VERSION 3.13.4)
project(myapp)
add_executable(myapp myapp.cpp)
target_link_libraries(myapp)
install(TARGETS myapp RUNTIME DESTINATION bin)
%set_build_flags \
CFLAGS="${CFLAGS:-%{build_cflags}}" ; export CFLAGS ; \
CXXFLAGS="${CXXFLAGS:-%{build_cxxflags}}" ; export CXXFLAGS ; \
FFLAGS="${FFLAGS:-%{build_fflags}}" ; export FFLAGS ; \
FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \
LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS ; \
LT_SYS_LIBRARY_PATH="${LT_SYS_LIBRARY_PATH:-%_libdir:}" ; export LT_SYS_LIBRARY_PATH ; \
CC="${CC:-%{__cc}}" ; export CC ; \
CXX="${CXX:-%{__cxx}}" ; export CXX \
%{?__llvm_pgo_instrumented_build_flags}
@kwk
kwk / myapp.spec
Last active April 20, 2023 12:29
Redfine macros upon installation.
# See https://docs.fedoraproject.org/en-US/packaging-guidelines/#_compiler_macros
%global toolchain clang
Name: myapp
Version: 1.0.0
Release: 1%{?dist}
Summary: A simple "Hello, World!" application.
License: Apache-2.0
URL: https://github.com/kwk/hello-world
@kwk
kwk / script.sh
Created March 30, 2023 21:17
llvm-profdata merge in the background
#!/bin/bash
# This script is supposed to show the usage of inotifywait when you want process
# files in a directory in batches once the files have been created.
#
#
# Test this script with:
#
# $ this-script.sh
# $ for i in a b c ; do echo $i > /tmp/$i.profraw; done \
@kwk
kwk / script.sh
Last active March 30, 2023 19:03
Inotifywait for doing batch file processing
#!/bin/bash
# This script is supposed to show the usage of inotifywait when you want process
# files in a directory in batches once the files have been created.
#
#
# Test this script with:
#
# $ this-script.sh
# $ for i in a b c ; do echo $i > /tmp/$i.profraw; done \
@kwk
kwk / README.md
Last active July 29, 2022 10:29
Transform Copr Build log API to Postgres Insert statements

REDAME

I wanted to create a dashboard in grafana about copr builds and needed to feed the build data into a postgres database. From there I can consume it in Grafana using a Postgres Data Source.

In order to have a simple conversion at hand I've written the script copr-json-to-sql.sh which prints SQL-INSERT-statements for the build information in a denomalized form.

The schema for the copr_build_logs table can be found in copr_build_logs.sql.

For example, you can call the script to get information about the builds of the @kdesig/python-qt6 project which is featured here.