Labels

Sunday, December 27, 2020

Install latex in Chromebook

// install basic version

sudo apt-get install texlive-latex-base

sudo apt-get install biblatex

sudo apt-get install texlive-fonts-recommended

#sudo apt-get install texlive-science

sudo apt-get remove *texlive*doc


// Cannot determine type of tlpdb

apt-get install xzdec

tlmgr init-usertree

// tlmgr: Remote repository is newer than local (2018 < 2020)

tlmgr option repository ftp://tug.org/historic/systems/texlive/2019/tlnet-final

// search the missed ".sty"

tlmgr search --global --file "/times.sty"

// install the package included ".sty" 

tlmgr install psnfss


Find sty file by yourself:
https://www.tug.org/texlive//Contents/live/texmf-dist/tex/latex/

Reference:

Saturday, December 19, 2020

Matplotlib notes

# adjust the tick font size 

ax.tick_params(axis='both', which='minor', labelsize=8)

#set tick to right side

ax.yaxis.tick_right()

# remove space between start and end of the axis
plt.margins(x=0)
ax.margins(x=0)
plt.rcParams['axes.xmargin'] = 0

# remove extra fig for subplot
fig.delaxes(axes[1][2])
axes[1,2].set_axis_off()
axes.flat[-1].set_visible(False)


# better minus symbol
matplotlib.rcParams['axes.unicode_minus'] = False

# fontsize
plt.rcParams['font.size'] = '16'


import matplotlib.pyplot as plt

SMALL_SIZE = 8
MEDIUM_SIZE = 10
BIGGER_SIZE = 12

plt.rc('font', size=SMALL_SIZE)          # controls default text sizes
plt.rc('axes', titlesize=SMALL_SIZE)     # fontsize of the axes title
plt.rc('axes', labelsize=MEDIUM_SIZE)    # fontsize of the x and y labels
plt.rc('xtick', labelsize=SMALL_SIZE)    # fontsize of the tick labels
plt.rc('ytick', labelsize=SMALL_SIZE)    # fontsize of the tick labels
plt.rc('legend', fontsize=SMALL_SIZE)    # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE)  # fontsize of the figure title

Reference:



Matplotlib legend location

 


Reference:

https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.legend.html

Wednesday, December 16, 2020

Share Chrome-OS files to Linux beta

It is important that if we can access the files outside of the linux beta.

The process is very simple.

a. Open the Chrome OS Files app and find the directory you want to share.

b. Right-click on the folder you want to share and select the “Share with Linux” option.

c. Within the Linux container, these shared folders will be located at /mnt/chromeos/MyFiles/. From the Terminal app run cd /mnt/chromeos.

Enjoy it!


Reference:
https://chromeos.dev/en/linux/setup


Friday, December 11, 2020

A simple guide to Install scikit ODES

Here is a simple guid to install scikit-odes. Odes is a scikit toolkit for scipy to add extra ode solvers. Specifically it interfaces the Sundials solvers cvode, cvodes, ida and idas.


a) Install BLAS and LAPACK

>sudo apt-get install libopenblas-dev liblapack-dev


b) Install Sundials 5.1.0

>wget https://computing.llnl.gov/projects/sundials/download/sundials-5.1.0.tar.gz

>tar xvf sundials-5.1.0.tar.gz 

>mkdir builder 

>cd builder 

>cmake ../../sundials-5.1.0/ -DLAPACK_ENABLE=ON 

>make 

>sudo make install

c) Install scikits odes

add export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/bin to .bashrc 

>source ~/.bashrc 

>sudo pip install scikits.odes


Reference:

https://scikits-odes.readthedocs.io/en/latest/installation.html

Friday, December 4, 2020

Display figure in remote machine

 

import matplotlib matplotlib.use('tkagg') import matplotlib.pyplot as plt plt.plot([1, 2, 3]) plt.show()

ssh -p port_number -X user@xxxx

Reference: https://stackoverflow.com/questions/3453188/matplotlib-display-plot-on-a-remote-machine

Monday, November 16, 2020

Sunday, November 15, 2020

Linux resource management tool Slurm

Slurm is a group utilities used for managing workloads on computer clusters.

Some clusters use Slurm as the batch queuing system and the scheduling mechanism.

Jobs are submitted to Slurm from a login node and Slurm handles scheduling these jobs on nodes.

sinfo -l command displays information about nodes and partitions.

sbatch job.sh submit a job where job.sh is the script you want to run.

scancel jobID cancels a job

squeue -u userID shows state of jobs


An example for job submit script, e.g., job.slurm 


Execute script

$ sbatch job.slurm


two examples interactive shell
$srun -n 1 --pty bash -i

$srun --mem=4096 --pty  /bin/bash --time=01:00:00

Wednesday, November 11, 2020

Show logged users in Linux

 There are few simple commands which can display who are logged in the Linux.

w

who

users

last

Typing one of these commands in the terminal, it will display the logged in users information.

Friday, October 23, 2020

Find the SD card in Chromebook linux beta terminal

step by step: 

a .   You should click the File and locate your SD card

b.    Right click the SD card catalog and select " share with linux"

c.     You can access your sd card content at /mnt/chromeos/removable/sdcard/.


Reference:

https://support.google.com/chromebook/thread/792757?hl=en

Monday, September 21, 2020

The derivation of sound speed

Consider the sound wave propagating through a pipe with cross-section area $A$. In time interval $dt$ it moves through a tube of length $dz=vdt$. In the steady state, the mass flow rate $dm/dt=\rho v A$ must be the same at the ends of the tube, therefore the mass flux $j=\rho v = const. \to v d\rho=-\rho dv$. The pressure-gradient force provides the acceleration and apply the Newton's second law,

\[ \rho \frac{dv}{dt} =-\frac{dP}{dz} \]

\[\to dP= -\rho\frac{dv}{dt}dz = -\rho \frac{dz}{dt}dv =(-\rho \frac{dv}{dt})v = v^2d\rho .\]

And therefore,

\[ v^2=\frac{dP}{d\rho} ,\]

where, $P$ is the gas pressure, $\rho$ is the density.

Reference:

https://en.wikipedia.org/wiki/Speed_of_sound#:~:text=The%20speed%20of%20sound%20is,a%20mile%20in%204.7%20s.

Thursday, September 17, 2020

Play open red alert on chromebook

 

Command & Conquer: Red Alert is a real-time strategy game of the Command & Conquer franchise.

It is easy to play the classic open red alert game on Chromebook once you get the Linux beta.

method 1

  sudo apt update
  sudo apt install snapd
  sudo snapd install openra
  
method 2
wget https://github.com/OpenRA/OpenRA/releases/download/release-20200503/OpenRA-Red-Alert
-x86_64.AppImage
sudo chmod +x OpenRA-Red-Alert-x86_64.AppImage
./OpenRA-Red-Alert-x86_64.AppImage
enjoying your game!

Friday, August 28, 2020

Image viewer feh

feh is a light-weight, configurable and versatile image viewer.

It is very small, and good for your disk.

Example:

feh -Z -x. file_name.png

vi .bashrc and add

alias feh='feh -Z -x.'


Reference:

https://man.finalrewind.org/1/feh/