Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Sunday, February 22, 2026

KVM install and configuration on Kubuntu

sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager


groups                    List groups for the current user.

groups <username>   List groups for a specific user.

id <username>    Display UID, GID, and all group memberships.

cat /etc/group            Show all local groups and their members by reading a file.

getent group            List all groups from all configured databases.

sudo adduser $USER libvirt

Virtual Machine Manager > File > New Virtual Machine > Local Install Media (ISO image or CD-ROM)

If failed to create image, create image.qcow2 in storage location and then choose it for OS install.


sudo nano /etc/libvirt/qemu.conf

# Some examples of valid values are:

#

#       user = "qemu"   # A user named "qemu"

#       user = "+0"     # Super user (uid=0)

#       user = "100"    # A user named "100" or a user with uid=100

#

#user = "libvirt-qemu"


# The group for QEMU processes run by the system instance. It can be

# specified in a similar way to user.

#group = "kvm"


user = "your_username"

group = "your_username"


user = "your_username"

group = "libvirt"


sudo systemctl restart libvirtd


Network selection > Bridge device... > virbr0


ifconfig


On KDE couldn't turn off full screen with shortcuts... but right mouse button > tick full screen > untick full screen... Changing window size and position with shortcuts started working.


dpkg-query -W -f='${Installed-Size} \t ${Package}\n' virtualbox*

qemu-img convert -f vdi -O qcow2 /path/to/your/vm.vdi /path/to/new/vm.qcow2

sudo apt purge "virtualbox*"

sudo apt autoremove


Rescue mode without graphics:

sudo grub-install /dev/vda

sudo update-grub

Tuesday, February 17, 2026

Android Studio sound problems on Kubuntu

Mucis palyers glitch when Android Studio emulator is running.

pw-top

pactl list short clients

cd ~/.android/avd

nano Medium_Phone_API_30.ini


avd.ini.encoding=UTF-8

path=/home/user/.android/avd/Medium_Phone_API_30.avd

path.rel=avd/Medium_Phone_API_30.avd

target=android-30

hw.audioInput = no

hw.audioOutput = no

audio.backend=none

Turning audio off NOT WORKING!!!


Before starting Android Studio:

export QEMU_AUDIO_DRV=none

Turning audio off NOT WORKING!!!


~/.android/avd$ emulator -avd Medium_Phone_API_30 -no-audio

Command 'emulator' not found, but can be installed with:

sudo apt install google-android-emulator-installer


emulator -avd Medium_Phone_API_30 -no-audio

PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT


Add to ~/.bashrc:

export ANDROID_HOME=$HOME/Android/Sdk

export ANDROID_SDK_ROOT=$ANDROID_HOME


Reload: source ~/.bashrc


emulator -avd Medium_Phone_API_30 -no-audio -verbose

Turning audio off WORKS!!!

pw-top

Monday, February 16, 2026

MobSF VM cannot be used for Dynamic Analysis

[INFO] 05/Feb/2026 09:25:06 - Performing System check

[INFO] 05/Feb/2026 09:25:06 - Android API Level identified as 30

[ERROR] 05/Feb/2026 09:25:06 - VM's /system is not writable. This VM cannot be used for Dynamic Analysis.

[ERROR] 05/Feb/2026 09:25:06 - Please start the AVD as per MobSF documentation!

[ERROR] 05/Feb/2026 09:25:06 - Cannot Connect to emulator-5554

[ERROR] 05/Feb/2026 09:25:06 - Internal Server Error: /android_dynamic/a312049526219c769f2fe0d599fc4bc8

[ERROR] 05/Feb/2026 09:25:06 - Internal Server Error: /android_dynamic/a312049526219c769f2fe0d599fc4bc8

adb root

adbd cannot run as root in production builds

Android Studio > Tools > Device Manager > Create Virtual Device > Medium Phone > API 29 > Services > Android Open Source


[INFO] 05/Feb/2026 10:56:33 - Testing Environment is Ready!

