Skip to content

Instantly share code, notes, and snippets.

View ghassemiN's full-sized avatar
👾

Nasrin ghassemiN

👾
View GitHub Profile
@ghassemiN
ghassemiN / docker_ps_network.txt
Last active March 21, 2024 12:34
Get docker ps + network's name
edit .bashrc and add following line :
docker_ps_networks() {
docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Image}}\t{{.Status}}" \
| awk 'NR==1{print $0 "\tNetworks"} NR>1{print $0 "\t" syste
m("docker inspect -f '\''{{range $key, $value := .NetworkSettings.Networks}}{{print $key \":\" $value.NetworkID \", \"}}{{end}}'\'' " $1)}'
}
If there is no need to countainer ID, just delete " {{.ID}}\t".
After adding to the file, source the bashrc file or restart the terminal.
docker_ps_networks
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQGNBGLiTwkBDADDloAStGDXf9mz22pkVBSla36MA5ylVVXcJZ07Ny7rfkWOk2eN
S1lwotHmEsShbgwXd63c6TdpePvMnOn4vATJvyKBrNKuMSZ3GC0ATJy+bzKQuq3a
UJvWs8JPCw61s41xl+qR/Sd59gilTKiRLaMSfITYVujG8OAMQe9Bo59ujFkZcl3d
IBrAqYkvLWIPQx4EfDDlSH1VwXM8t1iM1A3XtCbpzUUhDVXJngaKjY36eF88pc3s
U+OzlVS7nxWwNalNBKkqQ1/HwvAchsPeHI9mU3thgCONSjNWhfVvV626beHGf9bb
9GkB5zPe1fKNMQwFhaMON3nCUnC0av6H0wyjzVEjHOj5oVetAfQIW8rkN5cNd6mw
oX+M+zQXnVYgkotNgcnYTEFh1CeDZ6uT/tLmgWgSjNonHwW7/527gi5QDGycFMsm
oHNZa1NufM0ZZYbEzjtA04ENg5viPQABBmkOhgktc/UkXOWhKrXVrWP80rpSYq4C
@ghassemiN
ghassemiN / README.md
Last active June 16, 2022 08:31
Go concurrency

There was a programming challnege:

On average, how many times do we have to roll the dice to get the number 6? Imagine that the people of your country each have a dice. They roll until they get the number 6. Then, they announce how many times they had to roll the dice to got 6. The question is, what is the average of these numbers?

I solve it by python and got answer. the answer is 6. But my question is about procceing time, my code use only one core. python for 1 milion :

Keybase proof

I hereby claim:

  • I am ghassemin on github.
  • I am nasrin (https://keybase.io/nasrin) on keybase.
  • I have a public key ASCTU7evrqFXQI2scQFKSl8HZ8GyrotRmXEYOq998DWkXgo

To claim this, I am signing this object:

#!/bin/bash
# Add my ssh-key to ubuntu root user and active ssh root login
# Login as root or run with sudo
# wget -q -O - "https://gist.githubusercontent.com/ghassemiN/4158c4d63544c7991685b8af97f75333/raw" | bash -
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi