0%

我懒

1
2
pandoc '.\word.docx' -o
test.tex --extract-media="./"

--extract-media参数设置导出媒体文件(如图片)夹的路径, 不设置不导出

int 2 string

弯路

网上一般查到会说用itoa函数,

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdlib.h>
#include <stdio.h>
int main()
{
int number1 = 123456;
int number2 = -123456;
char string[16] = {0};
itoa(number1,string,10);
printf("数字:%d 转换后的字符串为:%s\n",number1,string);
itoa(number2,string,10);
printf("数字:%d 转换后的字符串为:%s\n",number2,string);
return 0;
}

像菜鸟教程都这样教, 不过itoa不是基础库函数而且不符合C99标准, 编译时候直接报警

1
2
3
4
5
6
7
8
9
main.c:13:13: warning: implicit declaration of function 'itoa' is invalid in C99 [-Wimplicit-function-declaration]
itoa(n, pr, 10);
^
1 warning generated.
Undefined symbols for architecture x86_64:
"_itoa", referenced from:
_main in main-2e9155.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

正道

后面找到用sprintf

1
2
3
4
5
6
7
8
9
10
#include<stdio.h>  
#include<stdlib.h>

void main (void)
{
int num = 100;
char str[25];
sprintf(str, " %d" , num);
printf ("The number 'num' is %d and the string 'str' is %s. \n" ,num, str);
}

补充

不过遇到比较长的整型时候, 发现疑似溢出的情况(像这个负号)

1
2
3362695274           // 输入
- 9 3 2 2 7 2 0 2 2 // 输出(每个数字中间加了空格))

其实是整型应该从int换成long, 然后就正常了

1
2
3
4
5
6
7
8
int main()
{
char str[10];
long x = 1234567890L;
sprintf(str,"%ld",x);
printf("%s",str);
return 0;
}

参考:

以后都用ssh来git

生成 SSH Key

  1. 设置git的用户名和邮箱

    一般考虑用来管理github的仓库, 所以这里的用户名和邮件都建议设置成github账号对应的

    1
    2
    git config --global user.name "username"
    git config --global user.email "example@gmail.com"
  2. 有则备份, 无则跳过

    先到.ssh文件夹下面看看有没有已经生成的ssh key, 有的话要么直接拿来用, 要么以防万一备个份再重新生成ssh key(覆盖旧文件)

    • mac/linux 路径: ~/.ssh
    • windows 路径: C:/User/username/.ssh
  3. 生成 SSH Key
    没错你又要再打一次邮箱地址

    1
    ssh-keygen -t rsa -C "example@gmail.com"

    然后连按三次回车, 密码为空就好了, 没事的. 看到一个奇怪的图形后说明OK了

  4. 测试github

    1
    ssh git@github.com

    输入yes, 你的电脑就认识github.com了, 也应该说明ssh没问题了

连接github

https://github.com/settings/keysnew SSH Key, 复制.ssh/rsa_id.pub下的全文黏贴进去, 起个好点的名字, 保存.

have to admit that WSL is not befect.

General tutorial always bring up ERROR:

1
2
$ service mysql start
mysql: unrecognized service

Luckily, I found an issue in WSL Github:(a bit modified)

1.Remove MySQL 8.x:

1
2
sudo apt-get purge mysql-server mysql-client
sudo apt-get -y autoremove

2.Change to MySQL 5.x candidate:

get download url from https://dev.mysql.com/downloads/file/?id=487007 or download the .deb directly

1
2
wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb

3.Double check current apt policy of MySQL is 5.x:

1
2
sudo apt policy mysql-server (it will show 5.x is the default candidate)
sudo apt-get update

4.Install MySQL 5.x

1
2
sudo apt-get -y install mysql-server
sudo service mysql start #(this should work without error)

5.Change to MySQL 8.x candidate

1
2
3
sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb (select 8.x)
sudo apt policy mysql-server (it will show 8.x is the default candidate)
sudo apt-get update

however, I still find that the candidate is 5.x.

1
2
3
4
5
6
7
8
9
10
$ sudo apt policy mysql-server
mysql-server:
Installed: (none)
Candidate: 5.7.27-0ubuntu0.18.04.1
Version table:
5.7.27-0ubuntu0.18.04.1 500
500 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 Packages
500 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-security/main amd64 Packages
5.7.21-1ubuntu1 500
500 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/main amd64 Packages

Continue the tutorial and I found out that it will download 8.x after all, so just go ahead!

6.Install MySQL 8.x

1
2
3
sudo apt-get -y install mysql-server
Modify a script as there is a bug
sudo vim /etc/init.d/mysql

search for a line “. /usr/share/mysql/mysql-helpers” and change it to
“. /usr/share/mysql-8.0/mysql-helpers”

7.Upgrade system tables to MySQL 8.x

1
2
sudo service mysql start #(this should start without error)
sudo mysql_upgrade -u root -p

then enjoy your MySQL.