Skip to content

Instantly share code, notes, and snippets.

View zhum's full-sized avatar

Zhumatiy Sergey zhum

View GitHub Profile
@zhum
zhum / nvidia-smi-q.txt
Last active October 21, 2023 00:33
nvidia-smi cheatsheet
nvidia-smi --query-gpu=OPTION,... [--format=csv[,hoheader]]
timestamp - YYYY/MM/DD HH:MM:SS.msec
driver_version
count
name or gpu_name
serial or gpu_serial
uuid or gpu_uuid
pci.bus_id or gpu_bus_id - domain:bus:device.function, in hex
pci.domain
@zhum
zhum / python-task-pool.py
Created December 2, 2022 13:47
Wrapper to execute one function with different arguments in parallel, using execution pools
import concurrent.futures
import functools
import queue
import subprocess
import random
def pool_wrapper(q_in, q_out, size=5):
def pool_wrapper_inner(func):
@zhum
zhum / bash-lib.sh
Last active January 20, 2024 01:44
A library of usefull BASH 4+ functions (many won't work in sh)
# Please, check https://github.com/dylanaraps/pure-bash-bible
# It is a great chest of treasures
######## STRINGS #############
# check if elemet is in the ARRAY
# Usage:
# arr=(a b x)
# containsElement 'x' arr
containsElement () {
@zhum
zhum / awk-replaces.sh
Created July 31, 2022 09:20
awk replacement sample
#!/bin/sh
# replace "Nodename=abc Uptime=1 CPUs=128 State=Drain Reason=no cpu detected [12:00]" -> "abc: no cpu detected"
gawk '{print gensub(/NodeName=([[:alnum:]]+).*Reason=([^[]+)\[.*/, "\\1: \\2", "g") }'
@zhum
zhum / kube-error-upgrade-connection
Last active April 29, 2022 12:33
kube-error-upgrade-connection
Cannot connect to any pod - get "Unable to upgrade connection".
Log:
Apr 2 03:42:59 graphit kubelet[18632]: E0402 03:42:59.173155 18632 server.go:253] Unable to authenticate the request due to an error: x509: certificate has expired or is not yet valid
Meanwhile:
CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY EXTERNALLY MANAGED
admin.conf Apr 02, 2023 00:29 UTC 364d no
apiserver Apr 02, 2023 00:29 UTC 364d ca no
@zhum
zhum / scheduler_for_buckets.rb
Created March 30, 2022 21:52
scheduler_for_buckets
# // # // Implement a function that orders inputs to schedule for min TAT (Turn around time == Total Run Time)
# // # // Input: (list of runtimes, number of parallel buckets)
# // # // Output: Should parallelize individual tasks such that total TAT is minimum.
# // # // Example:
# // # // In: [4, 3, 100, 2, 1], parallel = 2
# // # // Out: [[100], [4, 3, 2, 1]], TAT: 100
# // # // [100, 10] -> 100
# // # // In: [4, 3, 100, 2, 1], parallel = 1
# // # // Out: [[100, 4, 3, 2, 1]], TAT: 110
# // # //
@zhum
zhum / memoization.rb
Created January 28, 2022 08:49 — forked from cqfd/memoization.rb
Ruby memoization exercise
require 'minitest/autorun'
module Memoization
def memoize(f, injected_cache={})
m = instance_method(f)
define_method(f) do |*args|
cache = injected_cache.clone
define_singleton_method(f) do |*args|
unless cache[args]
puts "Actually calculating..."
@zhum
zhum / eink_demo.ino
Created October 24, 2021 06:24 — forked from xxlukas42/eink_demo.ino
MH-ET LIVE 1.54-inches E-Paper demo
#include <GxEPD.h>
#include <GxGDEP015OC1/GxGDEP015OC1.cpp>
#include <Fonts/OpenSansBold12pt7b.h>
#include <Fonts/OpenSansBold14pt7b.h>
#include <Fonts/OpenSansBold30pt7b.h>
#include <GxIO/GxIO_SPI/GxIO_SPI.cpp>
#include <GxIO/GxIO.cpp>
#include GxEPD_BitmapExamples
@zhum
zhum / gtk-test.rb
Created October 17, 2021 15:32
Incorrect columns edit example
#!/usr/bin/env ruby
# frozen_string_literal: true
#
require 'gtk2'
Gtk.init
@window = Gtk::Window.new( Gtk::Window::TOPLEVEL )
@window.set_size_request( 1500, 500 )
@window.signal_connect( "delete_event" ) { Gtk.main_quit }
#@window.set_border_width( 5 )
@zhum
zhum / bot.rb
Last active September 22, 2021 12:23 — forked from dideler/bot.rb
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#