Skip to content

Instantly share code, notes, and snippets.

View plashchynski's full-sized avatar
🎯
Focusing

Dzmitry Plashchynski plashchynski

🎯
Focusing
View GitHub Profile
@plashchynski
plashchynski / log_opcodes.py
Created March 17, 2025 14:08
log all opcodes in Python in realtime
import sys
import gc
from dis import get_instructions
def local_trace(frame, event, arg):
"""
The 'local' trace function, called for *each* opcode (if f_trace_opcodes=True)
or line (if f_trace_lines=True).
"""
# Turn on opcode-level tracing for this frame
dzmitry@ubuntu-test:~$ git clone https://github.com/plashchynski/cpython.git
Cloning into 'cpython'...
remote: Enumerating objects: 884202, done.
remote: Counting objects: 100% (442/442), done.
remote: Compressing objects: 100% (301/301), done.
remote: Total 884202 (delta 309), reused 141 (delta 141), pack-reused 883760 (from 2)
Receiving objects: 100% (884202/884202), 499.51 MiB | 39.53 MiB/s, done.
Resolving deltas: 100% (710845/710845), done.
dzmitry@ubuntu-test:~$ cd cpython/
dzmitry@ubuntu-test:~/cpython$ ./configure
dzmitry@ubuntu-test:~$ sudo apt install build-essential
[sudo] password for dzmitry:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
binutils binutils-aarch64-linux-gnu binutils-common bzip2 cpp cpp-13 cpp-13-aarch64-linux-gnu cpp-aarch64-linux-gnu dpkg-dev fakeroot g++ g++-13
g++-13-aarch64-linux-gnu g++-aarch64-linux-gnu gcc gcc-13 gcc-13-aarch64-linux-gnu gcc-13-base gcc-aarch64-linux-gnu libalgorithm-diff-perl libalgorithm-diff-xs-perl
libalgorithm-merge-perl libasan8 libatomic1 libbinutils libcc1-0 libctf-nobfd0 libctf0 libdpkg-perl libfakeroot libfile-fcntllock-perl libgcc-13-dev libgomp1
libgprofng0 libhwasan0 libisl23 libitm1 liblsan0 libmpc3 libsframe1 libstdc++-13-dev libtsan2 libubsan1 lto-disabled-list make
$
$
$ matlab
MATLAB is selecting SOFTWARE OPENGL rendering.
< M A T L A B (R) >
Copyright 1984-2021 The MathWorks, Inc.
R2021b Update 4 (9.11.0.2022996) 64-bit (glnxa64)
July 22, 2022
root@6c168ef8ff06:/mediapipe# bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 --copt -I/usr/include/opencv4/ mediapipe/examples/desktop/iris_tracking:iris_tracking_cpu_video_input
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
DEBUG: Rule 'rules_foreign_cc' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "c2cdcf55ffaf49366725639e45dedd449b8c3fe22b54e31625eb80ce3a240f1e"
DEBUG: Repository rules_foreign_cc instantiated at:
/mediapipe/WORKSPACE:49:13: in <toplevel>
Repository rule http_archive defined at:
/root/.cache/bazel/_bazel_root/4884d566396e9b67b62185751879ad14/external/bazel_tools/tools/build_defs/repo/http.bzl:353:31: in <toplevel>
WARNING: Download from http://mirror.tensorflow.org/github.com/bazelbuild/rules_closure/archive/cf1e44edb908e9616030cc83d085989b8e6cd6df.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.
@plashchynski
plashchynski / log.txt
Created November 9, 2022 12:39
mediapipe iris_tracking Docker compilation error
[ec2-user@ip-172-31-48-200 mediapipe]$ git rev-parse HEAD
b4e1833dd06f6fe3a4fe2e396df45e1fa0bf902e
[ec2-user@ip-172-31-48-200 mediapipe]$ docker build --tag=mediapipe .
Sending build context to Docker daemon 77.62MB
Step 1/18 : FROM ubuntu:20.04
20.04: Pulling from library/ubuntu
eaead16dc43b: Pull complete
Digest: sha256:450e066588f42ebe1551f3b1a535034b6aa46cd936fe7f2c6b0d72997ec61dbd
Status: Downloaded newer image for ubuntu:20.04
---> 680e5dfb52c7
@plashchynski
plashchynski / prime.rb
Last active April 11, 2020 22:03
Check if the number is prime in Ruby
# trial division — the simplest primality test
def is_prime(number)
return number > 1 if number <= 3
return false if number % 2 == 0 || number % 3 == 0
i = 5
while i * i <= number do
return false if number % i == 0 || number % (i + 2) == 0
i = i + 6

1.3

(define (proc x1 x2 x3)
        (cond   ((and (> x1 x3) (> x2 x3)) (+ (* x1 x1) (* x2 x2)))
                ((and (> x1 x2) (> x3 x2)) (+ (* x1 x1) (* x3 x3)))
                ((and (> x2 x1) (> x3 x1)) (+ (* x2 x2) (* x3 x3)))
        )
)
@plashchynski
plashchynski / save_as_small_jpg.rb
Created February 28, 2019 11:58
Ruby script to convert images using magick
ARGV.each do |input_file|
basename = File.basename(input_file, ".*")
dirname = File.dirname(input_file)
output_file = "#{dirname}/#{basename}.jpg"
`/usr/local/bin/magick convert '#{input_file}' -quality 20 '#{output_file}'`
end
@plashchynski
plashchynski / save_as_small_jpg.scpt
Created February 9, 2019 23:31
Apple script to save any images as low fidelity JPG
on run {input, parameters}
set theList to input
repeat with a from 1 to length of theList
set theCurrentListItem to item a of theList
set theFilePath to theCurrentListItem
set theFile to theFilePath as alias
tell application "Image Events"