Monday, August 18, 2025

Wednesday, July 2, 2025

SQL to delete all WooCommerce products except those with "draft" status

 -- Disable foreign key checks (important for InnoDB)

SET

    FOREIGN_KEY_CHECKS = 0;

    -- Delete product meta

DELETE

    pm

FROM

    wp_postmeta pm

JOIN wp_posts p ON

    pm.post_id = p.ID

WHERE

    p.post_type = 'product' AND p.post_status != 'draft';

    -- Delete term relationships

DELETE

    tr

FROM

    wp_term_relationships tr

JOIN wp_posts p ON

    tr.object_id = p.ID

WHERE

    p.post_type = 'product' AND p.post_status != 'draft';

    -- Delete the products

DELETE

FROM

    wp_posts

WHERE

    post_type = 'product' AND post_status != 'draft';

    -- Enable foreign key checks again

SET

    FOREIGN_KEY_CHECKS = 1;

Thursday, June 26, 2025

Restrict Access to PHPMyAdmin with DirectAdmin

cd /usr/local/directadmin/
./directadmin set one_click_pma_login 1 restart
cd custombuild
./build update
./build set phpmyadmin_public no
./build phpmyadmin

Wednesday, June 18, 2025

How not to fill filtered out cells when dragging down from another sheet

Steps:

  1. Apply your filter in Sheet1.

  2. Select the range where you want to paste the formula (e.g., A2:A100) but only visible cells will be selected.

    • Select the range.

    • Press F5 or Ctrl+G → Click Special… → Choose Visible cells only → OK.

  3. Type your formula (e.g.):

    =INDEX(Sheet2!A:A, ROW()-1)
  4. Press Ctrl+Enter (instead of just Enter).

Saturday, May 3, 2025

Resetting the DirectAdmin Password via SSH:

 Resetting the Password via SSH:

  1. Access the server as root: Use an SSH program like PuTTY to connect to your server as the root user. 
  2. Reset the password: Execute the command passwd <username> (replace <username> with your DirectAdmin username, often admin or your server username). 
  3. Follow the prompts: You'll be prompted to enter a new password twice. 
  4. Verify the change: Once successful, you'll see a message confirming the password change. 
  5. Restart DirectAdmin (optional): You may need to restart the DirectAdmin service using the command service directadmin restart. 

Sunday, April 20, 2025

Reset WordPress Admin Password via MySQL Command Line


mysql -umyUserName -paVeryStrongPassword

show databases;
 
use myWordpressDB;

SELECT ID, user_login, user_pass FROM wp_users;

UPDATE wp_users SET user_pass=MD5('YourNewStrongPassword') WHERE ID = 1;

SELECT ID, user_login, user_pass FROM wp_users;

Wednesday, March 19, 2025

Excel VBA Macro: Save Range (as PDF) and Send as Attachment in Email

Sub save_pdf_and_attach_in_email()


Dim OutApp As Object

Dim OutMail As Object

Dim ws As Worksheet

Dim pdf_range As Range

Dim pdf_path As String


Set OutApp = CreateObject("Outlook.Application")

Set OutMail = OutApp.CreateItem(0)


Set ws = ThisWorkbook.Sheets("Sheet 1")

Set pdf_range = ws.Range("A1:C11")


pdf_path = "C:\Users\greggowaffles\Documents\Youtube Videos\Test\Stats\" & _

    "Population Data.pdf"

    

'align range in pdf

ws.PageSetup.CenterHorizontally = True

    

pdf_range.ExportAsFixedFormat Type:=xlTypePDF, _

    Filename:=pdf_path, OpenAfterPublish:=False


'create email

On Error Resume Next

    With OutMail

        .to = "team@abc.com"

        .CC = ""

        .BCC = ""

        .Subject = "Country Population Data " & Format(Date, "mm-dd-yyyy")

        .Display

        .HTMLBody = "<BODY style = 'font-size:12pt; font-family:Calibri'>" & _

            "Hi Team,<p>Please see attached pdf file.<p>Thanks,<br>Greg" & .HTMLBody

        

        .Attachments.Add pdf_path

    

    End With

    On Error GoTo 0


