Nuke all content

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2022-07-09 19:46:43 +05:30
parent 91101a7ecb
commit 1d7f531ddd
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5
12 changed files with 0 additions and 1559 deletions

View file

@ -1,35 +0,0 @@
+++
title = "About Me"
id = "about"
date = 2021-10-16T12:29:41+05:30
+++
I am Baalaji Balasubramani, a 22 year old, popularly known around the internet world as baalajimaestro.
I work on a lot of opensource projects, you can find them all on my GitHub!
I use Linux as a primary distro for over 4 years now.
My primary distro choices include Alpine (for servers), Arch (for desktops).
I am currently running Debian Bullseye on an OrangePi 3 (ARM64)
And yes, that is my primary development system too. I connect to Codespaces incase I desire to code anything that needs high amount of resources (Rust)
GitHub Codespaces is a really good environment that is helping me do stuff even when I dont own a full-fledged PC.
For programming, I use Rust or Python as my primary choice. I can also code in C, C++, Java, Javascript, PHP.
I am looking forward to learning Go.
I use Bash Scripting to automate all tasks. Like even deploying this website.
I code all stuff with VSCode! No IDE specific for any language.
I love to work with Docker and Kubernetes clusters. I have created a few [Docker Images](https://hub.docker.com/u/baalajimaestro), newer ones are on Gitlab (blame Docker for ratelimiting pulls) respective repos, for my own personal use.
My repos are currently split across sourcehut/gitlab/github. In increasing order of age.
I am a person who feels music is a drug. Feel free to suggest me some nice music if you have some.
It's hard to see me without writing or thinking about code, even if you happen to do so, I would have been sleeping or gaming!
If you find some­one with the user­name `baalajimaestro` on any platform, you can be mostly sure its me
I am currently working at TheCareerLabs as a DevOps Engineer

View file

@ -1,14 +0,0 @@
+++
title = "Contact Me"
id = "contact"
date = 2021-10-16T12:29:41+05:30
+++
I would be available on [Telegram](https://t.me/baalajimaestro) almost all time except my sleep. You can DM me on telegram, provided you convey your information concisely and readably, rather than sending a dumb `hi` and expecting me to respond on it.
If you don't have Telegram, no problems, look up your if your preferred method [here.](https://links.baalajimaestro.me)
I respond to any message within the same day. If it wasnt responded, there is just two things:
- Your question wasnt put forth properly, that it needed a response from my end
- I was over-busy, and didnt even look at that message (engrossed on smth maybe?)
I am not on LinkedIn, I just reserved the username against misuse. So if you have been the one waiting for 7yrs to connect, you cant connect with me on LinkedIn ever!

View file

@ -1,8 +0,0 @@
---
title: "Blog"
description: "Guides, Rants and everything"
---
{{< lead >}}
Guides, Rants and everything
{{< /lead >}}

View file

@ -1,64 +0,0 @@
---
title: "Android and its hostile community"
date: 2021-06-22T12:29:41+05:30
---
I am writing this post with sheer disgust of huge nagging that I am facing for an OSS project.
You might have seen me work quite a lot on Android ROMs/Kernels. Have you as a user read its license that it comes with?
```code
Licensor provides the Work (and each Contributor provides its Contributions)
on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied, including, without limitation,
any warranties or conditions of TITLE, NON-INFRINGEMENT,
MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
```
Almost all common opensource licenses (Apache/MPL/GPL/BSD) have similar clauses of their own.
Its worth taking a moment to consider the implications of this statement and what
it says about the social aspects of free and open source software.
Many people who rely on OSS software, feel entitled to get both support and maintainance at no cost.
Which is absolutely not true!
![Meme](meme.webp)
Some project maintainers may provide QA and support like RHEL/SLES, in the form of a contract. This isnt the case with FOSS, where you aren't required to sweat and cry for the community. Let alone QA, you aren't required to publish documentation,
or even a proper commit message. My very dear friend was being called out for having "Update files" as commit message on his repos. GPL requires you to just share sources with the community, which also implies you are very much allowed to tarball it and send it up, instead of publish to a public git repo with all perfect git history.
> Tip: OEMs have been doing this for years!
It is nice that a maintainer offers your free time, and helps you get his binaries running, but by no means they are required to.
As per the [free software definition](https://www.gnu.org/philosophy/free-sw.en.html) you have the right to make changes to the binary and redistribute your changes to others,
and to sell the software with or without those changes.
Selling the software, this reminds me of one incident where a person was asked to make their binaries free-of-cost, for including
a certain *.so file inside. There were so many people standing in support, but asking someone about this, after the sources
were licensed under Apache-2.0 felt little idiotic.
The hostile community, is the most correct word to describe the android community. People expecting third-party AOSP forks,
to perform without bugs in weird edge cases is totally not fine. You haven't given them a **WARRANTY** of any sort.
You aren't required to fix those issues they describe overnight banging your head on the PC. This doesn't imply to be rude
or harass a user for asking questions at you. You could help them, or atleast redirect them to a better place to fetch help.
Harassing a maintainer for publishing binaries that broke their phones, or something of the sort is also idiotic.
**YOU chose to make the changes.**
**YOU are the one responsible.**
As a maintainer, you need to be prepared to say __no__.
Working on your project should never feel like a curse.
You started it for a reason — remember that reason. Was it to lose your sanity? Or was it to have fun?
Was it to solve a specific problem you had? Or was it to solve problems for someone youve never met?
If you enjoy helping others, then thats great! But don't tire yourself fixing issues that don't even bother you! Take your time fixing or attending only to those that really bother you.
If you are a user, and were sent to this post, please understand that all your developer's sources are opensource. You can become a potential maintainer. Its not that you don't know C/Java/Makefile/Soong whatever. You can learn it through time, just google up! There is tons and tons of resources that made your maintainer what he is. There are so many telegram chats dedicated to helping people with all this. Learn doing this, fix bugs, make a pull request, and boom, you have done a nice contribution to the community you were a part of!
---
Thanks for listening to my rant!
This post was sponsored by the numerous people who spammed my DMs for getting a build of PixelExperience for OnePlus 7

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

View file

@ -1,81 +0,0 @@
---
title: "Vendor Blob Extraction (v2)"
date: 2021-09-21T21:24:00+05:30
---
This is the updated instructions, and an update-to-date (as of writing) how-to guide for vendor blob extraction
Unlike the earlier guide, you won't need the full rom synced. Huge kudos to the guys at LineageOS for making this possible!
What you would need:
- Around like 20GB of disk space (just to be safe)
- Dump or OEM zip whichever is available
- A Popular GNU/Linux Distro
Where to search if your zip is dumped already?
Go to this link: https://dumps.tadiphone.dev/dumps
Use the search box to search your device name
If you find your device repo there, go in, and see its vendor or system build.prop if any prop matches what you need.
It's more of visual exploration for you now.
If the build you have is newer/the device is missing, you can request for it to be dumped here:
https://t.me/dumprequests
In the meanwhile, you can also dump it yourself, rather than waiting for it to be dumped.
Download the concerned OEM zip (like MIUI, OneUI, or whatever)
Dumpyara is a universal dumper script compatible with almost all OEM zips
```code
git clone https://github.com/AndroidDumps/dumpyara
cd dumpyara
```
If you have Arch Linux or Ubuntu, then simply run,
```code
bash setup.sh
```
else, you have to poke into that script and match accordingly with the deps for your distro.
With the setup part done,
Let's get to the dumping part.
```code
bash dumpyara.sh ./zipname.zip
```
Let it run for a while, and your dump should be at the `working/zipname` folder of dumpyara
Once you have the dump, let's start to extract from it.
```code
git clone https://github.com/LineageOS/android_tools_extract-utils -b lineage-18.1 android/tools/extract-utils
git clone https://github.com/LineageOS/android_prebuilts_extract-tools -b lineage-18.1 android/prebuilts/extract-tools
```
cd to the android folder and,
git clone your dt to the usual path like you would while building, like `device/brand/codename`
Clone the common tree also, if it exists
Check if your extract-files.sh is updated to track `tools/extract-utils`, if it's not, or the file itself doesn't exist,
you need to get it from GitHub, it's almost on every tree.
```code
bash extract-files.sh /path/to/dumpyara/working/zipname/
```
Wait and watch it do its thing
Once that is done, you just need to go to `vendor/brand/codename` and,
git init, commit and push it up!
This should be done for the common tree also which would be `vendor/brand/smxx-common`

View file

@ -1,77 +0,0 @@
---
title: "Vendor Blob Extraction"
date: 2019-10-10T21:24:00+05:30
---
{{< alert >}}
**Warning!** This article is deprecated, please use [this link](https://baalajimaestro.me/posts/extract-vendor-2/)
{{< /alert >}}
## How to extract vendor blobs from stock rom?
I got asked this question a lot, so I'll post it here. Its gonna just be steps on how to do it.
⚠️ Note that you need a fully synced rom source for this.
- Place the Device Tree with the extract-files.sh inside.
- If your device tree doesn't have an extract-files script, get it from github, its almost on every tree.
- Grab the stock rom for your device, MIUI/OOS or OneUI whatever.
- Create a new folder named dump and extract it there.
- Now see if it has a payload.bin or system.dat.br and vendor.dat.br
### If it has a payload.bin, then, your device is A/B, and the job is actually very easy,
- Use [this tool](https://forum.xda-developers.com/attachment.php?attachmentid=4760222) and run the python file in it.
- You will now have img files ready.
### You are unlucky and have br files inside.
So what? We can still extract them, a bit of more work, but yes we can.
- Install brotli from your package manager
- Run the following commands, it will decompress the brotli compression of your images
```bash
brotli --decompress system.new.dat.br
brotli --decompress vendor.new.dat.br
```
- Now we to convert the dat files to img, run these commands on terminal, to convert it
```bash
curl -sLo sdat2img.py https://raw.githubusercontent.com/xpirt/sdat2img/master/sdat2img.py
python3 sdat2img.py system.transfer.list system.new.dat
python3 sdat2img.py vendor.transfer.list vendor.new.dat vendor.img
```
- Now you would have both the images ready for extracting.
### Final Step
Lets Extract the img files we have!
- Create folders for extracting.
```bash
mkdir -p system
mkdir -p vendor
```
- Install P7-Zip from your package manager
- Now the extraction.
```bash
7z x system.img -y -osystem
7z x vendor.img -y -ovendor
```
In your folder, there would be two folders system and vendor, with many files now.
### Pulling blobs
- The work directory which had the system and vendor folders is assumed to be at ~/dump for now.
- cd to the device tree, and run the command
```bash
bash extract-files.sh ~/dump
```
- Your vendor blobs would be at `vendor/brand/device`

View file

@ -1,719 +0,0 @@
---
title: "Git For Newbies"
date: 2019-06-18T12:29:41+08:00
---
Before we start make sure `git --version` command successfully returns. If the output is something like **command not found** then please make sure Git is properly installed on your machine. My machine output is shown below. **Output on your machine might be different.**
> **Commands that a user should type on his/her terminal are prefixed with the shell prompt symbol `$`. The output of command follows the command. Also, you don't have to type `$` on your terminal.**
Please be nice to Mr.Git. Introduce yourself to him. Else git will blame you for not introducing yourself `please tell me who you are!`
```bash
$ git config --global user.name "Your name"
$ git config --global user.email "Your email"
```
The command shown above populates a file named `.gitconfig` in your user home directory with configuration information.
```bash
$ cat ~/.gitconfig
```
```
[user]
name = baalajimaestro
email = baalajimaestro@computer4u.com
```
## Table of Contents
* Why version control system?
* What the heck is Git?
* Git basics
* git init
* git status
* git add
* git commit
* git rm
* git log
* .gitignore files
* Working with branches
* git branch
* git checkout
* git merge
* Working with remote repositories
* git remote
* git pull
* git push
* git clone
* Github basics
* Why and What Pull Requests?
* Advanced topics
* git rebase
* git cherry-pick
* git alias
* Useful Git commands
VCS: Version Control System
----
A version control system is a kind of database for storing your software project source code. It lets you save a snapshot of your complete project at any time you want. When you later take a look at an older snapshot (let's start calling it "version").
You can use version control system to store:
1. Software source code
2. Text files
3. Writing books
4. Sharing datasets
## Why version control system?
You should use version control because it offers the below:
1. Collaboration among a team of Coders
2. Versioning the code. Could create multiple branches to setup binary releases
3. Restoring to previous versions
4. Tracking the history (who to blame!)
5. Backup. Old style backup methodologies like email storage, local file system or FTP backup are cumbersome.
## What the heck is Git?
Git is a distributed version control system. It was developed by Linus Torvalds in 2005 for linux developers and is being maintained by a large community across the world.
Every Git working directory is a full-fledged repository with complete history and full version-tracking capabilities, independent of network access or a central server.
<img src="https://upload.wikimedia.org/wikipedia/commons/e/e0/Git-logo.svg" width="150" height="150">
Distributed or Decentralized VCS allows many software developers to work on a project without requiring them to share a common network.
## Git basics
Let's start by creating an empty directory `git-basic`. Navigate to a convenient location on your local file system and create a new directory.
```bash
$ mkdir git-basic && cd git-basic
```
### git init
To make any repository a Git managed repository, you can type the following command. These commands should be typed from inside the `git-basic` directory.
```bash
$ git init
```
```
Initialized empty Git repository in ~/git-basic/.git/
```
This will create a directory named `.git` inside the `git-basic` directory.
`.git` is a directory where Git stores all the data. **Don't mess with the `.git` directory.**
If you want to override user for this repository, then you can add user section by either editing `.git/config` file or using the `git config --local` command.
```bash
$ git config --local user.name "Shekhar 123"
```
If you view the contents of the `.git/config` file now, then you will see your change.
### git status
Time and again we will need to know status of our Git repository. By status what we mean is the current state of the repository. E.g., what needs to be added to the index, what needs to be committed, if there is any change that we have to commit, etc., This is the command that you will use the most.
```bash
$ git status
```
```
On branch master
Initial commit
nothing to commit (create/copy files and use "git add" to track)
```
### git add
Let's create a new file `README.md` and add a dummy message.
```bash
$ echo "# Git Basics" >> README.md
```
> **It is a good practice to create a file named README.md in your repository root that tells the purpose of the repository.**
Now, check the status of the Git repository.
```bash
$ git status
```
```
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
README.md
nothing added to commit but untracked files present (use "git add" to track)
```
**git add** stages the changes so they are picked up by the next commit. In Git, you can't commit something until its tracked.
```bash
$ git add README.md
```
Now, check the status of your Git repository.
```bash
$ git status
```
```
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: README.md
```
> **If you have multiple files then you can use `git add <file1> <file2> .. <filen>` or `git add --all` or `git add -A` to stage them in one command.**
### git commit
Once you have a smallest working change, you should commit it to your version control system. Smallest working change could be a test case, a small piece of functional code, a line or paragraph in your text file, etc. **You should commit often and daily.** Also, every commit should strive to do exactly one change.
After staging your changes, next step is to commit them into your local Git repository. To do that, we will use commit command as shown below.
```bash
$ git commit -m "first commit"
```
```
[master (root-commit) 3d34eb3] first commit
1 file changed, 1 insertion(+)
create mode 100644 README.md
```
Staging and committing are two different steps in Git. You can't commit a change until it has been staged. If you are working with a tracked file, then you can do both of these steps in a single command.
```bash
$ echo "This is my Git." >> README.md
```
Check the status of your repository. This time it will say it is a **modified** change.
```bash
$ git status
```
```
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")
```
To stage and commit a change in a tracked file, you can use following command.
```bash
$ git commit -am "second commit"
```
### git rm
Let's suppose we added a bad file to the Git index that we want to remove.
```bash
$ echo "my stupid file" >> stupid.txt
$ git add stupid.txt
```
To remove such a file from the Git index, we can use Git `rm` command.
```bash
$ git rm -f stupid.txt
```
To remove directories,
```bash
$ git rm -rf crap
```
### git log
To view history of your commit logs, use the following command.
```bash
$ git log
```
If you want to see a commit in one line, then use `--oneline` option.
```bash
$ git log --oneline
```
There are many more options. You can refer to help `git help log` for more details.
### .gitignore files
Every Git repository should have another configuration file `.gitignore` present in the root i.e. directly inside the `git-basic` directory. This file is used to specify files and file patterns that you want git to ignore .
```bash
$ echo "*.log" >> .gitignore
$ echo "target/" >> .gitignore
$ echo "dummy.txt" >> .gitignore
```
1. The first pattern says any file with extension `log` will ignored.
2. The second pattern says directory with name `target` will be ignored.
3. The third pattern means file with name `dummy.txt` will be ignored.
Now add and commit the `.gitignore` to your Git repository.
```bash
$ git add .gitignore
$ git commit -m "Adding .gitignore file"
```
## Working with branches
A branch represents an independent line of development. You use branch for following:
1. Develop a new feature. Once you are done with the feature, it can be merged into your main branch.
2. Fix a bug.
3. Your experiment playground.
By default, every git repository has one branch called **master**. When you create a new branch, you get a new development workspace. Any change that you make to the new working directory has no impact on your previous working directory.
### git branch
**git branch** command lets you work with Git branches.
To view all the branches, you execute following command.
```bash
$ git branch
* master
```
> **branch marked with a * is the current branch.**
Let's suppose we have to implement some new functionality. To work on new functionality, we create a new branch called `feature1`.
```bash
$ git branch feature1
```
You can view branch list again.
```
$ git branch
feature1
* master
```
One thing that is important to understand here is Git branches are just pointers to commits. When you create a branch, all Git needs to do is create a new pointer; it doesnt change the repository in any other way.
```bash
$ git log --oneline --decorate
```
### git checkout
To switch to a branch, you use checkout command.
```bash
$ git checkout feature1
```
The `git checkout` command lets you navigate between the branches created by git branch.
To create a new branch and checkout it in one command
```bash
$ git checkout -b feature1
```
Let's add our new feature now.
```bash
$ echo "I will read a Git tutorial today to make sure I understand Git thoroughly." >> README.md
```
Commit it to the `feature1` branch.
```bash
$ git commit -am "fifth commit. Read tutorial"
```
### git merge (ff)
Once we are done with our feature, we can merge it back to master. First, we'll switch to `master` branch.
```bash
$ git checkout master
```
**git merge** command allows you to merge an independent development line created by `git branch` into a single branch.
> git merge will merge into the current branch.
To merge `feature1` branch into `master` branch, execute the following command.
```bash
$ git merge feature1
```
```bash
$ git log --oneline --decorate
```
> the default merge algorithm is ff i.e fast forward. When the merge resolves as a fast-forward, only update the branch pointer, without creating a merge commit. This is the default behavior.
A **fast-forward** merge can occur when there is a linear path from the current branch tip to the target branch.
Now that we are done with `feature1` branch, let's delete it.
```bash
$ git branch -d feature1
```
### git merge (--no-ff)
Create another new branch `feature2` and add a new commit.
```bash
$ git checkout -b feature2
$ echo "I will watch a Git video by Linus Torvalds https://www.youtube.com/watch?v=4XpnKHJAok8" >> README.md
$ git commit -am "sixth commit. Watch video."
```
Now checkout master again.
```bash
$ git checkout master
```
The `--no-ff` algorithm always generate a merge commit (even if it was a fast-forward merge)
```bash
$ git merge --no-ff feature2
```
View logs of master
```bash
$ git log --oneline --decorate
```
The interesting bit is that it created a merge commit. Git uses Three-way merge algorithm.
1. the `MERGE_HEAD` commit i.e. the modification that we want to merge
2. the `HEAD` commit i.e. the branch in which the `MERGE_HEAD` will be merged i.e. the branch on which the git merge command is called
3. the `ORIG_HEAD` commit i.e. the best common ancestor of `MERGE_HEAD` and `HEAD` that will serve as the reference.
Delete the feature branch `feature2`
```bash
$ git branch -d feature2
```
### git merge (commits in both master and branch)
Create another new branch `feature2` and add a new commit.
```bash
$ git checkout -b feature3
$ echo "I will try Git using tutorial https://try.github.io/" >> README.md
$ git commit -am "seventh commit. Try Git."
```
Checkout master branch and edit an existing line.
```bash
$ git checkout master
```
Change **I will read a Git tutorial today to make sure I understand Git thoroughly.** to **I will read a Git tutorial https://www.atlassian.com/git/tutorials/.**
```bash
$ cat README.md
```
```
# Git Playground
This is my Git playground.
I will learn Git today during the XKE.
I will read a Git tutorial https://www.atlassian.com/git/tutorials/.
I will watch a Git video by Linus Torvalds https://www.youtube.com/watch?v=4XpnKHJAok8
```
Now, commit the change to master branch.
```bash
$ git commit -am "fixed Git tutorial bullet point"
```
Now merge the `feature3` branch. This will create a merge commit.
```bash
$ git merge feature3
```
View the log graph.
```bash
$ git log --oneline --graph
```
### git merge (conflict)
In this section, we will look at scenario where there is a merge conflict. Merge conflict happens when you're trying to merge a branch that has changed the same part of the same file as master. Let's create a new branch `feature4`, make a change, and commit.
```bash
$ git checkout -b feature4
$ echo "I will create a Github account today." >> README.md
$ git commit -am "eighth commit. Signup for Github."
```
Now, checkout master, make a change, and then commit it.
```bash
$ git checkout master
$ echo "I will create my first repository today." >> README.md
$ git commit -am "eighth commit. Create repository on Github."
```
If you try to merge the `feature4` branch, you will get merge conflict as shown below.
```bash
$ git merge feature4
```
```
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.
```
To merge the conflict, open the file in your favorite editor. I like [Atom](https://github.com/atom/atom).
```bash
$ cat README.md
```
```
# Git Playground
This is my Git playground.
I will learn Git today during the XKE.
I will read a Git tutorial https://www.atlassian.com/git/tutorials/.
I will watch a Git video by Linus Torvalds https://www.youtube.com/watch?v=4XpnKHJAok8
I will try Git using tutorial https://try.github.io/
<<<<<<< HEAD
I will create my first repository today.
=======
I will create a Github account today.
>>>>>>> feature4
```
The merged output is shown below.
```
# Git Playground
This is my Git playground.
I will learn Git today during the XKE.
I will read a Git tutorial https://www.atlassian.com/git/tutorials/.
I will watch a Git video by Linus Torvalds https://www.youtube.com/watch?v=4XpnKHJAok8
I will try Git using tutorial https://try.github.io/
I will create a Github account today.
I will create my first repository today.
```
To make the merge resolved, execute `git add` command.
```bash
$ git add README.md
```
Commit it
```bash
$ git commit -am "Resolved merged conflict with feature4 branch"
```
## Working with remote repositories
In Git, every developer has their own local copy of the repository. It has all the repository history and branches. A developer works on their local copy and when done with the work, the changes can be pushed to a remote repository. A local repository can point to 0 or more remote repositories. A remote repository could be on Github or any other cloud VCS provider or even it could be on your own machine.
### git remote
The **git remote** command lets you create, view, and delete connections to other repositories.
To view all the remotes, execute the following command.
```bash
$ git remote
```
As we have not added any remote yet, this command will not print any output.
To add a new remote, execute the following command.
```bash
$ git remote add local ../git-basic-remote.git
```
> **Please use correct path to your remote repository.**
To push our repository changes to this remote repository we can run the following command. This command will be executed from inside the `git-basic` directory.
```bash
$ git push local master
```
```
Counting objects: 37, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (32/32), done.
Writing objects: 100% (37/37), 3.41 KiB | 0 bytes/s, done.
Total 37 (delta 11), reused 0 (delta 0)
To ../git-basic-remote.git
* [new branch] master -> master
```
Now, you can create multiple local copies of the remote repository using `clone` command.
```bash
$ git clone git-basic-remote.git git-basics
```
```
Cloning into 'git-basics'...
done.
```
Change directory and view the contents.
```bash
$ cd git-basic-1
```
You can see history of the repository using `git log --oneline --decorate` command.
Let's make a change in `git-basics` repository.
```bash
$ echo "I will read Git in Practice book" >> README.md
$ git commit -am "ninth commit. Read book."
$ git push local master
```
To get changes in our first repository i.e. `git-basic`, you will use `pull` command.
```bash
$ git pull local master
```
## Github basics
Github is a collaborative code management platform for open source and private projects. It has social features just like any other social website like Facebook, Twitter, etc.
You use Github to store your code on a remote Git repository.
You can [sign up](https://github.com/join) for Github.
### Create a repository
Create a [new repository](https://github.com/new).
Give it name `git-bas` and choose defaults.
### add remote
From inside your `git-basic`, execute the following command.
```bash
$ git remote add origin https://github.com/baalajimaestro/git-basic.git
```
### git push
Push the changes to Github.
### Create pull request
1. Clone your repo on your local machine.
3. Commit and push the changes to your fork
4. Create a pull request
### git rebase
Rebasing is the process of moving a branch to a new base commit. It is used to keep Git history linear so you will not have merge commits.
```bash
$ git checkout -b feature5
$ echo "I will prefer rebase over merge to avoid merge commit." >> README.md
$ git commit -am "tenth commit. Prefer rebase over merge"
```
Work on master branch.
```bash
$ git checkout master
$ echo "I will prefer merge over rebase as it is easy to understand." >> README.md
$ git commit -am "Merge over Rebase"
```
Rebase command
```bash
$ git rebase feature5 master
```
Fix merge conflicts.
```bash
$ git add README.md
$ git rebase --continue
```
Now view the logs using
```bash
$ git log --oneline --decorate --graph
```
Delete the branch
```bash
$ git branch -d feature5
```
### git cherry-pick
Applying a commit from one branch to another
```bash
$ git cherry-pick <commit-hash>
```
### git alias
Allows you write your own commands or shortcuts. Like we have been using `git log --oneline --decorate --graph`.
```bash
$ git config --global alias.mylog "log --oneline --decorate --graph"
```

View file

@ -1,20 +0,0 @@
---
title: "Google Analytics, the bad guy behind bad PageSpeed Scores"
date: 2021-10-22T10:41:41+05:30
---
I am not bothered about the data being collected by Google, as an ardent user of Google in every way or the other.
And yet, I became a hater of Google Analytics today. All thanks to their script slowing down the site.
My company has been doing page speed analysis for the past few weeks on their websites, and this triggered my curiosity to check my own site's score.
It did fairly well, giving a 70 on mobile, I was kinda surprised how it is that bad, and Google safely hid gtag.js from being shown as the culprit.
My browser of choice, Firefox, basically killed gtag.js from running every time, so I haven't noticed any significant change. Same with my other browser
Vivaldi. When I installed Chrome for this specific purpose, I saw gtag.js take a significant loading time.
Nuking it off and rebuilding the site, bumped my score straight to 95, which seems astonishing.
As a result, I went with self-hosted shynet (https://github.com/milesmcc/shynet/) and it's now available at https://analytics.baalajimaestro.me.
My shynet instance respects DNT, and is also GDPR compliant, should you have any issues with it, feel free to message me on any of the contact options listed [here](https://links.baalajimaestro.me.)

View file

@ -1,189 +0,0 @@
---
title: "Kernel For Newbies"
date: 2020-07-07T12:29:41+08:00
---
Lets gear up with the necessary things.
You would usually need a minimum of a dual core PC, some odd 4GB ram, and atleast 10GB disk free space.
If you dont match the specs, dont worry, we can workaround it.
And then, you need Linux installed, doesnt matter any distro, just grab up probably the latest ubuntu/openSUSE/fedora/Arch or whatever that suits you. Kernels can be compiled on literally any distro. They dont need much of dependencies. For deps, just check out akhilnarang/scripts
Lets jump into the what it is to compile a kernel. So, you have seen a developer sending fancy kernel zips for you, you wanna make your own kernel, with your name stamped on it? Well, thats too easy than you think.
A bit of terminologies………
Since we arent compiling a phone kernel inside a phone, you need a cross-compiler.
__What is cross compiler now?__
A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. For example, a compiler that runs on a Linux amd64 but generates code that runs on Android smartphone (aarch64) is a cross compiler.
__What is aarch64?__
Thats the common architecture for all android smartphones today. Well, there is an aarch32 but, thats too old to be considered in current age.
**So, where do I get a damn cross-compiler, I googled, I cant find it.**
https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads
Go to this link, and grab the toolchain AArch64 GNU/Linux target and is x86_64 host.
Just use some common sense, they are right there visible on that site. They are updated regularly, so be sure to check them out once in a while.
Ok, I have the toolchains, what more?
Can I compile?
Oh yes, you can almost compile now, did you clone the sources?
Probably look at your OEM code or someones code you wanna compile. Clone the sources fully with git.
Next steps, just few path changes, and finally we can hit the compile
> **A toolchain prefix is what all files on that dir start with. Like `aarch64-linux-gnu-***` The first part will remain almost constant. Remember the hyphen. You need to add it.**
Cd to the directory where you have the cross-compiler, and then run this.
`export CROSS_COMPILE=$(pwd)/bin/<toolchain_prefix>-`
Since you arent building a kernel for your PC, tell that to the kernel buildsystem
export ARCH=arm64 && export SUBARCH=arm64
This tells that you are building for arm64 architecture.
Find the defconfig to build.
> **The defconfig is, in simple terms, a file containing a lot of switches and configurations that your kernel build will read and work out the binary. If you donno anything, better dont mess with it.**
All the defconfigs are located at arch/arm64/configs/xxxxx_defconfig
You need to find which defconfig your OEM/the other person used. Use your common sense again.
Next:
The glorious make.
`make O=out <defconfig_name>`
and then
`make O=out -j$(nproc)`
Wait for a while, it takes around 1min-1hr depending on your system specs.
If those commands succeed, you will have an Image, Image-dtb, Image.gz, or Image.gz-dtb file at the end. They will be usually at `out/arch/arm64/boot/Image.gz-dtb` or accordingly.
Assuming you were able to compile the kernel successfully, you now need to flash it!
How do I make a dtb into zip? Rename?
No! Thats not how you do it.
Add this dtb file to the root dir of the cloned anykernel3
https://github.com/osm0sis/anykernel3
Get to the anykernel.sh and use a bit of common sense. Thats all. Your flashable zip must be ready.
Whats next:
**Upstreaming CAF:**
If your device has a qualcomm snapdragon processor, then sure it has CAF support. CAF is known for improving performance and other stuff with their patches.
__What all can you grab?__
Generally people grab QCACLD-3.0 and Techpack. You may also merge their own kernel repos. It contains a bit more latest patches than what your OEM would have shipped.
__How should I merge?__
Merging CAF requires tags. They arent normal repos with branches. They are tagged so that you can fetch a specific tag at any point.
Lets say your processor is Snapdragon 660. Look up for its codename(google), its sdm660.
If you wanna know the latest tag for your processor checkout this link: https://t.me/CAFReleases
Just use telegrams search button and search for your processor.
Mind it these are all tagged with android versions. If you use a kernel thats Pie and merge a CAF tag of android 10, you might be ending with 420 conflicts, not kidding.
- You need to get some patience looking for your tag, as usual
- Get here, https://source.codeaurora.org/quic/la/
- You will find kernel/msm-4.4, 4.9, 4.14 and a bunch others
- According to whats yours, copy that link
- Then its a usual git merge!
- git pull https://source.codeaurora.org/quic/la/kernel/msm-4.4/ {YOUR TAG}
- And boom! Again conflicts! Again resolution!
**QCACLD Upstreaming**
Just look out which android is your OEM/other developer using it on. Because Pie tags can work on 10 while the other way round wont.
You found the tag name, so get to your terminal and follow a few steps.
From LKN chat in telegram,
Initial merge:
```bash
git remote add qcacld-3.0 https://source.codeaurora.org/quic/la/platform/vendor/qcom-opensource/wlan/qcacld-3.0
git fetch qcacld-3.0 <TAG>
git merge -s ours --no-commit --allow-unrelated-histories FETCH_HEAD
git read-tree --prefix=drivers/staging/qcacld-3.0 -u FETCH_HEAD
git commit
```
**Updating to a newer tag**:
```bash
git fetch qcacld-3.0 <TAG>
git merge -X subtree=drivers/staging/qcacld-3.0 FETCH_HEAD
Repeat the above for
qca-wifi-host-cmn and fw-api as well.
qcacld-3.0 source: https://source.codeaurora.org/quic/la/platform/vendor/qcom-opensource/wlan/qcacld-3.0
fw-api source: https://source.codeaurora.org/quic/la/platform/vendor/qcom-opensource/wlan/fw-api
qca-wifi-host-cmn source: https://source.codeaurora.org/quic/la/platform/vendor/qcom-opensource/wlan/qca-wifi-host-cmn
```
If you happen to have some merge conflicts, just understand its some bunch of C code, you can understand the logic and figure it out.
Well, techpack of 4.14 too follows similar scheme as you did for the qcacld.
The repos you need to lookout for are audio-kernel and data-kernel
**Linux Upstream**
__Why upstream?__:
Upstreaming Linux helps you patch some critical vulnerabilities that might have been spotted after the kernel was released.
The point releases like 4.14.170, 171, indicate some vulnerability or performance or maybe even some driver fixes.
They dont usually add major changes.
__How to upstream?__:
Linux upstream can be done from three different places as of now.
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
https://android.googlesource.com/kernel/common/+refs
https://github.com/android-linux-stable/
__What is the diff?__
Kernel/common is done by the same person who deals with merges on kernel.org git.
Its adapted for android, if you want the bleeding edge patches working perfectly on android you need to head right here.
__Android-Linux-Stable:__
This has both CAF patches and Linux stable merged. Its a sweet spot for laziness. Go checkout their readme for more: https://github.com/android-linux-stable/notes/tree/master/trees
Merging any of these is bound to introduce a git conflict. Have fun resolving them.
__Upstreaming your kernel with ASB:__
What's android security patch doing in kernels?
- Well, Google releases security patches every month, and we know that, there's nothing new about it.
But they also fix some vulnerabilities they found on their Pixel Kernel. You can merge them up, showing off to your users that
security is maxxed (Bootloader unlocked, so nothing is safe)
- So lets get started.
- Go to Google kernel/common, if you forgot/donno what it is. Its here https://android.googlesource.com/kernel/common/
- Browse its tags, not branches!
- Look for the ASB-2020-01-05-{kernel-version}-{android-version}
- By android version, it means your kernel's base android version.
- Dont randomly pick an android q patch over android p kernel base. Thats not gonna work!
- Now for merging the tag!
- git pull https://android.googlesource.com/kernel/common/ {your tag you discovered}
- Its gonna throw a real bunch of conflicts, use some C knowledge and common sense to resolve them.
**Building with Clang:**
Clang is an LLVM C/C++/Objective-C compiler, which means, its basically just another C compiler. But whats so special about clang? Its faster!
When you compile 1million files, a bump of few ms on each file, bumps the whole process by minutes.
__Can every kernel build on clang?__
Yes, as long as your kernel is above 3.18
Do I need to do something to make it support?
Grab a clang-patchset from https://github.com/nathanchance/android-kernel-clang
Checkout the branches and decide which one you need.
4.14 and above natively support clang. You dont need to mess with your source.
Have fun hacking!

View file

@ -1,181 +0,0 @@
---
title: "Splitting git configs dynamically between work and personal accounts"
date: 2021-08-24T12:29:41+05:30
---
Earlier this month, I got a new job!
And they had all their code on GitHub, which seemed kinda cool too. But they wanted me to signup to GitHub with the work email.
So, I did, and simply tried to add my SSH key from main account, to the work account and GitHub simply refused it.
I did a huge workaround for this and will walk you through it on this post!
What we would be doing?
- Create an SSH key
- Create a GPG key
- Dynamic git configuration to match based on the folder path
**Creating SSH Key**
SSH is a superior means of connecting with Git servers, rather than HTTPS, in terms of speed, ease and the security ssh keys bring.
Once set up, you can simply forget the need for authentication since everything happens on the fly.
To add upon the security we would be using the ED25519 algorithm instead of the traditional RSA.
Open your terminal and type:
```bash
ssh-keygen -a 100 -t ed25519 -b 521 -f ~/.ssh/id_ed25519.workplace -C "me@myworkplace.com"
```
In case you get `ssh-keygen: Command not found` find out how to install ssh on your specific distro.
OpenSSH is provided by default in windows and accessible on Powershell
Once the key generation is done, you need to store the private key very very safely. If you couldn't figure out which your
private key is, then the file named `~/.ssh/id_ed25519.workplace` would be your private key and `~/.ssh/id_ed25519.workplace.pub`
is your public key.
Save both the files to Google Drive or any place you trust upon for cloud storage.
**How to add this key to GitHub?**
Type this on terminal
`cat ~/.ssh/id_ed25519.workplace.pub`
On windows, you can navigate to `C:\Users\YourUsername\.ssh\` and open the file on notepad
Goto https://github.com/settings/keys
And press the new ssh key
And copy the output into the text box provided
**Creating GPG key**
When you sign a Git commit, you can prove that the code you submitted came from you
and wasn't altered while you were transferring it.
You also can prove that you submitted the code and not someone else.
It also helps prevent untrustworthy developers from pushing backdoor commits with your name on them.
We would again be using the Curve25519 algorithm for increased security.
Open your terminal and type:
`gpg --expert --full-gen-key`
Choose `ECC (sign only)`
Curve25519 on the following menu
The rest of the process should be self-explanatory.
Export the private key first, so that we can save the key back in case of data corruption.
Type `gpg --list-secret-keys` to find the key id to export.
You should see ed25519 followed by date.
Grab the key id that's on the next line (HEX characters like 0F35EA585......)
Type this on the terminal to export your newly created gpg key
```bash
gpg --export-secret-keys YOUR_KEY_ID > work.gpg
```
Upload the work.gpg to Google Drive or any place you trust upon for cloud storage.
**Setting GPG Key on GitHub**
Type this on terminal:
To find your public key id, which is different from the secret key-id,
Run
`gpg --list-keys`
And your key id should be displayed in the same format as the secret key did.
```bash
gpg --export --armor YOUR_KEY_ID
```
Goto https://github.com/settings/keys
And press the new gpg key
And copy the output into the text box provided
**Dynamic Configuration..... (Here comes the magic)**
First, create a ssh config to split between our two accounts.
Edit `~/.ssh/config` and add these contents
```bash
#personal account
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
#work account
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519.workplace
```
Ensure your permissions on the file is 600 if you are using linux/mac.
Next is to do the configuration for git.
Nuke your existing user configs by typing this on terminal
```bash
git config --global --unset user.name
git config --global --unset user.email
```
Once both are unset, let's set our personal details in a new gitconfig file
```bash
git config --file=${HOME}/.gitconfig-personal --add user.name thatsme
git config --file=${HOME}/.gitconfig-personal --add user.email personal_mail@gmail.com
```
Once that's done, let's add our work details to another gitconfig file
```bash
git config --file=${HOME}/.gitconfig-work --add user.name thatsmebutworking
git config --file=${HOME}/.gitconfig-work --add user.email thatsme@workdomain.com
```
Our gpg settings for both accounts,
You need to find your key id which is not the same as your secret key id which you used for exporting it.
Find the gpg key corresponding to the right email, and then copy them up!
Type `gpg --list-keys` and it should show your key id in a similar fashion.
```bash
git config --file=${HOME}/.gitconfig-personal --add user.signingkey "YOUR_KEY_ID"
git config --file=${HOME}/.gitconfig-personal --add commit.gpgsign true
```
```bash
git config --file=${HOME}/.gitconfig-work --add user.signingkey "YOUR_KEY_ID"
git config --file=${HOME}/.gitconfig-work --add commit.gpgsign true
```
For SSH redirections,
```bash
git config --file=${HOME}/.gitconfig-work url."git@github.com-work:".insteadOf https://github.com/
git config --file=${HOME}/.gitconfig-personal url."git@github.com-personal:".insteadOf https://github.com/
git config --file=${HOME}/.gitconfig-work url."git@github.com-work:".insteadOf "git@github.com:"
git config --file=${HOME}/.gitconfig-personal url."git@github.com-personal:".insteadOf "git@github.com:"
```
Once this is done, we are left with a small piece of work, making git load `~/.gitconfig-personal` and `~/.gitconfig-work` on the fly.
The only issue here is, you need to ensure your personal code is stored at `~/code-personal` and your work code at `~/code-work`. You can obviously customise these paths.
```bash
git config --global --add includeif.gitdir:${HOME}/code-personal/.path ${HOME}/.gitconfig-personal
git config --global --add includeif.gitdir:${HOME}/code-work/.path ${HOME}/.gitconfig-work
```
Once this is done, you can create a dir inside `code-work` or `code-personal` and do a `git init` inside that folder and check `git config --get user.email` if it matches your profile!
---
It would be actually cool if there was a way to set a global default and override, but I haven't figured one yet. Do let me know in comments, or you can always feel free to discuss with me on any of the listed methods of communication on the home page!

View file

@ -1,171 +0,0 @@
---
title: "Hosting Trojan-GFW with Traefik"
date: 2021-12-04T21:24:00+05:30
---
For those who don't know what trojan-gfw is, please google up.
I searched far and wide on the internet, but there isn't any proper document or article that guided me to it.
I managed to self-host it, so I'll share the steps with you.
### What you need:
- Traefik (obviously)
- A domain (obviously)
- Certbot installed on the host
- A snakeoil caddy server (preferably some valid server)
Let's get started,
Connect to your server over SSH and then let's issue a certificate for the trojan to work
Change the domain name to whatever your VPN would be hosted on
```
sudo certbot certonly \
--standalone \
-m baalajimaestro@computer4u.com \
-d something.baalajimaestro.me
```
Once you get the certificate issued, let's start off working on the config for trojan-go
```
{
"run_type": "server",
"local_addr": "0.0.0.0",
"local_port": 443,
"remote_addr": "trojan-caddy",
"remote_port": 80,
"log_level": 2,
"log_file": "",
"password": [
"somethingsupersecret"
],
"disable_http_check": false,
"udp_timeout": 60,
"ssl": {
"verify": true,
"verify_hostname": true,
"cert": "/etc/trojan/cert.pem",
"key": "/etc/trojan/private.key",
"key_password": "",
"cipher": "",
"curves": "",
"prefer_server_cipher": false,
"sni": "something.baalajimaestro.me",
"alpn": [
"http/1.1"
],
"session_ticket": true,
"reuse_session": true,
"plain_http_response": "",
"fallback_addr": "",
"fallback_port": 0,
"fingerprint": "firefox"
},
"tcp": {
"no_delay": true,
"keep_alive": true,
"prefer_ipv4": true
},
"router": {
"enabled": false,
"bypass": [],
"proxy": [],
"block": [],
"default_policy": "proxy",
"domain_strategy": "as_is",
"geoip": "$PROGRAM_DIR$/geoip.dat",
"geosite": "$PROGRAM_DIR$/geosite.dat"
},
"websocket": {
"enabled": true,
"path": "/socketplug",
"host": "something.baalajimaestro.me"
},
"shadowsocks": {
"enabled": false,
"method": "AES-128-GCM",
"password": ""
},
"transport_plugin": {
"enabled": false,
"type": "",
"command": "",
"plugin_option": "",
"arg": [],
"env": []
},
"forward_proxy": {
"enabled": false,
"proxy_addr": "",
"proxy_port": 0,
"username": "",
"password": ""
},
"mysql": {
"enabled": false,
"server_addr": "localhost",
"server_port": 3306,
"database": "",
"username": "",
"password": "",
"check_rate": 60
},
"api": {
"enabled": false,
"api_addr": "",
"api_port": 0,
"ssl": {
"enabled": false,
"key": "",
"cert": "",
"verify_client": false,
"client_cert": []
}
}
}
```
### What changes do you need?
- The password field, generate a pretty strong password that someone cannot guess.
- sni and WebSocket host, to whatever domain you chose earlier
The rest of the configuration should be fine, if you need to tweak anything feel free to look into trojan-gfw docs.
Spin up a snakeoil caddyserver so that trojan can proxy to it whenever it detects non-trojan traffic.
```
docker run -d --restart unless-stopped \
--name trojan-caddy \
--network docker-network \
caddy:alpine
```
Now, for trojan itself, check to see the paths for the certificate, and the config and your HostSNI is edited properly to match your domain.
```
docker run -d --restart unless-stopped \
--name trojan-go \
--network docker-network \
-v /home/baalajimaestro/dockerhome/trojan/config.json:/etc/trojan/config.json \
-v /etc/letsencrypt/live/something.baalajimaestro.me/fullchain.pem:/etc/trojan/cert.pem \
-v /etc/letsencrypt/live/something.baalajimaestro.me/privkey.pem:/etc/trojan/private.key \
-l traefik.enable=true \
-l traefik.tcp.routers.trojan-gfw.rule='HostSNI(`something.baalajimaestro.me`)' \
-l traefik.tcp.routers.trojan-gfw.tls.passthrough="true" \
-l traefik.tcp.services.trojan-gfw.loadbalancer.server.port="443" \
p4gefau1t/trojan-go /etc/trojan/config.json
```
Now if you visit something.baalajimaestro.me, you should see Caddy's welcome page.
Ensure you point it to rather some valid page instead of the congratulations page of caddy, so that your ISP doesn't grow sus of you transferring a huge amount of data to a "Congratulations" page.
### How does this work?
We are doing a TLS passthrough on traefik so that it lets trojan handle the TLS itself for the proxy domain.
### Places to improve:
- Put it behind a CDN (I used Cloudflare), so that the connection latency improves much better and someone doesn't get your server IP.