Youtube channel !

Be sure to visit my youtube channel

Thursday, December 25, 2025

Things to do after install Fedora 43

#!/bin/bash

# 1. SETUP REPOSITORIES
echo ">>> Setting up Repositories (RPM Fusion, Copr, Cisco)..."
# Install RPM Fusion (Free & Nonfree)
sudo dnf install -y https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm

# Enable Cisco OpenH264
sudo dnf config-manager --set-enabled fedora-cisco-openh264

# Enable Vanilla Kernel Copr
sudo dnf -y copr enable @kernel-vanilla/stable

# Enable Caprine Copr
sudo dnf copr enable dusansimic/caprine

# 2. SYSTEM UPDATES & FIRMWARE
echo ">>> Updating System and Firmware..."
sudo dnf upgrade --refresh -y
# Update Core Group
sudo dnf groupupdate core -y

# Check Firmware (Only if supported hardware is found)
fwupdmgr refresh
fwupdmgr get-updates
fwupdmgr update -y

# 3. INSTALL DRIVERS & CODECS
echo ">>> Installing Multimedia Codecs and Intel Drivers..."
# Install basic multimedia packages and libraries
sudo dnf install -y libfreeaptx libldac fdk-aac ffmpeg-libs libva libva-utils openh264 gstreamer1-plugin-openh264 mozilla-openh264 intel-gpu-tools

# Swap restricted codecs (Allowerasing handles the swap)
sudo dnf swap -y ffmpeg-free ffmpeg --allowerasing
sudo dnf swap -y mesa-va-drivers mesa-va-drivers-freeworld
sudo dnf swap -y mesa-vdpau-drivers mesa-vdpau-drivers-freeworld

# Install Multimedia Groups (excluding PackageKit plugin to prevent conflicts)
sudo dnf group upgrade -y multimedia sound-and-video --setopt="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin

# INTEL DRIVERS
# Note: 'libva-intel-driver' is the legacy i965 driver (Sandy Bridge to Skylake). 
# Newer Intel CPUs (Broadwell+) use 'intel-media-driver'. 
# Since you specified Sandy Bridge, we keep 'libva-intel-driver'.
sudo dnf install -y libva-intel-driver

# 4. INSTALL APPLICATIONS & TOOLS
echo ">>> Installing Applications and Tools..."
# Archive Tools, System Info, Monitoring
sudo dnf install -y unzip p7zip p7zip-plugins unrar inxi btop lm_sensors git make gcc mono-devel vlc caprine

# Viber (Assumes you have downloaded the RPM, otherwise download it first)
# wget https://download.cdn.viber.com/cdn/desktop/Linux/viber.rpm
# sudo dnf install -y ./viber.rpm

# 5. KERNEL CONFIGURATION
echo ">>> Installing Vanilla Kernel..."
sudo dnf upgrade -y 'kernel*'
# Update metadata expiration for Copr
sudo sed -i 's!baseurl=https://download.copr.fedorainfracloud.org/results/@kernel-vanilla/\(mainline\|stable-rc\|next\).*!&\nmetadata_expire=1h!g; s!baseurl=https://download.copr.fedorainfracloud.org/results/@kernel-vanilla/\(stable\|fedora\)/.*!&\nmetadata_expire=3h!g;' /etc/yum.repos.d/_copr:copr.fedorainfracloud.org:group_kernel-vanilla:*.repo

# Secure Boot State
mokutil --sb-state

# 6. POWER & THERMAL MANAGEMENT
echo ">>> Configuring Power and Thermals..."

# Detect sensors
sudo sensors-detect --auto

# Install Thermald
sudo dnf install -y thermald
sudo systemctl enable --now thermald

# --- OPTION A: Power Profiles Daemon (Default/Recommended for GNOME/KDE) ---

#sudo dnf install -y power-profiles-daemon
#sudo systemctl enable --now power-profiles-daemon
#powerprofilesctl set performance

# --- OPTION B: TLP (Advanced battery life, conflicts with Option A) ---
# DO NOT RUN BOTH Option A and B. Uncomment below only if you remove power-profiles-daemon.
# sudo dnf install -y tlp tlp-rdw
# sudo systemctl mask power-profiles-daemon
# sudo systemctl enable --now tlp

