Comments | Types | Standard functions | Tables | Exceptions | Functions | I/O | Regexp | Objects | System
--Comments | Types | Standard functions | Tables | Exceptions | Functions | I/O | Regexp | Objects | System
--| # List to dict | |
| a = [10, 20, 30] | |
| b = {index: value for index, value in enumerate(a)} | |
| # {0: 10, 1: 20, 2: 30} | |
| a = ["a", 1, "b", 2, "c", 3] | |
| b = {a[i]: a[i + 1] for i in range(0, len(a), 2)} | |
| # {"a": 1, "b": 2, "c": 3} |
| 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 |
| 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): |
| # 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 () { |
| #!/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") }' |
| 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 |
| # // # // 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 | |
| # // # // |
| 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..." |
| #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 |