Minyu

知不知,尚矣;不知知,病也。圣人不病,以其病病。夫唯病病,是以不病。

服务端

rsyncd

raid一般不用于rsync远程同步,毕竟每次上传下载要增加一次唤醒磁盘阵列的次数和操作读写,日常还是以位于NVMe的work和doc为主,定期归档到raid即可。

/etc/rsyncd.conf:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
pid file = /run/rsyncd.pid
use chroot = yes
read only = false

uid={REAL_USER}
gid={REAL_USER}

auth users = {RSYNC_USER}
secrets file = /etc/rsyncd.secrets

[raid]
path = /data/raid/Sync
comment = personal data on raid

[work]
path = /home/{REAL_USER}/Workspace
comment = work data

[doc]
path = /home/{REAL_USER}/Documents
comment = documents

密码:

1
echo "{RSYNC_USER}:$(pwgen -syn1 24)" > /etc/rsyncd.secrets
阅读全文 »

pip 一直未提供软件包整体更新的功能,一般可以通过 list 参数列出所有的三方包再进行 install --upgrade 操作解决问题。

但在 Gentoo 还有一个问题:有部分程序是依赖于系统级的三方包的,如果用户级自己也安装了同一个包,但版本有问题,可能导致程序运行出错。比如我使用 calibre 时就曾因为用户级安装 html5-parserPyQt5 包的问题导致启动直接抛出异常

使用 equery g calibre | grep dev-python 可以查看到目前 calibre 依赖的 python 三方包还是很多的:

阅读全文 »

在Centos6上允许ip转发只需要在 /etc/sysctl.conf 里加入

net.ipv4.ip_forward = 1 

即可(reboot或用sysctl -p立即生效)

可在Centos7里这样是远远不够的。

阅读全文 »

grub引导

1
pacman -S grub efibootmgr

软件包管理工具和软件源

管理工具

1
2
3
4
5
pacman(使用wget)
powerpill
yaourt(可使用axel多线程加速)
reflector
reflector -l 30 -f 12 | cat > mirrorlist

配置/etc/pacman.conf 软件源

1
2
3
4
5
6
7
8
9
# to install owerpill
[xyne-any]
SigLevel = Required
Server = http://xyne.archlinux.ca/repos/xyne/

# archlinux中文社区
[archlinuxcn]
SigLevel = Optional TrustAll
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch
阅读全文 »

第一题

将考研分数分类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <cstdio>

int main(){
int t, a, b, c, d, s;
scanf("%d", &t);
while(t--){
scanf("%d %d %d %d", &a, &b, &c, &d);
s = a + b + c + d;
if(a < 60 || b <60 || c < 90 || d < 90 || s < 310)
printf("Fail\n");
else if(s < 350)
printf("Zifei\n");
else
printf("Gongfei\n");
}
return 0;
}
阅读全文 »

Given a 2D board and a list of words from the dictionary, find all words in the board.

Each word must be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once in a word.

For example,

1
2
3
4
5
6
7
8
Given words = ["oath","pea","eat","rain"] and board =
[
['o','a','a','n'],
['e','t','a','e'],
['i','h','k','r'],
['i','f','l','v']
]
Return ["eat","oath"].
阅读全文 »

这学期开始学计算机图形学基础,课后有个习题让用OpenGL实现折线和矩形的橡皮筋绘制技术,只要求了用右键菜单实现功能的选择。老师嫌有些简单,就说要加上教材上基于键盘实现的代码,可教材上的代码还是要先把鼠标移到一个点上,再用按键确定这个点,这样配合着使用很别扭。我想既然用键盘了,不如直接写个可以完全由键盘控制绘图过程的代码吧。

正好现在我想学下Python,就决定拿这道题开始练手。代码虽然很简单,但写的过程中,一边要学Python的语法,一边又要查OpenGL的库函数,还是挺费精力的。这算是我第一次用Python写代码,结果还算满意,写个博客纪念下吧。

程序用鼠标完成绘图就不用说了。键盘方面  A、D、W、X 用于移动窗口内的点,P用于选定某一点,L、 R、 C 分别为菜单各功能的快捷键,用于选择画折线、画矩形或清除图形。所有按键不区分大小写。为了使程序使用方便,键盘和鼠标没做什么限制,既可以分别使用,也可以结合使用。代码如下:

阅读全文 »

fdisk -l 查看的分区情况:

1
2
3
4
5
6
7
8
9
10
11
12
13
Disk /dev/sda:465.8 GiB,500107862016 字节,976773168 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:gpt
磁盘标识符:CCC3A254-1C29-4936-8535-53196D51488E

Device Start End Sectors Size Type
/dev/sda1 2048 307199 305152 149M EFI System
/dev/sda2 307234 6598690 6291457 3G Linux swap
/dev/sda3 6598691 111456299 104857609 50G Linux filesystem
/dev/sda4 111456300 136622132 25165833 12G Linux filesystem
/dev/sda5 136622133 976773134 840151002 400.6G Linux filesystem
阅读全文 »
0%