Skip to content

Instantly share code, notes, and snippets.

View DeivAstra's full-sized avatar

Design Excellence Integrity Value DeivAstra

  • Temporary landed on the Earth
View GitHub Profile
@DeivAstra
DeivAstra / apps-freezer.sh
Last active February 20, 2022 19:28
Inactive desktop apps freezer (bash script)
#!/bin/bash
### Info ###
# This script freez inactive desktop applications to save CPU and bandwidth consumption.
# When you open some window then script unfreeze the window back.
# Apps wmctrl and xwininfo need installed before start this script.
# List all windows by `wmctrl -l -x -p` to get string which you will be use in grep_query (see below).
# Show window info by window id: xwininfo -id <window_id>. The command shows window states: IsViewable or IsUnMapped.
# Modify grep_query variable to get which, for example, windows classes you want to freeze. You can use windows title or part also.
# This script runs infinitely with timeout 3 sec. Press Ctrl-C or kill him.
@DeivAstra
DeivAstra / thread_massive_error.d
Created February 5, 2022 17:34
Error creating many threads (D language)
// Error output:
// ...
// desctructed: 32631
// desctructed: 32632
// core.thread.threadbase.ThreadError@src/core/thread/threadbase.d(1217): Error creating thread
module test.thread;
import std.stdio;
import core.thread.osthread;
@DeivAstra
DeivAstra / multithread_semaphore_test.d
Last active February 5, 2022 08:31
Using Semaphore in multithreaded class (D language)
module multithread.semaphore.test;
import std.stdio;
import core.sync.semaphore;
import core.thread.osthread;
import core.time;
import std.random;
import std.conv;
@DeivAstra
DeivAstra / singleton.d
Last active February 5, 2022 09:09
Singleton examples (D language)
module singleton_test;
import std.stdio;
import core.thread.osthread;
void main() {
testSingletonMultithread();
}
class Singleton1 {
@DeivAstra
DeivAstra / IncredibleSlowGraalVmTest.java
Last active January 15, 2022 10:33
Incredible slow graalvm test
package test;
import java.util.ArrayList;
import java.util.List;
// Results (AMD Ryzen 7 5800H)
// JDK 17 (OpenJDK 64-Bit Server VM GraalVM CE 21.3.0 (build 17.0.1+12-jvmci-21.3-b05, mixed mode, sharing)
// generateRandomData >
// end generateRandomData (2937 ms)
@DeivAstra
DeivAstra / setup_ovirtmgmt.sh
Created April 7, 2021 14:29 — forked from phoracek/setup_ovirtmgmt.sh
setup ovirtmgmt network with static ip via vdsm-client
echo '{"bondings": {}, "networks": {"ovirtmgmt": {"nic": "eth0", "netmask": "255.255.255.0", "ipaddr": "1.1.1.2", "gateway": "1.1.1.1", "defaultRoute": true}}, "options": {"connectivityCheck": false}}' | vdsm-client -f - Host setupNetworks
vdsm-client Host setSafeNetworkConfig
@DeivAstra
DeivAstra / gpged
Last active November 29, 2019 23:35
Create / edit GPG encoded files by selected editor.
#!/bin/bash
if [ $# != 1 ]; then
printf "Usage: \n ./gpged file\n"
exit 1
fi
echo "Tip: run this script under separate user or root to make tmpfile unreadable for others"
FILE=$1