Everything AI – TOC

This blog has plenty of posts about AI, some are about AI tools, others are about installing AI locally, so this post is where I am putting all the AI stuff I have ever blogged about in one place !

The section Local AI is about creating your own AI server using freely available sources, the API section lists all the services that provide an API that can be used remotely (Most can not be installed locally anyway), and the Online Services is where you can get things done via AI online (That can be used using your browser, whether they provide an API or not, and whether they can be installed locally or not is a different story)

Continue reading “Everything AI – TOC”

BMW F10 M5 (2014), the everything

So, a good friend of mine bought a used but perfect condition M5, he is so happy about it, as a testament to how personal BMW cars can be, you can feel the adrenaline in his voice days before the handover date, and his happiness is contagious in a weird way, hence this page.

The hunt

1- Diagnostic software (And hardware)
2- Service manuals
3- Aftermarket infotainment
4- OEM upgrades
5- Aftermarket upgrades

Online tools

MDECODER: Should be able to show all the specs about the car

Vindecoderz : Good for finding the recalls

Bimmer.Work:

Android car units

I recently bought an android system for an old car, and to my surprise, the RAM installed on it was half of what was advertised !

It is easy to check, here are the commands you need

On linux

Get connected to phone for ADB , then

Screen resolution before upscaling
adb shell wm size

Ram and other features

getprop ro.boot.dramsize
adb shell getprop ro.build.version.sdk
adb shell getprop (Just show Everything)

On windows, you will execute all this differently

adb shell
getprop ro.build.version.sdk
getprop

This also applies to home android TV set top boxes ! I checked

Trixie… php8.4-imap missing

Error: Unable to locate package php8.4-imap
Error: Couldn’t find any package by glob ‘php8.4-imap’

the debian package maintainer (Ondřej Surý) has released it on his repository, but it is nowhere to be found for Debian 13 on “https://packages.debian.org/“, trixie didn’t trickle down to the website yet, but in SID, it reads “The extension is unbundled from php-src as of PHP 8.4.0.”

I am not yet sure what this means, there is a chance it means we should install it using PECL, I will not do that, I would rather installwith apt, but if i wanted to, i would execute

sudo apt install php-pear php8.4-dev
sudo pecl install imap

There is a chance that it will be coming back to debian’s repositories since Sury (The package maintainer) has it, but I have no idea when

So, let us install it (the IMAP extension and nothing else) from the sury repository to make things simpler when debian has it again

Let us start by adding

sudo apt install -y lsb-release apt-transport-https ca-certificates curl gnupg2
echo "deb https://packages.sury.org/php $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list
curl -fsSL https://packages.sury.org/php/apt.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/sury-php.gpg
sudo apt update

Now we have added Sury’s repository to apt, let us go ahead and pin it so that only php8.4-imap is sourced from that repo !

sudo tee /etc/apt/preferences.d/sury-php.pref >/dev/null <<'EOF'
Package: *
Pin: release o=deb.sury.org
Pin-Priority: 1

Package: php8.4-imap
Pin: release o=deb.sury.org
Pin-Priority: 990
EOF
sudo apt update

Now install

sudo apt install php8.4-imap

To make sure everything is correct

apt policy php8.4-imap

Now in my case, I need to restart PHP (systemctl restart php8.4), in your case, you might need to restart apache or something else, when in doubt, restart the machine 😛

Once the package is in debian repositories again, we will simply remove /etc/apt/preferences.d/sury-php.pref and /etc/apt/sources.list.d/sury-php.list, then reinstall php8.4-imap.

Failing spark plugs

My 2014 Toyota Prius uses iridium-tipped spark plugs such as the Denso SK16R11 or the NGK IFR5A11, both usually set you back around $20, but if you buy them from the official toyota dealer, they will set you back $150 ! but I have no choice, as the market is flooded with counterfeit spark plugs, and changing the spark plugs on the prius requiers the removal of the wiper area !

