Love My Love

How to enable TLS in Nginx by Let's Encrypt

{% centerquote %} 让你的网站 https 起来吧! {% endcenterquote %}

1. Enable TLS

Reference: https://letsencrypt.org https://certbot.eff.org

1.1. Setup Certbot

Enable EPEL repo:

$ sudo yum install epel-release
$ sudo yum install subscription-manager
$ subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms"

If you are using CentOS, you can enable the optional channel by running:

$ sudo yum -y install yum-utils
$ sudo yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional

After doing this, you can install Certbot by running:

$ sudo yum install certbot python2-certbot-nginx

If No package certbot available. occur, try the below:

$ sudo yum install certbot-nginx
......

Use utterances as Hexo Next theme comments

{% centerquote 王小波 %} 人的一切痛苦,本质上都是对自己无能的愤怒。 {% endcenterquote %}

Why Utterances?

  1. The most similar comments to github issue.
  2. Emoji add free as github issue.
  3. Markdown support.
  4. Data storage can be trusted and stable, thanks to github.

But my choice is Valine

Oh my, after study utterances, I have to changed my choice to Valine:

  1. utterances need to modify many theme files, I think I’ll forget where to restore it.
  2. utterances’s replies are not smart enough.
  3. utterances has more differ from github issue after all, it lost some great features like reply.
  4. utterances cannot display count of comments at home page.
  5. Valine not the best one but enough for me, except add emoji free to bottom line.

So, this post is just a study and successful attempt for utterances.

Why not Gitment or Gitalk?

Reference:

......

Binary I/O operation

I coped with character type coversion to let it looks like c type, and search bytes from *.dll to modify it. so, there is sth I learned and written down here. # Binary I/O operation Define! def hex_read(filepath: str) -> bytearray: if os.path.isfile(filepath): with open(filepath, 'rb') as f: data = bytearray(f.read()) return data Usage: dll_data = hex_read('D:\\test\\test.dll') Find bytes and replace it: index_start = dll_data.find(b'\x85\x69\xf0\x7f') index_end = index_start + 100 if index_start != -1: data_old = dll_data[index_start:index_end] data_new = replacebytes # replacebytes is the content you want to replace dll_data_new = dll_data.replace(data_old, data_new) with open('D:\\test\\test.dll', 'wb') as f: f.write(dll_data_new) ......

Hex byte string int coversion

Reference: https://docs.python.org/zh-cn/3/library/stdtypes.html https://docs.python.org/zh-cn/3/library/struct.html # Python Types Coversion hey, there are some usefull features below, I will update at intervals: bit_length() New in version 3.1: In [73]: n = -37 In [74]: bin(n) Out[74]: '-0b100101' In [75]: n.bit_length() Out[75]: 6 hex to int: In [59]: int('0x22357', 16) Out[59]: 140119 int to hex: In [32]: hex(141128) Out[32]: '0x22748' packed binary data to int: In [70]: struct.unpack("I", b'\x57\x23\x02\x00') Out[70]: (140119,) In [71]: type(struct.unpack("I", b'\x57\x23\x02\x00')) Out[71]: tuple In [72]: struct.unpack("I", b'\x57\x23\x02\x00')[0] Out[72]: 140119 what is param “I”? Read More about struct int to packed binary data:......