Set OutApp = Nothing

Set OutMail = Nothing


'Kill pdf_path


End Sub

Monday, February 24, 2025

How to inatall docker on Ubuntu using apt repository

 # Add Docker's official GPG key:

sudo apt-get update

sudo apt-get install ca-certificates curl

sudo install -m 0755 -d /etc/apt/keyrings

sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc

sudo chmod a+r /etc/apt/keyrings/docker.asc


# Add the repository to Apt sources:

echo \

  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \

  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \

  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

Install Latest version:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin


sudo docker run hello-world

Thursday, February 20, 2025

Reset Ubuntu with factory reset & and reinstall

Try configuring unconfigured packages:

sudo dpkg --configure -a

Update the contents of the repositories

sudo apt-get update

Try to fix missing dependencies:

sudo apt-get -f install

Update all packages with new versions available:

sudo apt-get full-upgrade

Reinstall Ubuntu desktop:

sudo apt-get install --reinstall ubuntu-desktop

Remove unnecessary packages:

sudo apt-get autoremove

Delete downloaded packages already installed:

sudo apt-get clean

Reboot the system to see if the issue was resolved:

sudo reboot

 

How to create a user in ubuntu with password giving all permissions ?

 o create a new user in Ubuntu with a password and grant them all permissions (including administrative privileges), follow these steps:

1. Create a New User

Run the following command, replacing username with your desired username:


sudo adduser username
  • You will be prompted to enter a password and some optional details.

2. Add User to the Sudo Group

To grant full administrative permissions, add the user to the sudo group:


sudo usermod -aG sudo username
  • This allows the user to execute commands as root using sudo.

3. Verify the User’s Permissions

Switch to the new user:


su - username

Then check if the user can run sudo commands:


sudo whoami

If it returns root, the user has full administrative access.

4. (Optional) Grant Passwordless Sudo Access

If you want the user to execute sudo commands without entering a password:


echo "username ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/username

Now the user has full administrative privileges. 

Thursday, February 13, 2025

How to install Install and Configure Alfresco Community Edition

System requirements:

Based on these assumptions, the following options are recommended:
  1. 2 servers with the following specifications:
    • 4 CPUs
    • 32 GB RAM per server
    • Tomcat Java options:
      • Xms512M
      • Xmx 20 G
      • XX:MaxPermSize=256m
      • XX:-DisableExplicitGC
    • web.xml
      • maxThreads=2 50
    • 30 GB HDD space
    • Servers must be load-balanced the load-balancer must have:
      • Session affinity: enabled
      • Web server probe: recommended
  2. 4 servers with the following specifications
    • 4 CPUs
    • 16 GB RAM per server
    • Tomcat Java Options:
      • Xms512M
      • Xmx1 0 G
      • XX:MaxPermSize=256m
      • XX:-DisableExplicitGC
    • web.xml
      • maxThreads= 125
    • 30 GB HDD space
    • Servers must be load-balanced the load-balancer must have:
      • Session affinity: enabled
      • Web server probe : recommended
We can follow the following instructions:
Part 01 : https://medium.com/p/6ddd06416711

Part 03 : https://medium.com/p/bcde44232f59

Friday, January 10, 2025

Command to install direct admin on ubuntu 22.04

 sudo apt update

sudo apt upgrade

sudo apt install wget gcc g++ make flex bison openssl libssl-dev

cd /usr/local/src

wget https://www.directadmin.com/setup.sh

chmod +x setup.sh

sudo ./setup.sh

sudo ufw enable

sudo ufw allow 2222

sudo ufw allow 80

https://YOUR_SERVER_IP:2222


Also you can follow the official guidelines here: https://docs.directadmin.com/getting-started/installation/installguide.html

Friday, December 20, 2024

How to get Ranking of the Students in Excel using RANK Function


