How to create and enable SSH Keys for github

Step1: Creating the Key Pair on OSX and Linux

>ssh-keygen -o -b 4096

>Enter file in which to save the key (/root/.ssh/id_rsa): press enter key

>Enter passphrase (empty for no passphrase): press enter key

>Enter same passphrase again: press enter key

output on CMD

Your identification has been saved in /root/.ssh/id_rsa

Your public key has been saved in /root/.ssh/id_rsa.pub

The key fingerprint is:

SHA256:nmBGy87NsXz49LtLSJc73Mxg8xwEx4QsPZ+OOfOu9u8 root@vishavjeet-Python

......

Step3: Display the public key content with the cat command and copy it :

> cat /root/.ssh/id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2...........KvAszrTVoGK8rgLgC/iw== root@vishavjeet-Python

Step4: Save the Content of the Public Key on the SSH Keys Section on BitBucket

url link: https://github.com/settings/keys

Add New SSH Key

Step5: set remote:

>git remote set-url origin git@github.com:vishavjeet/reponame.git


For More Details

View More...

What is Pickling in Python?

Python pickle module is used for serializing and de-serializing a Python object structure.

Pickling” is the process whereby a Python object is converted into a byte stream,

and “unpickling” is the inverse operation, whereby a byte stream is converted back into an object

Example: 

import pickle

def storeData():

  db = {}
  db['vishavjeet'] = {'key': 'Vishavjeet', 'name': 'Vishavjeet Singh', 'age': 28, 'pay': 40000}
  db['Scarpion'] = {'key': 'Scarpion', 'name': 'Scarpion', 'age': 28, 'pay': 50000}
  # Its important to use binary mode
  with open('my_pickle_file', 'ab') as f:
    pickle.dump(db, f) # source, destination

def loadData():
  # for reading also binary mode is important
  with open('my_pickle_file', 'rb') as f:
    db = pickle.load(f)

  for keys in db:
    print(keys, '=>', db[keys])

storeData() # pickling
loadData() # unpickling
View More...

Vim Command

1. Insert mode (Where you can just type like normal text editor. Press i for insert mode)

2. Command mode (Where you give commands to the editor to get things done . Press ESC for command mode)

Most of them below are in command mode

x - to delete the unwanted character

u - to undo the last the command and U to undo the whole line

CTRL-R to redo

A - to append text at the end

:wq - to save and exit

:q! - to trash all changes

dw - move the cursor to the beginning of the word to delete that word

2w - to move the cursor two words forward.

3e - to move the cursor to the end of the third word forward.

0 (zero) to move to the start of the line.

d2w - which deletes 2 words .. number can be changed for deleting the number of consecutive words like d3w

dd to delete the line and 2dd to delete to line .number can be changed for deleting the number of consecutive words

View More...

Deployment On DigitalOcean for Python Flask project

>sudo apt install libapache2-mod-wsgi-py3

www>mkdir flaskapp

>cd flaskapp

>mkdir flaskapp

>sudo apt install python3-pip

>pip3 install virtualenv

>sudo virtualenv venv

>source venv/bin/activate

>pip3 install flask request pandas flask-slqalchemy

>cd /etc/apache2/sites-available

>cp 000-default.conf flaskapp.conf


>nano flaskapp.conf

Open flaskapp.conf and copy paste below code:

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.python-ds.com
ServerName python-ds.com
ServerAlias www.python-ds.com
ServerAdmin python.ds.com@gmail.com
WSGIScriptAlias / /var/www/flaskapp/flaskapp.wsgi
<Directory /var/www/flaskapp/flaskapp/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/flaskapp/flaskapp/static
<Directory /var/www/flaskapp/static/>
Order allow,deny
Allow from all
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<Directory>

>sudo a2ensite flaskapp.conf

>service apache2 restart

>cd /var/www/flaskapp

>sudo nano flaskapp.wsgi

open flaskapp.wsgi and copy paste below code according to your need:

#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/flaskapp/")
from flaskapp import app as application
application.secret_key = '\xfd{H\xe5<\x95\xf9\xe3\x96.5\xd1\x01O<!\xd5\xa2\xa0\x9fR"\xa1\xa8'

>python3 __init__.py

>service apache2 restart

View More...

Deployment On DigitalOcean for php/html project

Step1: SSH Login for server access

$> ssh root@168.0.x.x.0

>cd home

>cd /

>adduser vishavjeet

>usermod -aG sudo vishavjeet

>ufw app list

>ufw status

>ufw allow OpenSSH

>ufw enable

>ufw status

>exit()

#login as vishavjeet

> sudo apt update

>sudo apt install apache2

>sudo ufw app list

>sudo ufw app info "Apache Full"

>sudo ufw allow in "Apache Full"

>sudo apt install mysql-server

>sudo mysql

>select user, authentication_strings, plugin, host from myqsl.user;

>exit

>sudo mysql -p

>exit

>sudo apt install php libapache2-mod-php php-mysql

#how can open default index.php

>nano /ect/apache2/mods-enables/dir.conf

<ifModule mod.dir>

Dir index.php index.cgi, ..index.html

...

>sudo service apache2 restart

>sudo apt install phpmyadmin php-mbstring php-gettext

>sudo phpenmod mbstring

>sudo service apache2 restart

>sudo mysql -p

>mysq>grant all privilleges en *.* 'vishavjeet'@'localhost' with grant option;

www>mkdir project_first

>ls -lart

>sudo chown -R $USER:$USER project_first

>ls -lart

project_first>nano index.html

>cd /etc/apache2/sites-available/

>cp 000-default.conf project_first.conf

>ls

000-default.conf project_first.conf

>sudo nano project_first.conf

<VirtualHost *:80>

ServevAdmin vishavjeet@tech-overflow.com

ServerName tech-overflow.com

ServerAlias www.tech-overflow.com

DocumentRoot /var/www/project_first

>

>sudo a2ensite project_first.conf

>sudo a2dissite 000-default.conf

>sudo service apache2 restart

>sudo apache2ctl config test

Step2:  Domain configuration in Goddady

A @ 192.241.142.132 600sec

Cname www @ h hours


View More...

First Previous 1 2 3 4 5 Next Last