Introduction

Welcome amigo!

I created this wiki just for documenting some of the stuff that I have learnt. I use it as a quick reference to save time and kind of avoid relearning things. This whole wiki is specifically made for myself - so not everything in here is explained in detail and some of the pages may even contain mistakes.

Of course, if you have any questions or spot any mistakes, you are always free to contact me

Git

Push an existing local repository to GitHub

How to push an existing local repository to GitHub

Make sure the default branch name is 'main'.(main is the default branch name in my case.)

  1. Create a new repo on GitHub. The repository should be empty.

  2. Copy the URL of the repo on GitHub

  3. Add the copied URL as remote URL.

    git remote add origin REMOTE-URL

  4. Push the repo

    git push origin main

Useful Git Commands

git stash

  • If you are working on a branch and you need to switch to another branch to work on something else, then git will not allow you to do so if you have uncommittedd changes.
  • In such a situation, git stash can be used to temporarily save uncommitted changes. It reverts your directory to the last committed state.

Use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.

  • Use git stash pop when you are ready to add the changes back to your code

git commit -am

  • Instead of using git add . then git commit -m "commit message", you can use

    git commit -am "message"

View git remote URL

  • git remote -v to view the remote URLs of a repository.

Useful Stuff for KTU

A collection of playlists, youtube videos and channels and websites that I use for studying.

S1 & S2

For first year, I mostly referred to the prescribed textbooks.

Engineering Mechanics

Engineering Physics

S3

DSA (Data Structures & Algorithms)

LSD (Logic System Design)

OOP (Object Oriented Programming) in Java

  • Head First Java: A Brain-Friendly Guide This is actually a really good book that I found helpful. All the important concepts are explained in simple language with plenty of examples. The book was pretty fun to read.

S5

FLAT (Finite Language and Automata)

Linux

Using tar.gz

I decided to try out the jetbrains applications. This is how I use the tarball.

Once the file is downloaded, you have to extract the file. The application can be launched by executing the ./bin/ WebStorm.sh script.

But it is much easier to launch the application by adding the directory to the PATH

  1. Extract the file

  2. Add directory to PATH

    nano ~/.bashrc

    export PATH=$PATH:/path/to/directory/

  3. Reload the shell environment

    source ~/.bashrc

apt package manager

Search for a package

To search for a package from the command line, use: apt-cache search keyword

Show package details

To show package details, use apt show package-name.

Basics of Vim

I just put this here so I can for future reference. Of course, there are many cheatsheets and guides on how to use vim. This is just my personal cheatsheets. I am not planning on adding every command, only just some useful ones.

If you find any mistakes here, please let me know.

Additional Reference

Start

Vim has basically four modes:

  1. Normal Mode (Command Mode) - the default mode.
  2. Command Line Mode - Play around with commands
  3. Insert Mode - for editing the contents of the file
  4. Visual Mode - for selecting the text.

How to enter each modes?

  • Press Esc to enter normal mode.
  • Press i to enter insert mode.
  • Press v for visual mode.
  • Press : to enter command line mode.

Saving and Quitting

Enter command mode

  • Use :w to save the file
  • Use wq to save and quit
  • Use q! to exit the file without saving changes made to the file
  • Use q if no changes were made.

Cursor Movements

  • h - to move left
  • l - to move right
  • j - move cursor down
  • k- move cursor up
  • G - to move to the last line
  • $ - to move to the end of a line

More commands for insert mode

  • o - insert new line after the current line
  • O - insert line before the current line
  • a - insert after cursor
  • i - insert before cursor
  • A - insert at end of line
  • I - insert at beginning of line

Undo Redo

  • u - Undo
  • Ctrl + R - for redo

Set line numbers or relative line numbers

  • set number - to display line numbers
  • set relativenumber - to display relative line number

Debian Mirrors

The sources file is located at /etc/apt/sources.list. More info on the sources.list file can be found on the Debian Wiki.

Mirrors that I use:

More mirrors can be found on the Free Software Mirrors in India page.

Thinkpad