# Disable NetworkManager wait online (speeds up boot)
sudo systemctl disable NetworkManager-wait-online.service

# 7. BUILD NBFC-LINUX (Manual Build)
echo ">>> Building NBFC-Linux..."
if [ ! -d "nbfc-linux" ]; then
    git clone https://github.com/nbfc-linux/nbfc-linux.git
fi
cd nbfc-linux
make
sudo make install
cd ..

# 8. FILESYSTEM MAINTENANCE
echo ">>> Filesystem Maintenance..."
sudo fstrim -av
# Only run defrag on BTRFS root
sudo btrfs filesystem defragment -r -v /

# 9. MANUAL CONFIGURATION STEPS
echo ">>> Opening Config Files (Manual intervention required)..."
# sudo nano /etc/dnf/dnf.conf
# sudo nano /etc/default/grub 
# After editing grub, run: sudo grub2-mkconfig -o /boot/grub2/grub.cfg

# 10. FINAL CHECK
echo ">>> Done. System Stats:"
systemd-analyze blame | head -n 10
vainfo
sudo intel_gpu_top 

git clone https://github.com/AdnanHodzic/auto-cpufreq.git
cd auto-cpufreq && sudo ./auto-cpufreq-installer
sudo auto-cpufreq --install
auto-cpufreq --stats

in /etc/environment:
LIBVA_DRIVER_NAME=i965 

 Notes:  sudo dnf install xfce4-notes-plugin 

 

#disable autoupdates && save ram 

sudo systemctl stop packagekit
sudo systemctl mask packagekit 

 