adb shell

su


https://stackoverflow.com/questions/43923996/adb-root-is-not-working-on-emulator-cannot-run-as-root-in-production-builds/45668555#45668555

https://xdaforums.com/t/question-how-to-get-writable-system-on-emulator-with-google-apps-android-13-arm-image.4567963/

You should use the open source version of Partition and run AVD with the following code:

emulator -avd <NameAVD> -writable-system

sudo apt install google-android-emulator-installer

Add to ~/.bashrc:

export ANDROID_HOME=$HOME/Android/Sdk

export ANDROID_SDK_ROOT=$ANDROID_HOME

Reload:

source ~/.bashrc

emulator -avd Medium_Phone_API_29 -writable-system -verbose

emulator -avd Medium_Phone_API_29 -writable-system -no-audio -verbose

Sunday, February 15, 2026

git patch automatic code replacement in repository

git show commitID -- folder/ >> 001commitID.patch

cd to fresh git repo without changes and

git apply 001commitID.patch

git format-patch -10 --author="YOURNAME" // look 10 commits and creat separate patch files

git apply ../0001-your.patch

git log -p // full commit history with code changes (the patch/diff output) for each commit

Saturday, February 14, 2026

GitHub hide and change mail in project repository files

git config --global user.name "USER"

git config --global user.email "123456789+USER@users.noreply.github.com"


git config --global --list

git config --local --list


Make sure working tree is clean:

git status


git add .

git commit -m "commit comment"


git filter-branch --env-filter '

export GIT_AUTHOR_EMAIL="123456789+USER@users.noreply.github.com"

export GIT_COMMITTER_EMAIL="123456789+USER@users.noreply.github.com"

' -- --all


rm -rf .git/refs/original

git reflog expire --expire=now --all

git gc --prune=now --aggressive


git log --reverse --format="%h %an <%ae>"

If you see:

yourname@users.noreply.github.com


git filter-branch --env-filter '

export GIT_AUTHOR_EMAIL="1123456789+USER@users.noreply.github.com"

export GIT_COMMITTER_EMAIL="123456789+USER@users.noreply.github.com"

' -- --all


git log


⚠️ This replaces the online repo history:

git push --force --all

git push --force --tags


git log


git log --all --author="yourname"

git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d

git stash clear

git reflog expire --expire=now --all

git gc --prune=now --aggressive


What others must do (if anyone cloned). They must reclone, or:

git fetch --all

git reset --hard origin/main


git log --all --author="yourname"

SHOULD SHOW NOTHING

Thursday, February 5, 2026

Rust Build completed with 4 failures in Android Studio

Install:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh


Reload environme:

source ~/.cargo/env


Verify:

which rustc

/home/user/.cargo/bin/rustc

rustc --version

rustc 1.92.0 (ded5c06cf 2025-12-08)

cargo --version

cargo 1.92.0 (344c4567c 2025-10-21)


FAILURE: Build completed with 4 failures.

1: Task failed with an exception.

-----------

* What went wrong:

Execution failed for task ':file_operations:cargoBuildArm'.

> A problem occurred starting process 'command 'rustc''

* Try:

> Run with --info or --debug option to get more log output.

> Run with --scan to get full insights.

> Get more help at https://help.gradle.org.

* Exception is:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':file_operations:cargoBuildArm'.

at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:130)

at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)...

Wednesday, February 4, 2026

NDK is not installed in Android Studio on Linux

ls /home/user/Android/Sdk/ndk/

29.0.14206865


IF NONE > Android Studio > Tools > SDK Manager > Language & Frameworks> Android SDK > SDK Tools > Tick NDK (Side by side), tick CMake > Apply > OK


nano Project/gradle/libs.versions.toml

[versions]

compileSdk = "34"

minSdk = "21"

targetSdk = "35"

kotlin = "1.9.25"

ndk = "29.0.14206865" #r28c // ENTER VERSION OF YOUR NDK


