Apache mod_rewrite on OpenSuse

sudo vim /etc/apache2/default-server.conf
<Directory "/srv/www/htdocs">
    Options Indexes FollowSymLinks MultiViews
    Require all granted
    AllowOverride All
</Directory>

Delete all unwanted from <Directory “/srv/www/htdocs”> </Directory>

sudo systemctl restart apache2.service

How to Install Dash to Dock gnome Extension

This post helps you install gnome dash_to_dock extension that lets you position gnome dock on top, right, bottom and left of your screen and also keeps it visible all the time.

Install gnome-extension first

First you must install gnome-extension if you already don’t have it.

Launch your preferred terminal and run the following command with your linux distro installer command.

sudo apt install gnome-extensions
sudo zypper install gnome-extensions

Launch gnome-extensions

open url in firefox and look for dash to dock

install it, enable and customize it

Customize Gnome Dock

To customize gnome dock, you must install dash to dock gnome extension first and then install dash to dock

Start Mariadb Server on OpenSuse w/ root

This post will guide you through the process of enabling and starting mariadb server on opensuse tumbleween and leap and setting up password for the existing root password.

Check the status of your mariadb no your opensuse

systemctl status mariadb.service

start mariadb.service

systemctl enable mariadb.service
systemctl start mariadb.service
systemctl status mariadb.service

Login to mariadb with sudo

Login into mariadb with sudo to alter password for the root user

Update mariadb root password

ALTER USER root@localhost BY 'password';

exit;

exit of mariadb to try new password for root user on mariadb on OpenSuse Tumbleweed and Leaps

Login with updated password to mariadb

To login into mariadb with updated password for root user, try the following command

mariadb -u root -p

when promoted to enter password, enter your newly updated password and you should be in mariadb.

List of Sorting Algorithms w/ Code Examples in Python and Ruby

There are numerous sorting algorithms, each with its own characteristics and advantages depending on the specific requirements and constraints of a given problem. Here is a list of some common sorting algorithms:

  1. Bubble Sort: Compares adjacent elements and swaps them if they are in the wrong order. Repeats this process until no swaps are needed.
  2. Selection Sort: Divides the input list into a sorted and an unsorted region. It repeatedly selects the minimum element from the unsorted region and moves it to the sorted region.
  3. Insertion Sort: Builds the final sorted array one item at a time by repeatedly taking an element from the unsorted part and inserting it into its correct position in the sorted part.
  4. Merge Sort: Divides the input list into two halves, sorts each half, and then merges the two sorted halves into a single sorted list.
  5. Quick Sort: Chooses a pivot element and partitions the array into two sub-arrays: elements less than the pivot and elements greater than the pivot. It then recursively sorts the sub-arrays.
  6. Heap Sort: Builds a binary heap from the input data and repeatedly removes the maximum element from the heap and adds it to the sorted list.
  7. Counting Sort: Suitable for sorting integers within a known range. It counts the occurrences of each element and uses that information to place elements in the correct order.
  8. Radix Sort: Sorts integers by processing individual digits from the least significant to the most significant. It can be used for integers represented in base 10 or other bases.
  9. Bucket Sort: Distributes elements into a finite number of buckets and then sorts each bucket individually, either using a different sorting algorithm or by recursively applying bucket sort.
  10. Tim Sort: A hybrid sorting algorithm derived from merge sort and insertion sort. It is designed to perform well on many kinds of real-world data.
  11. Shell Sort: An extension of insertion sort that divides the input into smaller sub-arrays and sorts each sub-array using insertion sort.
  12. Cocktail Shaker Sort: Similar to bubble sort but sorts in both directions, moving the largest and smallest elements to their correct positions.
  13. Bogo Sort: A highly inefficient and random sorting algorithm that generates random permutations of the input until it happens to be sorted.
  14. Pancake Sort: A sorting algorithm that only allows flipping sections of the array in order to sort it.
  15. Cycle Sort: A sorting algorithm that minimizes the number of writes to the data store and is useful for sorting data with expensive write operations.
  16. Stooge Sort: A recursive sorting algorithm that sorts a list by recursively sorting the first two-thirds and the last two-thirds of the list and then sorting the first two-thirds again.