=RANK(number,ref,[order])

To rank in descending order, we will use the formula =RANK(B2,($C$5:$C$10),0)

If we want unique ranks, we can use the formula:

=RANK(C5,$C$5:C$10,0)+COUNTIF($C$5:C5,C5)-1

For ascending order, the formula would be:

=RANK.EQ(C5,$C$5:C$10,1)+COUNTIF($C$5:C5,C5)-1

Friday, December 13, 2024

Prevent duplicate entry in excel.

On the Settings tab, choose "Custom" from the Allow drop down list and enter =COUNTIF($D:$D,D2)=1 into the Formula box

Tuesday, November 26, 2024

Sunday, October 20, 2024

Office 2021 Activation using command

 @echo off

title Activate Microsoft Office 2021 (ALL versions) for FREE - office.com&cls&echo =====================================================================================&echo #Project: Activating Microsoft software products for FREE without additional software&echo =====================================================================================&echo.&echo #Supported products:&echo - Microsoft Office Standard 2021&echo - Microsoft Office Professional Plus 2021&echo.&echo.&(if exist "%ProgramFiles%\Microsoft Office\Office16\ospp.vbs" cd /d "%ProgramFiles%\Microsoft Office\Office16")&(if exist "%ProgramFiles(x86)%\Microsoft Office\Office16\ospp.vbs" cd /d "%ProgramFiles(x86)%\Microsoft Office\Office16")&(for /f %%x in ('dir /b ..\root\Licenses16\ProPlus2021VL_KMS*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%%x" >nul)&echo.&echo =====================================================================================&echo Activating your product...&cscript //nologo slmgr.vbs /ckms >nul&cscript //nologo ospp.vbs /setprt:1688 >nul&cscript //nologo ospp.vbs /unpkey:6F7TH >nul&set i=1&cscript //nologo ospp.vbs /inpkey:FXYTK-NJJ8C-GB6DW-3DYQT-6F7TH >nul||goto notsupported
:skms
if %i% GTR 10 goto busy
if %i% EQU 1 set KMS=kms7.office.com
if %i% EQU 2 set KMS=e8.us.to
if %i% EQU 3 set KMS=e9.us.to
if %i% GTR 3 goto ato
cscript //nologo ospp.vbs /sethst:%KMS% >nul
:ato
echo =====================================================================================&echo.&echo.&cscript //nologo ospp.vbs /act | find /i "successful" && (echo.&echo =====================================================================================&echo.&echo #Please consider supporting this project: donate to my paypal "devomman@gmail" &echo #Your support is helping me keep my servers running 24/7!&echo.&echo =====================================================================================&choice /n /c YN /m "Would you like to visit my blog [Y,N]?" & if errorlevel 2 exit) || (echo The connection to my KMS server failed! Trying to connect to another one... & echo Please wait... & echo. & echo. & set /a i+=1 & goto skms)
explorer "https://www.office.com/"&goto halt
:notsupported
echo =====================================================================================&echo.&echo Sorry, your version is not supported.&echo.&goto halt
:busy
echo =====================================================================================&echo.&echo Sorry, the server is busy and can't respond to your request. Please try again.&echo.
:halt
pause >nul

Friday, October 11, 2024

Create an admin account in WordPress via MySQL

INSERT INTO `wp_users`(

    `user_login`,

    `user_pass`,

    `user_nicename`,

    `user_email`,

    `user_status`

)

VALUES(

    'admin999',

    MD5('password999'),

    'firstname lastname',

    'email@example.com',

    '0'

);

INSERT INTO `wp_usermeta`(

    `umeta_id`,

    `user_id`,

    `meta_key`,

    `meta_value`

)

VALUES(

    NULL,

    (

SELECT

    MAX(id)

FROM

    wp_users

),

'wp_capabilities',

'a:1:{s:13:"administrator";s:1:"1";}'

);

INSERT INTO `wp_usermeta`(

    `umeta_id`,

    `user_id`,

    `meta_key`,

    `meta_value`

)

