预装正版Office家庭学生版无法激活问题的处理

电脑型号:笔记本RedmiBook Pro 14

操作系统:预装版Windows 10家庭版

Office:预装版Office 2019家庭学生版

激活问题:提示“此帐户尚无Office关联”

解决方式:经与微软官方联系,技术人员邮件发送修复工具,修复后激活成功,工具下载链接如下:

https://microsoftdownload.oss-cn-shanghai.aliyuncs.com/Tools/cssemerg97275.diagcab?versionId=CAEQCRiBgID2tpaAuBciIGNiOGZiYWYwMGQ4ZDRlMDZiNzhiODBmMjRlZDQ1OTlj

Rufus use internal harddisk

Reference:
https://superuser.com/questions/1337415/make-rufus-show-internal-hard-drives
https://github.com/pbatard/rufus/wiki/FAQ

USE Alt+F or Ctrl+Alt+F

AltF – Enable fixed disk detection (v1.3.4 or earlier)/Enable USB HDD detection (v1.4.0 or later):

This is the same as enabling List fixed (non flash) or unpartitioned USB disks (v1.3.4 or earlier) or List USB Hard Drives (v1.4.0 or later) in the advanced options. This UNSUPPORTED mode will let Rufus detect and format USB drives such as USB HDDs, which it doesn’t do by default. The reason this is disabled by default is that it can be a potentially risky operation when Rufus is used by non technical-savvy people. For instance, if someone also keeps an USB HDD as a backup drive, and plug an USB Flash Drive, they may inadvertently end up formatting their HDD and lose valuable data. If you use Rufus with this option enabled, you are on your own!

If you REALLY want to try to play with internal drives, there is a non-publicized cheat mode (CtrlAltF — be mindful that this is not the same as AltF) that may list internal drives, such as SATA and so on, provided they have been set as REMOVABLE by your BIOS or UEFI firmware. For instance, this cheat mode should let Rufus list properly configured eSATA drives, that you may have plugged into your motherboard.

CentOS7扩展root分区大小

背景:一台运行Gitlab的CentOS7虚拟机,突然无法访问Gitlab,查了半天原因才发现是/dev/mapper/centos-root分区空间使用100%,而/dev/mapper/centos-home闲置空间很多,因此手动删除home分区,扩大root分区后再还原home分区

备份/home

tar czf /mnt/hgfs/D/home_backup.tar.gz /home

卸载/home

yum install -y psmisc
fuser -km /home/
umount /home

删除centos-home分区

lvremove /dev/mapper/centos-home

扩展centos-root分区

lvextend -L +200G /dev/mapper/centos-root

扩展centos-root文件系统

xfs_growfs /dev/mapper/centos-root

重建centos-home分区

lvcreate -L 1G -n /dev/mapper/centos-home
lvextend -l +100%FREE /dev/mapper/centos-home

创建centos-home文件系统

mkfs.xfs  /dev/mapper/centos-home

挂载centos-home分区

mount /dev/mapper/centos-home

恢复/home文件

tar xvf /mnt/hgfs/D/home_backup.tar.gz -C /home/
cd /home/home/
mv * ../
cd ../
rm -rf home

gitlab auto backup

使用CentOS7的crond执行定时任务实现gitlab的自动备份

crontab -e
0 1 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
0 1 * * * umask 0077; tar cfz /NFSroot/gitlab_backups/$(date "+etc-gitlab-\%s.tgz") -C / etc/gitlab

在Host中执行以下命令备份docker中运行的gitlab

docker exec -t gitlab-ce /opt/gitlab/bin/gitlab-rake gitlab:backup:create

可以使用网盘、群晖或者本地移动硬盘等自动拷贝备份文件,实现异地备份

群晖Synology Docker gitlab & gitlab-runner

群晖应用中自带了gitlab,版本较老,故采用docker里自行部署的方式架设gitlab和gitlab-runner。
相比较而言,群晖硬件能力有限,跑VMM虚拟机有些吃力,跑docker效率要好很多。

使用gitlab官方docker image:
https://hub.docker.com/r/gitlab/gitlab-ce/
https://hub.docker.com/r/gitlab/gitlab-runner/

Docker gitlab 配置

设置外部访问地址
挂载docker目录
映射docker端口
其中1080为gitlab访问端口,1081为gitlab-pages访问端口

gitlab.rb配置

## external_url 不用配置,上述docker图形化配置里已配置过
## external_url 'http://192.168.111.7:11080'

## 更改时区
gitlab_rails['time_zone'] = 'Asia/Shanghai'

################################################################################
## GitLab Pages
##! Docs: https://docs.gitlab.com/ce/pages/administration.html
################################################################################

##! Define to enable GitLab Pages
## 设置pages_external_url为自定义可用的域名,端口为1081,和docker图形化配置中的保持一致
pages_external_url "http://pthis.net:1081/"
gitlab_pages['enable'] = true
gitlab_pages['inplace_chroot'] = true

gitlab-runner配置

注册Runner

## 进入docker container
sudo docker exec -it gitlab-runner bash

## 注册Runner
gitlab-runner register --clone-url http://192.168.2.10:1080