I use a Lenovo ThinkPad E16 Gen 2 (AMD) with Fedora as my Operating System.

Operating System

  • Fedora 41 Workstation
  • GNOME Desktop

Specifications

  • Processor AMD Ryzen™ 5 7535U Processor (2.90 GHz up to 4.55 GHz)
  • Graphic Card Integrated AMD Radeon™ 660M
  • Memory 16 GB DDR5-4800MHz (SODIMM)
  • Storage 512 GB SSD M.2 2242 PCIe Gen4 TLC Opal
  • Display 40.64cms (16) WUXGA (1920 x 1200)
  • IPS, Anti-Glare, Non-Touch, 45%NTSC, 300 nits, 60Hz
  • Camera 720P HD RGB with Microphone and Privacy Shutter
  • Battery 3 Cell Li-Polymer 47Wh
  • WIFI Realtek 8852BE WIFI 6 2x2ax + BT5.x & Bluetooth® 5.1 or above

More information can be found in the PSREF

Charging Thresholds

To extend the lifespan of your battery, you can define charging thresholds.

A ThinkPad battery can be set for maximum runtime (hours), or for maximum lifespan (years).

More info

Setting the Charging Thresholds

Source: Reddit

  • You can set the charging start threshold in (At what value or below should charging start):

    /sys/class/power_supply/BAT0/charge_start_threshold

  • You can set the charging stop threshold in (At what value charging should stop):

    /sys/class/power_supply/BAT0/charge_stop_threshold

  • I have set the start threshold at 75 and stop threshold at 80 on my laptop

Optimizing for runtime (hours)

Source: Lenovo

The normal default Lenovo Power Manager Battery Maintenance setting keeps the battery fully charged. The setting starts charging when the battery drops below 96%, and stops at 100%. The battery runtime depends on the Power Plan settings.

Optimizing for lifespan (years)

Source: Lenovo

For maximum lifespan when rarely using the battery, set Custom charge thresholds to start charging at 40% capacity and stop at 50%, and keep the ThinkPad cool. The thresholds can be adjusted in the Battery Maintenance settings of Lenovo Power Manager.

If the battery is used somewhat frequently, set the start threshold at around 85% and stop at 90%. This will still give a good lifespan benefit over keeping the battery charged to 100%.

Swap Fn and Ctrl Key

On thinkpads for some reason, the function and control keys are in a different position. I have no clue why Lenovo does this.

Anyway, if you prefer, you can swap the keys by using the BIOS. Please refer this article by Lenovo to swap the function and control keys.

Linux Installation

You can install any distribution on your laptop. In my opinion, it is better to go with Fedora or Ubuntu to make sure the hardware works as intended.

Update System and BIOS

  • Before getting rid of Windows, update the BIOS using Lenovo Vantage software. For more information, visit Lenovo's website

Disable Bitlocker Encryption

Before installing Linux on your ThinkPad, you must check if Bitlocker encryption is enabled on your disk.

If BitLocker encryption is enabled, please disable it before following the below steps.

You must disable bitlocker encryption to install Linux and backup your keys

Secure Boot

What is Secure Boot?

UEFI Secure boot is a verification mechanism for ensuring that code launched by firmware is trusted. More info can be found in the Ubuntu Wiki

Enable Secure Boot

The Bitlocker recovery screen will appear on changing the BIOS settings. Make sure you have bitlocker encrpytion disabled and have a backup key of your recovery key. The screen appeared for me because I hadn't disabled Bitlocker.

Source of Instructions: Lenovo

  1. Reboot your PC
  2. Boot into the BIOS setup menu by pressing the F1 key when the Lenovo logo is displayed
  3. In the BIOS menu select the “Security” option and the “Secure Boot” sub-menu. Toggle the “Allow Microsoft 3rd party UEFI CA” to be “On” as shown below. BIOS of Lenovo
  4. Press F10 to save and reboot

