Posts

python snippet

Creating pr function instead of print yoo = 7 def names (thing): return [name for name , ref in globals ().items() if ref is thing][ 0 ] # print(names(yoo)) def pr (varname): print (names(varname)+ ": " , varname) pr(yoo)

Adding terminal title

Open bashrc gedit ~/.bashrc Add below line in end of the file function set-title() { if [[ -z "$ORIG" ]]; then ORIG=$PS1 fi TITLE="\[\e]2;$*\a\]" PS1=${ORIG}${TITLE} } put command source ~/.bashrc Done now you can add title in terminal tab set-title Hello

Creating blocks in gist.github to show on bl.ock.org

1. Create an account, if required, at https://gist.github.com/. 2. Go to your personal page eg https://gist.github.com/krajiv26. 3. Click New gist. Type in gist description. 4. We cant create here any folder so create .block to attach files in future.  Type in gist description 5. Also add Content for .block file which will be shown on bl.ock.org boxes list 6. Now click on Create Public gist. This will create a public gist. 7. Start editing just crated .block  8. Add files by "Add" below and must create index.html file and save 9. Go bl.ock.org to see your block

Creating OpenCv Logo with OpenCv

Image
OpenCV logo ¶ In [177]: from matplotlib import pyplot as plt % matplotlib inline In [178]: import cv2 In [179]: # Load an color image in grayscale ocvimg = cv2 . imread ( 'opencv-logo-white.png' , 1 ) plt . imshow ( ocvimg ) plt . xticks ([]), plt . yticks ([]) # to hide tick values on X and Y axis plt . show () In [180]: import numpy as np # Create a black image img = np . zeros (( 512 , 522 , 3 ), np . uint8 ) In [181]: img = cv2 . ellipse ( img ,( 256 , 100 ),( 98 , 98 ), 60 , 60 , 360 , 255 , - 1 ) plt . imshow ( img ) plt . xticks ([]), plt . yticks ([]) # to hide tick values on X and Y axis plt . show () ...

Creating new virtual env in Python3 core

First install virtualenv package pip3 install virtualenv Now you can create new environment lets flaskblog python3 -m virtualenv flaskblog Now Source it source flaskblog/bin/activate Use below command to quit environment deactivate You can alway check environment with  which python3

Adding Intellij Idea link in Application Launcher in Lubuntu

cd /usr/share/applications sudo nano intelij-idea.desktop Write the content as  #!/usr/bin/env xdg-open [Desktop Entry] Version=1.0 Name=Intelij Comment=Intelij Idea Exec=/home/rajiv/ideaIC-2018.2.2/idea-IC-182.4129.33/bin/idea.sh Terminal=false Type=Application Categories=Development; Icon=/home/rajiv/ideaIC-2018.2.2/idea-IC-182.4129.33/bin/idea.png save and close this file Now you can see Intelij under Programming menu.

installing anaconda for python 3.6

Conda installation Download conda installer sh file form site https://www.anaconda.com/download/#linux bash Anacondax-x.x.x.x-Linux-x86_64.sh First time to create conda envoirment conda create --name my_env python=3 move into envoirment source activate my_env installing any package conda install ggplot searching any package conda search ggplot getting list of all linked (can be installed) packages conda list closing environment source deactivate Once it is install you can use it with Jupyter notebook, Rodeo or Spyder Using Jupyter Notebook jupyter notebook Once launched in browser choose New => Python3 Python command in Rodeo http://rodeo.yhat.com/docs/ Go settings and change command path as : ~/anaconda3/envs/my_env/bin/python3.6 or /home/rajiv/anaconda3/envs/my_env/bin/python3.6 Python command in Spyder Change interpretor path : ~/anaconda3/envs/my_env/bin/python3.6 or /home/rajiv/anaconda3/envs/my_env/bin/python3.6 Adding R Langu...