注册使用gitlab-runner时必须增加–clone-url参数,否则gitlab里出现如下报错

解决方法参考链接:
https://docs.gitlab.com/runner/configuration/advanced-configuration.html#how-clone_url-works

安装yarn用于文档管理(基于vuePress)

## 进入docker container
sudo docker exec -it gitlab-runner bash

## 安装Nodejs 8 
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs

## 安装yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt-get update && sudo apt-get install yarn

附:gitlab-ce安装目录结构 https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#directory-structure

 /opt/gitlab holds application code for GitLab and its dependencies.
 /var/opt/gitlab holds application data and configuration files that gitlab-ctl reconfigure writes to.
 /etc/gitlab holds configuration files for omnibus-gitlab. These are the only files that you should ever have to edit manually.
 /var/log/gitlab contains all log data generated by components of omnibus-gitlab. 

VMware Workstation and Device/Credential Guard are not compatible Resolution

VMWare 15在Windows 10系统上出现与Device Guard冲突的问题,详见官方KB:
https://kb.vmware.com/s/article/2146361

KB中引入的解决方案为微软官方指南,很复杂,而且可能还不能解决这个问题。知乎上一个大神提出了一个简单的解决方案,实测有效,而且很方便:

# Windows 10中用管理员权限运行命令行工具cmd
# 关闭Device Guard
bcdedit /set hypervisorlaunchtype off

# 重新开启Device Guard
bcdedit /set hypervisorlaunchtype auto

WordPress 5.0.x主题添加ICP备案号

添加位置

主题目录下footer.php文件

例如:
/htdocs/wp-content/themes/twentynineteen/footer.php

添加内容

        <span>
        <a href="http://beian.miit.gov.cn" rel="external nofollow" target="_blank"><?php echo get_option( 'zh_cn_l10n_icp_num' );?>
        </a>
        </span>

具体位置如下:

<?php
/**
 * The template for displaying the footer
 *
 * Contains the closing of the #content div and all content after.
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package WordPress
 * @subpackage Twenty_Nineteen
 * @since 1.0.0
 */

?>

	</div><!-- #content -->

	<footer id="colophon" class="site-footer">
		<?php get_template_part( 'template-parts/footer/footer', 'widgets' ); ?>
		<div class="site-info">
			<?php $blog_info = get_bloginfo( 'name' ); ?>
			<?php if ( ! empty( $blog_info ) ) : ?>
				<a class="site-name" href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>,
			<?php endif; ?>
			<a href="<?php echo esc_url( __( 'https://wordpress.org/', 'twentynineteen' ) ); ?>" class="imprint">
				<?php
				/* translators: %s: WordPress. */
				printf( __( 'Proudly powered by %s.', 'twentynineteen' ), 'WordPress' );
				?>
			</a>
			<span>
			<a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank"><?php echo get_option( 'zh_cn_l10n_icp_num' );?>
			</a>
			</span>
			<?php
			if ( function_exists( 'the_privacy_policy_link' ) ) {
				the_privacy_policy_link( '', '<span role="separator" aria-hidden="true"></span>' );
			}
			?>
			<?php if ( has_nav_menu( 'footer' ) ) : ?>
				<nav class="footer-navigation" aria-label="<?php esc_attr_e( 'Footer Menu', 'twentynineteen' ); ?>">
					<?php
					wp_nav_menu(
						array(
							'theme_location' => 'footer',
							'menu_class'     => 'footer-menu',
							'depth'          => 1,
						)
					);
					?>
				</nav><!-- .footer-navigation -->
			<?php endif; ?>
		</div><!-- .site-info -->
	</footer><!-- #colophon -->

</div><!-- #page -->

<?php wp_footer(); ?>

</body>
</html>

Kindle paperwhite 阅读mobi格式电子书文字发灰的解决方法

部分mobi格式电子书由于内置CSS将文字颜色设置为了彩色或灰色,导致用kindle paperwhite阅读时文字发灰,看起来眼睛很累。

解决方案:使用calibre的电子书格式转换功能,转换过程中过滤颜色样式(见下图),最后将转换后的电子书导入Kindle即可解决问题。

自建Gitlab邮件发送服务器配置

自建了Gitlab服务器,为了使用邮件发送(密码找回、验证等等),可以直接使用腾讯企业邮箱或其他国内免费邮箱作为发送服务器,而不必架设Postfix等邮箱服务器。

以腾讯企业邮箱为例说明:

修改配置文件/etc/gitlab/gitlab.rb

gitlab_rails['gitlab_email_from'] = 'xxx@xxx.com.cn'
gitlab_rails['gitlab_email_reply_to'] = 'noreply@xxx.com.cn'

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "xxx@xxx.com.cn"
gitlab_rails['smtp_password'] = "xxxxxx"
gitlab_rails['smtp_domain'] = "exmail.qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true

修改完成后,运行gitlab-ctl reconfigure,然后运行gitlab-rails console,进入控制台后运行以下命令测试设置是否正确和生效:

irb(main):003:0> Notify.test_email('xxx@xxx.com', 'Message Subject', 'Message Body').deliver_now

其中xxx@xxx.com为接收人的邮箱,如果该邮箱成功收到邮件则说明设置成功。