Ctrl + Shift + O // Sync Project with Grade Files...

Sunday, January 25, 2026

Local AI RAG with LLama-3 llama.cpp

ChatGPT is best chat bot for now, IMHO… It’s ok to explore themes, philosophize... It’s not so heavily censored, it imitates logical thinking process very good. But at the same time it lies sometimes – distorts names of books, gives bad links, leads you astray with technical staff, like electronics and administrating… It’s nice to argument with it but when getting tech solutions and advice one should be cautious. Also it loves throwing rhetorical garbage.

Gemini. Very helpful in technical staff – short and precise. Good in programming. Worse with electronics than ChatGPT. Didn’t chat a lot with it, so do not know how "well spoken" it is, but generally feels neutral avoiding bold conclusions. Great addition to conventional Google Search.

Grok. Have mixed feeling of it. Very helpful with system administrating. In programming sometimes better than ChatGPT, but as a chat bot it is censored and avoids controversial topics. Even when cornered logically, dodges arguments to stay tolerant, which is bad.

Perplexity. Brief and straight to the point. Didn't used it much.

All local LLM models, I tried, suck… But maybe large ones for very powerful GPUs are OK, though I have no inclination to invest in hardware right now.

We can't rely on AI opinions, but as support and augmentation to idea exploration AIs are OK.

Tuesday, May 28, 2024

VAG KKL 409.1 on Ubuntu Linux

sudo apt install wine // and install VCDS, cable drivers already are in Linux core, interface will be found and cable indicator will be active only when connected to car, on PC - Port OK, interface not found.

Identify COM ports on Linux

sudo dmesg | grep tty

ls /dev/ttyS* // typically refers to hardware serial ports.

ls /dev/ttyUSB* // refers to USB-to-serial converters.

ls /dev/ttyACM* // refers to USB CDC (Communications Device Class) devices.

lsusb

udevadm info -e | grep -E 'DEVNAME|ID_SERIAL'

Create the Symbolic Link

cd ~/.wine/dosdevices

ln -s /dev/ttyUSB0 com1 // map /dev/ttyUSB0 to COM1

rm com1 // if it exists and not needed

ls -l ~/.wine/dosdevices // verify the symbolic link

Add user to dialout group

sudo usermod -aG dialout $USER // add your user to the dialout group

cat /etc/group

grep dialout /etc/group

groups user

Change permissions

ls -l /dev/ttyUSB0 // list permissions

crw-rw---- 1 root dialout 188, 0 May 28 12:06 /dev/ttyUSB0

sudo chmod a+rw /dev/ttyUSB0 // change permissions

sudo lsof /dev/ttyS0 // If no output is returned, no process is currently using it. Ignore error.

Create a Test Script

sudo apt-get install python3-serial

touch test_serial.py

import serial

port = '/dev/ttyS0'
baudrate = 9600

ser = serial.Serial(port, baudrate, timeout=1)
ser.write(b'Hello, serial port!\n')
response = ser.readline()
print(response.decode('utf-8'))

ser.close()

python3 test_serial.py // run script

Saturday, August 5, 2023

Adding Python deadsnakes ppa repository on Kubuntu Linux

apt-cache policy python3

sudo add-apt-repository ppa:deadsnakes/ppa

https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa

MAKE SURE your Linux version is supported: https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/dists/

IF NOT, use latest supported version for ppa


sudo nano /etc/apt/sources.list.d/deadsnakes-ubuntu-ppa-jammy.list

deb https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ focal main
deb-src https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ focal main


sudo apt edit-sources // edit repositories

sudo nano /etc/apt/sources.list // edit repositories

ls /etc/apt/sources.list.d // list additional repositories files


/etc/apt/sources.list.d$ sudo dpkg --force-depends --purge libpython3.10-stdlib
dpkg: libpython3.10-stdlib:amd64: dependency problems, but removing anyway as you requested:
python3.10 depends on libpython3.10-stdlib (= 3.10.7-1ubuntu0.4).

