二、八、十、十六进制转换(图解篇)

背景(Contexts)

之前使用SQL把十进制的整数转换为三十六进制,SQL代码请参考:SQL Server 进制转换函数,其实它是基于二、八、十、十六进制转换的计算公式的,进制之间的转换是很基础的知识,但是我发现网络上没有一篇能把它说的清晰、简单、易懂的文章,所以我才写这篇文章的念头,希望能让你再也不用担心、害怕进制之间的转换了。

下文会分4个部分对这个图进行分解,针对每个部分会以图文的形式进行讲解:

  1. (二、八、十六进制) → (十进制);
  2. (十进制) → (二、八、十六进制);
  3. (二进制) ↔ (八、十六进制);
  4. (八进制) ↔ (十六进制);
Read more

Icarus 添加 Mermaid 图表支持功能并修改为透明背景样式

Animal+int age+String gender+isMammal()+mate()Duck+String beakColor+swim()+quack()Fish-int sizeInFeet-canEat()Zebra+bool is_wild+run()

经过一番折腾,我的博客支持 Mermaid 图标功能了。

如何在Go中为控制台/终端输出添加颜色

许多关于 bash 的文章都建议使用看起来像\e[39m漂亮颜色的东西,虽然这些在 bash 中工作得很好,但对于 Go 来说却是另一回事——字符串只是按原样呈现。然而,有一些库可以让您为输出着色,但是代码太臃肿了,您甚至无法找到要解决的问题的答案。

毕竟,并不是每个人都想仅仅为了颜色而导入一个库。

Highlight.js bash and shell

bash

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~ [10:11:31] 
$ echo 'hello'
hello

# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~ [10:11:45]
$ pwd
/Users/ganzhixiong

# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~ [10:12:29]
$ cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~ [10:14:47]
$ echo $0
-zsh

shell

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~ [10:11:31] 
$ echo 'hello'
hello

# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~ [10:11:45]
$ pwd
/Users/ganzhixiong

# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~ [10:12:29]
$ cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~ [10:14:47]
$ echo $0
-zsh

sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~ [10:11:31] 
$ echo 'hello'
hello

# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~ [10:11:45]
$ pwd
/Users/ganzhixiong

# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~ [10:12:29]
$ cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~ [10:14:47]
$ echo $0
-zsh
1
ls -AF | grep -v '[^/]$' | wc -l
1
2
3
4
5
6
7
8
9
10
11
12
bash
$ echo $EDITOR
vim
$ git checkout main
Switched to branch 'main'
Your branch is up-to-date with 'origin/main'.
$ git push
Everything up-to-date
$ echo 'All
> done!'
All
done!
1
2
3
4
5
6
7
8
9
10
11
12
shell
$ echo $EDITOR
vim
$ git checkout main
Switched to branch 'main'
Your branch is up-to-date with 'origin/main'.
$ git push
Everything up-to-date
$ echo 'All
> done!'
All
done!
1
2
3
4
5
6
7
8
9
10
11
12
shell-session
$ echo $EDITOR
vim
$ git checkout main
Switched to branch 'main'
Your branch is up-to-date with 'origin/main'.
$ git push
Everything up-to-date
$ echo 'All
> done!'
All
done!
1
2
3
4
5
6
7
8
9
10
11
12
console
$ echo $EDITOR
vim
$ git checkout main
Switched to branch 'main'
Your branch is up-to-date with 'origin/main'.
$ git push
Everything up-to-date
$ echo 'All
> done!'
All
done!
1
2
3
4
5
6
7
8
9
10
11
12
properties
$ echo $EDITOR
vim
$ git checkout main
Switched to branch 'main'
Your branch is up-to-date with 'origin/main'.
$ git push
Everything up-to-date
$ echo 'All
> done!'
All
done!
1
2
3
powershell
cd ~/development
tar xf ~/Downloads/flutter_linux_2.2.3-stable.tar.xz
1
2
3
console
cd ~/development
tar xf ~/Downloads/flutter_linux_2.2.3-stable.tar.xz
1
2
3
shell
cd ~/development
tar xf ~/Downloads/flutter_linux_2.2.3-stable.tar.xz
1
2
3
bash
cd ~/development
tar xf ~/Downloads/flutter_linux_2.2.3-stable.tar.xz

Linux上统计文件和目录个数命令详解

使用Linux的时候我们经常百度或谷歌搜索命令,其实很多比较长命令我们没必要去死记它,其实你如果把长命令的每个命令分解下,就很容易记住它了。

比如统计目录下文件个数的命令 ls -l | grep "^-" | wc -l ,我们先分析这条命令中各个命令是什么意思,然后再推导出统计目录下目录个数的命令。

Read more

Father records +

Here's something encrypted, password is required to continue reading.