Posts

More than one ssh key for the github

 * Generate new key: [18:05:20 harsshal@dell:~/projects]$ ssh-keygen -t ed25519 -C "harsshal@gmail.com" * Add new key in the ssh config [18:07:35 harsshal@dell:~/projects]$ cat ~/.ssh/config  TCPKeepAlive yes Host 10.234.1.112   HostName 10.234.1.112   User harshal # Default GitHub Host github.com   HostName github.com   User git   IdentityFile ~/.ssh/id_rsa Host github-public   HostName github.com   User git   IdentityFile ~/.ssh/id_ed25519.pub Host github-personal   HostName github.com   User git   IdentityFile ~/.ssh/id_ed25519 * Clone the repo [18:09:02 harsshal@dell:~/projects]$ git clone git@github-personal:harsshal/icarus_gl.git

Jupyter notebook setup

jupyter notebook password cat ~/.ipython/profile_default/startup/start.ipy import os import dotenv dotenv.load_dotenv('/home/'+os.environ['LOGNAME']+'/.env',override=True) import pandas as pd # Pandas options pd.options.display.max_columns = None pd.options.display.max_rows = None pd.options.display.max_colwidth = None           pd.options.display.float_format = '{:,.2f}'.format print("Everything loaded") jupyter notebook --notebook-dir [LOCATION] --no-browser --ip=192.168.255.X jupyter nbconvert --execute --to html notebook.ipynb

Installing a module directly from repo

pip install git+https://github.com/blampe/IbPy.git pip install git+https://github.com/atreyuxtrading/atreyu-backtrader-api.git

command line / bash variable in awk command

 This is how we use a command line / bash variable (named num) in a awk command. We define an awk  variable 'var' with -v option. This also shows use of BEGIN block. awk -F, -v var=$num 'BEGIN{srand(var)} {print $1","$2","rand()}' file_name 

Change nameserver entries in resolve.conf

 We can directly change the contents of the file but they dont seem to be in effect. So I added Google's nameserver in the file as follows :  $ sudo cat /etc/resolvconf/resolv.conf.d/base  nameserver 8.8.8.8 nameserver 8.8.4.4 And then updated the file as follows :  $ sudo resolvconf -u   we can also just update /etc/resolve.conf and it will be in effect immediately. $ sudo sed -i '1 i\nameserver 8.8.8.8\nnameserver 8.8.4.4' /etc/resolv.conf  To remove the changes : $ sudo sed -i '1,2d' /etc/resolv.conf 

renaming all the files in a folder

 IF we want to rename all the files with a part of the file we can do something following: for file in $(ls); do nn=$(echo $file | awk -F'_' '{print($2)}'); mv $file $nn; done

shell loop through dates

 Easy command to loop through the dates :  for i in 2022-01-{01..31} 2022-02-{01..15}; do echo $i; done More comprehensive command : d=2015-01-01 while [ " $d " != 2015-02-20 ]; do echo $d d=$(date -I -d " $d + 1 day" ) done