(Reading database ... 254967 files and directories currently installed.)
Removing libpython3.10-stdlib:amd64 (3.10.7-1ubuntu0.4) ...
/etc/apt/sources.list.d$ sudo dpkg --force-depends --purge libpython3.10
dpkg: warning: ignoring request to remove libpython3.10 which isn't installed
/etc/apt/sources.list.d$ sudo dpkg --force-depends --purge libpython3.10-minimal
dpkg: libpython3.10-minimal:amd64: dependency problems, but removing anyway as you requested:
python3.10-minimal depends on libpython3.10-minimal (= 3.10.7-1ubuntu0.4).

(Reading database ... 254625 files and directories currently installed.)
Removing libpython3.10-minimal:amd64 (3.10.7-1ubuntu0.4) ...
Purging configuration files for libpython3.10-minimal:amd64 (3.10.7-1ubuntu0.4) ...
/etc/apt/sources.list.d$ sudo dpkg --force-depends --purge libpython3.10
dpkg: warning: ignoring request to remove libpython3.10 which isn't installed


/etc/apt/sources.list.d$ sudo apt install python3.10
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
python3.10 : Depends: python3.10-minimal (= 3.10.12-1+focal1) but 3.10.7-1ubuntu0.4 is to be installed
             Depends: libpython3.10-stdlib (= 3.10.12-1+focal1) but it is not going to be installed
python3.10-minimal : Depends: libpython3.10-minimal (= 3.10.7-1ubuntu0.4) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

sudo apt purge python3.10

sudo apt purge python3.10-minimal


sudo aptitude

https://packages.ubuntu.com/kinetic/libpython3.10-stdlib

sudo dpkg -i libmpdec3_2.5.1-2build2_amd64.deb

sudo dpkg -i libpython3.10-minimal_3.10.7-1ubuntu0.4_amd64.deb

sudo dpkg -i libpython3.10-stdlib_3.10.7-1ubuntu0.4_amd64.deb

sudo apt --fix-broken install


Spent lot't of time and failed...

Change the Python3 default version in Ubuntu

cd /usr/bin

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1

sudo update-alternatives --config python // choose python version

python3 --version

Python 3.10.7


sudo apt-get install --reinstall ca-certificates

See Technical details about this PPA => Signing key: => Fingerprint:

https://askubuntu.com/questions/1459362/how-to-resolve-the-key-not-available-error-on-deadsnakes-ppa

https://www.rosehosting.com/blog/how-to-install-and-switch-python-versions-on-ubuntu-20-04/

https://unix.stackexchange.com/questions/410579/change-the-python3-default-version-in-ubuntu

https://askubuntu.com/questions/1239829/modulenotfounderror-no-module-named-distutils-util

Remove python3 - Python 3.11 on Ubuntu

ls /usr/bin/python* // list all installed python versions

[Bug]: RuntimeError: Couldn't Install Torch

Stable Diffusion----------------------------------------------------------------------------
./webui.sh --xformers

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on user user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
Using TCMalloc: libtcmalloc_minimal.so.4
Python 3.11.4 (main, Jun  9 2023, 07:59:55) [GCC 12.3.0]
Version: v1.5.1
Commit hash: 68f336bd994bed5442ad95bad6b6ad5564a5409a
Installing torch and torchvision
/home/user/Downloads/stable-diffusion-webui/venv/bin/python3: No module named pip
Traceback (most recent call last):
  File "/home/user/Downloads/stable-diffusion-webui/launch.py", line 39, in <module>
    main()
  File "/home/user/Downloads/stable-diffusion-webui/launch.py", line 30, in main
    prepare_environment()
  File "/home/user/Downloads/stable-diffusion-webui/modules/launch_utils.py", line 311, in prepare_environment
    run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
  File "/home/user/Downloads/stable-diffusion-webui/modules/launch_utils.py", line 113, in run
    raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't install torch.
