Windows下Git的HOME环境变量冲突的解决方法

前几天装上了 Cadence, 然后使用 Git 的时候发现配置信息全没了。仔细一看,系统环境变量 HOME 变量不对,变成了 Cadence 的工作目录。

解决方法也很简单。我们不能直接修改系统的环境变量,否则 Cadence 可能就不能正确工作了。因此从 Git Bash 的配置文件入手就行了。

进入 Git 的安装目录,打开 etc/profile 文件,在文档第一块注释下面添加一行:

其中的 /c/Users/yourname 就是你原本的 HOME 路径。保存即可。

异步编程简介与C#中基于任务的异步编程入门

(注:这是我在系科协写的第一篇 Weekly, 同步到这里来)

一、什么是异步编程

请不要着急,在介绍异步编程前,让我们先耐心了解一下下面的几个概念,虽然可能会有些枯燥,但这对后面的学习是非常有必要的。

 

概念一 进程与线程、并发

进程 (process), 是运行中的可执行程序的实例。打开“任务管理器”,你会看到许多进程。如果你切换到“详细信息”选项卡,你还会看到每个进程含有的“线程”数目(如果看不到可以右键列表标题栏,在“选择列”中勾选“线程”)。那么“线程”又是什么呢?

任务管理器中显示的进程与线程信息

 

线程 (thread), 是操作系统能够进行运算调度的最小单位。它被包含在进程之中,是进程中的实际运作单位。默认情况,一个进程只包含一个线程,从程序的开始到执行结束。但线程可以派生自其它线程,并且它们共享该进程所拥有的全部资源。所以一个进程可以包含不同状态的多个线程,来执行程序的不同部分,最重要的是,它们是并发执行的。

 

所以“并发”是什么意思呢?想一想你平常使用电脑的时候,是不是能够一边听音乐一边上网呢?这种看上去像是在同时执行的情形就是所谓的“并发”(之所以说“看上去”是因为大多数情况下各线程所含的指令只是在逻辑上是同时执行的,而在物理上并不是真正地同时执行的(即不是并行的),这涉及到现代操作系统的 CPU 调度机制,有兴趣的同学可以去了解)。

 

所以说,线程的并发性不仅使得我们能够同时运行不同的程序,还保证了每个程序能够通过多线程同时执行不同的任务,这是十分重要的。

阅读全文→

Some Reflections after the Scholarship Presentation

I made a scholarship presentation last evening. There were 17 students presenting for this Comprehensive Scholarship, and I was lucky to be one of them.

 

However, I hardly thought I could get this opportunity when I clicked the applying button casually serveral days ago. When the counselor told me that I've made it to the presentation stage, I was really surprised.

 

But after I saw the student list , I realized that I was probably just "lucky" to get this opportunity. It seemed that many top students didn't even submit the application, while I happened to apply (just for fun), so I was involved.

 

In fact, though my grade was not bad, it's far from excellent. Maybe they chose me because I was versatile. I comforted myself. Such being the case, I started to prepare for the presentation.

 

I was the third student to make the presentation. After I finished it, I began to listen to other students' presentation. Then I was stunned.

 

Most of them did not only excel at academics, but also perform well in many other aspects like art, sports and social work. They had an ample amount of experience. I felt ashamed. Then I thought of one of my friend's words—"the gap between people enlarges hugely during college years". I was lost in thought.

 

I recalled my freshman year. Not so satisfying. No excellent grade, few social activities, poor time management... I was even kind of shiftless.

 

There definitely needs to be a change.

Let’s Encrypt: 让Certbot续期证书后重新加载Nginx

普通用户使用 Let's Encrypt 证书有 90 天有效期的限制,但通过 Certbot 可以实现证书的自动续期。不过,更新证书后必须重新加载 nginx 配置文件才能生效。遗憾的是,Certbot 的默认定时任务并没有包含重载配置文件的命令。

 

为了避免未重载配置文件导致的服务不可用,我们需要对 Certbot 任务配置文件做出修改。其位于 /etc/cron.d/certbot.

默认配置大概是这样:

 

我们只需要将向最后一行命令末尾添加 --renew-hook "/etc/init.d/nginx reload" 即可。即:

--renew-hook 后面的命令会在每次成功续期证书后运行。此处即为重新加载 nginx 配置文件。

 

参考链接:https://www.guyrutenberg.com/2017/01/01/lets-encrypt-reload-nginx-after-renewing-certificates/

本博客刚刚增加了邮件订阅功能哦!如果你对我的博客感兴趣,欢迎通过侧边栏的订阅小工具订阅(使用屏幕较小的设备访问时,侧边栏可能隐藏)。