These are just some of the many sorting algorithms available. The choice of which algorithm to use depends on factors such as the size of the data, the distribution of values, memory constraints, and the desired time complexity.

Sorting Algorithms Code Example in Python

Certainly! Here are Python 3 implementations of various sorting algorithms:

  1. Bubble Sort:
def bubble_sort(arr):
    n = len(arr)
    for i in range(n):
        swapped = False
        for j in range(0, n - i - 1):
            if arr[j] > arr[j + 1]:
                arr[j], arr[j + 1] = arr[j + 1], arr[j]  # Swap elements
                swapped = True
        if not swapped:
            break
    return arr
  1. Selection Sort:
def selection_sort(arr):
    n = len(arr)
    for i in range(n):
        min_index = i
        for j in range(i + 1, n):
            if arr[j] < arr[min_index]:
                min_index = j
        arr[i], arr[min_index] = arr[min_index], arr[i]  # Swap elements
    return arr
  1. Insertion Sort:
def insertion_sort(arr):
    n = len(arr)
    for i in range(1, n):
        key = arr[i]
        j = i - 1
        while j >= 0 and arr[j] > key:
            arr[j + 1] = arr[j]
            j -= 1
        arr[j + 1] = key
    return arr
  1. Merge Sort:
def merge_sort(arr):
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    left_half = arr[:mid]
    right_half = arr[mid:]

    left_half = merge_sort(left_half)
    right_half = merge_sort(right_half)

    return merge(left_half, right_half)

def merge(left, right):
    result = []
    i = j = 0

    while i < len(left) and j < len(right):
        if left[i] < right[j]:
            result.append(left[i])
            i += 1
        else:
            result.append(right[j])
            j += 1

    result.extend(left[i:])
    result.extend(right[j:])
    return result
  1. Quick Sort:
def quick_sort(arr):
    if len(arr) <= 1:
        return arr

    pivot = arr[len(arr) // 2]
    left = [x for x in arr if x < pivot]
    middle = [x for x in arr if x == pivot]
    right = [x for x in arr if x > pivot]

    return quick_sort(left) + middle + quick_sort(right)

You can use these functions to sort lists of elements by passing the list as an argument to the respective sorting function.

Sorting Algorithms Code Example in Ruby

Implementing sorting algorithms in Ruby can be a great way to learn and practice algorithmic concepts. Here, I’ll provide a basic outline for implementing some common sorting algorithms in Ruby. You can use these outlines as a starting point and then write the actual Ruby code for each algorithm based on these descriptions.

  1. Bubble Sort:
   def bubble_sort(arr)
     n = arr.length
     loop do
       swapped = false
       (n - 1).times do |i|
         if arr[i] > arr[i + 1]
           arr[i], arr[i + 1] = arr[i + 1], arr[i] # Swap elements
           swapped = true
         end
       end
       break unless swapped
     end
     arr
   end
  1. Selection Sort:
   def selection_sort(arr)
     n = arr.length
     (n - 1).times do |i|
       min_index = i
       (i + 1...n).each do |j|
         min_index = j if arr[j] < arr[min_index]
       end
       arr[i], arr[min_index] = arr[min_index], arr[i] # Swap elements
     end
     arr
   end
  1. Insertion Sort:
   def insertion_sort(arr)
     n = arr.length
     (1...n).each do |i|
       key = arr[i]
       j = i - 1
       while j >= 0 && arr[j] > key
         arr[j + 1] = arr[j]
         j -= 1
       end
       arr[j + 1] = key
     end
     arr
   end
  1. Merge Sort:
   def merge_sort(arr)
     return arr if arr.length <= 1

     mid = arr.length / 2
     left_half = merge_sort(arr[0...mid])
     right_half = merge_sort(arr[mid..-1])

     merge(left_half, right_half)
   end

   def merge(left, right)
     result = []
     until left.empty? || right.empty?
       result << (left.first <= right.first ? left.shift : right.shift)
     end
     result.concat(left).concat(right)
   end
  1. Quick Sort:
   def quick_sort(arr)
     return arr if arr.length <= 1

     pivot = arr.pop
     left, right = arr.partition { |x| x < pivot }

     quick_sort(left) + [pivot] + quick_sort(right)
   end

You can test these sorting algorithms with sample input arrays to verify their correctness and efficiency. These implementations are basic and may not handle all edge cases or optimizations that you might find in production-ready libraries, but they serve as a good starting point for understanding how these algorithms work in practice.

How to Install Nerdtree on vim with nerdtreetoggle

In Vim, NERDTree is a popular plugin that provides a file system explorer within the Vim interface, allowing you to navigate and manage files and directories directly from your text editor. The NERDTreeToggle command is used to show or hide the NERDTree file explorer window. Here’s why you might want to use NERDTree along with NERDTreeToggle:

Install NERDTree first

Error detected while processing VimEnter Autocommands for “*”: E492: Not an editor command: NERDTree

Make sure you have installed NERDTree before you start setting up NERDTreeToggle on your VIM.

If you have vim version 8.* then you can use inbuilt package manager to install NERDTree on your vim.

sudo apt install git vim

Once you have git and vim on your system, you should clone NERDTRee on your system with git

Clone NEDTree with git

git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/nerdtree

Install NERDTree with VIM package manager

vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q

Update .vimrc for NERDTreeToggle

" NERDTree configuration
nnoremap <F2> :NERDTreeToggle<CR>

" Automatically open NERDTree when Vim starts (optional)
autocmd VimEnter * NERDTree

  1. Convenient File Navigation: NERDTree makes it easy to navigate through your project’s file structure without leaving the Vim environment. This can be especially helpful when you need to switch between different files or directories frequently.
  2. Visual Representation: NERDTree provides a visual representation of your project’s file structure in a sidebar, making it easier to locate and open files compared to using Vim’s built-in file navigation commands.
  3. File Operations: With NERDTree, you can perform various file operations (e.g., creating, deleting, moving, copying files) directly from the file explorer window, simplifying file management tasks.
  4. Project Management: NERDTree is useful for working on larger projects with multiple files and directories. You can quickly see the project’s structure and navigate to different parts of your project without relying solely on the command line.
  5. Customization: NERDTree is highly customizable. You can configure it to fit your workflow, define custom shortcuts, and adapt it to your specific needs.

Using NERDTreeToggle is a common way to toggle the visibility of the NERDTree file explorer, allowing you to hide it when you don’t need it and bring it back when you do. Here’s how you can set it up in your .vimrc:

" NERDTree configuration
nnoremap <F2> :NERDTreeToggle<CR>

" Automatically open NERDTree when Vim starts (optional)
autocmd VimEnter * NERDTree

In the example above, pressing <F2> in normal mode will toggle the NERDTree file explorer’s visibility. You can replace <F2> with any key combination you prefer.

The decision to use NERDTree and NERDTreeToggle depends on your workflow and preferences. Some Vim users prefer to work exclusively within Vim’s built-in file navigation commands, while others find NERDTree to be a valuable tool for managing files and directories within Vim. Experiment with it and see if it enhances your productivity and fits your editing style.

Why a Minimalist vimrc for VIM

A minimalist .vimrc file is a configuration file for the Vim text editor that contains only essential settings and customizations. The goal of a minimalist .vimrc file is to keep Vim simple and fast while still providing a personalized and efficient editing environment. Here are some reasons why someone might choose to have a minimalist .vimrc file:

  1. Performance: Vim is known for its speed and efficiency. By keeping your .vimrc file minimal, you ensure that Vim loads quickly and doesn’t consume unnecessary resources. This is especially important for users who work on remote servers or older computers.
  2. Simplicity: Vim’s default settings are quite powerful, and many users find that they don’t need to add a lot of customizations to be productive. A minimalist .vimrc file promotes simplicity and avoids clutter.
  3. Portability: If you frequently switch between different machines or accounts, having a minimalist .vimrc file makes it easier to maintain consistency in your Vim setup. You can quickly copy your minimal configuration to new environments without worrying about conflicts or dependencies.
  4. Focus on Essentials: By only including essential settings and key mappings in your .vimrc, you can focus on the features and customizations that truly improve your workflow. This can make you a more efficient and proficient Vim user.
  5. Learn Vim’s Default Behavior: Vim has a steep learning curve, and some users prefer to start with the default settings to fully understand Vim’s built-in features before adding customizations. A minimalist .vimrc file encourages this approach.
  6. Avoiding Bloat: Adding too many plugins and customizations can lead to a bloated .vimrc file and a more complex editing environment. Some users prefer to avoid this complexity and rely on Vim’s core functionality.
  7. Flexibility: A minimalist .vimrc file is a great starting point. Users can gradually add additional settings and plugins as they discover specific needs, ensuring that their Vim setup remains tailored to their workflow.

Here’s an example of what a minimalist .vimrc file might look like:

set autoindent             
set expandtab              
set softtabstop=2         
set shiftwidth=4         
set shiftround             
set backspace=indent,eol,start  
set hidden                 
set laststatus=2         
set display=lastline  
set showmode               
set showcmd                
set incsearch              
set hlsearch               
set ttyfast                
set lazyredraw             
set splitbelow             
set splitright             
set cursorline             
set wrapscan               
set report=0         
set synmaxcol=200       
set list 
set number    

This minimal configuration includes some fundamental settings for line numbering, syntax highlighting, indentation preferences, and line wrapping while avoiding more advanced customizations or plugin integrations. Users can then build upon this foundation as needed.

Ultimately, the choice of whether to have a minimalist .vimrc file or a more extensive one depends on your personal preferences, workflow, and the specific tasks you perform with Vim.

How to Install Chess Titans on Windows 10

Chess Titans was a popular chess game that was included with earlier versions of Windows, such as Windows 7. However, it is not available in Windows 10. Microsoft replaced Chess Titans with Microsoft Chess in Windows 10.

If you want to play chess on Windows 10, you can follow these steps to install and play Microsoft Chess:

  1. Open the Microsoft Store: Click on the Windows Start button and type “Microsoft Store” in the search bar. Click on the Microsoft Store app when it appears in the search results to open it.
  2. Search for “Chess Titans or Microsoft Chess”: In the Microsoft Store, use the search bar at the top right corner and type “Chess Titans or Microsoft Chess” or simply “Chess.” Press Enter or click on the search icon.
  3. Select and Install: Find the chess app you want to install (usually simply called “Chess”), and click on it to view its details. Click the “Install” button to download and install the app on your Windows 10 computer.
  4. Launch the Game: Once the installation is complete, you can launch the game from the Start menu. Type “Chess” in the Start menu search bar, and you should see the Chess app listed. Click on it to start playing.
  5. Play Chess: In the game, you can choose your level of difficulty, play against the computer, or even play against another player if you’re using a Windows 10 device with multiple user accounts.

Please note that while Chess Titans had its unique charm, Microsoft Chess offers a similar chess-playing experience on Windows 10. Enjoy your games!

Install Create Drupal Project on Ubuntu

Install git-hub and set it up

sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev

Setup githug

git config --global color.ui true
git config --global user.name "YOUR NAME"
git config --global user.email "[email protected]"
ssh-keygen -t ed25519 -C "[email protected]"
cat ~/.ssh/id_ed25519.pub
https://github.com/settings/ssh
ssh -T [email protected]

Install Latest Versoin of php & unzip

sudo apt update
sudo apt install php-cli php-common php-mysql unzip

Install Composer

cd ~
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
HASH=curl -sS https://composer.github.io/installer.sig
php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer

composer should run on your terminal now.

Enable php extensions for drupal

sudo apt install php-opcache php-pdo php-calendar php-ctype php-exif php-ffi php-fileinfo php-ftp php-iconv php-phar php-posix php-readline php-shmop php-sockets php-sysvmsg php-sysvsem php-sysvshm php-tokenizer php-gd

Create drupal product with composer

composer create-project drupal/recommended-project app-name

Install Drush

composer require drush/drush

How to install php extensions for Drupal on Ubuntu

Make sure you have install php-cli php-common php-mysql, before enabling required php extensions for Drupal on Ubuntu, Debian or Mint.

You don’t need add version of PHP in fron of all the extensions unless you have multiple versions of php installed on your system.

Just run the following commond, you can add all that I am missing here on the list.

sudo apt install php-opcache php-pdo php-calendar php-ctype php-exif php-ffi php-fileinfo php-ftp php-iconv php-phar php-posix php-readline php-shmop php-sockets php-sysvmsg php-sysvsem php-sysvshm php-tokenizer php-gd

Change WordPress Admin Login Logo

Customizing the WordPress admin login page can serve several purposes and provide various benefits for website owners and administrators. Here are some reasons why you might want to customize the WordPress login page:

  1. Branding and Identity: Customizing the login page allows you to reinforce your brand’s identity. You can add your logo, brand colors, and other design elements to make the login page align with the rest of your website’s aesthetics.
  2. Professionalism: A customized login page can give your website a more professional appearance. It shows visitors that you pay attention to details and care about user experience.
  3. Security: Changing the default login page URL or customizing it can enhance security by making it harder for hackers to target your login page for brute force attacks. When you have a custom login URL, it’s less predictable and can help deter unauthorized access attempts.
  4. User Experience: Customizing the login page can improve the user experience for your website’s administrators and users. You can add helpful links, instructions, or even a login widget directly on the homepage to make it easier for users to access their accounts.
  5. Membership Sites: If you run a membership site or an e-commerce platform, a customized login page can help create a seamless and branded experience for your users when they log in or register.
  6. Personalization: You can personalize the login page with a welcome message or dynamically display information to logged-in users, such as their profile picture or recent activity.
  7. Marketing and Promotion: You can use the login page to promote products, services, or upcoming events by adding banners, call-to-action buttons, or newsletter sign-up forms.
  8. Redirection: Customizing the login page allows you to control where users are redirected after login. This can be useful for directing users to specific pages, dashboards, or custom welcome screens.
  9. Client Projects: If you’re a web developer or agency working on client projects, customizing the login page can be part of your service to give clients a unique website experience.
  10. Accessibility: By customizing the login page, you can ensure it complies with accessibility standards and is usable by individuals with disabilities.

To customize the WordPress login page, you can use various methods, including custom CSS, themes, plugins, and code modifications. It’s essential to balance customization with usability and security, ensuring that your changes do not interfere with the functionality of the login process or compromise website security.

Add the following code to your functions.php

Don’t forget to replace your logo URL

// change wordpress login logo

function tubemint_wplogo_replace() { 
?> 
<style type="text/css"> 
body.login div#login h1 a {
 background-image: url(https://tubemint.com/wp-content/uploads/2023/09/your-logo.png); 
} 
.login h1 a {
    background-size: 132px !important;
    height: 120px !important;
    width: 120px !important;
    border-radius: 10px;
-webkit-box-shadow: -1px -5px 19px -7px rgba(115,167,235,1);
-moz-box-shadow: -1px -5px 19px -7px rgba(115,167,235,1);
box-shadow: -1px -5px 19px -7px rgba(115,167,235,1);
}
</style>

 <?php 
} add_action( 'login_enqueue_scripts', 'tubemint_wplogo_replace' );