Linux Install

  1. Flash the ISO on to a USB using Rufus, Balena Etcher or the software of your choice (Since I use Fedora, I used Fedora Media Writer)
  2. Take your freshly written USB key and insert it in the powered down installation platform.
  3. Power on the device and press F12 during early boot to enter the Boot Menu.
  4. Navigate down to the USB HDD device and press Enter.
  5. Select the appropriate option from the GRUB Menu (In my case it was Test this media & start Fedora-Workstation-Live.)

Updating the BIOS

Please also refer to the references used to write these instructions

You should always be careful when updating the BIOS. I will not be responsible for any damage caused to your system. Always take the necessary precautions and follow the instructions carefully.
If you are on Windows, you can easily update the BIOS with Lenovo Vantage.

But on Linux distributions, Lenovo Vantage is not supported and since Thinkpad 16 G2 (AMD) is not Linux certified, you cannot get udate the BIOS using fwupd.

You can manually update the BIOS by downloading the image and flashing it on to a USB Drive.

  1. Download the BIOS image from Lenovo Support. Make sure you choose the correct model. You should download the CD ISO image.

  2. Download geteltorito

  3. Change directory to geteltorito

  4. Set permissions by using the below command

    chmod +x ./geteltorito.pl

  5. Extract the bootable image from the ISO:

    ./geteltorito.pl -o bios.img iso_file.iso

The below command will delete everything in your USB Drive. Make sure you don't have any important files in it
When copying the image in your USB stick, make sure you have chosen the correct device
6. Copy the image into your USB stick by dd utility
sudo dd if=bios.img of=/dev/sdb

You now have a bootable USB drive.

Secure boot must be disabled it for the computer to boot the USB drive

ffmpeg

  1. Convert all the files in a particular directory to another format

    • For Linux and macOS this can be done in one line, using parameter expansion to change the filename extension of the output file
      for i in *.avi; do ffmpeg -i "$i" "${i%.*}.mp4"; done
      

    Source

scrcpy

scrcpy (screen copy) is a tool used for mirroring and controlling your Android device via ADB. I found this tool particularly useful when I cracked the display on my phone and touch did not work properly.

To use scrcpy, you will need to enable USB Debugging on your device

You can download scrcpy from GitHub. To install it on Linux, see the following page.

  • To control the device using your keyboard and mouse (without Android Debugging). Use the following command.
scrcpy --otg
  • To mirror the device and control the device, simply run the following command
scrcpy

Screenshot

alt text

ytdlp

  1. Download a video from YouTube as mp3

    yt-dlp --audio-format mp3 --add-metadata https://www.youtube.com/watch?v=r5PtlHs9igM
    
  2. Download video without audio

    yt-dlp youtube_link -F
    

CSS

Improving CSS Reset

How you can make your site a little bit more better by using the css below. Source

h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
}

p,
li,
figcaption {
  text-wrap: pretty;
  max-width:65ch;
}
 

Dark Theme

How to add dark theme to a website using only css.

@media (prefers-color-scheme: dark) {
  img {
    opacity: .75;
    transition: opacity .5s ease-in-out;
  }
  img:hover {
    opacity: 1;
  }
}

Source

Setting up a Printer with EG8145V5

How to set up a printer on Huawei EG8145V5 rotuter?

This guide focuses on Linux users but even if you are a windows user - you can follow this video

  1. First connect the printer to the USB port and turn on the printer.
  2. Access the router gateway (192.168.18.1) in your browser. You may have a different gateway address....see the back of your router.
  3. Enable printer and storage sharing. Note the name of the printer as you will need it. You need to press the icon of of USB port to access the below settings. See image below.

Screenshot of router gateway...choose the USB option on the router home page to access the settings of devices connected to the ISB port

  1. Open CUPS by going to http://localhost:631 in your browser.
  2. Go to the administration section and add the printer
  3. Choose Internet Printing Protocol (ipp)

alt text

  1. Enter the url as http://192.168.18.1:631/printers/name_of_printer. Replace name_of_printer with the name you noted down earlier from the router's gateway.
  2. Choose the manufacturer of your printer. On the next page choose the correct model and try printing a test page.
  3. Your printer should be working.