04 Oct

Ubuntu删除无用的ppa(之前安装的ppa现在因为proxy缘故下载不下来,需要删除)

  1. 直接在/etc/apt/sources.list.d/文件夹中删除对应的文件即可。
  2. 可以安装ppa-purge

GitHub回到指定的commit

1
2
3
git clone $URL
cd $PROJECT_NAME
git reset --hard $SHA1

返回最近提交:git pull

更新了oh-my-zsh的主题

默认主题由于过于简洁导致时长分不清当前工作目录;因此更换了一个新的eastwood主题,这是和westwood相互照应吗🤔, 效果不错。 image.png

05 Oct

Check the version and codename in WSL

1
2
3
[~]$ lsb_release -dc
Description:    Ubuntu 20.04.5 LTS
Codename:       focal

Bug: Protocol “https:” not supported. Expected “http:” #2003

In node, when the npmversion is lower than 7.0.6, you will get the error. you can either upgrade the npmversion or unset you proxy settings.

Install NVIM

Trying to install nvim, and use the config from the github, there are some problems:

  1. mind the python, pathvariable, you need to change it.
  2. install the correct nodeversion, refer to the bug above. 16 is better.
  3. this sh use all from souce, so you might have problem when you install from the package manager ( like apt).
  4. the shell script needs to be update, some are not so good (it use zsh as default, but it don’t config the zsh).

Currently I will still use the vim with some default configs, when I have time, I will migrate to nvim. In case I forget, the relevant folders are ~/package, ~/tools.

Show the size of a directory

1
2
3
4
5
6
7
[main][~/archive/CS/data_structure/hashtable]$ du -sh *
4.0K    Cargo.lock
4.0K    Cargo.toml
4.0K    README.md
12K     hashtable.cpp
12K     src
20K     unsafe.gif

08 Oct

Ubuntu apt problem

When updating ubuntu with sudo apt update, got the error:

1
2
3
4
5
6
7
8
9
[~]$ sudo apt update
Hit:1 https://mirrors.ustc.edu.cn/ubuntu focal InRelease
Get:2 https://mirrors.ustc.edu.cn/ubuntu focal-security InRelease [114 kB]
Get:3 https://mirrors.ustc.edu.cn/ubuntu focal-updates InRelease [114 kB]
Get:4 https://mirrors.ustc.edu.cn/ubuntu focal-backports InRelease [108 kB]
Reading package lists... Done
E: Release file for https://mirrors.ustc.edu.cn/ubuntu/dists/focal-security/InRelease is not valid yet (invalid for another 14h 9min 28s). Updates for this repository will not be applied.
E: Release file for https://mirrors.ustc.edu.cn/ubuntu/dists/focal-updates/InRelease is not valid yet (invalid for another 15h 3min 44s). Updates for this repository will not be applied.
E: Release file for https://mirrors.ustc.edu.cn/ubuntu/dists/focal-backports/InRelease is not valid yet (invalid for another 14h 11min 52s). Updates for this repository will not be applied.

Run:

1
sudo hwclock --hctosys

This command gets the latest time from Windows machine’s RTC and sets the system time to that.

09 Oct

Git SSH

I want to add another github account in my terminal, I refer stackoverflow for some ways. The following is a work way:

  1. Generate new ssh id_rsakey (Link1 & Link2)
  2. Add the SSH key to ssh-agent Link
  3. Add a new SSH key to your account Link
  4. Change remote for repository from httpsto git
1
2
3
4
5
6
ssh-keygen -t rsa -b 4096 -C "mail@host.com" -f id_rsa_user  # step 1: should at ~/.ssh/

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa_user  # step 2: add ssh key to ssh-agent

git remote set-url origin git@github.com:username/repository.git #step 4: change remote for the repo

This is also a work Link. I haven’t give it a try.

10 Oct

yt-dlp

Download the youtube video, the youtube-dlis so slow, even with proxy. Use the command:

1
yt-dlp -f b --proxy http://$host_ip:7890 $LINK

Speed is alright.

14 Oct

Make microsoft software available even when using proxy

Use the clash, then in UWP Lookback, mark the software you want to use. image.png

15 Oct

Make pythonexcute Python 3

Install python-is-python3 with

1
sudo apt install python3

Then the python2in your computer will also be useless, then just

1
sudo apt autoremove python2 

and every thing works fine.

Change the hostname of Ubuntu

The default config for standard Ubuntu is at /usr/hostnameand /usr/hosts, just replace them with the name you want. But in WSL2, you should change the wsl.confwhich is under /usr/wsl.confwith

1
2
3
[network]
hostname = focal
generateHosts = false

Then restart, everything works fine.

18 Oct

Picture the code

siliconis a tool that can make png file with code input.

1
silicon main.rs -o main.png

Use with cargo install silicon, in Ubuntu, perhaps need install some libs to make it work, use apt search xxxto search the package.

20 Oct

SQL standard

