对博客的新规划

与其说是对博客的规划,倒不如是说对我最近紊乱生活的梳理。漫无目的会让人疲惫,前一阵子我累得走也不动,站也不直。糟乱之下,自然不会做一些轻松愉快的事情。现在让我最头疼的是注意力涣散,还有拖延的毛病。

话说对个人来说,长效的改变都是一点一滴开始的,晨练从几日前开始了,吃灰的哑铃擦干净放到了门边,清晨喝水尚未落实到位,前几天删了几个博客分类,在 spirit 和 life 之间犹豫许久,最后认为信仰、神话与宗教掺杂的精神世界也是生活的一部分,遂保留了后者。

常常说起时间不够用,其实是把时间花费在了发呆,刷推,喝汤,听歌,看视频上,娱乐在正常生活所占的地位的确重要,但不仅仅是我,更多人用一种只会使自己更加疲惫、而非让精神愈发充沛的方式去娱乐。往往在电脑手机的信息冲刷下精疲力尽,累得发困,还怎么继续充实地生活工作学习呢?

有时候很渴,渴得让我烦躁,却懒得去接一杯水;有时候憋尿,千钧一发,岌岌可危,非要做完手头的事情才去厕所。现在感觉这跟自己过不去的做法是个笑话,但又那么真实、对我来讲理由充分。

Read More

Mac Address Spoofing and Dynamic Hostname on Linux

Last Update: 2019-09-10


Functions: changing the mac address and hostname for each boot.

Tip: The example code is on Debian.

Mac Address Spoofing

Use macchanger to spoof manually

The macchanger (a.k.a., the GNU MAC Changer) provides a variety of features such as changing the address to match a certain vendor or completely randomizing it.

Install the package macchanger from the official repositories.

1
2
sudo apt update
sudo apt install macchanger -y

Display available network interfaces.

1
ip a

Change the mac address:

1
sudo macchanger -r your_interface_name

Read More

利用 GPG 签名验证文件的完整及可靠性

如果你想要同时验证下载文件的可靠性(拥有者)和完整性(内容),你需要依赖于加密签名。本教程中,将描述如何使用 GnuPG(GNU Privacy Guard)来检查文件的可靠性和完整性。

本例中将验证一个从 https://opensuse.org 上下载的磁盘镜像。这个网站中,发行商会提供他们的公钥,还有它用于密钥验证的指纹。

Public Key and Fingerprint

至于下载的文件,发行商提供它了相关的利用 GPG 签名的含有 sha256 校验值的文件。

Download Files

安装 GnuPG 并且生成一个键对

在 Debian、Ubuntu 和其他 Debian 衍生版上:

1
sudo apt install gpg

在 Fedora、CentOS 或者 RHEL 上:

1
sudo yum install gnupg

完成安装后,生成一个键对。

Gen Key

在生成键对期间,用户会被要求提供姓名和 email,还有保护私钥的密码。用户同样也可以选择键对何时过期(默认不会过期)。依赖于用户选择的 key 的大小(在 1024 和 4096 位之间),key 生成会花上几分钟或者更多,同时它要求收集来自你桌面活动的大量的随机数据。(比如键盘输入、鼠标移动、磁盘访问等等,所以这个时候随便动动鼠标键盘什么的)。

一旦 key 生成完毕后,公钥和私钥会存储在 ~/.gnupg 目录。

Created

Read More

Centos 7 下安装 Shadowsocks Python 版

本文以 Vultr 购买的 Centos 7 主机为例,详细介绍了安装 Shadowsocks Python 版的方法。建议以密钥的方式绑定主机并以此登录,注意保护好自己的密钥。

准备

首先,更新系统:

yum update

为了防止被人暴力扫描破解登录密码,我们先对 Vultr 自动生成的密码进行重置:

passwd root

这里我个人使用了 256 位随机密码,包含特殊字符。

另外也可以安装 fail2ban 来禁止掉反复尝试登录的ip地址:

yum install fail2ban

启用 fail2ban:

systemctl enable fail2ban

Read More

Line and Circular Interpolation on XY Plane

Tips: This is my homework of “Computer Control System” course, so mistakes do happen.

This article will discuss an interpolation algorithms for line and circular. And it provides an implement of C language.

Interpolation Algorithms

Many numerical control machines are powered by stepping motors. When a pulse is sent to a stepping motor, the stepping motor alters its position by a unit step. Two motors can be used to control the XY movements of an arm or tool over a working plane.

If the pulse are generated by a device which can remember or generate a specified train of pulses, repetitive operations such as grinding, painting, or cutting can be performed hunderds of times with virtually no variation. A microcomputer is an obvious choice to gernerate and remember the pulse.

Since stepper motors can move only in discrete steps, we must approximate the actual curve by a series of small XY motions. Many algorithms rely upon parametric functions such as sine and cosine to perform the necessary calculations. Parametric functions, however, typically require a high degree of numeric precision. Calculating sine and cosine values with a microcomputer can be too time-consuming to be useful in a realtime application.

The following two algorithms require no parametric functions. This makes them ideally suited to the
computation and memory capacities of microcomputers. Since these algorithms do not require a large amount of complex mathematical calculation, they are fast enough to be used in real-time applications.

Read More

Mastodon