0%

前言

发现了游戏里一个有意思的机制:

血量低于80%时,减伤(80%-当前血量%)

无聊就打算建模一下,看看残血减伤有多可怕。

阅读全文 »

Connecting to VPS in VS Code

Installation

In Windows

Install VS Code. Install Remote - SSH in VS Code.

Press F1, edit the configuration. Then Connect.

In Explorer, you can open the remote directory.

Using FTP in VPS

Install vsftpd

sudo apt-get update
sudo apt-get install vsftpd

check vsftpd version

vsftpd -v

Change FTP password

sudo passwd ftp

Configuration

The configuration file locates in /etc/vsftpd.conf . Change Below:

listen=YES
write_enable=YES
local_umask=022

Go to file /etc/pam.d/vsftpd , change below:

#auth    required        pam_shells.so

Install WinSCP

In Windows, install WinSCP .

Choose SFTP. Login to VPS.

Done. Enjoy.

File Commands

pwd

Print Working Directory. Find out the path of the current working directory.

cd

Change Directory. Change the current working directory

  • cd somewhere to go to that directory.
  • cd .. (with two dots) to move one directory up.
  • cd to go straight to the home folder.
  • cd- (with a hyphen) to move to your previous directory.

ls

List. View the contents of a directory.

  • ls will list current directory.
  • ls somewhere will list the directory named.
  • ls -R will list all the files in the sub-directories as well.
  • ls -a will show the hidden files.
  • ls -al will list the files and directories with detailed information like the permissions, size, owner, etc.

cat

Concatenate. List the contents of a file on the standard output (stdout).

  • cat filename (or filename1 filename2 filename3 …) will show content of given filename(s).
  • cat -n filename will show contents with line numbers.
  • cat > filename creates a new file
  • cat filename1 filename2 > filename3 joins two files (1 and 2) and stores the output of them in a new file (3)
  • to convert a file to upper or lower case use, cat filename | tr a-z A-Z > output.txt

cp

Copy. cp filename somewhere will copy file to the directory.

mv

Move files, and also can be used to rename files.

  • mv filename somewhere will move the file to the directory.
  • mv old_filename new_filename will rename the file with a new name.

mkdir

Make Directory.

  • mkdir somewhere
  • mkdir somewhere1/somewhere2/…/destination
  • mkdir somewhere1/destination/somewhere2

rmdir

Remove Directory. Only allows you to delete empty directories.

rm

Remove Files. rm -r alternative to rmdir.

touch

Create a blank new file.

locate

Locate a file. Use locate -i to be case-insensitive. locate A*B search files contain A and B.

find

Similar to locate. But you need to give it a directory.

grep

Search through all the text in a given file.

Higher

sudo

SuperUser Do.

df

Get a report on the system’s disk space usage, shown in percentage and KBs.

df -m to show in megabytes.

du

Disk Usage. type -h to get human readable statics.

View the first lines of any text file.

head -n somenumber filename.txt. View fist somenumber lines of file.

tail

View last lines.

diff

Difference. Compares the contents of two files line by line. After analyzing the files, it will output the lines that do not match.

tar

Archive multiple files into a tarball.

chmod

Change the read, write, and execute permissions of files and directories.

chown

Change or transfer the ownership of a file to the specified username.

jobs

Display all current jobs along with their statuses.

Kill

Send a certain signal to an app and instructs the app to terminate itself. Kill by its PID.

Reference

https://www.hostinger.com/tutorials/linux-commands

Squarified Treemap

Algorithm

procedure squarify(list of real children, list of real row, real w)
begin
real c = head(children);
if worst(row, w)  worst(row++[c], w) then
squarify(tail(children), row++[c], w)
else
layoutrow(row);
squarify(children, [], width());
fi
end
阅读全文 »