I am working miniob to add some basic SQL syntex, I find in most database, like mysql, postgres, mariadb, the SQL query select id, * from t;will cause the SQL error.

But in spark-sql, I can even write this query: select id, *, id, *, id from t;, this is ridiculous, I need to remove the COMMA STAR attr_listin attr_listcause it is not the standard SQL in most databases.

Docker in WSL

I install dockerin my WSL2, I can test something on wsl mysql easily. My conf is

1
2
[boot]
command="service docker start"

But since wsl supports systemdon Sep, after I set

1
2
3
[boot]
systemd=true
command="service docker start"

I can’t start my docker service, I tried sudo dockerd --debug, sudo systemctl start dockerfrom stackoverflow, but none of them works. Then I tried remove systemd=true, docker works again. But I still don’t know why.

22 Oct

Type Conversion in C++

  1. Implicit Type Conversion
1
2
3
4
5
6
7
8
int num_int = 99;
double num_double;
num_double = num_int;

// Or
int num_int;
dourble num_double = 9.99;
num_int = num_double;

Implicit type conversion may cause data lossing when convert the larger type to smaller type. like from Long double to double.

  1. Explict Type Conversion
  • C style type conversion
1
2
3
4
(data_type)expression
int num_int = 26;
double num_double;
num_double = (double)num_int;
  • Function-style casting
1
2
3
4
data_type(expression)
int num_int = 23;
double num_double;
num_double = double(num_int);
  • Type conversion Operators
    • static_cast
    • dynamic_cast
    • const_cast
    • reinterpret_cast

25 Oct

The wingetis built-in program for windows to install softwares. The scoopis another package manager like brewin Mac, aptin Debian.

