All posts by admin

How to Trim, Cut or Combine MP4 or MP3 Files Without Re-Encoding

Motivation:

  • You have MP4 files with unwanted portions. You want to trim these portions.
  • You want to cut a MP4 file into files with equivalent length for uploading to specific storage that limits length of an uploaded video.
  • You want to combine multiple MP4 files into single file for copying to specific storage in a single upload.
  • You want to trim start and end portion of MP3 file.

Trimming MP4 file:

  1. Download XMedia Recode.
  2. Unzip the downloaded package.
  3. Click on the XMedia Recode.exe file to open the application.
  4. Open a MP4 file.
  5. Under the Format tab set
    Profile = Custom
    Format = MP4
    File Extension = mp4
  6. Click the Video tab and set Mode = Copy on the middle panel.
  7. Click the Audio tab and set Mode = Copy on the middle panel.
  8. Click the Filters/Preview tab and set Start Time and to (End Time) value text boxes.
  9. Click the Add to queue button (with the + icon) on the tool bar.
  10. Click the Encode button on the tool bar.

Splitting MP4 file to multiple files with equivalent length:

    1. Download XMedia Recode.
    2. Unzip the downloaded package.
    3. Click on the XMedia Recode.exe file to open the application.
    4. Open a MP4 file.
    5. Under the Format tab set
      Profile = Custom
      Format = MP4
      File Extension = mp4
    6. Click the Video tab and set Mode = Copy on the middle panel.
    7. Click the Audio tab and set Mode = Copy on the middle panel.
    8. Click the Filters/Preview tab and specify appropriate time range for each file, for example from 00:00:00:0000 to 00:09:00:0000.
    9. Click the Add to queue button (with the + icon) on the tool bar.
    10. Click the Encode button.

    Repeat the procedure for the same file with different time ranges.

    For example use time range from 00:09:00:0000 to 00:18:00:0000 for creating the second file, then time range from 00:18:00:0000 to 00:27:00:0000 for creating the third file, etc.

    Combining multiple MP4 files into single MP4 file:

    1. Download ffmpeg.
    2. Unzip the downloaded package.
    3. Copy MP4 files to the bin folder.
    4. Create vidlist.txt with the content below in the bin folder.
    file 'Part 1.mp4'
    file 'Part 2.mp4'
    file 'Part 3.mp4'
    file 'Part 4.mp4'
    file 'Part 5.mp4'
    file 'Part 6.mp4'

    4. Open Command Prompt, navigate to the bin folder and execute the command below.

    ffmpeg -f concat -safe 0 -i vidlist.txt -c copy output.mp4

    Trimming start and end portion of MP3 file:

    1. Download ffmpeg.
    2. Unzip the downloaded package.
    3. Copy MP3 file to the bin folder.
    4. Execute the command below:
    ffmpeg -ss 671 -t 2169 -i 01.mp3 -c:a copy out_01.mp3
    # -s: start position (in seconds)
    # -t: end position (in seconds) 
    # -c:a copy: no reencoding.

     

     

    How to Put Your eBooks into Kindle or Apple Books or Google Play Books

    Motivation:

    You have an ebook with .epub or .mobi format in your MacBook or PC.
    You want to put it into your iPhone or iPAD so that you can read it on the go.

    Solution 1:

    1. Upload your ebook to iCloud Drive.
    2. Install Kindle or Apple Books or Google Play Books on your iPhone or iPAD.
    3. Login your Kindle or Apple or Google account.
    4. Open the Files app to go to iCloud Drive.
    5. Open the ebook.
    6. Tap the Share icon in the lower left hand corner.
    7. Select Kindle or Open in iBooks or Play Books.

    Solution for Google Play Books:

    1. Install Google Play Books on your iPhone or iPAD..
    2. Log in Google Play Book website using your Google account.
    3. Upload your ebook in EPUB format to Google Play Book website.
    4. Open Google Play Books on your iPhone or iPAD.

    How to Install a Clean Windows

    Motivation:

    Most of Windows machines are delivered with a limited Windows version and unnecessary preinstalled software.

    You want to format the hard drive and install a fresh Windows that can be booted from UEFI secure boot to improve machine performance and stability.

    Prerequisites:

    You need to have a 8Gb USB stick and an ISO file of Windows 10, version 21H2 or Windows 11, version 22H2 updated May 2023.

    Note: Use the command below to check the checksum of the ISO file and ensure its authenticity.

    certUtil -hashfile Win10_x64.iso SHA256
    certUtil -hashfile Win10_x64.iso SHA1

    Solution:

    Step 1: Backup your machine and create an USB recovery by entering “Create a recovery drive” text to the search box on the task bar and follow the instructions.

    Step 2: Create a bootable USB with Windows installation files.

    2.A. If you plan to install Windows 11 then you can use Windows 11 Installation Assistant to create a bootable USB (click Download Now link below Create Windows 11 Installation Media section).

    2.B. If you plan to install Windows 10 then you can use the commands below to create a bootable USB.

    • Right click Windows logo, click Command Prompt (Admin).
    • Enter diskpart.exe, press Enter.
      DISKPART> list disk
      DISKPART> select disk 1 -- the USB disk should be selected, the number may be different in your machine.
      DISKPART> clean
      DISKPART> create partition primary size=1024
      DISKPART> select partition 1
      DISKPART> active
      DISKPART> format quick fs=fat32
      DISKPART> assign
      DISKPART> create partition primary
      DISKPART> select partition 2
      DISKPART> format quick fs=ntfs
      DISKPART> assign
      DISKPART> exit
    • Double click on the Windows ISO file to create a virtual drive.
      xcopy f:\sources\boot.wim d:\sources\ /s /e
      
      where 
      f: the virtual drive and 
      d: the USB fat32 partition.
      We copy only the f:\sources\boot.wim file to d:\sources\.
      
      robocopy f:\ d:\ /IS /S /XD sources
      
      where 
      
      f: the virtual drive and 
      d: the USB fat32 partition.
      We copy everything from f:\ to d:\ except the sources folder.
      
      xcopy f:* e:\ /s /e 
      
      where 
      f: the virtual drive and 
      e: the USB ntfs partition.

    Step 3: Boot your laptop using the USB.

    1. Plug the USB to a machine.
    2. For a Dell laptop, power on the machine, press F12 until a one-time boot up menu appears. Select the option to boot the machine from the USB. (You may need to access BIOS to select the UEFI option for Boot Sequence, and select the AHCI option for SATA operation).
    3. For a Sony VAIO laptop, power off the machine, then press the Assist button to enter VAIOCare. Select the option to boot the machine from the USB. (You may need to access BIOS to enable the option to boot the machine from an USB).
    4. For a ThinkPad laptop, power on the machine, press F12 until a one-time boot up menu appears. Select the option to boot the machine from the USB. Alternatively go to Settings > Update & Security > Recovery, click the Restart now button under the Advanced setup section and follow the instructions to boot the machine from a USB.

    Step 4: Install Windows.

    1. If your laptop is NOT officially supported by Windows 11, then on the first screen asking you to choose the language of your install, press Shift + F10 or Fn + Shift + F10 to open Command Prompt. Then type regedit and press Enter. Then locate the HKEY_LOCAL_MACHINE\SYSTEM\Setup key. Then create a new LabConfig key. Then click on the LabConfig key, and create 3 DWORD (32-bit) Values named BypassTPMCheck, BypassSecureBootCheck and BypassRAMCheck and set each to 1. Then click View menu item, then click Refresh. Then close the regedit program and the Command Prompt, and continue the setup process.
    2. Follow the instructions to install Windows.
    3. Set Windows partition size to 123748Mb for DellXPS if you want to have a 120Gb C drive, or 614516Mb for DellPrecision if you want to have 600Gb C drive, or 819815Mb for ThinkPad if you want to have a 800Gb C drive.
    4. You can delete all the partitions, including MRP (Microsoft Reserved Partition – this is just a reserved partition for Windows later use if needed), ESP (EFI System Partition – this is where UEFI firmware files are stored to boot Windows), WINRETOOLS (Windows Recovery Environment (WinRE) Tools – this is where files for repairing or recovering Windows are stored), and PBR image (this is where original the manufacture Windows installation file  are stored) because you already created an USB recovery in the Step 1.

    Step 5: Allow  Windows to be configured without the Internet.

    1. Press Shift + F10 or Fn + Shift + F10 to open Command Prompt.
    2. Type oobe\bypassnro.
    3. Press Enter.
    4. Setup will reboot your computer and after reboot, you will get  I don’t have Internet option, and then Continue with limited setup option, to skip the Internet requirement.

    Step 6: Configure Windows.

    1. Change Computer Name, turn off System Restore, enable Remote Desktop,
    2. Change Time Zone.
    3. Add Wireless LAN Service feature for Windows Server 2019.
    4. For a Dell laptop, install Dell Wireless 1820A 1830 WiFi Driver. Set battery charge threshold value to 50% in BIOS.
    5. Turn on Network discovery and file sharing by clicking on Network icon on the left side of Explorer.
    6. Activate Windows. Use Software Licensing Management Tool if you get any issue when activating your Windows using default activation feature:
      slmgr /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
      slmgr /ato
      slmgr /xpr
    7. Disable Hibernation (powercfg.exe /h off).
    8. Configure Power options (Hard disk >> Turn of hard disk after: 0, Wireless Adapter Settings >> Power Saving Mode: Maximum Performance, Sleep >> Sleep after: 0).
    9. Uninstall unnecessary applications.
    10. Use the manage-bde -status command to show BitLocker status (There is a space between bde and status). Use the manage-bde -off C: command to turn off BitLocker for the C drive.
    11. Turn on Automatic Logon.
    12. For a Dell laptop, go to Dell Support, scroll down and enter your Dell laptop service tag, click Search button, click Drivers & Downloads tab, expand Find drivers section, install Dell Command Update, and use it to check and install necessary drivers.
    13. For Windows Server 2019, install Chipset Device, Graphics, Audio, Ethernet, Bluetooth, Memory Card Reader, Dynamic Platform and Thermal Framework driver.
    14. For a ThinkPad laptop, install Lenovo Vantage. Set battery charge threshold value to 40% using Lenovo Vantage.

    Step 7: Configure Windows for developer’s needs.

    1. Turn the following Windows features on: .NET 3.5, ASP.NET 4.8, Hyper-V, Internet Information Services, Telnet Client.
    2. Install Total Commander, Office 365 Offline, MS Project 2016, MS Visio 2016, MS SQL Server 2016, Visual Studio 2022, Adobe Acrobat Pro DC v15.8, Adobe Photoshop CC 2015, TortoiseSVN 1.14.6
    3. Install Remote Desktop Connection Manager, PuTTY 0.80, WinSCP 6.3.
    4. Create a VPN connection. Configure the VPN connnection.
    5. Prevent normal traffic from going through VPN: Go to Control Panel >> Network and Sharing Center >> Change adapter settings >> Right click VPN Connection >> Properties >> Select the Networking tab:
      – Disable Internet Protocol Version 6 (TCP/IPv6).
      – Select Internet Protocol Version 4 (TCP/IPv4) >> Properties >> Advanced >> IP Settings: Uncheck the Use default gateway on remote network option.
    6. Install Python 3.6.8, TensorFlow, Keras
      1. Install Firefox, MPC-HC.1.7.13. (Go to View >> Options >> Player and turn off all options under the History section. Go to View >> Options >> Playback and disable the Auto-zoom feature.)
      2. Configure secure protocols using IIS Crypto GUI (Select Best Practices, disable TLS 1.0, TLS 1.1, MD5, SHA).
      3. Install Hyper-V, create an external Virtual Switch for Internet access, set Scheduler Type to Core.
      4. Apply Windows updates to the machine.

      Information:

      The bypassnro.cmd which is in \Windows\System32\oobe folder, is a script which contains:

      @echo off
      reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OOBE /v BypassNRO /t REG_DWORD /d 1 /f
      shutdown /r /t 0

       

      How to Fully Uninstall Cocoapods from macOS

      Problem:

      You run pod update but you get command not found error.

      You want to fully uninstall the Cocoapods from macOS, and then to reinstall it to remove the error.

      Solution:

      Execute below commands:

      for i in $( gem list --local --no-version | grep cocoapods );
      do 
          sudo gem uninstall $i; 
      done
      rm -rf ~/.cocoapods

      If you have a Cocoapods icon on the Launchpad then

        • Click on the  Cocoapods icon on the Launchpad,
        • Right click the Cocoapods icon in the Dock,
        • Point your mouse to Options, then click Show in Finder,
        • Right click the Cocoapods icon and select Move to Trash.

      Execute below command to reinstall Cocoapods

      sudo gem install cocoapods

       

      How to fix “An internal error has occurred” issue of Remote Desktop Connection

      Problem:

      You get “An internal error has occurred” error message when trying to connect to a remote machine using Remote Desktop Connection.

      Solution:

      1. Type Local Security Policy to the Windows Search box.

      2. Click Open link.

      3. Expand Local Policies > Security Options on the left panel.

      4.  Double click on System cryptography: Use FIPS compliant algorithms for encryption, hashing, and signing row on the right panel.

      5. Select Enabled, click Apply and click OK.

      6. Log in the remote machine.

      7. Apply all the Windows Updates to the remote machine.

      8. Revert the System cryptography: Use FIPS compliant algorithms for encryption, hashing, and signing setting back to Disabled.

      9. Log in the remote machine again.

       

      How to increase your Wi-Fi connection speed

      Problem:

      You have a slow Wi-Fi connection speed.

      You want to increase your Wi-Fi connection speed.

      Solution:

      Execute below command on Windows:

      netsh wlan show interface
      • If your Signal is less than 20% then try to increase your Wi-Fi signal strength by moving your device closer to your Wi-Fi router.
      • If you cannot change your device and Wi-Fi router location then try connecting your Wi-Fi router to another Wi-Fi router (Wi-Fi extender) that acts as a new access point using LAN cable.
      • If you cannot use a LAN cable then try connecting your router to a Wi-Fi repeater that is closer to your device.
      • If your Radio type is 802.11n then try to upgrade both your device and router to support 802.11ac.
      • Try to upgrade your Wi-Fi router to support 5 GHz band.
      • Try to upgrade your Wi-Fi router to support MU-MIMO (which stands for Multi-User, Muliple Input, Multiple Output).
      • Compare Receive rate (Mbps) and Transmit rate (Mbps) before and after making a change.
      • Use Speedtest to compare your Wi-Fi connection speed before and after making a change.

      How to add multiple IPs to an Amazon EC2 virtual machine

      Motivation:

      You have a Server 2008 R2 machine on Amazon EC2.

      You want to secure multiple domains using different  SSL/TLS certificates.

      Server 2008 R2 does not support Server Name Indication (SNI). Therefore you need to add multiple IPs to Server 2008 R2 machine to use different SSL/TLS certificates.

      Solution:
      1. Create an EC2 virtual machine.
      2. Click on Network Interfaces tab.
      3. Click Create Network Interface button or select an existing network interface and select Actions > Attach.
      4. Click on a network interface ID, click Actions, click Manage IP Addresses, click on the network interface name (beginning with eth…), click the Assign new IP Address button, enter a private IP Address (e.g. 172.30.0.32), click the Save button, click the Confirm button.
      5. Click Elastic IPs tab, click the Allocate Elastic IP address button, click the Allocate button, optionally name the new allocated IP.
      6. Select the new allocated IP, click on Actions , click Associate Address, choose Network interface, then choose a private IP of the network interface with which the elastic IP will be associated, click the Associate button.
      7. Login Windows.
      8. View the network configuration using below command, note the Default Gateway and DNS Servers information.
      ipconfig /all

      9. Open Control Panel\All Control Panel Items\Network and Sharing Center.

      10. Click Change adapter settings link, click a Local Area Network Connection Network.

      11. Manually enter one IP address, Default Gateway and DNS Servers information.

      12. Click Advance… button to open Advanced TCP/IP Settings screen, and add the private IPs in the 4th step to the machine.

      13. Restart the machine.

      If you get any issue then try limit the number of private IPs of a network interface to 4 (including the default private IP).

      How to move a WordPress instance from one server to another Linux server

      Motivation:

      You want to move a WordPress instance from one server to another to consolidate your websites to reduce cost.

      Solution:

      Install and use below Duplicator plugin to achieve your goal.

      https://wordpress.org/plugins/duplicator/

      User guide: https://snapcreek.com/duplicator/docs/quick-start/

      If everything goes well for you then congratulation!

      Otherwise, please review below possible problems and corresponding solutions.


      Problem 1:

      You don’t have a website on the new server.

      Solution 1:

      1. Create a new virtual host in the /etc/httpd/conf/httpd.conf

      <VirtualHost *:80>
      ServerName example.com
      ServerAlias www.example.com
      DocumentRoot "/var/www/www.example.com"
      </VirtualHost>

      2. Set 775 permission for /var/www/www.example.com

      3. Restart httpd service

      sudo systemctl restart httpd

      Problem 2:

      You are using Amazon Linux 2 server.

      You are logged in as ec2-user.

      You use WinSCP to upload files and edit configuration files.

      You cannot modify /etc/httpd/conf/httpd.conf and /etc/php.ini.

      Solution 2:

      1 View permission settings for the file

      ls -ld /etc/httpd/conf/httpd.conf

      The result indicates that the file owner is root user and root group, not ec2-user.

      2. View groups of a user

      groups ec2-user

      The result indicates that the ec2-user does not belong to root group.

      3. Add a user to root group

      sudo usermod -a -G root ec2-user

      4. Grant Read-Write permission against a file to root group

      sudo chmod g+rwx /etc/httpd/conf/httpd.conf
      sudo chmod g+rwx /etc/php.ini

      5. Logout and login to the server again.


      Problem 3:

      You are using Amazon Linux 2 server. The ZipArchive feature is missing.

      Solution 3:

      1. Execute below commands:

      sudo amazon-linux-extras install php7.2
      sudo yum install php-pear php-devel gcc libzip-devel zlib-devel
      sudo pecl install zip-1.13.5 # we must specify a slightly older version due due to compatibility

      2. Add “extension=zip.so” to /etc/php.ini

      3. Restart the server

      sudo reboot

      Problem 4:

      You don’t have a WordPress database on the new Linux server.

      Solution 4:

      Execute below MySQL commands:

      CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
      CREATE DATABASE `wp_database`;
      GRANT ALL PRIVILEGES ON `wp_database`.* TO "username"@"localhost";
      FLUSH PRIVILEGES;

      Problem 5:

      An database error occurs while restoring a website.

      Solution 5:

      1. Execute below commands to remove the website:

      sudo chown -R ec2-user:apache /var/www/example.com
      sudo chmod 2775 /var/www/example.com && find /var/www/example.com -type d -exec sudo chmod 2775 {} \;
      find /var/www/example.com -type f -exec sudo chmod 0664 {} \;
      rm -r /var/www/example.com

      2. Upload the Duplicator files again, and restore the website again.


      Problem 6:

      No write access against /var/www/example.com is available for Duplicator.

      Solution 6:

      1. Execute below commands:

      sudo chown -R ec2-user:apache /var/www/example.com
      sudo chmod 2775 /var/www/example.com && find /var/www/example.com -type d -exec sudo chmod 2775 {} \;
      find /var/www/example.com -type f -exec sudo chmod 0664 {} \;

      2. Run http://example.com/installer.php again.

      How to connect and upload files to a remote machine using OpenVPN and SSH on macOS

      Motivation:

      You have a server inside a network. You are granted OpenVPN and SSH access to the server. You have a MacBook. You want to upload files to the server. You want to execute a process on the server (e.g. training a machine learning model).

      Procedure:

      • Request a certificate and an Open VPN configuration file (an .ovpn file) from your network administrator.
      • Install Tunnelblick https://tunnelblick.net
      • Drag the Open VPN configuration file to the Tunnelblick Configurations tab.
      • Click the Connect button.
      • On macOS, open Terminal and execute below command
      ssh [email protected] -p 7081

      where 172.29.64.144 is the machine IP and 7081 is the SSH port

      How to Completely Uninstall Python on macOS

      Problem:

      • You have an issue with a specific Python version (e.g. version 3.7).
      • You want to install differerent version (e.g. version 3.6).
      • You want to completely uninstall the current version before installing the new one.

      Solution:

      Assume the current version is 3.7, replace it with the version you installed (e.g. version 3.8).

      Follow the 3 steps below.

      1. Remove the third-party Python 3.7 framework

      sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.7

      2. Remove the Python 3.7 applications directory

      sudo rm -rf "/Applications/Python 3.7"

      3. Remove the symbolic links, in /usr/local/bin, that point to this Python version. Ensure that the links exit using below command:

      ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.7'

      then run the following commands to remove all the links:

      cd /usr/local/bin/ ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.7' | awk '{print $9}' | tr -d @ | xargs rm

      Installing a new version:

      1. Download a version from https://www.python.org/downloads/mac-osx/, double click the file and follow the instructions.
      2. Verify installation: python3 –version
      3. Install Homebrew from https://brew.sh
      4. Install virtualenv:
        pip3 install virtualenv
        pip3 install virtualenvwrapper
      5. Create and activate a virtual environment:
        cd /Users/admin/Downloads/training_model/model
        python3 -m virtualenv /Users/admin/Downloads/training_model/model
        source bin/activate