This commit is contained in:
nm1 2026-11-04 00:33:23 +05:30
commit 74ae93a96e
8 changed files with 94691 additions and 0 deletions

View file

@ -0,0 +1,9 @@
- https://docs.github.com/en/authentication/securing-your-account-with-two-factor-authentication-2fa/about-mandatory-two-factor-authentication
I have to make a E2E chat application where users can create a room and invite others. RSA can be used to send text messages easily.
To send message from user A to users B,C,D and E i need to encrypt my message 4 times for different users using public key of B,C,D and E and these encrypted version of messages to them. Its not a big deal for text.
But if i have to encrypt larger files using RSA then i have to make encrypted version of files 4 times for different 4 users and it would be much slower if there are like 100s of users. So a smart way is to instead of encrypting files using RSA, we can encrypt using any symmetric encryption then encrypt the keys using RSA and send it
Users will get different versions of keys but only 1 encrypted version of that file

View file

@ -0,0 +1,122 @@
Basics
- https://www.nobledesktop.com/learn/git/git-branches
[Git Branches_ List, Create, Switch to, Merge, Push, & Delete (11_2_2023 4_41_42 PM).html](../../../_resources/Git%20Branches_%20List,%20Create,%20Switch%20to,%20Merge,%20Push.html)
- Branches
- If you want to push your code to a different branch of the remote repository on Codeberg, you can specify the branch in the git push command. Here's how you can do it:
Assuming you have already added the remote repository using a command like:
`git remote add origin your-codeberg-repo-url.git`
You can push your code to a different branch as follows:
`git push origin your-local-branch-name:your-remote-branch-name`
Here's what each part of the command does:
your-local-branch-name: Replace this with the name of the local branch you want to push. This is the branch that contains the code you want to deploy.
your-remote-branch-name: Replace this with the name of the branch in the remote repository (on Codeberg) where you want to push your code.
For example, if you have a local branch called "feature-branch" and you want to push it to a branch named "production" on Codeberg, you would use the following command:
`git push origin feature-branch:production`
This command will push the code from your local "feature-branch" to the "production" branch on the remote repository on Codeberg. Make sure the branch names are accurate to avoid any conflicts or errors.
**to change default branch**
`git push -u origin --all`
- undo git add
For specific files use
`git reset <file>`
For all files
`git reset HEAD`
- diff
When using diff and we wanna avoid the changes in whitespace bcz of pretty formatting then use
`git diff -w`
or
` git diff -w --numstat`
When using diff filemode ie permissions is different by default in windows and unix machines so when using git diff output can be
```text
old mode : 100644
new mode : 100755
```
So to fix it use
`git config core.filemode false`
https://stackoverflow.com/questions/1257592/how-do-i-remove-files-saying-old-mode-100755-new-mode-100644-from-unstaged-cha
- pull requests
1. after cloning the repo(original one) and cd into it fetch the pull request to branch named 'local-branch-name'. name can be anything.
`git fetch origin pull/PR_NUMBER/head:local-branch-name`
2. Then switch to `local-branch-name` and check it, if changes are good then merge it by
```bash
git checkout main # or develop, or another branch
git merge local-branch-name
```
- to list all files tracked by github use `git ls-files`
- to push non interactively use this
found this, this is the way
`git push https://$GIT_USERNAME:$GIT_TOKEN@github.com/username/repo.git`
&nbsp;
to have different user and email for repo use this
```sh
git config user.name "Your Work Name"
git config user.email "work@email.com"
```
&nbsp;
**clearing .git folder**
sometimes git folders can become very large. few things to clear is
to check issues or dangling blobs(uncommited files/data to repo)
`git fsck --full`
and to remove dangling blobs
`git prune`
but if it got commited then
for untracking
```sh
git rm -r --cached bin/
git rm -r --cached obj/
```
and for actual removing
```sh
# using filter branch
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch path/to/bigfile.zip" \
--prune-empty --tag-name-filter cat -- --all
# Clean up refs and gc
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now --aggressive
# Force push
git push origin --force --all
git push origin --force --tags
```
instead of filter branch, this can be used too, though it needs to be installed `pip install git-filter-repo --break-system-packages`
```sh
git filter-repo --path path/to/bigfile.zip --invert-paths
```
&nbsp;
**applying patches **
from a file
`git apply --check ytfetch-403-fix.patch`
If it doesn't return anything, that's good.
then
`git apply ytfetch-403-fix.patch`
create patch with
`git diff > my_patch.patch`

View file

