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.)
-
Create a new repo on GitHub. The repository should be empty.
-
Copy the URL of the repo on GitHub
-
Add the copied URL as remote URL.
git remote add origin REMOTE-URL
-
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 .
thengit commit -m "commit message"
, you can usegit 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
- Learn with Josy
- KTU Engineering Mechanics Textbook
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
-
Extract the file
-
Add directory to PATH
nano ~/.bashrc
export PATH=$PATH:/path/to/directory/
-
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:
- Normal Mode (Command Mode) - the default mode.
- Command Line Mode - Play around with commands
- Insert Mode - for editing the contents of the file
- 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 leftl
- to move rightj
- move cursor downk
- move cursor upG
- 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 lineO
- insert line before the current linea
- insert after cursori
- insert before cursorA
- insert at end of lineI
- insert at beginning of line
Undo Redo
u
- UndoCtrl
+R
- for redo
Set line numbers or relative line numbers
set number
- to display line numbersset 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).
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
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
- Lenovo Bitlocker Encryption Page
- Guide from Lenovo on how to disable bitlocker encryption
- Guide from Its FOSS - This guide also contains on how you can backup your recovery key
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
Source of Instructions: Lenovo
- Reboot your PC
- Boot into the BIOS setup menu by pressing the F1 key when the Lenovo logo is displayed
- 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.
- Press F10 to save and reboot
Linux Install
- 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)
- Take your freshly written USB key and insert it in the powered down installation platform.
- Power on the device and press F12 during early boot to enter the Boot Menu.
- Navigate down to the USB HDD device and press Enter.
- 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
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.
-
Download the BIOS image from Lenovo Support. Make sure you choose the correct model. You should download the CD ISO image.
-
Download geteltorito
-
Change directory to geteltorito
-
Set permissions by using the below command
chmod +x ./geteltorito.pl
-
Extract the bootable image from the ISO:
./geteltorito.pl -o bios.img iso_file.iso
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
-
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
- For Linux and macOS this can be done in one line, using parameter expansion to change the filename extension of the output file
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
ytdlp
-
Download a video from YouTube as mp3
yt-dlp --audio-format mp3 --add-metadata https://www.youtube.com/watch?v=r5PtlHs9igM
-
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;
}
}
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
- First connect the printer to the USB port and turn on the printer.
- Access the router gateway (192.168.18.1) in your browser. You may have a different gateway address....see the back of your router.
- 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.
- Open CUPS by going to
http://localhost:631
in your browser. - Go to the administration section and add the printer
- Choose
Internet Printing Protocol (ipp)
- Enter the url as
http://192.168.18.1:631/printers/name_of_printer
. Replacename_of_printer
with the name you noted down earlier from the router's gateway. - Choose the manufacturer of your printer. On the next page choose the correct model and try printing a test page.
- Your printer should be working.