Skip to content

Instantly share code, notes, and snippets.

View ktsaou's full-sized avatar

Costa Tsaousis ktsaou

View GitHub Profile
@ktsaou
ktsaou / autoscaled.sh
Created September 10, 2017 22:06
autoscale X/Wayland applications based on current DPI settings
#!/usr/bin/env bash
program="${1}"
append=
# -----------------------------------------------------------------------------
# HiDPI decision
primary_found="no"
@ktsaou
ktsaou / systemd-journal-self-signed-certs.sh
Last active October 15, 2023 23:49
systemd-journal-remote/upload self-signed certificates management script
#!/usr/bin/env bash
# The directory to save the generated certificates (and everything about this certificate authority).
# This is only used on the node generating the certificates (usually on the journals server).
DIR="/etc/ssl/systemd-journal-remote"
# The journals centralization server name (the CN of the server certificate).
SERVER="server-hostname"
# All the DNS names or IPs this server is reachable at (the certificate will include them).
@ktsaou
ktsaou / stress-with-curl.sh
Last active August 15, 2023 18:54
Command line web server stress testing tool, implemented with curl and real-time statistics to netdata
#!/usr/bin/env bash
# Stress With Curl
# Run multiple curl worker to stress a web server
# Real-time statistics at a Netdata server
#
# To use, you need:
# - curl
# - The nc command from the openbsd-netcat package
# - Netdata
@ktsaou
ktsaou / JulyL.c
Last active January 9, 2023 21:51
An implementation of JudyL with fewer memory allocations, when items are mainly appended to the array
// SPDX-License-Identifier: GPL-3.0-or-later
#include "july.h"
#define JULYL_MIN_ENTRIES 10
struct JulyL_item {
Word_t index;
void *value;
};
@ktsaou
ktsaou / spinlock.c
Last active December 2, 2022 23:41
spinlock vs mutex benchmark
//
// compile with:
// gcc -O2 -o spinlock spinlock.c -lpthread && ./spinlock
//
// verification and spinlock stats can be enabled with this:
// gcc -O2 -DSPINLOCK_VERIFY_AND_STATS=1 -o spinlock spinlock.c && ./spinlock
#define _GNU_SOURCE
#define __USE_GNU
(gdb) taas bt
Thread 463 (Thread 0x7fd5d4952700 (LWP 272185) "DBENGINE"):
#0 futex_abstimed_wait (private=0, abstime=0x0, clockid=0, expected=3, futex_word=<optimized out>) at ../sysdeps/nptl/futex-internal.h:287
#1 __pthread_rwlock_rdlock_full (abstime=0x0, clockid=0, rwlock=0x5615817057c8) at pthread_rwlock_common.c:460
#2 __GI___pthread_rwlock_rdlock (rwlock=0x5615817057c8) at pthread_rwlock_rdlock.c:27
#3 0x00007fd6d2e746e9 in uv_rwlock_rdlock () from target:/lib/x86_64-linux-gnu/libuv.so.1
#4 0x000056157bd0b1a6 in get_descriptor (page_index=0x5615817057a0, start_time_s=1668212224) at database/engine/rrdengine.c:763
#5 0x000056157bd0b24d in try_to_remove_v2_descriptor (ctx=0x56157c34fcc0 <multidb_ctx_storage_tier0>, page_index=0x5615817057a0, start_time_s=1668212224, expired=false) at database/engine/rrdengine.c:772
#6 0x000056157bd0b4b8 in check_journal_file (journalfile=0x5615829dda10) at database/engine/rrdengine.c:830
@ktsaou
ktsaou / gist:36b7ae1680a909a88642c5d75e9248fb
Created October 27, 2021 11:12
gvpe static compilation log
$ ./compile-gvpe/build-gvpe-linux-static.sh
ME : build-gvpe-linux-static.sh
DIR : /home/costa/src/netdata-demo-site.git/gvpe/compile-gvpe
/home/costa/src/netdata-demo-site.git/gvpe/compile-gvpe > sudo docker run -a stdin -a stdout -a stderr -i -t -v /home/costa/src/netdata-demo-site.git/gvpe/compile-gvpe:/tmp/mapped:rw alpine:edge /bin/sh /tmp/mapped/build-gvpe-linux-static.sh inside-container
/ > apk update
fetch https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
v3.15.0_alpha20210804-4905-ga7f55994b5 [https://dl-cdn.alpinelinux.org/alpine/edge/main]
# netdata contributors license agreement
**Thank you for contributing to netdata!**
This agreement is part of the legal framework of the open-source ecosystem
that adds some red tape, but protects both the contributor and the project.
To understand why this is needed, please read [a well-written chapter from
Karl Fogel’s Producing Open Source Software on CLAs](http://producingoss.com/en/copyright-assignment.html).
@ktsaou
ktsaou / dell-xps9560-linux-cpufreq.sh
Last active July 3, 2018 07:38
dell XPS9560 cpufreq fix for acpi-cpufreq
#!/bin/sh
base="/sys/devices/system/cpu/cpufreq/policy0/"
ME="${0}"
SCALING_DRIVER="$(<${base}/scaling_driver)"
SCALING_GOVERNOR="$(<${base}/scaling_governor)"
AC_ONLINE=$(</sys/class/power_supply/AC/online)
# install this script in udev
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Horizon - Server Monitoring</title>
<script>var netdataTheme = 'slate';</script>
<script type="text/javascript" src="https://horizon.scotthelme.co.uk/reporturi-shared-01/dashboard.js?v20170105-7"></script>
<link href="style.css?d=20170210-2035" rel="stylesheet">