WeiNote

yyrcd

web

TA

pl

2020

Mar 07

2019

Jul 29

(2019)

Note that calling my_tensor.to(device) returns a new copy of my_tensor on GPU. It does NOT overwrite my_tensor. Therefore, remember to manually overwrite tensors: my_tensor = my_tensor.to(torch.device('cuda')).

2020

May 25

TODO

  • add overlay at show page
  • add name by filename if name is empty
  • 时间格式

2020

May 23

sudo netstat -tunlp
  • -t - Show TCP ports.
  • -u - Show UDP ports.
  • -n - Show numerical addresses instead of resolving hosts.
  • -l - Show only listening ports.
  • -p - Show the PID and name of the listener’s process. This information is shown only if you run the command as root or sudo user.

2020

May 23

mysqlclient

linux

sudo apt-get install build-essential libmysqlclient-dev
pip install mysqlclient

mac

brew install mysql-client
pip install mysqlclient

2020

May 21

缓存方式: 获取:a.mp4?dandruff=adfjaldasdfasdf 读取:a.mp4

2020

May 20

少数派网页开启暗黑模式

window.localStorage.setItem('darkMode', 2)

2020

May 20

2020

May 19

Screen - linux

screen -ls
screen -L       # output to a file named as screenlog.#
screen -S name  # give the session a name
screen -r [session]

2020

May 15

New Loss Function

\[\mathrm{loss_1}=\frac{1}{N_{mo}} \sum\left(Y_{i}-\hat{Y}_{i}\right)^{2}+\frac{1}{N_{mo} - 1} \sum\left(GAP_{i}-\hat{GAP}_{i}\right)^{2} \\ \\ \mathrm{loss_{batch}}=\mathrm{(loss_{1..n}).mean} \]

2020

May 15

Git Large File Storage (git-lfs)

ubuntu

sudo apt-get install git-lfs
git lfs install

mac

brew install git-lfs
git lfs install

usage

git lfs track "*.psd"
git add .gitattributes
git add file.psd
git commit -m "Add design file"
git push origin master
git lfs ls-files
git lfs pull --all

Reference: Git Large File Storage

2020

May 12

游戏

等待发售

2020

May 11

  tell application "System Events"
    -- https://eastmanreference.com/complete-list-of-applescript-key-codes
    key code 3 using {command down, control down} -- cmd+ctrl+f
  end tell

2020

May 10

2020

May 08

Check safari Reading list

2020

May 05

X: 24
T: Clouds Thicken
C: Paul Rosen
S: Copyright 2005, Paul Rosen
M: 6/8
L: 1/8
Q: 3/8=116
R: Creepy Jig
K: Em
|"C" C2 "D" D2 "E" E2 "F" F2 G2 A2 B2 "CDEFGAB"|adfadfga|
|abcdefg|ABCDEFG|ABCDEFG|

2020

May 03

汇率

100w 日元 == 6.5w 人民币 1w 日元 == 650 人民币 100 日元 == 6.5 人民币 15 日元 == 1 人民币

2020

May 03

2020

May 02

Click a button every 10 seconds

refresh_bnt = document.getElementsByClassName("el-button--primary")[0]
setInterval(function () {refresh_bnt.click();}, 10000);

2020

Apr 28

2020

Apr 28

2020

Apr 27

2020

Apr 27

2020

Apr 26

Git Config

git config --global user.name "richard"
git config --global user.email "yueyericardo@gmail.com"
git config --global color.ui true 

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git config --global alias.last 'log -1'
git config --global alias.unstage 'reset HEAD'
git config --global alias.st 'status'
git config --global core.quotepath false  # Chinese

2020

Apr 25

Sass to CSS

node-sass 的安装和使用

node-sass --watch ~/dev/WeiNote/public/css/wiki.scss ~/dev/WeiNote/public/css/wiki.css

2020

Apr 25

Linux 硬盘

格式化硬盘

Ubuntu16.04挂载新硬盘并格式化硬盘

$ lsblk -f
sda                                                             
├─sda1      vfat     EFI   67E3-17ED                            
└─sda2      hfsplus  data  1217e44e-a8e9-3cc1-9a42-f2fef205f037 
sdb                                                             
└─sdb1      ext4           a4d98232-7849-4f50-812d-32b99451380c 
nvme0n1                                                         
├─nvme0n1p1 vfat           393B-1943                            /boot/efi
└─nvme0n1p2 ext4           5cd74521-33de-438d-9273-420609266079 /

Mount exFAT

Command

sudo mount -t exfat /dev/sdb2 /media/hdd

Or in /etc/fstab

/dev/sdb2 /media/hdd exfat rw,async,umask=0 0 0

2020

Apr 24

Download m3u8

ffmpeg -user_agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.3 Safari/537.86.7" \
-i https://link.com/playlist.m3u8 -c copy download.mkv

2020

Apr 23

Weinote 书写习惯

# Weinote 书写习惯

序号

### 序号

  • H2, H3, H5 有
  • H1, H4, H6 没有

字号相同

### 字号相同

  • H3 - H4
  • H5 - H6

长文章:

### 长文章

  • H1 用于长文章的大标题
  • H2 H3 用于长文章的小标题

短文章

### 短文章

  • H1H4 用于短文的大标题
  • H3 用于短文的小标题

2020

Apr 23

Regex

Extract text from makdown url

function remove_link_from_md(str) {
  var regex = /\[([^\]]+?)\]\([^)]+\)/g;
  str = str.replace(regex, "$1");
  return str;
}
str = "- [adfadf](af) \n- [adb](adfadfb)"
result = remove_link_from_md(str)
console.log(result)
// - adfadf 
// - adb

remove illegal charactor

