Skip to content

Instantly share code, notes, and snippets.

View eblokhin's full-sized avatar

Eugene Blokhin eblokhin

View GitHub Profile
@eblokhin
eblokhin / gist:e61b2b5316fe2bab1666d71330686dbe
Last active June 21, 2025 16:46
How to deploy npm project to shared hosting using github actions + rsync

1. Generate SSH keys

For security reasons, it's better to generate the keys locally.

cd ~/.ssh
ssh-keygen -t rsa -b 4096 -C "[email protected]"

Use a name like hosting-key.

2. Copy the public key to the server

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@eblokhin
eblokhin / github_bitbucket_multiple_ssh_keys.md
Created September 30, 2024 06:00 — forked from yinzara/github_bitbucket_multiple_ssh_keys.md
Managing SSH keys and repo cloning using multiple accounts on GitHub and BitBucket

Why Multiple SSH keys?

There are numerous reasons you may need to use multiple SSH keys for accessing GitHub and BitBucket

You may use the same computer for work and personal development and need to separate your work.

When acting as a consultant, it is common to have multiple GitHub and/or BitBucket accounts depending on which client you may be working for.

You may have different projects you're working on where you would like to segregate your access.

Generate UUID

Python

python -c 'import uuid; print(str(uuid.uuid4()))'

JS

crypto.randomUUID()

Parse large JSON file

cat response.json | python -m json.tool > pretty-response.json

Remove all untracked local branches:

git checkout master
git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D

Another way:

git fetch -p ; git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
@eblokhin
eblokhin / gist:f269fc6c4ca9798c9f4b54020f5c94f2
Last active January 10, 2023 13:50
Fix bash with oh-my-bash to keep the working directory on a new tab

OHMYBASH to open in new tab in current directory

Add the following to .bashrc or whatever config file you use

# Open new tab in current directory
[[ -f /etc/profile.d/vte.sh ]] && . /etc/profile.d/vte.sh