VALUES(

    NULL,

    (

SELECT

    MAX(id)

FROM

    wp_users

),

'wp_user_level',

'10'

);

Wednesday, October 2, 2024

Contatenate text to Date to Sort

Convert 01.01.2024  to 01/01/2024 to count as date in Excel.


 =DATE(RIGHT(A2,4),MID(A2,FIND(".",A2,1)+1,FIND(".",A2,FIND(".",A2,1)+1)-FIND(".",A2,1)-1),MID(A2,1,FIND(".",A2,1)))

Monday, September 30, 2024

How to install Plesk on Ubuntu 22.00 using a single command

 # sh <(curl https://autoinstall.plesk.com/one-click-installer || wget -O - https://autoinstall.plesk.com/one-click-installer)

Monday, September 16, 2024

Toshiba e studio 2829a print using lan cable without router

 To set up a Toshiba e-STUDIO 2829A printer to print using a LAN cable without a router, you'll need to directly connect the printer to your computer with an Ethernet cable and configure both devices to communicate with each other. Here's how you can do it:

  1. Connect the Printer to the Computer:

    • Plug one end of the Ethernet cable into the LAN port of the Toshiba e-STUDIO 2829A.
    • Plug the other end of the Ethernet cable into the Ethernet port of your computer.
  2. Set Static IP Addresses:

    • Since there is no router to assign IP addresses dynamically, you need to set static IP addresses for both the printer and the computer.
  3. Configure the Printer’s IP Address:

    • Access the printer’s control panel.
    • Navigate to the network settings (this can usually be found under Admin or System settings).
    • Set a static IP address for the printer. For example, you might use 192.168.0.10.
    • Ensure the subnet mask is set to 255.255.255.0.
    • Save the settings.
  4. Configure the Computer’s IP Address:

    • On your computer, go to the network settings.
      • Windows:
        1. Open Control Panel.
        2. Go to Network and Sharing Center.
        3. Click on Change adapter settings.
        4. Right-click on the Ethernet adapter connected to the printer and select Properties.
        5. Select Internet Protocol Version 4 (TCP/IPv4) and click Properties.
        6. Choose "Use the following IP address" and set the IP address to 192.168.0.20 (it should be different from the printer’s IP).
        7. Set the subnet mask to 255.255.255.0.
        8. Leave the Default Gateway and DNS fields blank.
        9. Click OK to save the settings.
      • Mac:
        1. Open System Preferences.
        2. Go to Network.
        3. Select Ethernet and click on Advanced.
        4. Go to the TCP/IP tab.
        5. Set Configure IPv4 to Manually.
        6. Enter 192.168.0.20 for the IP address and 255.255.255.0 for the subnet mask.
        7. Leave the Router field blank.
        8. Click OK and Apply to save the settings.
  5. Add the Printer on the Computer:

    • Now, you need to add the printer on your computer.
      • Windows:
        1. Go to Control Panel.
        2. Select Devices and Printers.
        3. Click on Add a printer.
        4. Choose "Add a local printer or network printer with manual settings".
        5. Select "Create a new port" and choose Standard TCP/IP Port.
        6. Enter the printer’s IP address (192.168.0.10).
        7. Follow the prompts to install the printer driver (you may need the printer driver software from Toshiba's website).
      • Mac:
        1. Open System Preferences.
        2. Go to Printers & Scanners.
        3. Click the plus (+) button to add a printer.
        4. Select the IP tab.
        5. Enter the printer’s IP address (192.168.0.10).
        6. Choose the appropriate protocol (typically HP Jetdirect - Socket).
        7. Enter a name for the printer and select the appropriate driver.
        8. Click Add.

After completing these steps, your Toshiba e-STUDIO 2829A printer should be set up to print using a LAN cable directly connected to your computer without a router

Replace old IP with New one in Direct Admin

./ipswap.sh Old_IP  New_IP for example:  ./ipswap.sh 35.224.2.88 104.197.113.37