name = "jfkadldjf 12 029834 &12 ajsdlkf!"
var name_ = name
name_ = name_.replace(/[~`!@#$%^&*(){}\[\];:"'<,.>?\/\\|_+=-]/g, '')
name_ = name_.replace(/\s|\"/g, "-");

2020

Apr 20

WeiBlog

Sketch

Why not merge into weinote?

Weinote should not be tracked by google analytics. Weinote and Weiblog should be seperated, 更有仪式感。 庞大的生态系统,并不一定是好事。

Fist Priority

  • 学一下react
  • like https://immmmm.com/zan-by-leancloud-cn/
  • Backup keep 30 most recent backups
  • 导出为markdown gitadd gitcommit
  • url post_id
    如果不指定: 001
    指定:001_n2s
    限制在999篇,应该够了。
    archive被隐藏,但知道url可以访问。
    hide完全被隐藏,知道url也不可以访问。
  • pv count: goatcount

Not priority

Comment (might continue vanila?)

Weinote

n2s

必须用python写,数据处理

Hugo

Hello Friend — A simple theme for Hugo joway/hugo-theme-yinyang: a black-white theme for Hugo. Joway's Blog 天空的城

2020

Apr 18

2020

Apr 16

Python print colord text to terminal

print('\033[91m', "hello", '\33[0m')  # red
print('\033[32m', "hello", '\33[0m')  # green

2020

Apr 12

Dash Grid example

fig1 = html.Div([dcc.Graph(figure=getfig1(), id="fig1")], className="eight columns")
sliders1 = html.Div([
    html.Label('The value for k (in $ Å^{-\;1} $)'),
    dcc.Slider(id='fig1_k_slider', min=1, max=15, value=4, marks={str(x): str(x) for x in np.arange(1, 16, 1)}, step=1),
    html.Label('the maximum value for x (in Å)'),
    dcc.Slider(id='fig1_xmax_slider', min=1, max=15, value=5, marks={str(x): str(x) for x in np.arange(1, 16, 1)}, step=1),],
                    className="four  columns")
fullfig1 = html.Div([fig1, sliders1], className="row")

2020

Apr 10

Mathjax 3

<script>
MathJax = {
  tex: {
    inlineMath: [['$', '$']]
  }
};
</script>

<script id="MathJax-script" async
  src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">
</script>

2020

Apr 09

alias以,开头

2020

Apr 09

2020

Apr 09

Generate Table of Content

var headers = ["h1", "h2", "h3", "h4"]

for (var i=0, h; h=headers[i]; i++) {  
  var tags = document.getElementsByTagName(h);
  a = ''
  for (var j=0, hi; hi=tags[j]; j++) {
    a += `<a href="#${hi.id}"> ${hi.innerHTML} </a>\n<br>`
  }
  console.log(a)
}

2020

Apr 08

Scale bokeh in supervisord

[program:tornado_web_demo]
numprocs=4
numprocs_start=1
command=python /home/me/www/demo.py --port=80%(process_num)02d
process_name=%(program_name)s%(process_num)d

gunicorn部署Flask服务 - 简书

2020

Apr 08

bilibili 收益

 10w 播放  300 ¥
 20w 播放  800 ¥
 50w 播放 2000 ¥
150w 播放 3500 ¥

2020

Apr 07

Format an USB on mac

sudo diskutil eraseDisk JHFS+ richard disk5

2020

Apr 06

2020

Apr 03

2020

Apr 01

2020

Mar 31

Architecture

CPU Architecture

Intel和AMD 与 x86,ARM,MIPS有什么区别? - 知乎 分不清ARM和X86架构,别跟我说你懂CPU! - 知乎

GPU Architecture

Nvidia GPU架构 - Cuda Core,SM,SP等等傻傻分不清?_Python_咚咚锵的博客-CSDN博客

  • IPC: Instruction Per Cycle
  • OoO: Out of Order (指令重排)
  • SM: Streaming Multiprocessor

8 ALU run if pic

64 (stream) * 8 (ALU) = 512 pic

GTX 480 pic pic

2020

Mar 31

find

find . -iname vectoradd
./0_Simple/vectorAdd/vectorAdd
find . -iname *.cu
./3_Imaging/SobelFilter/SobelFilter_kernels.cu
./3_Imaging/postProcessGL/postProcessGL.cu
....

Ref: Linux find命令 | 菜鸟教程

2020

Mar 30

2020

Mar 24

2020

Mar 20

2020

Mar 18

2020

Mar 16

2020

Mar 16

Avoid use np.append for big array in for loop

In [1]: import numpy as np                                                                                                                                                  

In [2]: %%timeit 
   ...: a = np.array(1) 
   ...: for i in range(5000): 
   ...:     a = np.append(a, 1) 
   ...:                                                                                                                                                                     
31.8 ms ± 615 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [3]: %%timeit 
   ...: a = [1] 
   ...: for i in range(5000): 
   ...:     a.append(1) 
   ...:                                                                                                                                                                     
380 µs ± 9.29 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

2020

Mar 14

Python tips and tricks

List Comprehensions

# [ expression for item in list if conditional ]
def square(x):
    return x**2
a = [square(i) for i in range(10) if (i % 2 == 0)]
# [0, 4, 16, 36, 64]

dataclass, Python 3.7 中 dataclass

from dataclasses import dataclass
@dataclass
class Card:
    rank: str
    suit: str
card = Card("Q", "hearts")
print(card == card)
# True

Slicing a list

a[start:stop:step], default is a[0:-1:1]

"abcdefgh"[::2]
# 'aceg'
"abcd"[::-1]
# 'dcba'

map

def upper(s):
    return s.upper()
mylist = list(map(upper, ['sentence', 'fragment']))
# ['SENTENCE', 'FRAGMENT']

Ternary Operator For Conditional Assignment

x = "Success!" if (y == 2) else "Failed!"

Integer division

Python 3
5 / 2 = 2.5
5 // 2 = 2

Reference:

30 Python Best Practices, Tips, And Tricks - Towards Data Science

2020

Mar 14

2020

Mar 13

chmod

chmod 777 file
x: 1
w: 2
r: 4

2020

Mar 13

2020

Mar 13

2020

Mar 10

2020

Mar 10

2020

Mar 10

conda rollback to previous version

conda list --revisions
conda install --revision=14

2020

Mar 10

Jupyter style

<div class="alert alert-success"> 
    <p><b>alert-success</b></p>
</div>

<div class="alert alert-info"> 
    <p><b>alert-info</b></p>
</div>

<div class="alert alert-warning"> 
    <p><b>alert-warning</b></p>
</div>

<div class="alert alert-danger"> 
    <p><b>alert-danger</b></p>
</div>

2020

Mar 08

Shortcuts

Chrome

Crtl + Shift + Del: Delete current suggestion from 地址栏

Terminal

Ctrl + W 删除你键入的最后一个单词 Ctrl + U 可以删除行内光标所在位置之前的内容 Ctrl + K 可以删除光标至行尾的所有内

Youdao-Alfred

Cmd + Enter Pronounce

Safari

Ctrl + R: Reader Mode in safari default is Shift + cmd + R

mac

option + cmd + H: hide all

2020

Mar 08

2020

Mar 06

编译器

LLVM / Clang / GCC

MLIR - Chris Lattner

MLIR (Multi-Level Intermediate Representation)

XLA - TF

XLA (Accelerated Linear Algebra) is a domain-specific compiler for linear algebra that can accelerate TensorFlow models with potentially no source code changes. Most internal benchmarks run ~1.15x faster after XLA is enabled.

2020

Mar 06

Abbreviation

  • IR Intermediate Representations (IR)
  • TBD To Be Determined
  • a.k.a. Aka Also known as
  • BLAS Basic Linear Algebra Subprograms
  • GPU Graphics Processing Unit
  • CPU Central Processing Unit
  • misc miscellaneous

2020

Mar 03

How to upgrade from 18.10 to 19.10, using the command line? - Ask Ubuntu When run do-release-upgrade on the 18.10 system. This will give you an error about being unsupported.

2020

Mar 03

2020

Mar 02

2020

Mar 02

程序的编译与解释有什么区别? - 知乎

  1. 编译型语言在编译过程中生成目标平台的指令,解释型语言在运行过程中才生成目标平台的指令。
  2. 虚拟机的任务是在运行过程中将中间代码翻译成目标平台的指令。

也就是

  1. 一个是翻译成machine code,machine去解释
  2. 一个是翻译成bytecode,virtual machine去解释

2020

Mar 01

瑜伽动作: 两种最基本的瑜伽动作:downward dog 和 child pose。把这两个动作保持一分钟,你就会看到效果。

2020

Feb 27

pip release

~/.pypirc file

[distutils]
  index-servers = pypi

[pypi]
  repository = https://upload.pypi.org/legacy/
  username = __token__
  password = API_Token
pip install setuptools-scm
pip install twine
git commit -m "update"
git push origin maseter 
git tag v0.4
git push origin v0.4
python setup.py sdist bdist_wheel # creating pkbar-0.4
twine upload dist/*

2020

Feb 24

Weinote Colorful Font

  • Red Green Purple Yellow
<span style="color: red"> Red </span>
<span style="color: #3fff11"> Green </span>
<span style="color: #ff6ffa"> Purple </span>
<span style="color: #ffdf69"> Yellow </span>

Markdown Superscript and Subscript

Emin<sup>Maj7</sup> 
H<sub>2</sub>O  CO<sub>2</sub>

EminMaj7 H2O CO2

2020

Feb 20

2020

Feb 19

CUDA

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
print('Using device:', device)
if torch.cuda.is_available(): print(torch.cuda.get_device_name()) 

2020

Feb 18

2020

Feb 17

2020

Feb 17

2020

Feb 15

VS Code - Common setting

{
    "python.pythonPath": "/Users/richard/Program/anaconda3/envs/ml/bin/python",
    "python.linting.pylintEnabled": false,
    "python.linting.flake8Enabled": true,
    "python.linting.enabled": true,
    "python.linting.flake8Args": [
        "--max-line-length=120", 
        // "--ignore=None"
    ]

}

2020

Feb 11

python assert

assert torch.cuda.is_available(), "CUDA is not avaliable"

2020

Feb 10

2020

Feb 10

Pytorch

Common

pytorch/CONTRIBUTING.md update

git pull --rebase
git submodule sync --recursive
git submodule update --init --recursive
# or 
git pull --rebase; git submodule sync --recursive; git submodule update --init --recursive

Mac

Mac build Pytorch with CUDA

All versions | CUDA Toolkit Archive | NVIDIA Developer

PyTorch (1.0), CUDA & cuDNN on MacOS / Data Scientist from Chile Installing-Pytorch-Cuda-on-Macbook

Magma

Magma Bitbucket - Magma Webpage RuntimeError: inverse: MAGMA library not found in compilation. Please rebuild with MAGMA.

# environment
brew install openblas
brew install libomp
brew install lapack

export CUDADIR=/Developer/NVIDIA/CUDA-10.1
export LAPACKDIR="/usr/local/opt/lapacke"
export OPENBLASDIR="/usr/local/opt/openblas"
export OpenBLAS_LIB="/usr/local/opt/openblas/lib"
export OpenBLAS_INCLUDE_DIR="/usr/local/opt/openblas/include"

# magma
wget http://icl.utk.edu/projectsfiles/magma/downloads/magma-2.5.2.tar.gz
tar xvf magma-2.5.2.tar.gz
cd magma
vim make.inc
sudo mkdir /usr/local/magma
sudo chown richard:admin /usr/local/magma
make install prefix=/usr/local/magma -j 4

# to build pytorch, add magma/lib to dyld path
export DYLD_LIBRARY_PATH=/usr/local/magma/lib:$DYLD_LIBRARY_PATH

# build
MACOSX_DEPLOYMENT_TARGET=10.13 CC=clang CXX=clang++ python setup.py install

# build wheel
MACOSX_DEPLOYMENT_TARGET=10.13 CC=clang CXX=clang++ TORCH_CUDA_ARCH_LIST="2.0;3.0;3.5;5.2;6.1;7.0" python setup.py bdist_wheel

Build pytorch wheel for mac

pytorch-osx-build/BuildInstractions-1.0.1.md

2020

Feb 09

2020

Feb 09

2020

Feb 08

mac sshd config

PermitRootLogin no
PasswordAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
UsePAM no  # important

then restart

sudo launchctl stop com.openssh.sshd
sudo launchctl start com.openssh.sshd

2020

Feb 05

root密码忘记了怎么半?

linux安装盘,比如ubuntu安装盘

mount -t auto /dev/系统盘
cd /etc/
nano passwd
# remove x in next line
root:x:0:0:root:/root:/bin/bash

然后就可以tty以root登陆,不需要密码 然后,passwd重制密码

2020

Feb 05

3D Plot

Code on Gist

2020

Feb 04

Birthday Paradox

n is the number of students in a class

import numpy as np
import matplotlib.pyplot as plt

def prob(n):
    p = 1
    for i in range(n):
        p *= (365-i)/365
    return p

def prob_list(x):
    result = []
    for n in x:
        result.append(prob(n))
    return np.array(result)

x = np.linspace(1, 100, num=100, dtype=int)

plt.plot(x, prob_list(x), label='P (no same birtyday)')
plt.plot(x,1 - prob_list(x), label='P (same birtyday)')
plt.title('Birthday Paradox')
plt.legend()
plt.show()

2020

Feb 03

algorithm steps:

  1. check input
  2. check boundary (<= or >=)
  3. length (counts) and index a[length-1]

2020

Feb 03

copy.copy() and copy.deepcopy()

>>> a = [1, 2, [3]]
>>> c = copy.deepcopy(a)
>>> b = copy.copy(a)
>>> a[-1][0] = 4
>>> a
[1, 2, [4]]
>>> b
[1, 2, [4]]
>>> c
[1, 2, [3]]

is and ==

a = 1
b = 1
a == b  # True  | Value
a is b  # False | Object

Sort

  • 1
intervals = [[1, 2], [2, 3], [5, 8], [0, 1]]
intervals.sort(key=lambda x: x[0])
from functools import cmp_to_key
def cmp_xy(x, y):
    spe_dict = {'C':1, 'H':0, 'N':1, 'O':2}
    x = spe_dict[x]
    y = spe_dict[y]

    if x > y:
        return 1
    elif x < y:
        return -1
    else:
        return 0

a = ['C', 'H', 'N', 'O']
a.sort(key=cmp_to_key(cmp_xy))
print(a)  # ['H', 'C', 'N', 'O']
  • 3
a = ['C', 'H', 'N', 'O']
spe_dict = {'C':1, 'H':0, 'N':1, 'O':2}
a.sort(key=lambda x: spe_dict[x])
print(a) # ['H', 'C', 'N', 'O']

dict

dict.values()
dict.keys()
dict.items()

max(dict, key=dict.get)
max(dict.keys(), key=lambda k: dict[k])

2020

Feb 02

quick access a file in server

python -m http.server 8080

2020

Jan 16

2020

Jan 12

2020

Jan 10

Huge Wrong interpretation: MO是由AO线性组合来的 而不是对AO进行correction,无脑sort就能相互匹配的

2020

Jan 09

一个有意思的网站 Neal.fun The Size of Space

2020

Jan 09

Counting parameters in a model

sum(p.numel() for p in model.parameters())

2020

Jan 09

ANI_D Trial

  • [NO] distance decay before go into network
  • [NO] squared decay of network ouptut
  • [NO] 1 / R decay of network ouptut
  • [NO] 1/2 (abT + baT)

2020

Jan 06

h5ls

$ h5ls data/ANI-1x-hf-mo/6-31gd/ANI_1x_HF_631gd_MO_e_lt71.v5.train.h5 
MO_energies              Dataset {4173863}
coordinates              Dataset {4173863}
energies                 Dataset {4173863, 1}
id                       Dataset {4173863}
name                     Dataset {4173863}
no                       Dataset {4173863, 1}
num_e                    Dataset {4173863, 1}
runtime                  Dataset {4173863, 1}
species                  Dataset {4173863}

2020

Jan 06

2020

Jan 05

byte string (ASCII) UTF-8 string

>>> a =  b"Hello"
>>> a
b'Hello'
>>> a.decode()
'Hello'

2020

Jan 04

pandas

df = pd.DataFrame(dict([(k, pd.Series(v)) for k, v in data.items()]))

2019

2019

Dec 27

- /mnt/hdd/richard/mongo/mongo:/data/db

2019

Dec 25

Linux – top命令详解 | | Bruce's Blog 1 show all cpus t change cpu display m change momery display E KiB MiB GiB W save current config

2019

Dec 24

LAN: Local Area Network WAN: Wide Area Network

NAT: Network Address Translation

SNAT: Source Network Address Translation 内网多台机器由路由器连起来,内网机器访问外网,路由器将数据包的报头中的源地址替换成路由器的ip。

DNAT: Destination Network Address Translation 外网通过防火墙访问处于内网的web服务,外网访问防火墙,防火墙将目标地址改写成web服务器的内网ip。

转发redis

iptables -t nat -A PREROUTING -p tcp -d 104.111.111.111 --dport 1111 -j DNAT --to-destination 172.1.1.5
iptables -t nat -A POSTROUTING -o wg0 -j MASQUERADE
$ sudo iptables -t nat -L -vn
Chain PREROUTING (policy ACCEPT 4 packets, 208 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            104.111.111.111       tcp dpt:1111 to:172.1.1.5

Chain POSTROUTING (policy ACCEPT 5 packets, 403 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 MASQUERADE  all  --  *      wg0     0.0.0.0/0            0.0.0.0/0           

Reference:

2019

Dec 24

max value for num_e

# max
db.getCollection("ani-1x-631gd").find({}).sort({num_e: -1}).limit(1)  
# min
db.getCollection("ani-1x-631gd").find({}).sort({num_e: +1}).limit(1)  

2019

Dec 21

Dock-compose /mnt/hdd/richard/mongo/mongo local folder to mount

mongo: 
  volumes:
    - /mnt/hdd/richard/mongo/mongo:/data/db

2019

Dec 20

Git stash

git stash
git stash list
git stash pop  #(recover)

2019

Dec 20

2019

Dec 20

2019

Dec 20

2019

Dec 18

Gaussian

export g09root="/apps"
 . $g09root/g09/bsd/g09.profile
g09 c.com
formchk c.chk c.fchk

2019

Dec 17

2019

Dec 12

Usage of dcp

cd ~/
mkdir apps
cd apps
wget https://yyrcd-1256568788.cos.na-siliconvalley.myqcloud.com/yyrcd/2019-12-12-dcp
mv 2019-12-12-dcp dcp
~/apps/dcp 

2019

Dec 12

Print without new line

import sys
sys.stdout.write('.')
sys.stdout.flush()

2019

Dec 11

Mongo add archive field to every documents.

db.wikis.update(
  {},
  { $set: {"archive": false} },
  {upsert:false,multi:true}
)

2019

Dec 09

Polymorphism - 多态

继承 inheritence 重载 overload 一个函数名对应多个函数(根据参数类型,个数,顺序) 重写 override 子类override父类的方法 模板 genericity 类型type作为一个parameter

More info: Java 多态 | 菜鸟教程

2019

Dec 08

Python Internal

  1. Book Inside The Python Virtual Machine pdf | Read online Python源码剖析 pdf

  2. 谈谈 Python 程序的运行原理 | 淡水网志

  3. CPython的Global Interprate Lock(GIL): Preventing multiple threads from executing Python bytecodes at once.

    • 大家听说过对 CPython的GIL的抱怨不?经常听到对不对? 有多少一般 Python用户知道吐槽GIL其实真的在吐槽的就是 CPython的引用计数及C API实现? -- 知乎

    • Python的全局解释器锁(GIL) - 简书

      Done is better than perfect

2019

Dec 03

2019

Nov 29

2019

Nov 28

2019

Nov 28

>db.stats()
{
    "db" : "test",
    "collections" : 5,
    "views" : 0,
    "objects" : 53829,
    "avgObjSize" : 43.555,
    "dataSize" : 2344556121,
    "storageSize" :3124416336,
    "numExtents" : 0,
    "indexes" : 7,
    "indexSize" : 8096876,
    "ok" : 1
}
  • dataSize The total size in bytes of the uncompressed data held in this database.
  • storageSize The total amount of disk space allocated to all collections in the database.

Mongo IS USING RAM! wiredTiger

2019

Nov 26

richard@pc~> df -h
Filesystem      Size  Used Avail Use% Mounted on
dev              40G     0   40G   0% /dev
run              40G  1.9M   40G   1% /run
/dev/nvme0n1p4  1.4T  961G  447G  69% /
tmpfs            40G     0   40G   0% /dev/shm
tmpfs            40G     0   40G   0% /sys/fs/cgroup
tmpfs            40G  5.8M   40G   1% /tmp
/dev/nvme0n1p4  1.4T  961G  447G  69% /mnt/nvme
/dev/nvme0n1p4  1.4T  961G  447G  69% /home
/dev/nvme0n1p4  1.4T  961G  447G  69% /root
/dev/nvme0n1p4  1.4T  961G  447G  69% /var/lib/docker
/dev/sdb2       3.4T  934G  2.3T  29% /mnt/hdd
tmpfs           7.9G   12K  7.9G   1% /run/user/1001 

2019

Nov 20

Use python in bash script

Simple case:

for i in {0..5}
do
    file=$(python -c "a='wavefunction{:02d}'.format($i); print(a)")
    echo $file
    sleep 0.5
done
#wavefunction00
#...
#wavefunction05
python -c "print('some')"
some  #output
a=$(python -c "a='I am {}'.format('richard'); print(a)")
echo $a
I am richard   #output
a=$(python -c "print('some')" 2>&1)  # 2>&1的意思是python的stderr输出重定向到stdout
echo $a
some   #output
for i in {0..29}
do
    echo $i
    python -c "import os; os.remove('input'); a = 'set nat = \'/ufrc/alberto.perezant/arup.mondal/project/nmr/1st_trial/metaclust/ExperimentalStructures/N0968s2_leap.pdb\'\ntrajin follow.{:02d}.dcd\nparm \$nat\nreference \$nat parm \$nat\nrmsd reference :1-115@CA out rmsd_walker/rmsd.{}.txt\ngo\nclear trajin'.format($i,$i); print($a); file=open('input', 'w+'); file.write(a); file.close()"
    cpptraj -p ../template.pdb -i input
done
set nat = '/ufrc/alberto.perezant/arup.mondal/project/nmr/1st_trial/metaclust/ExperimentalStructures/N0968s2_leap.pdb'
trajin follow.29.dcd
parm $nat
reference $nat parm $nat
rmsd reference :1-115@CA out rmsd_walker/rmsd.29.txt
go
clear trajin
~

2019

Nov 18

Slater not Slator

2019

Nov 16

unzip alternative

ditto -V -x -k --sequesterRsrc --rsrc file.zip dir/

2019

Nov 15

2019

Nov 09

单附点音符:原音符的时值延长一半 双附点音符:再加上原音符时值的1/4

2019

Nov 09

2019

Nov 08

Mongo commands runtime larger than 200

{'wb97mv.pre1.runtime': {$gte: 200}}

total_energy is null

{'wb97mv.wb97md3bj.total_energy': null}

2019

Nov 07

Check if is SSD drive

lsblk -d -o name,rota

2019

Nov 06

2019

Nov 06

2019

Nov 04

he = psi4.geometry("""
H
""")
psi4.set_options({'guess': 'core',
                  'basis': 'cc-pvdz',
                  'scf_type': 'pk',
                  'e_convergence': 1e-8,
                  'reference': 'uhf'})
psi4.energy('SCF')

2019

Nov 03

einsum

  1. python - Understanding NumPy's einsum - Stack Overflow
  2. A basic introduction to NumPy's einsum – ajcr – Haphazard investigations
  3. 能「看到」的张量运算:​因子图可视化
A = np.array([0, 1, 2])
B = np.array([[ 0,  1,  2,  3],
              [ 4,  5,  6,  7],
              [ 8,  9, 10, 11]])

(np.expand_dims(A, 1) * B).sum(axis=1)  # array([ 0, 22, 76])
np.einsum('i,ij->ij', A, B)  # array([[ 0,  0,  0,  0],
                             #        [ 4,  5,  6,  7],
                             #        [16, 18, 20, 22]])

np.einsum('i,ij->i', A, B)   # array([ 0, 22, 76])

np.einsum('i,ij->', A, B)    # 98

Here is what happens next:

  • A has one axis; we've labelled it i. And B has two axes; we've labelled axis 0 as i and axis 1 as j.

  • By repeating the label i in both input arrays, we are telling einsum that these two axes should be multiplied together.

  • Notice that j does not appear as a label in our desired output. By omitting the label, we're telling einsum to sum along this axis.

2019

Nov 03

GiB vs GB

2019

Nov 02

Shift + Opt + M - copy current tab as markdown url

2019

Nov 01

2019

Nov 01

2019

Nov 01

Install ORCA

Openmpi

wget https://yyrcd-1256568788.cos.na-siliconvalley.myqcloud.com/yyrcd/2019-10-30-openmpi-3.1.4.tar.gz
tar -xvf 2019-10-30-openmpi-3.1.4.tar.gz
cd openmpi-3.1.4
./configure --prefix=/home/richard/apps/openmpi314
make all install -j  # remove -j if error

ORCA

wget https://yyrcd-1256568788.cos.na-siliconvalley.myqcloud.com/yyrcd/2019-10-30-orca_4_2_1_linux_x86-64_shared_openmpi314.tar.xz
tar -xvf 2019-10-30-orca_4_2_1_linux_x86-64_shared_openmpi314.tar.xz

Env

# openmpi
export PATH=$PATH:/path/to/openmpi314/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/openmpi314/lib
# orca
export PATH=$PATH:/path/to/orca
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/orca
export ORCA_PATH=/path/to/orca

Test

mpiexec -V  # openmpi
mkdir test_orca
cd test_orca
wget https://yyrcd-1256568788.cos.na-siliconvalley.myqcloud.com/yyrcd/2019-11-01-test.inp
/path/to/orca/orca 2019-11-01-test.inp > test.out

2019

Oct 30

2019

Oct 30

docker

part 1 orientation

docker
docker container --help

docker --version  # Display Docker version and info
docker version
docker info

docker run hello-world  # Execute Docker image

docker image ls  # List Docker images

docker container ls  #List Docker containers (running, all, all in quiet mode)
docker container ls --all
docker container ls -aq

part 2 containers

docker build -t friendlyhello .  # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyhello  # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyhello         # Same thing, but in detached mode
docker container ls                                # List all running containers
docker container ls -a             # List all containers, even those not running
docker container stop <hash>           # Gracefully stop the specified container
docker container kill <hash>         # Force shutdown of the specified container
docker container rm <hash>        # Remove specified container from this machine
docker container rm $(docker container ls -a -q)         # Remove all containers
docker image ls -a                             # List all images on this machine
docker image rm <image id>            # Remove specified image from this machine
docker image rm $(docker image ls -a -q)   # Remove all images from this machine
docker login             # Log in this CLI session using your Docker credentials
docker tag <image> username/repository:tag  # Tag <image> for upload to registry
docker push username/repository:tag            # Upload tagged image to registry
docker run username/repository:tag                   # Run image from a registry

part 3 services

docker stack ls                                            # List stacks or apps
docker stack deploy -c <composefile> <appname>  # Run the specified Compose file
docker service ls                 # List running services associated with an app
docker service ps <service>                  # List tasks associated with an app
docker inspect <task or container>                   # Inspect task or container
docker container ls -q                                      # List container IDs
docker stack rm <appname>                             # Tear down an application
docker swarm leave --force      # Take down a single node swarm from the manager

2019

Oct 29

2019

Oct 28

Set power supply for GPU

sudo nvidia-smi -q -d POWER  # check the current limit
sudo nvidia-smi -i 2 -pl 250  # set power limit of gpu3 to 250W
sudo nvidia-smi -pm 1  # set to persistent mode (no need to change everytime start?)

2019

Oct 26

curl

curl github.com

Node.js

var request = require('request');

var options = {
    url: 'github.com'
};

function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body);
    }
}

request(options, callback);

python

import requests

response = requests.get('http://github.com')

2019

Oct 22

Slurm, there is resource, but why my job is still pending?

There might be one resource job is also pending. Then you submitted another job, though resources are enough to run your job. And your job is also pending, the reason is priority.

Whether slurm will run your job will depend on how long your priority job needs to run. for example: This job might take few hours, then slurm might determin it could run. If it will take days, might not, because the resource job came first, and he will needs to wait days to get his job started.

2019

Oct 16

High Performance Computing (HPC) and parallel programming

  1. OpenMp
  2. MPI

2019

Oct 13

  1. Float 为单精度,4 个字节,有效数位是 7 位(因为有正负,所以不是8位) double为 双精度,占 8 个字节,有效数位是 16 位

  2. 浮点数:数符,尾数,指数符,指数四部分。

    • 数符占 1 位二进制,表示数的正负。
      尾数表示浮点数有效数字,0.xxxxxxx, 但不存开头的 0 和点。
    • 指数符占 1 位二进制,表示指数的正负。
      指数存指数的有效数字。
    • 可能是数符加尾数占 24 位,指数符加指数占 8 位 -- float。
      数符加尾数占 48 位,指数符加指数占 16 位 -- double。

2019

Oct 07

2019

Oct 07

NAMES

  1. Federico (M)
  2. Y(sh)amila (F)
  3. Nilu (F)
  4. Pierre Louis (M) (French)

2019

Oct 05

Backup mongodb

  1. backup.sh
#!/bin/bash

MONGO_DATABASE="roitberg"
APP_NAME="roitberg-web"
MONGO_HOST="ds8888.mlab.com"
MONGO_PORT="88888"
USER="username"
PW="password"

TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/richard/production/backup/$APP_NAME"
BACKUP_NAME="$APP_NAME-$TIMESTAMP"

$MONGODUMP_PATH -h $MONGO_HOST:$MONGO_PORT -d $MONGO_DATABASE -u $USER -p $PW

mkdir -p $BACKUPS_DIR
mv dump $BACKUP_NAME
tar -zcvf $BACKUPS_DIR/$BACKUP_NAME.tgz $BACKUP_NAME
rm -rf $BACKUP_NAME

# only keep the newest 30 backups
cd $BACKUPS_DIR
ls --color=no -t | sed -e '1,30d' | xargs -d '\n' rm
  1. Automatic backup
# install mongodb backup tools
sudo apt install -y mongodb-org-shell
sudo apt install -y mongodb-org-tools
# edit the crontab file
sudo crontab -e
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any')
# m h  dom mon dow   command
00 01 * * * /bin/bash /home/richard/production/backup/scripts/backup.sh

Online crontab editor: https://crontab.guru/

 sudo service cron restart

2019

Oct 05

2019

Oct 04

Show two image one line at weinote (Not usable on mobile)

<p class="img" style="display: inline-flex;">
<img width=49% src="imglink">
<img width=49% src="imglink">
</p>
<p class="img" style="display: inline-flex;">
<img width=49%  height=initial src="https://yyrcd-1256568788.cos.na-siliconvalley.myqcloud.com/yyrcd/2019-05-02-IMG_1303_HDR.jpg">
<img width=49%  height=initial src="https://yyrcd-1256568788.cos.na-siliconvalley.myqcloud.com/yyrcd/2019-05-02-IMG_1479_HDR.jpg">
</p>

2019

Oct 04

Update Slurm after Replace GPU

If chang gpu on mordor or isengard, both of them needs to be updated

sudo vim /etc/slurm-llnl/slurm.conf
sudo vim /etc/slurm-llnl/gres.conf

Then restart

sudo /etc/init.d/slurmd restart
sudo /etc/init.d/slurmctld restart

2019

Oct 03

2019

Oct 02

2019

Oct 02

从邓丽君到周杰伦——流行音乐和声全解析

  1. 基础课:和声进行,原来如此!
  2. 经典歌曲是怎么用和声套路的
  3. 被忽略的秘密——和声节奏
  4. 流行音乐怎么用五度循环圈
  5. 能力飞跃1——副属和弦
  6. 小调的和声
  7. 能力飞跃2——调式混合
  8. 挂留和弦
  9. 变化低音经过和弦

2019

Oct 02

2019

Sep 30

  • (AB) = BA

  • Hermitian
    Hermitian matrix (or self-adjoint matrix) is a complex square matrix that is equal to its own conjugate transpose

  • Commutator
    • If two operators commute
      The observables A and B can be measured simultaneously with infinite precision
    • If the operators do not commute
      They can't be prepared simultaneously to arbitrary precision, and there is an uncertainty relation between the observables

2019

Sep 30

细思极恐的音程度数

continue here

2019

Sep 29

关系大小调

C大调: CDEFGAB a小调:ABCDEFG

大调的六级音是小调的主音(或者说大调主音下方小三度的音是小调的主音) 小调的三级音是大调的主音

每个大调都有他的关系小调,反之亦然


小调的调号用的就是关系大调的调号

2019

Sep 29

自然小调

大调:欢快,明朗(也能表达悲伤) 小调:悲伤,浪漫(也能表达快乐的情感)


C大调:C D E F G A B C (C - E 大三度) C小调:C D Eb F G Ab Bb C (C - Eb 小三度)(最重要的是Eb:调式特性音级) 小三度是小调听起来悲伤的重要原因 小调另一个特征:六级和七级音比大调对应位置低半音


因此可以说: 主音 - 三级音 是大三度 即为大调 主音 - 三级音 是小三度 即为小调


还有:旋律小调、和声小调


小调: 全 半 全 全 半 全 全 C D Eb F G Ab Bb C 记法: (全 半 全)(全 半 全) 全


A小调 所有音都是白键 A B C D E F G A


构成音一样,主音不同的大调和小调叫做关系大小调 如:C大调与A小调

2019

Sep 29

Table template

|      |      |      |
| :--- | :--: | ---: |
|      |      |      |
|      |      |      |

2019

Sep 29

2019

Sep 27

Potential energy = Electronic energy Total energy = Potential energy + Kinetics energy

2019

Sep 26

2019

Sep 25

Save CSV file and load from http

Save

import pandas as pd
df = pd.DataFrame(dict([(k, pd.Series(v)) for k, v in data.items()]))
data = {'wavenumber': wavenumber, 'absorbance': absorbance}
df.to_csv('wave_abs.csv', mode='a', index=False)

Load from http

data = pd.read_csv('https://yyrcd-1256568788.cos.na-siliconvalley.myqcloud.com/yyrcd/2019-09-25-wave_abs.csv')
wavenumber = data['wavenumber'].values
absorbance = data['absorbance'].values

2019

Sep 23

EMAIL

  1. Thanks for your prompt reply!

2019

Sep 22

2019

Sep 19

Ubuntu add user

sudo adduser username
sudo usermod -aG sudo username

2019

Sep 17

Disccusion

  1. ESI is very low amount
  2. Open source?
  3. What equation I should display on enzyme page?
  4. Server?
  5. Is uncompetitive behavior normal?
  6. Description (one page)
  7. Show all parameters somewhere
  8. Unit

Questions

  1. Equations for Non-competitive Inhibition
  2. rate constant, always first order?

2019

Sep 15

2019

Sep 15

Gas for one round trip to ST Augustine is about 16$, about 6.75 gallon (2.37$/g) MPG (Mile per Gallon) is around 25

2019

Sep 11

Junit test on storm.cise

  1. moyi
    jar -cMf jinze_xue_38239101_hw1.jar cop5556fa19/ testInputFiles/
    scp jinze_xue_38239101_hw1.jar jinze@storm.cise.ufl.edu:~/
  2. storm
    jar xf jinze_xue_38239101_hw1.jar 
    mkdir out
    javac -d out/ -cp .:/cise/homes/jinze/lib/junit-jupiter-api-5.5.1.jar:/cise/homes/jinze/lib/apiguardian-api-1.1.0.jar cop5556fa19/ScannerTest.java
    java -jar /cise/homes/jinze/lib/junit-platform-console-standalone-1.5.1.jar -cp ./out/ --scan-classpath -details=tree
    output
    Test run finished after 132 ms
    [         3 containers found      ]
    [         0 containers skipped    ]
    [         3 containers started    ]
    [         0 containers aborted    ]
    [         3 containers successful ]
    [         0 containers failed     ]
    [        17 tests found           ]
    [         0 tests skipped         ]
    [        17 tests started         ]
    [         0 tests aborted         ]
    [        17 tests successful      ]
    [         0 tests failed          ]

2019

Sep 09

VSCode Shortcuts

Code > Preferences > Keyboard Shortcuts > keybindings.json (see image above)

[
    {
        "key": "ctrl+shift+tab",
        "command": "workbench.action.previousEditor"
    },
    {
        "key": "ctrl+tab",
        "command": "workbench.action.nextEditor"
    },
]

2019

Sep 04

Slurm: Kill task failed

And state=MIXED+DRAIN

  • log file

    richard@moria~> sudo cat /var/log/slurm-llnl/slurmctld.log
    [2019-09-04T15:16:31.313] backfill: Started JobID=2076 in queue on moria
    [2019-09-04T15:36:52.152] _slurm_rpc_submit_batch_job: JobId=2077 InitPrio=4294899834 usec=645
    [2019-09-04T15:37:01.327] backfill: Started JobID=2077 in queue on moria
    [2019-09-04T15:38:41.041] _slurm_rpc_kill_job: REQUEST_KILL_JOB job 2077 uid 1026
    [2019-09-04T15:38:43.734] _slurm_rpc_submit_batch_job: JobId=2078 InitPrio=4294899833 usec=648
    [2019-09-04T15:39:34.232] Resending TERMINATE_JOB request JobId=2077 Nodelist=moria
    [2019-09-04T15:39:42.055] error: slurmd error running JobId=2077 on node(s)=moria: Kill task failed
    [2019-09-04T15:39:42.055] drain_nodes: node moria state set to DRAIN
    [2019-09-04T15:39:42.081] cleanup_completing: job 2077 completion process took 61 seconds
  • nodes information

    richard@moria~> scontrol show nodes
    NodeName=moria Arch=x86_64 CoresPerSocket=8
     CPUAlloc=4 CPUErr=0 CPUTot=16 CPULoad=4.34
     AvailableFeatures=(null)
     ActiveFeatures=(null)
     Gres=gpu:gtx1080ti:2,gpu:titanv:3,gpu:v100:1,gpu:gp100:2
     NodeAddr=moria NodeHostName=moria Version=17.11
     OS=Linux 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 
     RealMemory=120000 AllocMem=0 FreeMem=1023 Sockets=2 Boards=1
     State=MIXED+DRAIN ThreadsPerCore=1 TmpDisk=0 Weight=1 Owner=N/A MCS_label=N/A
     Partitions=queue 
     BootTime=2019-02-03T15:36:08 SlurmdStartTime=2019-02-13T18:00:18
     CfgTRES=cpu=16,mem=120000M,billing=16
     AllocTRES=cpu=4
     CapWatts=n/a
     CurrentWatts=0 LowestJoules=0 ConsumedJoules=0
     ExtSensorsJoules=n/s ExtSensorsWatts=0 ExtSensorsTemp=n/s
     Reason=batch job complete failure [slurm@2019-09-04T15:39:42]
  • how to fix

    richard@moria~> scontrol update nodename=moria state=resume
  • For more information

  • show cpu information

    richard@moria~> sinfo -O cpusstate
    CPUS(A/I/O/T)(allocated/idle/other/total)
    5/11/0/16 

2019

Sep 02

Extract file from a foo.jar file

jar -xf myFile.jar

compile

javac -cp .:/home/richard/study/COP5556/hw/lib/junit-jupiter-api-5.5.1.jar cop5556fa19/*.java

run

java -jar /home/richard/study/COP5556/hw/lib/junit-platform-console-standalone-1.5.1.jar -cp . --scan-classpath

2019

Sep 02

2019

Sep 02

JAVA

Some simple notes for java

for each loop

public class TestArray {
   public static void main(String[] args) {
      double[] myList = {1.9, 2.9, 3.4, 3.5};

      // 打印所有数组元素
      for (double element: myList) {
         System.out.println(element);
      }
   }
}

Ternary operator

variable x = (expression) ? value if true : value if false

Keyword

final constant

Float

In JAVA, values like: 8.5, 3.9 are assumed as double and not float. You can also perform a cast in order to solve the problem:

float b = (float) 3.5;
// or
float b = 3.5f;

Convention

  • 类名:对于所有的类来说,类名的首字母应该大写。如果类名由若干单词组成,那么每个单词的首字母应该大写,例如 MyFirstJavaClass 。
  • 方法名:所有的方法名都应该以小写字母开头。如果方法名含有若干单词,则后面的每个单词首字母大写。
  • 源文件名:源文件名必须和类名相同。当保存文件的时候,你应该使用类名作为文件名保存(切记 Java 是大小写敏感的),文件名的后缀为 .java。(如果文件名和类名不相同则会导致编译错误)。
  • 主方法入口:所有的 Java 程序由 public static void main(String []args) 方法开始执行。

2019

Aug 31

鸡胸肉怎么做好吃?

(Due to the connectivity issue of AWS us-east-1 (mlab status), wiki is currently not avaliable. This is a temporary place for wiki.

2019

Aug 29

2019

Aug 24

python global

globvar = 0

def set_globvar_to_one():
    global globvar    # Needed to modify global copy of globvar
    globvar = 1

def print_globvar():
    print(globvar)     # No need for global declaration to read value of globvar

set_globvar_to_one()
print_globvar()       # Prints 1

2019

Aug 23

pathlib is better than os.path

2019

Aug 18

git undo a commit

git reset --hard HEAD^
git push origin +branch_name  # force push 

2019

Aug 16

Car

  • Oil change today (every 3000miles)
  • Air engine filter changed today. (every 15000miles)

2019

Aug 16

python import a package

# ~/.bashrc
export $PYTHONPATH=/path/to/package:$PYTHONPATH

then the path will be shown in sys.path, then you can import package Another way is

import sys
sys.path.append(/path/to/package)

2019

Aug 14

python str.format()

'CPU  {: 4d}%'.format(100)
'CPU  {: 4d}%'.format(10)
'CPU  {: 4d}%'.format(0)
CPU   100%
CPU    10%
CPU     0%
'CPU  {:04d}%'.format(100)
'CPU  {:04d}%'.format(10)
'CPU  {:04d}%'.format(0)
CPU  0100%
CPU  0010%
CPU  0000%

If there is {} in string, change it to {{}}

title1 = r'$ \text {{Wavefunction for }} k = {:0} \; Å^{{-1}}$'.format(k)

2019

Aug 14

create a restricted guest user on linux

# root
useradd -s /bin/rbash -d /home/guest guest
mkdir /home/guest
chown guest:guest /home/guest
passwd guest

At this point, guest user still can access all the commands which are in $PATH. At least you need to remove all shell from $PATH. E.G. bash zsh

change guest shell to specific command

# write command to .sh file
sudo chsh -s /home/guest/guest-shell.sh guest

2019

Aug 13

2019

Aug 12

2019

Aug 12

macOS 应用开发 Swift 入门教程 - 菜鸟

感觉还是html最简单啊。。

2019

Aug 11

五度循环圈

C大调中所有的纯五度音程,连起来。 纯五度:7个半音。 重要性:纯五度的两个音,协和程度仅次于纯一度和纯八度 原因:频率比,泛音列 记法:共12个点,刚好是钟表的形状,C在12点

2019

Aug 10

2019

Aug 10

大乱斗

皮卡丘

ZeRo

零基础攻略 电玩部落

  • (上B)的作用:当角色处于浮空状态时,各种招式的形态都会发生变化,其中大部分上必杀技将能提供一段向上的位移。
  • 闪避通过肩键+左/右完成,能够在水平方向上进行位移并且躲避敌人的伤害。
  • 下+A:
  • 奔跑时按A
  • 连按A

2019

Aug 07

netdata

Web API

Webfile location: /opt/netdata/netdata-web-files/my.html

API usage: http://pc.moyi.yyrcd.com/api/v1/chart?chart=system.ram

API for shell

eval "$(curl -s 'http://localhost:19999/api/v1/allmetrics')"

# GPU RAM
NETDATA_NVIDIA_SMI_GPU0_MEM_USAGE_USED
# GPU UTIL
NETDATA_NVIDIA_SMI_GPU0_GPU_UTILIZATION_UTILIZATION

# CPU RAM
NETDATA_SYSTEM_RAM_USED
# CPU UTIL
NETDATA_SYSTEM_CPU_VISIBLETOTAL

2019

Aug 06

NFS setting

server:

sudo apt install nfs-kernel-server
sudo vim /etc/exports

client:

sudo apt install nfs-common
sudo vim /etc/fstab

if client is mac

use vifs instead of /etc/fstab, more detail

useful commands

showmount -e : Shows the available shares on your local machine
showmount -e <server-ip or hostname>: Lists the available shares at the remote server
showmount -d : Lists all the sub directories
exportfs -v : Displays a list of shares files and options on a server
exportfs -a : Exports all shares listed in /etc/exports, or given name
exportfs -u : Unexports all shares listed in /etc/exports, or given name
exportfs -r : Refresh the server’s list after modifying /etc/exports

2019

Jul 31

pytorch two test molecule

model = ANI_D.model.ANI_MO_Pair_Model(device=device)

coordinates = torch.tensor(
    [[[0.03192167, 0.00638559, 0.01301679],
      [-0.83140486, 0.39370209, -0.26395324],
      [-0.66518241, -0.84461308, 0.20759389],
      [0.45554739, 0.54289633, 0.81170881],
      [0.66091919, -0.16799635, -0.91037834]],
     [[-4.1862600, 0.0575700, -0.0381200], 
      [-3.1689400, 0.0523700, 0.0200000],
      [-4.4978600, 0.8211300, 0.5604100], 
      [-4.4978700, -0.8000100, 0.4155600],
      [0.00000000, -0.00000000, -0.00000000]]],
    requires_grad=True,
    device=device)

species = torch.tensor([[1, 0, 0, 0, 0], [2, 0, 0, 0, -1]], device=device)

pred, _, MO_num = model([(species, coordinates)])

2019

Jul 14

Nullboard Notes

2019

Jul 13

Alfred Youdao cmd + enter 发音

2019

Jul 02

TensorFlow-nightly anaconda setup

# base
conda update -n base -c defaults conda
conda update conda-build
# tf
conda create -n tf python=3.6 anaconda
conda update setuptools #tf needs setuptools>=41.0.0
pip install tf-nightly-gpu==1.14.1.dev20190620
conda install -c conda-forge jupytext
conda install -c conda-forge pysnooper
conda install -c conda-forge matplotlib
conda install -c anaconda jupyter 

2019

Jul 02

git

所有更改都add上

git add -u .

remove from git, but keep in local

git rm --cached mylogfile.log 
git rm --cached -r directory

2019

Jul 01

常用network工具

ip route
default via 10.30.160.1 dev enp3s0 proto dhcp metric 100 
10.30.160.0/20 dev enp3s0 proto kernel scope link src 10.30.171.30 metric 100 
169.254.0.0/16 dev enp3s0 scope link metric 1000 

ip route get 10.241.124.148
10.241.124.148 via 10.136.0.1 dev en0  src 10.136.196.12

2019

Jun 30

Wireguard

Install

Set Up WireGuard VPN on Ubuntu | Linode

IPv6

IPv4 only环境下通过Wireguard获取全局IPv6地址

tcpdump

richard@miami > sudo tcpdump -i wg0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wg0, link-type RAW (Raw IP), capture size 262144 bytes
12:05:06.856663 IP 172.22.2.2 > 172.22.2.3: ICMP echo request, id 28433, seq 0, length 64
12:05:06.856721 IP 172.22.2.2 > 172.22.2.3: ICMP echo request, id 28433, seq 0, length 64
12:05:06.876567 IP 172.22.2.3 > 172.22.2.2: ICMP echo reply, id 28433, seq 0, length 64
12:05:06.876592 IP 172.22.2.3 > 172.22.2.2: ICMP echo reply, id 28433, seq 0, length 64
12:05:07.859800 IP 172.22.2.2 > 172.22.2.3: ICMP echo request, id 28433, seq 1, length 64
12:05:07.859827 IP 172.22.2.2 > 172.22.2.3: ICMP echo request, id 28433, seq 1, length 64
12:05:07.879684 IP 172.22.2.3 > 172.22.2.2: ICMP echo reply, id 28433, seq 1, length 64
12:05:07.879707 IP 172.22.2.3 > 172.22.2.2: ICMP echo reply, id 28433, seq 1, length 64

ping

richard@mbpr > ping 172.22.2.3
PING 172.22.2.3 (172.22.2.3): 56 data bytes
64 bytes from 172.22.2.3: icmp_seq=0 ttl=63 time=32.214 ms
64 bytes from 172.22.2.3: icmp_seq=1 ttl=63 time=32.074 ms
^C
--- 172.22.2.3 ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 32.074/32.144/32.214/0.070 ms

2019

Jun 28

pm2

pm2 save  # Saving current process list
pm2 resurrect  #Manually resurrect processes

NY

pm2 stop wlm liwei qianchen aria gigim

2019

Jun 24

linux系统硬件信息

cat /proc/cpuinfo
lspci
lscpu
lshw # 最全

linux安装ssd硬盘

vim /etc/fstab  #安装硬盘上之后,mount到某文件夹;每次开机都会自动mount

Show RAM information

$ sudo lshw -short -C memory
H/W path      Device     Class          Description
===================================================
/0/0                     memory         64KiB BIOS
/0/3c                    memory         24GiB System Memory
/0/3c/0                  memory         8GiB DIMM DDR4 Synchronous Unbuffered (Unregistered) 2133 MHz (0.5 ns)
/0/3c/1                  memory         [empty]
/0/3c/2                  memory         16GiB DIMM DDR4 Synchronous Unbuffered (Unregistered) 2133 MHz (0.5 ns)
/0/3c/3                  memory         [empty]
/0/42                    memory         256KiB L1 cache
/0/43                    memory         1MiB L2 cache
/0/44                    memory         6MiB L3 cache
/0/100/1f.2              memory         Memory controller

2019

Jun 23

2019

Jun 23

nmap secure jupyter

2019

Jun 20

Transformer Model Bert XLNet

2019

Jun 18

和弦

三和弦

分类

  • 大三和弦 Cmajor(Cmaj C): C(大三度)E(小三度)G
  • 小三和弦 Dminor(Dmin Dm): D(小三度)F(大三度)A
  • 减三和弦 Bdiminished(Bdim B°): B(小三度)D(小三度)F

C大调和弦:

  • 1 4 5(C F G)为根音的和弦为大三和弦
  • 2 3 6(D E A)为根音的和弦为小三和弦
  • 7(B)为根音的和弦为减三和弦

和弦转位 和弦中的低音不等于根音 根音为C是C和弦(CEG)。 但是低音可以是C、E 或者 G

  • 原位 CEG
  • 第一转位 EGC - C/E 和弦/根音
  • 第二转位 GCE - C/G 和弦/根音

七和弦

分类

  • 大七和弦(大大七和弦 = 大三和弦 + 大七度) Cmajor7 (Cmaj7 CM7): C(大三度)E(小三度)G(大三度)B

  • 小七和弦(小七和弦 = 小三和弦 + 小七度) Aminor7 (Amin7 Am7): A(小三度)C(大三度)E(小三度)G

  • 属七和弦(属七和弦 = 大三和弦 + 小七度) Gdominant7 (Gdom7 G7): G(大三度)B(小三度)D(小三度)F 这里的小七度可以根据G的大二度来推算

  • 小大七和弦(小大七和弦 = 小三和弦 + 大七度) EminMaj7 (EmM7): E(小三度)G(大三度)B(大三度)D# 这里的大七度可以根据E的小二度来推算

和弦转位

  • 原位 CEGB - CM7
  • 第一转位 EGBC - CM7/E
  • 第二转位 GBCE - CM7/G
  • 第二转位 BCEG - CM7/B

总结 根音:C、D、E、F... 类型:M(Major)、m(minor)、M7、m7...

2019

Jun 18

TensorFlow: Could not load dynamic library 'libcupti.so.10.0'

conda install cudatoolkit=10.0 -c pytorch

2019

Jun 18

TensorFlow get operation by name

op = tf.get_default_graph().get_operation_by_name("training_2/SGD/gradients/loss_1/output_1_loss/Mean_grad/DynamicStitch")
op.inputs[1]

2019

Jun 18

2019

Jun 18

2019

Jun 18

2019

Jun 17

Piano - frequently used English word

  • C sharp 升C
  • B flat 降B

2019

Jun 17

Logic Pro X Shortcut

enter 回到开头 opt + 拖动 复制拖动 , 快退 . 快进 shift + , 快退8小节 shift + . 快进8小节


C 开启/关闭循环 U 开启/关闭特定片段循环 cmd + →/↑ 放大 cmd + ←/↓ 缩小 Z(空白处) 放大所有,充满显示区 Z(特定片段) 放大特定片段 Ctrl + opt + 选框 放大选框 Ctrl + opt + 空白 返回放大之前


cmd + A 全选 cmd + B 导出并轨 mp3

2019

Jun 16

2019

Jun 16

Piano

  • 36个黑键,52个白键,Total: 88
  • 每组5个黑键,7个白键,Total: 12个
  • 共7组,3 + 7x12 + 1 = 3 + 84 + 1
  • 中央C:C4

  • 4/4:每小节有4拍 / 以四分音符为一拍
  • 120:每分钟有多少拍(bpm: beats per minute)

  • 大调:全全半全全全半
  • 稳定音:1 5 3
  • 不稳定音:6 2 4 7
  • 不稳定音倾向于运动到稳定音,1 ← 2, 3 ← 4, 5 ← 6, 7 → 1

音程

  • 一四五八无大小
  • 音程度数:从1开始数
  • 半音数:从0开始数
  • 转位
    • 4 → 7 :增四
    • 7 ← 4 :减五
    • 度数相加等于九
    • 大小增减是互换,例如:大三转位变成小六度
    • 纯音程不变,例如:纯四度转位变成纯五度
  • 音程协和性
    • 完全协和音程:纯一度、纯八度
    • 协和音程:纯四度、纯五度
    • 不完全协和音程:大小三度、大小六度
    • 不协和音程:大小二度、大小七度、增四减五度

2019

Jun 13

npm install so slow, this might because no swap space enabled. https://stackoverflow.com/a/32444643/9581569

sudo fallocate -l 2G /swapfile #Create a 4 gigabyte swapfile
sudo chmod 600 /swapfile #Secure the swapfile by restricting access to root
sudo mkswap /swapfile #Mark the file as a swap space
sudo swapon /swapfile #Enable the swap
echo "/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab #Persist swapfile over reboots (thanks for the tip, bman!)

2019

Jun 12

Multiple CSS/JS Dropdowns https://stackoverflow.com/a/49745579/9581569 The dropdown buttons used in this website are based on this answer (Jquery way).

2019

Jun 10

2 numpy molecule

import numpy as np
coor = np.array([[[0.03192167,  0.00638559,  0.01301679],
[-0.83140486,  0.39370209, -0.26395324],
[-0.66518241, -0.84461308,  0.20759389],
[0.45554739,   0.54289633,  0.81170881],
[0.66091919,  -0.16799635, -0.91037834]],
[[-1.46909, 2.22911, 0.00000],
[-0.44909, 2.22911, 0.00000],
[-1.80908, 1.69374, 0.79886],
[-1.80909, 1.80497, -0.86308],
[-1.80909, 1.80497, -0.86308]]])
spe = np.array([[1, 0, 0, 0, 0], [1, 0, 0, 0, 0]])

2019

Jun 10

trainable weights

homo_model.animodel.layers[0].trainable
homo_model.weights

2019

Jun 10

print all numpy values

import sys
import numpy
numpy.set_printoptions(threshold=sys.maxsize)

2019

Jun 10

GPU status

watch -n 1 -d nvidia-smi 

2019

Jun 10

保持fork之后的项目和上游同步

git remote add upstream https://github.com/staticblog/staticblog.github.io.git
git remote -v
git fetch upstream
git checkout master
git merge upstream/master
origin  git@github.com:ibrother/staticblog.github.io.git (fetch)
origin  git@github.com:ibrother/staticblog.github.io.git (push)
upstream        https://github.com/staticblog/staticblog.github.io.git (fetch)
upstream        https://github.com/staticblog/staticblog.github.io.git (push)

2019

Jun 07

jupyter

jupyter notebook password
jupyter notebook --generate-config # ip port open_browser
conda config --set changeps1 False #terminal是否显示env名字

2019

Jun 07

git reset everything

git checkout -- .

2019

Jun 07

tensorflow gpu set

# 1
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.5)
with tf.Session(config=tf.ConfigProto(allow_soft_placement=True, gpu_options=gpu_options)) as sess:

# 2
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
tf.enable_eager_execution(config=config)
with tf.Session(config=config) as sess:

2019

Jun 07

vim Comment multiple lines https://stackoverflow.com/a/1676690/9581569

2019

Jun 07

nohup command &

nohup scp -P 2022 confs_gdb01-06_red03-07_cv_1_chkpts.tar.gz \
ly.yyrcd.com:/mnt/data/richard/ &

jobs
kill %1

2019

Jun 07

vim copy cut paste

y copy
d cut
p paste

2019

Jun 07

mongodb sort

db.getCollection('music163s').find({}).sort({ _id: 1})

2019

Jun 07

inspect

import inspect
print(inspect.getsource(tf.keras.metrics.RootMeanSquaredError))
print(inspect.getsource(tf.keras.metrics.mean_squared_error))
print(inspect.getmro(tf.keras.metrics.RootMeanSquaredError))

2018

2018

Dec 07

如何练习发声

面部

  • 笑肌
  • 嘶 练习
  • 张大嘴巴,做出咬苹果的姿式
  • 努嘴
  • 用舌头顶左边腮帮子

腹部

  • 站直,挺胸,深呼吸
  • 腹部使劲

伪声