The text to ASCII, use the figletcommand (a fun fact: there is also a software named toilet that can also generate ASCII characters.

The fehuse the X window to display image, which is very lightweight, besides, use the explorer.exe xxx.pngcan also open the image file. Just add an alias with alias winfile="explorer.exe". This is very useful.

01 Nov

SELECT *will make the query slow

  1. 效率低的原因
    1. 不需要的列会增加数据传输时间和网络开销
      1. 需要解析更多的对象、字段、权限、属性等相关内容,在SQL语句复杂,硬解析较多的情况下,会对数据库造成沉重的负担
      2. 增大网络开销;*有时会带上如log、IconMD5之类的无用且大文本字段,数据传输size会集合增长。如果DB和应用程序不在同一台机器,这种开销非常明显。
      3. 即使MySQL服务器和客户端是在同一台机器上,使用的协议还是tcp,通信也是需要额外的时间。
    2. 对于无用的大字段,如varchar、blob、text,会增加io操作
      1. 准确来说,长度超过728字节的时候,会先把超出的数据序列化到另外一个地方,因此读取这条记录会增加一次io操作。
    3. 失去MySQL优化器“覆盖索引”策略优化的可能性
      1. 基于MySQL优化器的“覆盖索引”策略又是速度极快,效率极高,业界极为推荐的查询优化方式。

18 Nov

perf tool in WSL2

Normally, there is no perf tools in WSL2 linux, (Debian/Ubuntu), in order to use perf tools, you need to use WSL kernel to compile it locally. The folder is /WSL*/tools/perf. Before compile, install the bison and flex. Then just run make. After compiling, there are two ways to use perf:

  1. add the perf realpath to PATH, like export PATH=$PATH:/<path of perf> in .zshrc or .bashrc file.
  2. just copy the perf file to usr/local/bin.

Way 2 is better.

Then refer this blog and flamegraph github readme file to draw flamegraph.

Python tools

There are some tools to check the python code. Like mypy, pyflakes3, black. In C/C++, cpplint is a good choice.

19 Nov

IRC on Debian

I am using the weechat as my IRC client, my IP is banned by libera, luckily, the OFTC is still available. There are some interesting channels on Debian IRC, and I even find a #debian-zh channel.

Here are step I use weechat(I did not use the ssl):

  1. use /help server to check some useful command to connect, list, or delete a server.
  2. use /server add oftc irc.oftc.net to add this server to weechat. PS. refer to weechat guide
  3. you can alias your name like /set irc.server.oftc.nicks "<your nicks>"
  4. some channels like #debian-zh requires you to register and verify your usename. refer to msg NickServ help.
  5. use /join #debian-zh, here you are!

IRC NickServ

Some channels require you to register a nickname before chatting. /msg NickServ help will show how to register. use /msg NickServ register <passwd> <mail> to register a nickname. Both are required to register. mail is only used to find the passwd when you do not remember. After that you can use /msg NickServ info <nick> and /msg NickServ status <nick> to check your nickname. image

Blog with hugo and papermod

Coder theme supports code not well, so I choose change coder to papermod.

It takes me a lot of time to understand the domain. At last, it works! I put the CNAME file in the static folder according to manual, then every time I update my blog, aucker.me works well, cool.👏

Plus, I also learn a git command refererence:

Delete a remote branch

1
2
3
git push origin --delete <branch> # Git version 1.7.0 or newer
git push origin -d <branch>   
git push origin :<branch>         # Git version older than 1.7.0

Delete a local branch

1
2
3
git branch --delete <branch>
git branch -d <branch>
git branch -D <branch>

To set a local mirror of git, refer this

20 Nov

IP地址是如何跳转的

很久之前利用GitHub pro的账号在namecheap上白嫖了一个一年的.me 域名,于是乎就可以用这个域名作为我的博客地址。 这两天在配置博客的时候老是出问题,问题的起因就在于用了hugo中的papermodx主题,但是之前用papermod构建的主题用aucker.me托管之后不会自动更新,现在在我的chrome上输入aucker.github.io之后还是会跳转到aucker.me,这个问题困扰了我好久,直到我在Firefox上输入aucker.github.io之后,并没有跳转。我意识到可能是浏览器的问题。

11 Feb 2023

Set the token for private repo

When you push commits in private repo, you have to enter your username and password, if you enable two step authentication, you have to use your token, so set the token before push can save a lot of time

1
git remote set-url --push https://username:token@github.com/username/repo.git

Then you can directly push your commits.

You can also use ssh to push your commits other than https, before this, you need to configure ssh key in your computer and GitHub, then:

1
git remote set-url --push git@github.com:username/repo.git

Install deb file in debian manually

  1. sudo apt install file.deb
  2. sudo dpkg -i file.deb

Both works on debian/ubuntu.

23 Mar 2023

Configure hugo blog to render images well

This is also a MD format, just refer to stackoverflow.

LaTeX compile problem

When I compile my thesis, there is a problem: Something's wrong--perhaps a missing \item. \end{thebibliography}.

The reason is the *.bbl file under this repo, but there is no \cite{} on the paragraph, I will encounter a compilation problem.

Solution for me:

  1. delete the *.bbl file
  2. edit the *.tex file, add \cite{*} anywhere
  3. recompile, all done<3

25 Mar 2023

How to start docker image in CLI

Use mysql as example, when download from the dockerhub, you can use docker images to list all the images.

Then you need to start this image, use the command:

1
docker run --name mysql5.7 -e MYSQL_ROOT_PASSWORD=passwd -d mysql:tag

this command will start this image in a container, you can use docker ps or docker containers ls to list all the active containers.

Note: when you got nothing when run docker ps, perhaps some container is not active, just use the docker start container-id to start the container. Is this a bug?

Then when we want to use this mysql, just run the command:

1
docker exec -it mysql mysql -uroot -p

06 May 2023

Ping not working in WSL2 Debian

Use ping in Debian WSL2, got ping: socket: Operation not permitted, after run with sudo, I can use ping again, weird.

There is a issue in GitHub, just for reference.

09 May 2023

Reading the book The Linux Command Line.

Below is the Ch6, Redirection.

Redirecting Standard Error

While we have refered to the first three of these file streams as standard input, ouput, and error, the shell references them internally as file descriptors 0, 1 and 2, respectively. Since standard error is the same as file descriptor 2, we can redirect standard error with this notation:

1
ls -l /bin/usr 2> ls-error

Redirecting Standard Output and Standard Error to One File

There are cases in which we may want to capture all of the output of a command to a single file. So we need redirect both standard output and standard error at the same time. There are two ways, the first traditional way, which works with old version of the shell is as follows:

1
ls -l /bin/usr > ls-output 2>&1

Using this method, we perform two redirections. First we redirect standard output to the file ls-output and then we redirect file descriptor 2 (standard error) to file descriptor 1 (standard output) using the notation 2>&1.

Recent version of bash provide a second, more streamlined method for performing this combined redirection shown here:

1
ls -l /bin/usr &> ls-output

In this example, we use the single notation &> to redirect both standard output and standard error to the file ls-output. We can also append the standard output and standard error streams to a single file like so:

1
ls -l /bin/usr &>> ls-output

Disposing of Unwanted Output

When we don’t want output from a command, we just want to throw it away. This applies particularly to error and status messages. The system provides a way to do this by redirecting output to a special file called “/dev/null”. This file is a system device often referred to as a bit bucket, which accepts input and does nothing with it. To supress error messages from a command, we do this:

1
ls -l /bin/usr 2> /dev/null

Below is Ch7, Shell.

Pathname Expansion

The mechanism by which wildcards work is called pathname expansion. If we try some of the techniques that we employed in earlier chapters, we will see that they are really expansions. Given a directory that looks like this:

1
2
[~/Documents]$ ls
alg  algorithms  beamer  Blog  cuckoofilter  data-structure  flame-graph  oi_slides  python101  rust

we could carry out the following expansions:

1
2
3
4
[~/Documents]$ echo a*
alg algorithms
[~/Documents]$ echo *s
algorithms oi_slides

or even this:

1
2
[~/Documents]$ echo [[:upper:]]*
Blog