Tune ZRAM for performance.

  1. Edit/Create the config:

    Bash
  • sudo nano /etc/systemd/zram-generator.conf 
    [zram0]
    zram-size = ram
    compression-algorithm = zstd
    Restart the service:
    sudo systemctl restart systemd-zram-setup@zram0.service
  • List services:systemctl list-units --type=service
    Fedora specific:
    sudo systemctl disable --now switcheroo-control.service ModemManager.service pcscd.service
    sudo systemctl disable --now abrtd.service abrt-journal-core.service abrt-oops.service abrt-xorg.service rsyslog.service atd.service
    sudo systemctl disable --now gssproxy.service rpc-statd-notify.service
    sudo systemctl disable --now irqbalance.service 
    balooctl disable 
     
    sudo systemctl disable --now pcscd.service
    sudo systemctl mask power-profiles-daemon
     
    edit /etc/default/grub and add mitigations=off to the GRUB_CMDLINE_LINUX line
    sudo grub2-mkconfig -o /boot/grub2/grub.cfg
     
     

    Monday, April 07, 2025

    Modernizing old php project with the help of AI

    0. Keep docker running in separate outside of VSCODE terminal
    1. The importance of GIT for version control - create modernization branch
    2. Add rules:
    Prefer simple solutions
    Only make requested changes, that are well understood and related to the request
    Think about what other methods and areas of code that might be affected by code changes
    Always look for existing code to iterate instead of creating new code
    Avoid code duplication, which means checking for other areas of the codebase that might already have similar code and functionality
    Do no touch code that is unrelated to the task
    Focus on the code areas that are relevant to the task
    Keep the codebase clean and organized
    Generate code for specific, defined transformations (e.g., adding namespace to one file, updating callers for one file), do not to perform project-wide automated changes

    3. Have two different chats: for fixes, and enhancements

    1. Refactoring:
    Start refactoring with Cursor using agents as it reads best context: use thinking model for understanding better the prompt and deep code relations.
    Initial prompt: Analyze the include and require statements in /src. Suggest and create a PSR-4 namespace structure (e.g., App\), move, update and refactor the existing files based on the new structure. @src
    Context: If the project is large instead of providing the entire src directory, provide more specific context (e.g., @src/Models or: @UserModel.php @Database.php) when the task is focused on a particular area.

    2. Fixes:


    Prompt 1: could you fix the following: Keep in mind that the project path: /var/www/html(inside docker) points to location: /real_path/src

    Prompt:2 I am receiving the following warnings, could you try to fix them: add as context the whole directory @src
    (repeat multiple times until the code is running)

    If there is persistant bug / error. Use the gemini code extension, but carefully provide context of related files!

    Remember: On success save in git and then continue && Don't overflow the chat buffer, start new chat.

    Second prompt: Could you suggest an optimization of the PHP class structure that could encapsulate the logic and data handled in this code. Please use PDO and make it compatible with the rest of the code.

    3. Advanced prompts:
    3.1. Refactor the PHP code to improve readability and maintainability. Consider breaking down long functions, using modern PHP syntax (e.g., PHP 7.x/8.x features like null coalesce operator, short array 3.2. Look at the application as a whole and tell if there are architectural patters that can be used to improve the project.syntax, type hints if applicable), and adhering to PSR-12 coding standards.

    4. Security
    Analyze this PHP code snippet for common security vulnerabilities like SQL Injection, Cross-Site Scripting (XSS), and insecure variable handling. Suggest safer alternatives using modern practices (e.g., prepared statements, output escaping). Add rate limiting if possible.

    Tuesday, October 22, 2024

    Integrating AI code helpers into Visual Studio Code

    In this guide, we’ll walk through setting up a local AI-powered coding assistant within Visual Studio Code (VS Code). By leveraging tools such as Ollama, CodeStral, and the Continue extension, we can enhance our development workflow, get intelligent code suggestions, and even automate parts of the coding process.

    Installation:

    Configuring the Environment:

    • Step 1: Installing the Required Extensions

      1. Install CodeStral: Open the Extensions panel in VS Code, search for “CodeStral,” and click “Install.” This extension helps with managing your local AI models for code assistance.
      2. Configure CodeStral: Once installed, follow the extension’s configuration guide. You will need to install additional components, such as Ollama, which sets up a local server to run AI models.

      Step 2: Setting Up Ollama for Local AI Models

      • Install Ollama: Download and install Ollama, a server that will allow your system to host AI models locally. Once installed, you should be able to run the command Ollama run from your terminal.
      • Use Granite 8B Model: For code suggestions, use the Granite 8B model from IBM, which is optimized for code-related tasks. Note that loading the model may take some time as it’s about 5GB in size.

      Step 3: Working with the Continue Extension

      • Installing Continue: The Continue extension integrates with models running on Ollama and helps provide code assistance based on context.
      • Configure Privacy Settings: If you want to work offline or avoid telemetry, open your configuration file (config.json) and set the allow_telemetry parameter to false.
      • Configure Continue extension: Open the configuration settings in VS Code (Ctrl+P) and search for config.json. Add the following configuration:
      JSON
      {
        "models": [
          {
            "provider": "ollama",
            "name": "granite_8b",
            "model": "granite_8b"
          }
        ],
        "allowTelemetry": false
       
      • Using the Extension: You can highlight specific parts of your code, press Ctrl+L, and interact with the AI. For instance, if you highlight a few lines of code and ask, “How can I improve this code?” the AI will analyze the snippet and suggest improvements.
      • Accepting Code Changes: Once the AI provides suggestions, you can either accept the changes directly or refine them by asking follow-up questions.

      Step 4: Advanced Features

      • Context Detection: Continue supports context detection across files, repositories, and even web URLs. It can analyze your entire project and provide suggestions based on your overall code structure.
      • Working Offline with Privacy: If privacy is important, Continue can be configured to keep everything offline, unlike some extensions that send data for research purposes.

      Step 6: Hardware Considerations and Speed Optimization for Ollama

      • Optimizing GPU Usage: If you have multiple Nvidia GPUs, use the nvidia-smi -L command to identify the unique ID of each card. You can then set the CUDA_VISIBLE_DEVICES environment variable to ensure the AI model utilizes the right GPU for faster performance.
      • Check Logs: Periodically check Ollama’s logs to troubleshoot any issues, such as problems initializing the server or GPU.
      • Hardware Recommendations: If possible, use more powerful GPUs like RTX 4070 or 3090 for faster model performance, especially when running large models.

      Use Cases of Cursor editor, or Cody VSCode extension

      • Highlight the relevant code and use the AI tool to suggest changes. While having the code highlighted, by pressing Ctrl +K in Cursor you can even ask the assistant to rewrite the code, which will automatically update the code in place.
      • By using the option to scan the entire codebase from the chat menu option, the AI can add it to the context and suggest improvements.
      • You can switch between different AI models, such as Claude or Gemini, depending on your coding needs. Each model has strengths in areas like code generation or identifying code smells.
      • If the model generates incorrect suggestions, you can refine your query or switch models to get a better response. Always test and review changes before fully integrating them into your codebase.

      Useful videos:








       
       

    Monday, February 26, 2024

    Burnout or toxic culture ?

    Outsourcing companies are hell to be in for an experienced programmer, because managers are being allowed to mistakes, which are covered, thus putting the rest of the workers in not favourable position.

    So it is very important to keep track of your health and please do not try to compensate the toxic workplace effect with: letting it out to other people, overeating not sleeping etc.

    Restorative is : running, and weight lifting.

    From the herbs I recommend: thyme, glog and passiflora tea to help with the sleep as well as taking ashwagandga.

    Take your time and enjoy!

    Thursday, April 21, 2022

    Simple Laravel REST API


    1) Create the user model in models/UserModel.php 

    php artisan make:model User

    <?php

    namespace App\Models;

    use Illuminate\Database\Eloquent\Factories\HasFactory;
    use Illuminate\Foundation\Auth\User as Authenticatable;
    use Illuminate\Notifications\Notifiable;
    use Laravel\Sanctum\HasApiTokens;

    class User extends Authenticatable
    {
    use HasApiTokens, HasFactory, Notifiable;

    /**
    * The attributes that are mass assignable.
    *
    * @var array<int, string>
    */
    protected $fillable = [
    'name',
    'email',
    'password',
    ];

    /**
    * The attributes that should be hidden for serialization.
    *
    * @var array<int, string>
    */
    protected $hidden = [
    'password',
    'remember_token',
    ];

    /**
    * The attributes that should be cast.
    *
    * @var array<string, string>
    */
    protected $casts = [
    'email_verified_at' => 'datetime',
    ];
    }

     

    2) 

    create validation for the update requests:  php artisan make:request UserUpdateRequest

    <?php

    namespace App\Http\Requests;

    use Illuminate\Foundation\Http\FormRequest;

    class UserUpdateRequest extends FormRequest
    {
    /**
    * Determine if the user is authorized to make this request.
    *
    * @return bool
    */
    public function authorize()
    {
    return true;
    }

    /**
    * Get the validation rules that apply to the request.
    *
    * @return array
    */
    public function rules()
    {
    return [
    'name'=>'required',
    'email'=>'required|email',
    // 'password'=>''
    ];
    }
    }


     and for the post request:

    php artisan make:request UserPostRequest

    <?php

    namespace App\Http\Requests;

    use Illuminate\Foundation\Http\FormRequest;

    class UserPostRequest extends FormRequest
    {
    /**
    * Determine if the user is authorized to make this request.
    *
    * @return bool
    */
    public function authorize()
    {
    return true;
    }

    /**
    * Get the validation rules that apply to the request.
    *
    * @return array
    */
    public function rules()
    {
    return [
    'name'=>'required',
    'email'=>'required|email',
    'password'=>'required'
    ];
    }
    }


     

     

    create user controller based on the user model: php artisan make:controller UserController --model=User --resource

    <?php

    namespace App\Http\Controllers;

    use App\Http\Controllers\Controller;
    use App\Http\Requests\UserPostRequest;
    use App\Http\Requests\UserUpdateRequest;
    use App\Http\Resources\UserCollection;
    use App\Http\Resources\UserResource;
    use App\Models\User;
    use Illuminate\Support\Facades\Hash;

    class UserController extends Controller
    {
    public function index()
    {
    return new UserCollection(User::paginate(5));
    }

    public function store(UserPostRequest $request)
    {
    $userData = $request->validated();
    $userData['password'] = Hash::make($userData['password']);
    $userData['email_verified_at'] = now();

    $user = User::forceCreate($userData);
    return new UserResource($user);
    }

    public function show(User $user) //route model binding
    {
    return new UserResource($user);
    }

    public function update(User $user, UserUpdateRequest $request)
    {
    $user->update($request->validated());
    }

    public function destroy(User $user)
    {
    $user->delete();
    return response()->noContent();
    }
    }



    3) create resources/UserCollection:  php artisan make:resource UserCollection

    to return user collection and user resource, when required by the user controller.

    <?php

    namespace App\Http\Resources;

    use Illuminate\Http\Resources\Json\ResourceCollection;

    class UserCollection extends ResourceCollection
    {
    /**
    * Transform the resource collection into an array.
    *
    * @param \Illuminate\Http\Request $request
    * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
    */

    public function toArray($request)
    {
    return
    [
    'data'=>$this->collection,
    'total_count'=> $this->total()
    ];
    }
    }

     

    create UserResource: //expose which fields to be returned in the json response.

    <?php

    namespace App\Http\Resources;

    use Illuminate\Http\Resources\Json\JsonResource;

    class UserResource extends JsonResource
    {
    /**
    * Transform the resource into an array.
    *
    * @param \Illuminate\Http\Request $request
    * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
    */
    public function toArray($request)
    {
    return [
    'id' => $this->id,
    'name' => $this->name,
    'email' => $this->email,
    ];
    }
    }

     

    4) enable the requests to be performed, and add validation rules when posting and updating information, inside Requests/UserPostRequest.php

    php artisan make:request UserPostRequest

    <?php

    namespace App\Http\Requests;

    use Illuminate\Foundation\Http\FormRequest;

    class UserPostRequest extends FormRequest
    {
    /**
    * Determine if the user is authorized to make this request.
    *
    * @return bool
    */
    public function authorize()
    {
    return true;
    }

    /**
    * Get the validation rules that apply to the request.
    *
    * @return array
    */
    public function rules()
    {
    return [
    'name'=>'required',
    'email'=>'required|email',
    'password'=>'required'
    ];
    }
    }

    for updating info:

    <?php

    namespace App\Http\Requests;

    use Illuminate\Foundation\Http\FormRequest;

    class UserUpdateRequest extends FormRequest
    {
    /**
    * Determine if the user is authorized to make this request.
    *
    * @return bool
    */
    public function authorize()
    {
    return true;
    }

    /**
    * Get the validation rules that apply to the request.
    *
    * @return array
    */
    public function rules()
    {
    return [
    'name'=>'required',
    'email'=>'required|email',
    ];
    }
    }

     

    6) add routes/api.php in order to redirect /users to the index() method of the UserController.
    <?php

    use Illuminate\Http\Request;
    use Illuminate\Support\Facades\Route;

    use App\Http\Resources\UserCollection;
    use App\Models\User;
    use App\Http\Controllers\UserController;

    Route::apiResource('users', UserController::class);

    Cheers!

    Wednesday, April 20, 2022

    WSL2 - how to make it accessible through outher machines

    1) enable wildcard listening address of the app like 0.0.0.0

    ss -anpst will show you the on which address/port the app is listening to.

    2) use powershell to setup portproxy to forward all the outside requests to the windows machine to land in the WSL2 system:

    netsh interface portproxy add v4tov4 listenport=3000 listenaddress=0.0.0.0 connectport=3000 connectaddress=localhost

    listenport and listenaddress are on the Windows side.

    connectport and connectaddress are on the WSL2 side.

    (for a node app the listening port (connectport) is usually 3000, check you app listening port in 1)

    verify with:  netsh interface portproxy show all

    3) open port 3000 on the firewall with:

    netsh advfirewall firewall add rule name="WSL2 app" dir=in action=allow protocol=TCP localport=3000

    verify from the windows defender firewall, advanced settings, inbound rules.

    Cheers !

    Subscribe To My Channel for updates

    Things to do after install Fedora 43

    #!/bin/bash # 1. SETUP REPOSITORIES echo ">>> Setting up Repositories (RPM Fusion, Copr, Cisco)..." # Install RPM Fusion ...