What about those $150 spark plugs (I will check the exact price and update this soon, so when I took them out after less than 5000 KMs and found two of them broken ! specifically the Insulator Nose (shield) around the copper core !

I had a failing head gasket, and the removal was part of fixing that, so I thought that the seeping oil or water into the piston might have been the problem, but since i maintained their order after removing them, It turns out that the one that has the inner shield fully broken was in a piston that did not suffer any head gasket leak !

Prius 2014 head gasket replacement

Seems the Prius is known to blow head gaskets, reason being attributed to the hybrid system, the engine switches off and on so often, heating up and cooling down all the time.

I am using the official TIS repair manuals. I am warning you, this is a lengthy job, it is not something you can finish in a day.

Tools

There are plenty of tools that you will need along the way, everything from the tools needed to take out the EGR, to a triple square bit to remove the cylinder head bolts, in any case, here is a list of tools i recall needing

  • A ratchet, breaker bar, and a cheater bar
  • A torque wrench (I use ACDelco’s ARM302-4s)
  • Oil filter removal tool
  • 10mm bi-hexagon wrench (An M12 (12mm triple square) bit will do if you fail to obtain the bi-hexagon ! but you will feel a bit of wiggle in it)
  • A pair of pliers
  • 12mm socket (Many screws)
  • 14mm socket (Many screws)
  • 19mm socket (The harmonizer / crank pulley)
  • Feeler gauges down to 0.004 (0.004 is the maximum acceptable engine warp)
  • A super straight bar to assess the engine against (Laser cut)
  • Harmonic Damper removal tool such as Schley 64300 (I made my own simple tool that works)
  • A tool to take out the valve stem seals (I made my own)
  • Patience

The Harmonic Damper removal tool

There are many ways to remove the pulley (Harmonic Damper), 1- the most common of which is using a torque impact drill, it just works, but my gut feeling tells me it might not be wise, if it was, Toyota would have approved it, 2- another popular way is to use a belt or strap and tie it to a strong part of the vehicle and around the pulley to use friction to hold the pulley in place, problem with this method is that if it is not 100% horizontally aligned, and the pulley is being pulled in or out, it might cause damage, 3- and there is the Toyota way, which is based on using a tool to hold the pulley in place while you loosen the screw, examples of such a tool is the Schley Products 64300, I don’t have access to such a tool, so I improvised a tool that holds the pulley against the engine mount

Parts

Distilled water

7 Liters of distilled water, You are probably going to need to use distilled water before engine coolant to flush the engine from the contaminated coolant in the car, it was contaminated because your head gasket broke, and exhaust went through that coolant.

Engine Coolant

(Applies to both Fix and repair)
If the coolant has been contaminated with engine exhaust, you will need to flush and add distilled water, then after a day (a day of light use, and zero days of the car sitting), remove as much of the water as you can and add the SLLC coolant (Do not run on distilled water for more than 1 day).

Totota’s coolant is super expensive, if you are looking for something other than the OEM, or want to understand the risks and advantages, check out my Toyota’s coolants post

The car takes 6.5 liters of coolant, every container is 2 liters !

Oil and oil filter

(Applies to both Fix and repair)

if the engine oil has been contaminated (And it has), you will need a new filter and new oils

Expected cost (35JD)

Gasket kit

PN: 04111-37316

The repair manual states that you will need a new gasket kit, the gasket kit has the following parts.

FIPG 103

PN: 00295-00103

The form in place gaskets from Toyota are best, but they are very pricey, I went with an aftermarket German brand (Victor Reinz Reinzosil) that is high quality (Used by German brands as OEM !) and have my fingers crossed, the Toyota FIPG costs around $50, the Victor Reinz Reinzosil (Universal) aftermarket brand costs less than 6 dollars

Cylinder head bolts

(90910‑02164 and later was superseded by 90910‑A2009)

Those are Torque to yield bolts, when you install them, they are stretched, and should not be used again, In my case unfortunately, Al markazeyah Toyota does not provide them, I was told today that they did have them at one point, and they cost $5 each (10 of them is $50), but they no longer carry them ! yes, I know, what the duck, as an exclusive dealer in Jordan, they absolutely should have them.

The Toyota repair manual often tells you to measure the bolts after removal, and replace them if they are out of spec — a classic sign of TTY design, even if not spelled out.

The process

Removing the spark plugs

Getting started with a big surprise !

I started by removing the spark plugs, like you normally would, and to my surprise, those brand new spark plugs (Less than 5000 KMs) are broken, and the ones that were broken are not even the ones where the head gasket leaked into ! Here is more about the failing spark plugs

Toyota’s coolants

The following is a result of me checking the right way to flush my engine of contaminated coolant in my 2014 prius, but it applies equally to modern Toyotas. my coolant was contaminated due to a blown head gasket !

The lowdown: fill it with distilled water, use it for a day in light traffic (Don’t let the water sit, you have to fill it and use it for a day, if the weather is hot, you should not stress it as water has less cooling capacity), then, flush as much as you can from those 6.5 liters of distilled watter, and once you have removed 5 or more liters, fill it up with SLLC (Not a drop of LLC is allowed)

The coolant from Toyota for modern cars (2004+) is super expensive ($21 for every 2L), my 2014 Prius for example has 10 liters of coolant in both engine and inverter loops, that would set me back around $100,

The coolant suitable for such new cars is called the SLLC (Super long life coolant), it comes premixed 50/50 (With distilled water)

Can i mix SLLC with the older LLC ?

You certainly can not ! they are chemically incompatible, You are not free to mix and match.

SLLC is compatible with both inverter and aluminum engine cooling systems, LLC is not, they have different chemical formulations and should not mix in any way. here is what is given by Toyota in the MSDS documents, obviously done by Toyota in a way to keep it ambiguous and keep others from copying the formulation

Long Life (LLC)Super Long Life (SLLC)
Ethylene Glycol 107-21-1. 87% – 95%Ethylene Glycol 107-21-1. 45% – 50%
Diethylene Glycol 111-46-6. Less than 5%
Hydrated inorganic acid, organic acid salts. Less than 5%Hydrated inorganic acid, organic acid salts. Less than 5%
Water. Less than 5%Water. Less than 45% – 50%
Bittering agent (Trace amounts)
NOTES: NOTES: This is P-OAT chemistry.
OAT = Organic Acid Technology
“P-OAT” or “Phosphated OAT”

So what alternative coolants can be used ?

The coolant compatible with your aluminum engine is a P-OAT, which in Toyota terms is called the super long life, if you find the brands “AISIN or Zerex”, that is the OEM for the SLLC, as for the LLC the OEM is probably castle, As they have a product that comes in an identical container, but that is not definitive proof.

Things you DON’T need to know
LLC *(The one you should not use on modern cars) is not premixed, you add 50% distilled water, but this is for older vehicles.

Remotely controlling the S10+

I have been using a google pixel 6 pro for some time now, excellent phone, and it already got the android 16 update, so thanks to google for extending our support ! rumor has it that with this extended support, we will also get android 17 !

Now, my old Samsung S10+ that I had before the pixel 6 has a broken screen, the upper side of the screen works, but the touch is broken, the lower 30% of the screen are black but the touch screen works, it sustained this injury when a bottle of vodka went crashing down on the screen when the phone was fairly new ! the poor thing never stood a chance, and was only used for a few months (if even that)

Anyway, to avoid keeping my phone occupied when I am taking a video, I have been using a xiaomi note 4, not bad a camera, but the S10+ is obviously a better option for this task

So, how can I use it, turns out there is open source software called scrcpy that should be able to do both jobs, mirror the screen on a PC or another phone, and send the input to the phone ! scrcpy should be able to connect to the PC through WIFI (If your phone is recent enough) or USB (Whatever is ADB compatible)

Installing scrcpy on my PC

NOTE: I use Gnome on a Linux Debian machine, but installing it on windows should be straight forward !

sudo apt install scrcpy adb -y

This installs both Scrcpy and Android Debug Bridge (ADB), which are needed to communicate with your phone.

NOTE: The above does not work in bookworm as there is no such package (Both previous and next versions do have it), so instead, if you are on bookworm, follow the steps below

Bookworm installation

sudo apt install git ffmpeg libsdl2-dev adb gcc make meson ninja-build pkg-config libavcodec-dev libavformat-dev libavutil-dev libusb-1.0-0-dev libavdevice-dev adb

sudo apt install openjdk-17-jdk gradle

Now, we need the SDK !
mkdir -p ~/Android && cd ~/Android
wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
unzip commandlinetools-linux-*.zip -d cmdline-tools
cd cmdline-tools
mv cmdline-tools latest
NOTE: You will have the folder cmdline-tools inside the folder cmdline-tools so we renamed the inner to latest

vi ~/.bashrc
export ANDROID_HOME=$HOME/Android
export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH

source ~/.bashrc

Now, you need to accept all the license agreements

~/Android/cmdline-tools/latest/bin/sdkmanager --licenses

cd ~
mkdir src
cd ~/src

git clone https://github.com/Genymobile/scrcpy

cd scrcpy

meson setup build
ninja -C build
sudo ninja -C build install

Now, I assume you know how to connect your phone to your PC via ADB, if not, there are tutorials all over the internet… You start by enabling developer tools mode on the phone by tapping the build number 7 times then enable debug (Either USB or WIFI or both)

Once that is done, you can get a clone of the screen with the following

adb devices

scrcpy -s device1_serial

You don’t need the -s serial part if there is only 1 device

Also, you can run multiple instances

Installing Whisper AI to a an entry level GPU

Obviously, as you can see from my blog, I have a bunch of high end GPUs for my AI work, the GPU I use on my daily driver PC on the other hand is a complete joke (Nvidia rtx 1650) with 4GB of ram… Not exactly a GPU you would use for anything remotely demanding

But running whisper on my local machine is very convinient, the audio files are already there, no need to login to any remote machines and the like, so i will be installing a small version of whisper here, and let us see how this ancient GPU does

1- I already have Python 3.12.7 installed, if you don’t, then “sudo apt install python3 python3-pip”

python3 -m venv whisper-env

And activate it

source whisper-env/bin/activate

Now, before you procede, if you want your “HuggingFace” directory on a different drive or something (Where the models actually live), you should start by adding the following line to ~/.bashrc or whatever your system uses, also remember to either run (source ~/.bashrc) or to close and open your terminal again for the changes to take effect

export HF_HOME=/mnt/bigdrive/huggingface

Now, let us go ahead and install faster-whisper

pip install faster-whisper

Also, make sure PyTorch with GPU support is available:

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

Test GPU availability:

python3 -c "import torch; print(torch.cuda.is_available())"

Now, I thought tiny would be the correct size that suits my GPU, but it turned out “mini”base” works just fine !

faster-whisper sample.wav --model-size base --compute-type float16

How do we know if we are hitting the GPU limits ?

watch -n 1 nvidia-smi

BeautifulSoup

BeautifulSoup is a python package that allows you to extract data from HTML files, it is very easy and intuitive

Let us assume you have an HTML page !

First, let us assume you want the title from that HTML page….

mysoup = BeautifulSoup(response.content, 'html.parser')
title = soup.title.string if soup.title else "No title found"

Now, assuming you want to remove everything that has to do with CSS and presentation, you can remove the following things with this easy code snippet, then putting whatever is lef in a variable called text

for irrelevant in mysoup.body(["script", "style", "img", "input"]):
irrelevant.decompose()
text = soup.body.get_text(separator="\n", strip=True)

Gnome calculator freezes instantly

Well, the calculator that ships with Gnome would launch instantly, then freeze instantly, I would then have to keep clicking the (x) in the corner and wait for the OS to suggest killing the app

No matter how long I wait on the app, it won’t budge, you can’t even move it around the screen

Turns out the calculator works if I am not connected to the internet (Pull the Ethernet cable out)

The solution was simple, it seems the calculator freezes waiting for data from the internet, when there is no internet, it skips the step

The solution was simple, it goes online for currency conversion rates, something i never use, so the solution is to execute the following command to stop it from doing that

dconf write /org/gnome/calculator/refresh-interval 0

Yup, that is it, the calculator works perfectly now