@ -0,0 +1,27 @@
Multi account with ssh keys on a device
https://www.techaddressed.com/tutorials/add-verify-ssh-keys-gitea/
- Linux
The permissions have to be set like this
This means that the permissions on that file are also set incorrectly, and can be adjusted with this:
`sudo chmod 644 ~/.ssh/known_hosts` : it means read and write for user and read for group and others
Finally, you may need to adjust the directory permissions as well:
`sudo chmod 755 ~/.ssh` : it means read,write,execute for user, read,execute for group and others
This should get you back up and running.
&nbsp;
The keys need to be read-writable only by you:
`chmod 600 ~/.ssh/id_rsa`
Alternatively, the keys can be only readable by you (this also blocks your write access):
`chmod 400 ~/.ssh/id_rsa`
600 appears to be better in most cases, because you don't need to change file permissions later to edit it. (See the comments for more nuances)

View file

@ -0,0 +1,80 @@
branches
1. suppose there is a problem
```txt
if i have to make multiple versions of a page and thats where version control like git helps and i use multiple branch for multiple versions of my page.
so lets say i create a page which has
1. blue background
2. red foreground
now i have created a branch v2 which is branched from this earlier master branch
now this page have
1. black bg
2. white fg
and few more changes to be done
3. rectangle div at center of screen
and now my boss saw my both version and preferred version 1 ie master branch but master branch is lacking 3rd change
so how do i get changes from master branch and also new changes from v2 and create another branch so it have
1. master branch properies ie blue bg and red fg and 3rd property ie rectangle div at center of screen
```
then
maybe this will help
https://joseewouters.nl/blog/cherry-picking-with-git-in-your-terminal/
if editing 1st and 2nd property has separate commit named `edit colors` and adding rectangle div have commit named `adding container` then go to v2 and craete a branch from this `git checkout -b v3`
Now using rebase
`git rebase -i master`
this will be the output
```txt
pick a1b2c3 edit colors
pick d4e5f6 adding container
```
change to
```txt
edit a1b2c3 edit colors
pick d4e5f6 adding container
```
now when u save this, it will stop the git to that edit colors commit
now do this
`git reset HEAD~` ( move back to parent commit of HEAD )
as we want to actually dont want edit colors thing to be taken place. as the edit colors commit changes has been applied here so we need to move back to parent commit of HEAD
now make changes manually here as we r just editing changes of one commit without dealing with others
now add commits
```sh
git add file.txt
git commit -m "Add center div container"
```
there can be more commits after this and we may not need to add all of them
then just do
`git rebase --continue`
to abort all this in between in case things can get messy use
`git rebase --abort`
above steps have a manual appraoch too bcz changes to be made before staging is still to be done manually.
more git rebase words
```txt
Keep commit : pick
Modify / split commit : edit
Rename commit : reword
Combine commits : squash
Auto-combine commits : fixup
Remove commit : drop
Run command : exec
```
in vscode accept combination to merge changes in merge editor or just do it manually after dropping one of commit
**and maybe this might help**
after forking it, keep one branch unchanged to always follow upstream. Periodically sync the fork so the upstream branch is up to date. Periodically merge changes you want to your other branches
also
git rebase implies adding your commits after the other guys'
git merge would add their commits after yours

View file

@ -0,0 +1,42 @@
- Hosting static pages
1. Create a public repository named pages to make the site available at the main subdomain.
or
Create a branch pages in a public repository:
`git switch --orphan pages`
`git rm --cached -r . `
2. Push your static content, HTML, style, fonts, images or anything else.
3. Access your new website using this link:
https://USERNAME.codeberg.page[/REPOSITORY][/@BRANCH]
or
To use a custom domain, create a file .domains in your repository with the domain name you wish to use.
Then, add a DNS record for that domain:
CNAME [[branch.]repo.]user.codeberg.page.
Or for apex domains where CNAME doesn't work:
ALIAS codeberg.page.
TXT [[branch.]repo.]user.codeberg.page
If ALIAS isn't supported, use A & AAAA instead:
A 217.197.91.145
AAAA 2001:67c:1401:20f0::1
\+ TXT as above
4. Example: Repo name: https://broSahru.codeberg.page/test/
- Hosting react pages
Deploy build folder manualluy
```bash
git init
git add .
git commit -m "Initial build"
git remote add origin your-codeberg-repo-url.git
git push -u origin master
```
Also make sure that in package.json there is a field
`"homepage" : "https://broSahru.codeberg.page/test"`

View file

@ -0,0 +1,6 @@
extras
tips
1. go to any project, click on the commit, add .patch in the URL bar and it will most likely show you an email you can message without it looking stupid on github
2. to get personal aaccess token go to this url
https://github.com/settings/tokens

View file

@ -0,0 +1,13 @@
forgejo
for self hosted instance do this
1. get binary from codeberg release page
https://codeberg.org/forgejo/forgejo
2. create `app.ini` file and have custom port like this
```ini
[server]
HTTP_PORT = 3005
```
3. finally open this executable while also having path of app.ini file
`./forgejo-15.0.3-linux-amd64 --config ./app.ini`
4. for overview tab like in github repo needed to be create with name `.profile` instead of username and add README.md there