Command: "/home/user/Downloads/stable-diffusion-webui/venv/bin/python3" -m pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118
Error code: 1
----------------------------------------------------------------------------Stable Diffusion

sudo rm /usr/bin/python3.11
sudo apt purge python3.11
usr/bin$ sudo apt remove python3.11-minimal

sudo find / -xdev -name python3.11*
sudo find / -xdev -name 'python3.11*' -exec rm -r {} \; // remove all found

sudo apt-get purge python3-uno
sudo apt-get install python3-uno

sudo apt-get purge python3.11-minimal python3.11 python3 python3-uno

sudo apt update -y && sudo apt upgrade -y
sudo apt --fix-broken install
sudo apt autoremove --purge *python* // remove all python packages

apt-cache policy python3

SOLUTION in my case:
sudo dpkg --force-depends --purge libpython3.11-stdlib
sudo dpkg --force-depends --purge libpython3.11
sudo dpkg --force-depends --purge libpython3.11-minimal
sudo apt --fix-broken install

AVOID creating conflicts by installing different kernel version updates!!!

sudo apt install -f --reinstall python3-minimal
sudo apt install -f --reinstall python3-pip
sudo apt install -f --reinstall python3
sudo apt update
sudo apt upgrade
sudo apt full-upgrade
sudo apt reinstall plasma-desktop
sudo apt reinstall kwin-x11

https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-programming-environment-on-ubuntu-22-04
https://askubuntu.com/questions/1402419/cant-remove-python-3-10-from-ubuntu-20-04lts
https://gist.github.com/zhensongren/811dcf2471f663ed3148a272f1faa957
https://computingforgeeks.com/how-to-install-python-on-ubuntu-linux-system/?expand_article=1
https://linuxhint.com/uninstall-python-ubuntu-22-04/
https://www.debugpoint.com/install-python-3-10-ubuntu/

Tuesday, November 1, 2022

Server error messages in Node.js

 //

app.use((err, req, res, next) => {
console.log(err);
err.statusCode = err.statusCode || 500;
err.status = err.status || 'error';
res.status(err.statusCode).json({
status: err.status,
message: err.message,
}); // {"status":"fail","message":"Page / not found!"}
next();
});

//

Express req request Node.js

Show Express req content:

app.all('*', (req, res, next) => {
console.log(req);
});

Monday, October 31, 2022

Jest testing framework for React & Node.js

https://jestjs.io/docs/getting-started

{
"name": "project",
"version": "1.0.0",
"description": "API",
"main": "src/server.js",
"scripts": {
"test": "jest",
"test-watch": "jest --watchAll",
"start": "node src/server.js",
"watch": "nodemon src/server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"csv-parse": "^5.3.1",
"express": "^4.18.2",
"morgan": "^1.10.0"
},
"devDependencies": {
"jest": "^29.2.2",
"supertest": "^6.3.1"
}
}

npm i jest --save-dev

npm i supertest --save-dev

Sunday, October 30, 2022

Run client & server in separate folders

Node.js server and React client:

"scripts": {
"install-server": "cd server && npm install",
"install-client": "cd client && npm install",
"install": "npm run install-server && npm run install-client",
"server": "cd server && npm run watch",
"client": "cd client && npm start",
"watch": "npm run server & npm run client",
"test": "echo \"Error: no test specified\" && exit 1"
},

Node.js server and React client:

"scripts": {
"install-server": "npm install --prefix server",
"install-client": "npm install --prefix client",
"install": "npm run install-server && npm run install-client",
"server": "npm run watch --prefix server",
"client": "npm start --prefix client",
"watch": "npm run server & npm run client",
"deploy": "npm run build --prefix client && npm start --prefix server",
"test": "npm test --prefix server & npm test --prefix client"
},

//

Thursday, October 27, 2022

http Node.js module status codes

node > http

STATUS_CODES: {
   '100': 'Continue',
   '101': 'Switching Protocols',
   '102': 'Processing',
   '103': 'Early Hints',
   '200': 'OK',
   '201': 'Created',
   '202': 'Accepted',
   '203': 'Non-Authoritative Information',
   '204': 'No Content',
   '205': 'Reset Content',
   '206': 'Partial Content',
   '207': 'Multi-Status',
   '208': 'Already Reported',
   '226': 'IM Used',
   '300': 'Multiple Choices',
   '301': 'Moved Permanently',
   '302': 'Found',
   '303': 'See Other',
   '304': 'Not Modified',
   '305': 'Use Proxy',
   '307': 'Temporary Redirect',
   '308': 'Permanent Redirect',
   '400': 'Bad Request',
   '401': 'Unauthorized',
   '402': 'Payment Required',
   '403': 'Forbidden',
   '404': 'Not Found',
   '405': 'Method Not Allowed',
   '406': 'Not Acceptable',
   '407': 'Proxy Authentication Required',
   '408': 'Request Timeout',
   '409': 'Conflict',
   '410': 'Gone',
   '411': 'Length Required',
   '412': 'Precondition Failed',
   '413': 'Payload Too Large',
   '414': 'URI Too Long',
   '415': 'Unsupported Media Type',
   '416': 'Range Not Satisfiable',
   '417': 'Expectation Failed',
   '418': "I'm a Teapot",
   '421': 'Misdirected Request',
   '422': 'Unprocessable Entity',
   '423': 'Locked',
   '424': 'Failed Dependency',
   '425': 'Too Early',
   '426': 'Upgrade Required',
   '428': 'Precondition Required',
   '429': 'Too Many Requests',
   '431': 'Request Header Fields Too Large',
   '451': 'Unavailable For Legal Reasons',
   '500': 'Internal Server Error',
   '501': 'Not Implemented',
   '502': 'Bad Gateway',
   '503': 'Service Unavailable',
   '504': 'Gateway Timeout',
   '505': 'HTTP Version Not Supported',
   '506': 'Variant Also Negotiates',
   '507': 'Insufficient Storage',
   '508': 'Loop Detected',
   '509': 'Bandwidth Limit Exceeded',
   '510': 'Not Extended',
   '511': 'Network Authentication Required'
 },

https://nodejs.org/api/http.html

Tuesday, October 25, 2022

Using local JSON file without database in Node.js

 //

////////////////////////////////////////////////////////
// JSON WITHOUT DATABASE
// //////////////////////////////////////////////////////
const fs = require('fs');
////////////////////////////////////////////////////////
const cards = JSON.parse(fs.readFileSync(`${__dirname}/data/card-data.json`));
////////////////////////////////////////////////////////
exports.checkId = (req, res, next, val) => {
if (req.params.id * 1 > cards.length) {
return res.status(404).json({
status: 'fail',
message: 'Invalid ID',
});
}
next();
};
////////////////////////////////////////////////////////
exports.getAllCards = (req, res) => {
res.status(200).json({
status: 'success',
time: req.requestTime,
result: cards.length, // if sending array!!!
data: { images: cards },
});
};
////////////////////////////////////////////////////////
exports.getCard = (req, res) => {
const id = req.params.id * 1; // convert String into Number
const card = cards.find((el) => el.id === id); // console.log(req.params);
res.status(200).json({
status: 'success',
time: req.requestTime,
data: {
card: card, // or just card instead of card: card
},
});
};
////////////////////////////////////////////////////////
exports.postCard = (req, res) => {
// solution to work without database
const newId = cards[cards.length - 1].id + 1;
const newCard = Object.assign({ id: newId }, req.body); // console.log(req.body);
cards.push(newCard);
fs.writeFile(
`${__dirname}/../data/card-data.json`,
JSON.stringify(cards),
(err) => {
res.status(201).json({
status: 'success',
data: { images: newCard },
});
}
); // use asynchronous writeFile
};
////////////////////////////////////////////////////////

//