J

jdhao's digital space

Recent content on jdhao's digital space

About

<p>Welcome to my personal website! I am glad to hear what brings you here. Do not hesitate to share in the comment below!</p> <h1 class="relative group">Who am I? <div id="who-am-i" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#who-am-i" aria-label="Anchor">#</a> </span> </h1> <p>Hi, I am jdhao, a machine learning engineer who is passionate about working with computer vision. I am experienced in tools like NumPy, <a href="https://jdhao.github.io/tags/OpenCV/" target="_blank" rel="noreferrer">OpenCV</a>, and <a href="https://jdhao.github.io/tags/PIL/" target="_blank" rel="noreferrer">PIL</a>, and also in data visualization tools like <a href="https://jdhao.github.io/tags/Matplotlib/" target="_blank" rel="noreferrer">Matplotlib</a>. I have broad experiences working on various vision-related projects, ranging from image retrieval, OCR, document image analysis and reconstruction, to video deduplication.</p>

2001/1/1
阅读更多

Elastic_vector_not_shown_in_source

<p>Recently, I was working on migrating our Elasticsearch cluster to <a href="https://www.elastic.co/docs/deploy-manage/deploy/elastic-cloud/serverless" target="_blank" rel="noreferrer">serverless</a>. We have an index where some field stores dense vectors used in KNN search.</p>

2026/7/7
阅读更多

Elasticsearch Dynamic Mapping Pitfalls

<p>In Elasticsearch, when you index document to an index, if you do not specify the mapping for the field, Elastic will use <a href="https://www.elastic.co/docs/manage-data/data-store/mapping/dynamic-field-mapping" target="_blank" rel="noreferrer">dynamic mapping</a> to infer the data type for your field.</p>

2026/7/3
阅读更多

Manage uv.lock file with Renovate

<p>In our work, we are using <a href="https://github.com/renovatebot/renovate" target="_blank" rel="noreferrer">renovate</a> to update the dependency packages for Python projects. Previously when we are using good old pip and <code>requirements.txt</code> for package management, renovate works fine since it only needs to update the package version in <code>requirements.txt</code>. We switch to <a href="https://docs.astral.sh/uv/" target="_blank" rel="noreferrer">uv</a> this year as our project management tool. Since uv uses <code>pyproject.toml</code> and <code>uv.lock</code> (lockfile) to ensure reproducible project setup, we have an issue that when renovate bot creates a PR for the package updates: it only changes <code>pyproject.toml</code> without updating <code>uv.lock</code>.</p>

2026/5/13
阅读更多

Set up Python Provider for Neovim

<p>To make python plugins work in Neovim, we need to set up the python provider properly. Usually, this means setting up the correct path to Python executable and also installing the <a href="https://github.com/neovim/pynvim" target="_blank" rel="noreferrer">pynvim</a> &ndash; Neovim client for Python.</p>

2026/5/11
阅读更多

Ripgrep Config to Search Hidden Files

<p>Notes about how to use <a href="https://github.com/burntsushi/ripgrep" target="_blank" rel="noreferrer">ripgrep</a> to search hidden files and configuration related to Neovim.</p>

2026/4/17
阅读更多

Pre-commit Setup for Your Project

<p>We have a Python project where there are several developers, and we have a mature CI pipeline to do code linting, formatting check for python, yaml, json, and testing etc. The problem with CI pipeline is that you can only get feedback after you commit your code and push to the remote repo. The feedback is not instant and may be delayed for several minutes. If there are some linting issues, you then need to fix the issue and make another commit. This is also making the PR history messy.</p>

2026/4/14
阅读更多

I read the nvim v0.12 release note so you don't have to

<p>A major Neovim release (version 0.12) has been released a few days ago, after more than one year from the last major release (version 0.11). The following is a list of feature I am interested. For a complete set of features, check <a href="https://github.com/neovim/neovim/commit/fc7e5cf6c93fef08effc183087a2c8cc9bf0d75a" target="_blank" rel="noreferrer">full changelog</a> and <a href="https://neovim.io/doc/user/news-0.12/" target="_blank" rel="noreferrer">news</a>.</p> <h2 class="relative group">builtin package manager <code>vim.pack</code> <div id="builtin-package-manager-vimpack" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#builtin-package-manager-vimpack" aria-label="Anchor">#</a> </span> </h2> <p>Now you can use the builtin <code>vim.pack</code> API to manage your plugins. Check <a href="https://echasnovski.com/blog/2026-03-13-a-guide-to-vim-pack" target="_blank" rel="noreferrer">this detailed post</a> if you want to migrate to vim.pack.</p>

2026/4/2
阅读更多

Return Different Values for Each Call of A Mock

<p>When unit-testing a function that make multiple external calls/requests, we want to mock the actual call and return the mock results. For each call, we might want to return different results.</p>

2026/3/31
阅读更多

Migrate Python Project from Pip to Uv

<p>Previously, our projects are still using the old Python 3.10, which will be <a href="https://devguide.python.org/versions/" target="_blank" rel="noreferrer">deprecated soon this year</a>. We are also using the good old pip and <a href="https://docs.python.org/3/library/venv.html" target="_blank" rel="noreferrer">venv</a> for the project/package management. This is already posing some issues for us:</p> <ul> <li>venv is a pure virtual env tool without the ability to manage python versions (it just picks your local python), so it is hard to enforce the local env of each developer</li> <li>pip&rsquo;s <code>requirements.txt</code> is not a <a href="https://pydevtools.com/handbook/explanation/what-is-a-lock-file/" target="_blank" rel="noreferrer">lockfile</a> and thus does not ensure a fully reproducible python environment</li> <li>pip as a package management tool is not performant enough in resolving and installing packages</li> </ul> <p>In order to solve these problems, I took the effort to migrate our project management to <a href="https://docs.astral.sh/uv/" target="_blank" rel="noreferrer">uv</a>. Here are some of the things that I learned in the process as a first-time uv user.</p>

2026/3/27
阅读更多

德语常用不规则动词

2026/2/15
阅读更多

葱油鸡腿制作

2026/2/7
阅读更多

Check Trailing White Spaces in Your Project

<p>When I am working on a Python project, I am using <a href="https://github.com/psf/black" target="_blank" rel="noreferrer">black</a> to format the code, so that we have a unified format across the code base.</p> <p>One pain point, however, is the super annoying trailing white spaces:</p> <ol> <li>black can remove trailing spaces for doc string, code and comment, but it will not touch trailing spaces in, e.g., multi-line strings.</li> </ol>

2025/12/19
阅读更多

菜谱:茄子肉丁

2025/11/19
阅读更多

object vs nested type in data mapping in Elasticsearch

<p>In this post, I compare the object vs nested type used in data mapping in Elasticsearch.</p>

2025/11/19
阅读更多

Node, Index, Shard in Elasticsearch

2025/11/14
阅读更多

Logging setup for Pytest

<p>When you do code testing using pytest, pytest can do sophisticated changes to your logging. This is a very powerful feature, but carries some subtlety.</p>

2025/10/29
阅读更多

Select fields in Elasticsearch: _source, fields and stored_fields

<p>In Elasticsearch, when we index documents to an index, by default the source of the document is stored in meta field <code>_source</code>. When you search your index, you see a special field <code>_source</code> for each matched/hit product.</p>

2025/10/16
阅读更多

中式葱花饼制作

<p>本文总结如何制作中式家常版本的“葱花饼”。</p>

2025/8/23
阅读更多

菜谱: 凉拌苤蓝(卜留克/kohlrabi)

<p>今天总结一下在德国超市里常见的蔬菜苤(piě)蓝(德语叫<a href="https://en.wikipedia.org/wiki/Kohlrabi" target="_blank" rel="noreferrer">kohlrabi</a>,在中国东北叫“卜留克”) 凉拌的做法。</p>

2025/8/5
阅读更多

我也有高考 PTSD

<p>和众多网友一样,我也有高考 <a href="https://en.wikipedia.org/wiki/Post-traumatic_stress_disorder" target="_blank" rel="noreferrer">PTSD</a>。</p>

2025/6/9
阅读更多

Garmin Course Syncing Not Working?

<p>Recently I was trying to sync my hiking course from Garmin connect to my Garmin Forerunner 965 and found that it does not work.</p>

2025/6/7
阅读更多

Prevent Accidental Index Delete in Elasticsearch

<p>In Elasticsearch, you can use wildcard in a lot of the index operations. This is very handy, but can be dangerous sometimes, e.g., when you use wildcards when deleting indexes. You may delete unintended indexes accidentally and cause serious interruptions to your business/work.</p>

2025/6/7
阅读更多

How to Import GPX File into Garmin Watch

<p>This post will give a quick summary on how to import GPX route into Garmin watch.</p>

2025/5/17
阅读更多

Python system PATH issues When We Use Pytest

<p>When I try to run <code>pytest</code> locally for a Python project, I noticed that the import in those test scripts may fail if I run <code>pytest</code> in different directories. The import error usually means that your actual code modules is not in the python path, so they can not be imported successfully by your test scripts.</p> <p>This has something to do with how pytest set up the python path when you run it.</p>

2025/5/13
阅读更多

菜谱:泰式打抛牛肉

<p>本次来复刻泰国非常受欢迎的打抛饭。</p>

2025/3/11
阅读更多

菜谱:烤箱羊肉串

<p>本文总结如何用烤箱烤羊肉串。</p>

2025/3/8
阅读更多

How to Filter Warnings in Python/pytest

<p>When we are using 3rd packages in Python, we may see some warning messages. For example, when you use the package BeautifulSoup and provide it with an url:</p>

2025/3/5
阅读更多

家常烤箱烤鸡腿

<p>这次来总结一下烤箱烤鸡腿的做法。</p>

2025/2/2
阅读更多

Comparison between Several Desktop Speakers

<p>In this post, I would like to compare several speakers that are relatively small in size and are suitable as desktop speakers.</p>

2025/1/23
阅读更多

How to Use LuaRocks Package in Neovim

<p>Although neovim has built a lot of modules to ease the use of Lua, sometimes we may still want to use packages from <a href="https://luarocks.org/" target="_blank" rel="noreferrer">LuaRocks</a>. In this post, I would like to share how you can install a package from LuaRocks and use it in nvim.</p>

2024/12/11
阅读更多

Macbook 外接显示器

<p>最近趁着黑五入手了外接显示器,顺便了解了一下显示器相关的各种标准和技术,本文做一个总结。</p>

2024/12/4
阅读更多

家常萝卜炖羊排

<p>寒冷的冬天,和羊肉汤更配。</p>

2024/11/29
阅读更多

Run the Job Immediately after Starting Scheduler in Python APScheduler

<p>When using APScheduler package in Python, I want to run the scheduled job right after I start the scheduler. How can I do it properly?</p>

2024/11/1
阅读更多

Retry for Google Cloud Client

<p>When we use one of the google cloud python clients to communicate with GCP, there may be errors occurring sometime calling the client API methods.</p>

2024/10/8
阅读更多

菜谱:土豆金枪鱼沙拉

<p>今天来总结一下土豆金枪鱼沙拉的做法。</p>

2024/10/2
阅读更多

菜谱:椰香咖喱鸡

<p>本次来总结一下椰汁咖喱鸡的做法。</p>

2024/9/26
阅读更多

凉拌绿豆宽粉制作

<p>本次来总结凉拌绿豆宽粉的做法。</p>

2024/9/23
阅读更多

Make Python logging Work in GCP

<p>When deploying a Python application to GCP Kuberntes Engine, we may see issues that the <a href="https://stackoverflow.com/q/75361466/6064933" target="_blank" rel="noreferrer">logging level is not correct</a> in the cloud logging explorer. In order for the <a href="https://docs.python.org/3/library/logging.html" target="_blank" rel="noreferrer">Python logging package</a> to work with GCP, we need some additional configurations.</p>

2024/9/20
阅读更多

Liveness and Readiness Check in Kubernetes

2024/9/20
阅读更多

Notes on Using GCP Logging

2024/9/16
阅读更多

西班牙土豆饼制作

<p>本次来复刻一下在网上看到的西班牙土豆饼。</p>

2024/9/12
阅读更多

Elasticsearch Version Conflict Error

<p>The version conflict error is often seen when doing document indexing operations in Elasticsearch.</p>

2024/9/11
阅读更多

How to Use the Elasticsearch task API

<p>In Elasticsearch (ES), you can run a task and check its status with the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html" target="_blank" rel="noreferrer">task API</a>. For example, if you use the <code>reindex</code> API in ES with parameter <code>with_for_completion=False</code>, ES will not wait for the process to finish and will return a task instead.</p>

2024/8/15
阅读更多

Speed up document indexing in Elasticsearch via bulk indexing

<p>In Elasticsearch, there is <a href="https://elasticsearch-py.readthedocs.io/en/v8.14.0/api/elasticsearch.html#elasticsearch.Elasticsearch.index" target="_blank" rel="noreferrer">index API</a> where you can index a single document to an index.</p>

2024/7/26
阅读更多

Index refresh issue in Elasticsearch

<p>Recently when I was working with Elasticsearch, I found this weird issue that the document count for the newly created index is not correct. Also there are problems with reindex, if you reindex the source index to destination index, there is nothing in the destination index despite no errors.</p>

2024/7/24
阅读更多

Google Cloud Storage Usage

<p>Some notes on using the <a href="https://cloud.google.com/storage/docs/introduction#quickstarts" target="_blank" rel="noreferrer">Google Cloud storage</a>.</p>

2024/7/10
阅读更多

家常煎羊排制作

<p>在德国的德超很少能见到羊肉,不过在土耳其超市可以很方便买到羊肉。 本期我来做一个煎羊排,之所以不是因为烤羊排是因为我没有合适的烤盘和锡箔纸,所以没有尝试。</p>

2024/4/9
阅读更多

凉拌茄子制作

<p>本文简单总结凉拌茄子的制作方法。</p>

2024/4/9
阅读更多

Configure Python logging with dictConfig

<p>Apart from directly configuring the Python logging in the code itself. We can also configuring the logging using <a href="https://docs.python.org/3/library/logging.config.html#logging.config.fileConfig" target="_blank" rel="noreferrer">fileConfig</a> or <a href="https://docs.python.org/3/library/logging.config.html#logging.config.dictConfig" target="_blank" rel="noreferrer">dictConfig</a>.</p>

2024/3/11
阅读更多

Debugging Wezterm Issues

<p>A short summary on how to debug <a href="https://wezfurlong.org/wezterm/index.html" target="_blank" rel="noreferrer">Wezterm</a> issues.</p>

2024/2/26
阅读更多

Black Formatter Setup for Python Project

<p>This post is about how to set up <a href="https://github.com/psf/black" target="_blank" rel="noreferrer">black</a>, the popular code formatter for Python projects.</p>

2024/2/22
阅读更多

Git line ending config

<p>This post is about how to set up Git so that people using different operating systems can work in the same repository, without messing up the line ending of source files.</p>

2024/2/21
阅读更多

Garmin Forerunner 965 Essential Tips and Setups

<p>In this post, I want to share a list of tips/setups for the Garmin Forerunner 965 watch. Some of the settings are also applicable to other Garmin watches.</p>

2024/2/4
阅读更多

How to Download Files from Google Cloud Storage in the Databricks Workspace Notebook

<p>In this post, I want to share the complete process and setup to download files from GCP in a Databricks workspace notebook. Since the notebook itself is non-interactive when you run the shell command, the setup process is a bit different from the normal GCP authentication.</p>

2023/11/21
阅读更多

Databricks Cli Usage

<p>We can use the <a href="https://learn.microsoft.com/en-us/azure/databricks/dev-tools/cli/" target="_blank" rel="noreferrer">Databricks cli</a> to interact with Databricks workspaces programmatically on the command line. In this post, I want to share simple usage about Databricks cli.</p>

2023/11/21
阅读更多

Working with Databricks Workspace Files

<p>Some observation and finding in working with Databricks workspace files.</p>

2023/11/18
阅读更多

手抓羊肉饭制作

<p>这次我来复刻手抓羊肉饭。</p>

2023/11/9
阅读更多

Databricks Init Scripts

2023/10/20
阅读更多

Using Virutal Environment in Python with venv

<p>Using a virtual environment for Project dev in Python is a good practice. <a href="https://docs.python.org/3/library/venv.html" target="_blank" rel="noreferrer">venv</a> is module that is available since Python 3.3. It can help us to manage the virtual environment in a simple way.</p>

2023/10/10
阅读更多

File Systems in Databricks

<p>A summary of different file systems in Databricks.</p>

2023/10/3
阅读更多

LATERAL VIEW EXPLODE in Spark

<p>For array type column, <code>explode()</code> will convert it to <code>n</code> rows, where <code>n</code> is the number of elements in the array. For map/dictionary type column, <code>explode()</code> will convert it to <code>nx2</code> shape, i.e., n rows, 2 columns (for key and value).</p>

2023/9/26
阅读更多

菜谱:麻婆豆腐

<p>本文总结麻婆豆腐的做法。</p>

2023/9/23
阅读更多

在德国做台湾卤肉饭

<p>本次来复刻台湾卤肉饭。</p>

2023/9/22
阅读更多

FastAPI testing and OpenAPI doc generation

<p>Some notes on developing a web application with FastAPI.</p>

2023/9/20
阅读更多

Change Timezone in Databricks Spark

<p>The Databricks cluster is using UTC as the default timezone. So when you run some time-related code, the displayed time is not the local time, which is not ideal. In this post, I want to share how to change the timezone setting for Databricks cluster.</p>

2023/9/15
阅读更多

How to Profile Your Python Script/Module

<p>In my <a href="https://jdhao.github.io/2020/11/06/profile_python_line_profiler/" target="_blank" rel="noreferrer">previous post</a>, I shared how to profile a single function using line_profiler. In this post, I want to share how to profile Python script/module and visualize the profile stat to pinpoint the slow part of the code.</p>

2023/9/12
阅读更多

菜谱:茄子肉沫

<p>家常少油版本茄子肉沫制作。</p>

2023/9/9
阅读更多

Migrating from Packer.nvim to Lazy.nvim

<p><strong>TL;DR: Lazy.nvim is amazing. It is easy to switch and reduce your startup time immensely. Just try it!</strong></p> <p>I think <a href="https://github.com/wbthomason/packer.nvim" target="_blank" rel="noreferrer">Packer.nvim</a> has been a revolutionary plugin manager after nvim 0.5. It introduces a lot of lazy loading techniques to speed up the startup process of Neovim.</p>

2023/9/2
阅读更多

How to Extract PDF file on macOS

<p>To extract pdf pages from several files, we can use the open source tool <a href="https://github.com/qpdf/qpdf" target="_blank" rel="noreferrer">qpdf</a>.</p>

2023/8/24
阅读更多

How to Deploy Fastapi Application with Docker

<p>In post, I want to summarize the complete steps to deploy a demo web service implemented with FastAPI in Docker container.</p>

2023/8/1
阅读更多

Nerdfont Icon Missing after Wezterm Upgrade

<p>When I upgrade wezterm from <a href="https://github.com/wez/wezterm/releases/tag/20230408-112425-69ae8472" target="_blank" rel="noreferrer">April release</a> to <a href="https://github.com/wez/wezterm/releases/tag/20230712-072601-f4abf8fd" target="_blank" rel="noreferrer">July release</a>, I noticed that some of the unicode icons in my neovim config are shown as box.</p>

2023/7/25
阅读更多

Pylsp setup for Neovim in 2023

<p>TL;DR: my config for pylsp can be found <a href="https://github.com/jdhao/nvim-config/blob/4d8ef868ad0ef7f6433d91332aa6649186d9a2fb/lua/config/lsp.lua" target="_blank" rel="noreferrer">here</a>.</p> <p>In this post, I would like to share my latest setup for Pylsp in Neovim.</p>

2023/7/22
阅读更多

How to Parse Query Param With Multiple Values in FastAPI

<p>In HTTP request, same query parameter with multiple values are allowed. For example, for query parameter <code>brand</code>, the query string looks like this: <code>brand=foo&amp;brand=bar</code>. How to parse value of this parameter to a list in FastAPI? There are several different ways.</p>

2023/7/13
阅读更多

菜谱:土豆胡萝卜烧牛肉

<p>本文总结简易版“土豆胡萝卜烧牛肉”做法。</p>

2023/7/1
阅读更多

Zsh Startup Files in macOS

<p>In this post, I want to share what I find about the Zsh startup files and their loading order in macOS.</p>

2023/6/16
阅读更多

PATH Variable Changed inside Tmux on macOS?

<p>Recently, I met a strange issue related to Tmux. After open a tmux session, the <code>PATH</code> variable is changed and is different from outside tmux.</p>

2023/6/12
阅读更多

Work with JSON File in Neovim

<p>In this post, I want to share how you can work effectively with JSON file inside Neovim.</p>

2023/6/12
阅读更多

Running/importing Python code/module in Databricks

<p>Databricks is centered around notebooks for doing a lot of works. As a result, it is often not obvious how to run or re-use code from another notebook or Python module. In this post, I want to share how to do this in the Databricks.</p>

2023/6/6
阅读更多

Agile and Scrum

<p>This is my learning notes for <a href="https://en.wikipedia.org/wiki/Agile_software_development" target="_blank" rel="noreferrer">Agile</a> and <a href="https://en.wikipedia.org/wiki/Scrum_%28software_development%29" target="_blank" rel="noreferrer">Scrum</a>.</p>

2023/5/24
阅读更多

菜谱:凉拌牛肉

<p>本文总结简易版凉拌牛肉的做法。</p>

2023/5/21
阅读更多

Awesome Command Line Tools Written in Rust

<p>In this post, I want to share some command line tools written in Rust, which are good alternatives to some of the original tools used in command line.</p>

2023/5/15
阅读更多

How to get or set Databricks spark configuration

<p>In this post, I summarize how to get or set a Databricks spark configuration/property.</p>

2023/5/13
阅读更多

Set Up German Version macOS

<p>I got a Macbook with a German keyboard layout, and I am not accustomed to it. This post summarizes some tweaks made to the German version of Macbook to make it work for me.</p>

2023/4/21
阅读更多

Add A Custom Search Engine for Vimium

<p><a href="https://github.com/philc/vimium" target="_blank" rel="noreferrer">Vimium</a> is a Chrome extension that lets us to browse the internet with our fingers, rather than using the mouse. In this post, I will going to share how to add a custom search engine for Vimium.</p>

2023/4/18
阅读更多

中国大陆小米手机如何使用 Google Pay

<p>要使用 <a href="https://en.wikipedia.org/wiki/Google_Pay_%28payment_method%29" target="_blank" rel="noreferrer">Google Pay</a> 需要谷歌服务的支持,小米手机至少旗舰机型都是自带谷歌服务的,但是默认没有打开。以我的小米 12S Pro 为例,直接在系统设置界面搜索 “谷歌”,有个“谷歌基础服务”,打开即可。</p>

2023/3/20
阅读更多

春节回乡记

<p>由于疫情的影响,已经有两年没有在老家过春节。中国国内疫情管控放开以后,终于有机会回乡过春节。</p>

2023/3/4
阅读更多

滇西之行 2023

<p>我在高中还是大学读了宗璞的系列小说<a href="https://book.douban.com/subject/30425634/" target="_blank" rel="noreferrer">《野葫芦引》</a>,其中的《西征记》描写了滇西抗战的经历,所以我一直想去腾冲走一趟,去拜访一下<a href="https://zh.wikipedia.org/zh-hans/%E5%9B%BD%E6%AE%87%E5%A2%93%E5%9B%AD" target="_blank" rel="noreferrer">国殇墓园</a>,苦于打工人没有时间,这个愿望在今年实现了。</p>

2023/3/1
阅读更多

贵阳行 2023

<p>每次去贵阳都是浮光掠影,因为它不是我的终点站。这次是因为去云南,需要在贵阳转车停留一晚。</p>

2023/2/20
阅读更多

程序员海外工作---语言篇

<p>找海外工作很重要的一个要求语言过关,根据国家的不同,对语言的要求也不同,英语国家当然英语就足够了,有的欧洲国家公司还会要求你掌握当地语言,如果你不会,那投递简历时就可以跳过这些公司了。本文谈一谈我的英语学习经验,仅供参考。英语主要分为听说读写四个方面,下面就分开写一写我的经验。</p>

2023/2/18
阅读更多

2023 长沙行

<p>大学毕业以后,就没去过长沙了,来深圳工作几年也没去过长沙一次,正好趁着这次有时间去长沙逛一下。</p>

2023/2/10
阅读更多

2023 西安行

<p>如果你要问我心中第一美食之都,我会说是西安。西安我此前已经去过两次了,但仍意犹未尽。</p>

2023/2/3
阅读更多

德国工签申请指南

<p>拿到德国工作 offer 以后,我们需要申请合适的签证前往德国。本文将会详细总结德国工签(欧盟蓝卡)申请需要的材料,填写细节,以及面签的流程,希望能够帮助到有同样疑惑的人。</p> <p><font color="red">Disclaimer: 本文仅仅代表个人经历,非官方权威建议,仅供各位读者参考。</font></p>

2023/1/18
阅读更多

2022 年博客回顾

<p>2022 年总共写了 <a href="https://jdhao.github.io/post/" target="_blank" rel="noreferrer">49 篇博客</a> <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>,大部分博客很短,没花太多时间就可以写完。从类别上看,大部分都是技术相关的,关于 Neovim,Lua,机器学习,SQL,Python 使用等等,可能并没有太多人看,主要是自己总结留给自己以后参考,有几篇是记录自己平时做菜的过程,还有一些是自己对一些问题的思考或者记录,例如 <a href="https://jdhao.github.io/2022/02/21/on_asking_tech_questions/" target="_blank" rel="noreferrer">如何提技术问题</a> 以及 <a href="https://jdhao.github.io/2022/07/25/under_the_shadow_of_covid/" target="_blank" rel="noreferrer">对新冠的记录</a>。</p>

2023/1/5
阅读更多

感染 omicron 记录

<p>在 2022 年 12 月底,我也感染了 omicron 病毒,本文对感染过程做一记录。</p>

2023/1/2
阅读更多

How to Override Default Options in Neovim

<p>A very common confusion for new users of Neovim is that their option settings for a particular filetype does not work in <code>init.vim</code> (or <code>init.lua</code>).</p>

2022/12/1
阅读更多

Variadic Arguments in Lua

<p>In Lua, to pass variable number of arguments, we can use <code>...</code> (three ellipses) syntax in function argument.</p>

2022/12/1
阅读更多

How to Enable Method Autocompletion for OpenCV

<h2 class="relative group">Introduction <div id="introduction" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#introduction" aria-label="Anchor">#</a> </span> </h2> <p>In Python, some packages are written mainly or partially in C++, and the Python interfaces are just wrappers around the binary C++ module. Among these packages, there is <a href="https://github.com/opencv/opencv" target="_blank" rel="noreferrer">OpenCV</a>.</p>

2022/11/16
阅读更多

How to Read Local CSV File to Table in MySQL

<p>I am using MySQL server version <code>8.0.30</code> on my macOS. I try to read a local csv file into a mysql table using <code>LOAD DATA LOCAL INFILE</code> following some post<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>, but unfortunately I get the following error:</p>

2022/10/15
阅读更多

I read the nvim v0.8 release note so you do not have to

<p>This is not a complete list of changes. Just what I have noticed. Complete release note for nvim 0.8 is <a href="https://github.com/neovim/neovim/releases/tag/v0.8.0" target="_blank" rel="noreferrer">here</a>.</p>

2022/10/5
阅读更多

Creating A Trigger in PostgreSQL

<p>We can use trigger to automate oerations, for example, preventing insertion of a record if certain condition is met. In this post, we show an example trigger function and its usage.</p>

2022/9/12
阅读更多

Cost of Living in Shenzhen

<p>Here is how much I spend for living in <a href="https://en.wikipedia.org/wiki/Shenzhen" target="_blank" rel="noreferrer">Shenzhen, China</a> as a non-local people. Note the cost may vary a lot depending on various factors.</p> <p>All numbers are in the unit of <a href="https://en.wikipedia.org/wiki/Renminbi" target="_blank" rel="noreferrer">Chinese Yuan</a> (symbol <code>¥</code>).</p>

2022/9/4
阅读更多

You Do Not Need a Plugin for This Feature

<p>I saw from the repo awesome neovim<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup> a plugin that helps the user create the intermediate dir when they save a file. I wondered why this feature even needs a whole plugin? You can literally do this with a few lines of code.</p>

2022/8/21
阅读更多

Ctrl-left and Ctrl-right Not Working in macOS?

<p>Recently, when I try to use <code>Ctrl-left</code> and <code>Ctrl-right</code> in <a href="https://github.com/neovim/neovim" target="_blank" rel="noreferrer">Neovim</a>, I found that they are not received by Neovim. I thought this is a Neovim issue. However, when I test these two shortcuts using <code>cat</code> in the terminal (I tried both Kitty and wezterm), it does not work either.</p>

2022/8/20
阅读更多

Benchmarking Your HTTP Service Using wrk

<p>As a machine learning engineer/data scientist, after the model development process is finished, we need to deploy the model as a web service using different web frameworks. To achieve maximum performance and lower the hardware cost, we often need to optimize the speed our service, including TensorRT acceleration, config tuning, etc.</p>

2022/8/9
阅读更多

How to Change Commit Author Info in Git

<p>This post summarizes how to update author info of Git commits.</p>

2022/8/4
阅读更多

Monitoring Service Stat with uwsgitop

<p>When we serve a HTTP service via uWSGI, we can monitor its stats via <a href="https://github.com/xrmx/uwsgitop#readme" target="_blank" rel="noreferrer"><code>uwsgitop</code></a>.</p>

2022/8/1
阅读更多

A Dive into super() in Python

<p>In Python, we often see the use of <a href="https://docs.python.org/3/library/functions.html#super" target="_blank" rel="noreferrer">super()</a> in class initialization.</p>

2022/7/31
阅读更多

How to Pass List by Value as Parameter in Python

<p>If we pass list as parameter to a function and change the parameter, the original list is also changed. This is because list is a mutable type, when we pass list to a function, we are passing the same list.</p>

2022/7/26
阅读更多

在疫情的阴影下 (My Life under the Shadow of Covid19)

<p>序:有感于无休无止的核酸检测,我觉得有必要写点什么,记录下正在发生的和已经发生的历史。</p> <p>很多年后,回过头看 2020 年 1 月,我们无法预料到 Covid19 竟然对人类社会造成了如此大的影响。</p>

2022/7/25
阅读更多

我们为何工作?

<p>工作的意义是什么?</p>

2022/7/7
阅读更多

Nvim 0.7.2 Released

<p>Recently the <a href="https://github.com/neovim/neovim/commit/e8ee6733926db83ef216497a1d660a173184ff39" target="_blank" rel="noreferrer">nvim 0.7.2 version</a> is released following the <a href="https://github.com/neovim/neovim/releases/tag/v0.7.0" target="_blank" rel="noreferrer">0.7.0 release</a> two months ago. Here are some of the updates in 0.7.0.</p>

2022/6/29
阅读更多

Learning SQL from Scratch(2): Setup and Preparations

<details> <summary><font size="2" color="red">update log</font></summary> <ul> <li><font color="blue">2022-10-12: add fake data generation website.</font></li> <li><font color="blue">2022-10-11: add TUI client for MySQL and Postgres.</font></li> <li><font color="blue">2022-09-24: add sample database we can try.</font></li> </ul> </details> <p>In this post, I will talk about setting up SQL databases and also the tools needed to write SQL queries.</p>

2022/6/4
阅读更多

Learning SQL from Scratch(1): Do We Even Need to Start?

<p>As a machine learning engineer who mainly deals with vision-based projects, I have little opportunity in my work to actually use SQL (Structured Query Language.). Even when I need it, I often just ask the data engineers for a favor.</p> <p>However, I thought it would be an essential skill to learn even if I do not need it for now.</p>

2022/6/3
阅读更多

What Happened When Logging without Handlers in Python

<p>I saw a post from stackoverflow asking why his logger does not work as expect? The code is like:</p>

2022/5/27
阅读更多

How To Read and Write ply File in Python

<p>In this post, I want to share how to generate <a href="https://en.wikipedia.org/wiki/PLY_%28file_format%29" target="_blank" rel="noreferrer">ply files</a> in Python.</p>

2022/5/26
阅读更多

Lua Learning Notes

<p>As a long time nvim user, I am learning Lua and slowly transition my nvim config to lua. In this script, I will share some tips and lessons I have learned the hard way.</p>

2022/5/21
阅读更多

Fix Nvidia Apt Repository Public Key Error

<p>When running <code>apt-get update</code> inside Ubuntu 18.04, I have the following error:</p>

2022/5/5
阅读更多

豆角焖面制作

<p>今天总结一下“豆角焖面”的做法。</p> <h1 class="relative group">材料 <div id="材料" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e6%9d%90%e6%96%99" aria-label="Anchor">#</a> </span> </h1> <p>四季豆,五花肉或瘦肉,大料,大蒜,姜,青椒,五香粉,酱油,老抽,料酒,鲜面条</p>

2022/5/1
阅读更多

Fix the Logitech Bluetooth Shit and Use Unifying Receiver

<h1 class="relative group">Background <div id="background" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#background" aria-label="Anchor">#</a> </span> </h1> <p>The thing is that I have a Logitech pebble and mx keys mini keyboard, and I use Bluetooth to connect them to my mac, but they randomly lost connection when I was using them, especially for the mx keys mini keyboard, this occurred on a daily basis.</p>

2022/4/29
阅读更多

How to Calculate Square Root without Using sqrt()?

<p>I saw an interesting question that how to get square root of x without using builtin function from your language. There are different ways to approach this problem.</p>

2022/4/28
阅读更多

How to Match Non-greedily in Nvim/Vim

<p>A short note on how to match <a href="https://blog.finxter.com/python-regex-greedy-vs-non-greedy-quantifiers/" target="_blank" rel="noreferrer">non-greedily</a> in Nvim/Vim.</p>

2022/4/26
阅读更多

Push to GitHub with Personal Access Token (PAT)

<p>To promote security, starting from Aug. 2021, many GitHub operations require use of personal access tokens (PAT).</p>

2022/4/23
阅读更多

How to Use Tensorboard in Pytorch

<p>This is a brief note on how to use <a href="https://github.com/tensorflow/tensorboard" target="_blank" rel="noreferrer">Tensorboard</a> in PyTorch.</p>

2022/4/20
阅读更多

How to Add Color Emoji to Image in Python

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202204031210116.png" width="500"> </p> <p>In this post, I would like to share how to add <a href="https://en.wikipedia.org/wiki/Emoji" target="_blank" rel="noreferrer">color emoji</a> to image with Python.</p>

2022/4/3
阅读更多

How to Do Image Alpha-compositing in Pillow

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202204020034075.jpg" width="800"> </p> <h1 id="what-is-alpha-compositing">What is alpha-compositing</h1> <p>If you have two images A and B, you <a href="https://en.wikipedia.org/wiki/Alpha_compositing">alpha-composite</a> A over B, it will create an effect that you can see both image A and B in the resulting image, as if A has transparency and you can <em>see</em> through A and also see B.</p>

2022/4/1
阅读更多

地道美味炸酱制作方法

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202203280008836.jpg" width="200"> </p> <p>今天介绍另外一种风格的炸酱制作,区别于之前写过的 <a href="https://jdhao.github.io/2021/09/05/how_to_make_zhajiang_noodles/" target="_blank" rel="noreferrer">老北京炸酱</a>.</p>

2022/3/27
阅读更多

Nonlinear Activations for Neural Networks

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202203271740705.png" width="600"> </p> <p>Non-linear activations are important in deep neural networks. It is important in the sense that without non-linear activation functions, even if you have many linear layers, the end results is like you have only one linear layer, and the approximation ability of the network is very limited<a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a>. Some of most commonly-used nonlinear activation functions are Sigmoid, ReLU and Tanh.</p>

2022/3/27
阅读更多

Accelerate Batched Image Inference in PyTorch

<p>I have a web service where the images come in a batch so I have to do inference for several images in PIL format at a time. Initially, I use a naive approach and just transform the images one by one, then combine them to form a single tensor and do the inference. The inference becomes really slow when I have a batch with more than 30 images. The inference time is about 1-2 seconds per batch.</p>

2022/3/18
阅读更多

Define A String Variable in LaTeX

<p>Like other programming languages, the best way to to use a value multiple times in LaTeX is to define a variable for it. Later when you want to change the value, you only need to change it once. Here is how to do it.</p>

2022/3/14
阅读更多

Merging Branches with Git Rebase

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202202021114754.jpg" width="800"> </p> <p>When merging branches, the most direct way we can use is to <code>git merge</code>. However, with git-merge, the commit history and graph will be messy if there are a lot of branches.</p>

2022/3/7
阅读更多

Softmax with Temperature Explained

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202202271549378.jpg" width="800"> </p> <p>Softmax function is commonly used in classification tasks. Suppose that we have an input vector <span class="math inline">\([z_1, z_2, \ldots, z_N]\)</span>, after softmax, each element becomes:</p>

2022/2/27
阅读更多

A Curated List of File Explorers for Nvim

<p>File explorer is one of the most widely-used types of plugin for Vim/Nvim. Below are my curated list of file explorers for Nvim. Some of these plugins are specifically written for Nvim and will not work for Vim.</p>

2022/2/26
阅读更多

关于正确提问技术问题

<p>有个人 A 在 <a href="https://t.me/vimzh_real" target="_blank" rel="noreferrer">Vim tg 群</a>,问了一个简单的 vim 问题,另外一位群友 B 给了间接的回答,告诉他应该多搜索一下。结果引发了大讨论,有人认为直接回答就好,没必要指教别人,没必要那么傲慢,居高临下,就炸锅了,引发了大讨论,还导致几个人退群。</p>

2022/2/21
阅读更多

Install pyav inside Ubuntu Docker

<p>Building a usable Docker image with all the packages living peacefully is hard. Here is how to install <a href="https://github.com/PyAV-Org/PyAV" target="_blank" rel="noreferrer">pyav</a> using Docker.</p>

2022/2/11
阅读更多

Dependency Hell When Building A PyTorch GPU Docker Image

<p>In order to for PyTorch to use host GPU inside a Docker container, their versions must match.</p>

2022/2/9
阅读更多

External Executable Not Allowed to Run after Hugo v0.91?

<p>Today I upgrade <a href="https://github.com/gohugoio/hugo" target="_blank" rel="noreferrer">Hugo</a> from v0.75 to the latest version (v0.92). When I run the deployment script to build the site and push, I saw the following error:</p>

2022/2/2
阅读更多

凉菜调味汁制作方法

<p>凉菜万能调料汁制作方法。</p>

2022/2/1
阅读更多

菜谱:蒜蓉炒虾

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202202012330649.jpg" width="400"> </p> <p>家常版蒜蓉炒虾🦐制作方法。</p>

2022/2/1
阅读更多

A Dig into PyTorch Model Loading

<h1 class="relative group">Saving and loading PyTorch models <div id="saving-and-loading-pytorch-models" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#saving-and-loading-pytorch-models" aria-label="Anchor">#</a> </span> </h1> <p>Models in PyTorch are a subclass of <code>torch.nn.Module</code>. To save the model parameters, we use <code>model.state_dict()</code> to get all the model parameters:</p>

2022/1/28
阅读更多

Selected Questions from LinkedIn Git Assessment

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202202012337737.jpg" width="600"> </p> <p>I took the <a href="https://github.com/Ebazhanov/linkedin-skill-assessments-quizzes/tree/master/git" target="_blank" rel="noreferrer">LinkedIn Git assessment</a> and got a certificate<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>, but found that I am not super clear on some of the questions. Here is an analysis of some of the questions and their answers.</p>

2022/1/14
阅读更多

Why do We Use LogSumExp in Machine Learning?

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202201092324184.jpg" width="600"> </p> <p>LogSumExp is often used in machine learning. It has the following form:</p>

2022/1/9
阅读更多

How to Squash Last N Commits in Git?

<p>We often need to squash several related commits to make the commit history cleaner. There are several different ways to achieve this.</p>

2022/1/9
阅读更多

How to Make An Impressive and Beautiful GitHub Profile

<details> <summary><font size="2" color="red">update log</font></summary> <ul> <li><font color="blue">2022-08-21: add section on profile visitor stat</font></li> <li><font color="blue">2022-04-09: add section on Stack Overflow stats card.</font></li> </ul> </details> <p>In this post, I will share how to customize your GitHub profile page, and you can find the end result <a href="https://github.com/jdhao" target="_blank" rel="noreferrer">here</a>.</p>

2022/1/3
阅读更多

Using Neovim after Three Years -- A Retrospect

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202202031428905.jpg" width="800"> </p> <p>I started using <a href="https://neovim.io/" target="_blank" rel="noreferrer">Neovim</a> (nvim for short) about three years ago, in Sep. 2018. At that time, nvim had just released <a href="https://github.com/neovim/neovim/releases/tag/v0.3.1" target="_blank" rel="noreferrer">v0.3.1</a>. Over the years, I have been a staunch nvim user, constantly learning new knowledge, and sharing tips, tricks and interesting plugins in <a href="https://jdhao.github.io/categories/Nvim/" target="_blank" rel="noreferrer">my blog posts</a>.</p>

2021/12/31
阅读更多

How to Extract Key Frames from A Video with FFmpeg

<p>In order to get enough information from videos, we often need to extract video frames. However, we do not want to extract every frame from a video due to:</p> <ul> <li>information redundancy in successive video frames.</li> <li>huge storage space needed by these video frames.</li> </ul> <p>In this post, I want to share how to extract <em>key</em> frames from video to reduce the storage, but still capture enough information from a video.</p>

2021/12/25
阅读更多

Download Files to Local Storage in iPad

<p>When downloading files using Safari browser in iPad, the files will be saved on your iCloud drive. For me, I want to download the files locally without filling up my iCloud space.</p>

2021/12/25
阅读更多

Using STL Containers with pybind11

<p>In my <a href="https://jdhao.github.io/2021/08/17/pybind11_first_impression/" target="_blank" rel="noreferrer">old post</a>, I have shared how to use <a href="https://pybind11.readthedocs.io/" target="_blank" rel="noreferrer">pybind11</a> to accelerate execution of Python code.</p>

2021/12/23
阅读更多

Sort lines based on a column in Vim/Nvim

<p>I have a file where each line has several comma-separated items. I want to sort the lines, based on a certain column. How do we do it inside Vim/Nvim?</p>

2021/12/21
阅读更多

Process video in a certain time range with FFmpeg?

<p>When dealing with videos, we may want to process video in a specific time range, for example, to only process video from 50 seconds to 70 seconds. How do we specify the time range in ffmpeg?</p>

2021/12/15
阅读更多

回顾我的手机换代史

<p>科技发展的这样快,常常让我们忘了以前是什么样的。手机现在已成了现代人的一部分,须臾离不开了,十几年前还不是这样。有时候我坐在地铁上,看着低头认真滑手机的人们,就在想没有手机之前大家的生活都是什么样的,竟然想不起来了。</p>

2021/12/12
阅读更多

【2021 年】iPad 安装 Shadowrocket

<p>在苹果系统上安装一个工具真麻烦,简单总结如何在 iPad 上安装 Shadowrocket 小火箭。</p>

2021/12/12
阅读更多

Migration from Nvim 0.5.1 to Nvim 0.6.0

<p>About five months ago, the biggest update of Nvim comes with its <a href="https://github.com/neovim/neovim/releases/tag/v0.5.0" target="_blank" rel="noreferrer">v0.5.0 release</a>. With v0.5, we finally get the official LSP support in Nvim core and better Lua support, among other features and bug fixes<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>.</p> <p>TL;DR: My LSP-related config can be found <a href="https://github.com/jdhao/nvim-config/blob/master/lua/config/lsp.lua" target="_blank" rel="noreferrer">here</a>.</p>

2021/12/1
阅读更多

How I Manage My Personal Blog

<p>In this post-web2.0 age, people seem to blog less and less, and blogs seem to <a href="https://www.google.com/search?q=blogs&#43;are&#43;dying" target="_blank" rel="noreferrer">be dying slowly</a>. People are separated in different Apps where the content is not searchable by search engines.</p> <p>However, I still prefer to write using a blog. In this post, I want to share how I manage my blog.</p>

2021/11/28
阅读更多

Git Learning Notes (4)

<p>My Git learning notes.</p>

2021/11/27
阅读更多

Nifty Nvim/Vim Techniques That Make My Life Easier -- Series 11

<p>This is the 11th post of my post series on nifty Nvim/Vim techniques that will make my editing experience easier.</p> <details> <summary><font size="3" color="red">Click here to check other posts in this series.</font></summary> <ul> <li>Series 10: <a href="https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/</a></li> <li>Series 9: <a href="https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/</a></li> <li>Series 8: <a href="https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/</a></li> <li>Series 7: <a href="https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/</a></li> <li>Series 6: <a href="https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/</a></li> <li>Series 5: <a href="https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/</a></li> <li>Series 4: <a href="https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/</a></li> <li>Series 3: <a href="https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/</a></li> <li>Series 2: <a href="https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/</a></li> <li>Series 1: <a href="https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/</a></li> </ul> </details>

2021/11/22
阅读更多

Fuzzy-switching Tmux Sessions with Ease

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202111211332634.png" width="400"> </p> <p>During my work, I use multiple Tmux sessions to manage different projects. When I create a new session, I usually give it unique name so that I know that the project is about via the session name.</p>

2021/11/20
阅读更多

事情经常是 Now or Never

<p>我平时用 chrome 浏览器,有时候查一个新东西,喜欢把有关系的网页都打开,所以浏览器就塞满了 tab,这些内容我不一定都有时间去看一遍,所以 tab 就一直留在那里,有时候不得已要重启浏览器或者重启系统,不想丢失这些 tab,就用 supertabs 插件把 tab 保存下来,期望有时间了再去看。</p>

2021/11/16
阅读更多

小米平板 5 Pro 体验

<p>kindle voyage 看 PDF 格式电子书体验太差,正好八月份小米发布了小米平板 5 pro,小米平板 5 销售还挺火爆的,京东上一直断货,需要预约,遂从小米之家入手一台体验<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>。以下是使用小米平板 5 pro 两个多月的体验。</p>

2021/11/13
阅读更多

Audio Processing Using FFmpeg

<p>Collected tips on audio processing with FFmpeg.</p>

2021/11/9
阅读更多

PyAV for video processing

<p><a href="https://www.ffmpeg.org/" target="_blank" rel="noreferrer">ffmpeg</a> is an excellent tool for video processing. However, using ffmpeg directly inside Python is not convenient enough. Previously, I have been using <a href="https://github.com/kkroening/ffmpeg-python" target="_blank" rel="noreferrer">ffmpeg-python</a>, which is a thin wrapper around the <code>ffmpeg</code> command line executable.</p>

2021/11/4
阅读更多

茅海建 《天朝的崩溃》

<p>花了一周的时间,看完了茅海建的<a href="https://book.douban.com/subject/1675478/" target="_blank" rel="noreferrer">《天朝的崩溃》</a>,虽然中学历史书中简略讲过第一次鸦片战争,对这段历史了解却甚少,我甚至天真地以为鸦片战争就是虎门战争之后就和谈了,然后签订了《南京条约》。</p>

2021/10/31
阅读更多

Using Diffs in Vim

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202202020040611.jpg" width="600"> </p> <p><a href="https://man7.org/linux/man-pages/man1/diff.1.html" target="_blank" rel="noreferrer">Diff</a> can be used to compare two versions of the same file to find the changes. If you use vim, you can use <code>vimdiff</code> to compare files:</p>

2021/10/24
阅读更多

Git Diff Setup

<p>When we run git-diff, git uses its internal diff algorithm to generate diff for changed files.</p>

2021/10/23
阅读更多

Find Which Font is Used in A PDF

<p>Sometimes, we are interested in which font is used for the main text in a PDF. How do we find out?</p>

2021/10/20
阅读更多

Scheduling Your Tasks with Apscheduler

<p>In Python, to run a task periodically, we can use the package <a href="https://github.com/agronholm/apscheduler" target="_blank" rel="noreferrer">apscheduler</a>.</p>

2021/10/19
阅读更多

Why Use Cross Entropy in Classification Task?

<p>In classification tasks, the de facto loss to use is the <a href="https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html" target="_blank" rel="noreferrer">cross entropy loss</a>.</p>

2021/10/16
阅读更多

Setting up Yasnippet for Emacs

<p>Unlike Vim/Neovim, where there are snippet engines like <a href="https://github.com/SirVer/ultisnips" target="_blank" rel="noreferrer">ultisnips</a> and <a href="https://github.com/rockerBOO/awesome-neovim#snippet" target="_blank" rel="noreferrer">other plugins</a>. In Emacs, the de facto snippet engine is <a href="https://github.com/joaotavora/yasnippet" target="_blank" rel="noreferrer">yasnippet</a>.</p>

2021/10/6
阅读更多

Customize Tabline in Emacs

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202109300037148.jpg" width="400"> </p> <p>A short note on how to set up a more beautiful tabline for Emacs.</p>

2021/9/29
阅读更多

中秋贵阳重庆行

<p>趁着中秋节小长假,去重庆和贵阳玩了几天。</p>

2021/9/22
阅读更多

Straight.el Bootstrap and Package Install Issue

<details> <summary><font size="2" color="red">update log</font></summary> <ul> <li><font color="blue">2022-02-08: update fastgit URL</font></li> </ul> </details> <p>I am using <a href="https://github.com/raxod502/straight.el" target="_blank" rel="noreferrer">straight.el</a> to manage my Emacs packages. However, due to GitHub access issues, the <a href="https://github.com/raxod502/straight.el#getting-started" target="_blank" rel="noreferrer">bootstrap snippet</a> can not be downloaded successfully and run. After staring Emacs, it hangs forever with high CPU usage.</p>

2021/9/15
阅读更多

Learning Emacs as A Nvimmer in One Day

<details> <summary><font size="2" color="red">update log</font></summary> <p><font color="blue">2021-11-24: Add more detailed instructions for installing doom-modeline.</font></p> </details> <p>I have been using <a href="https://github.com/neovim/neovim" target="_blank" rel="noreferrer">Neovim</a> for over three years and I have been constantly hearing the greatness of its rival editor <a href="https://www.gnu.org/s/emacs/" target="_blank" rel="noreferrer">Emacs</a>. So today I am gonna to try it and see if it is truly great.</p> <p><strong>Edit: My final Emacs conf is <a href="https://github.com/jdhao/emacs-conf" target="_blank" rel="noreferrer">here</a>.</strong></p>

2021/9/12
阅读更多

Hands on with Three Git TUI Clients

<p>If you are not accustomed to typing git commands on the command line, there are also some TUI clients for easing the use of git.</p>

2021/9/10
阅读更多

Using Virtual Text in Neovim

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202109150127349.png" width="800"> </p> <p>In Neovim, we can use the <code>virtual text</code> feature to place virtual text anywhere in the current buffer, which is not possible with normal text.</p>

2021/9/9
阅读更多

老北京炸酱面制作

<p>总结一下老北京炸酱面的制作过程,备忘。</p>

2021/9/5
阅读更多

Integer Literal Type and Overflow In C++

<p>I want to print the largest number that <code>unsigned int</code> can represent, which is <code>2^32 - 1</code>. I use the following code:</p>

2021/9/3
阅读更多

GNU Make FAQ

<p><a href="https://www.gnu.org/software/make/" target="_blank" rel="noreferrer">GNU Make</a> is a <a href="https://en.wikipedia.org/wiki/Build_automation" target="_blank" rel="noreferrer">build</a> <a href="https://en.wikipedia.org/wiki/List_of_build_automation_software" target="_blank" rel="noreferrer">automation</a> tool typically used on Linux systems<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>. Below I will summarize a list of FAQs, which explain how Make works and how to use Make.</p>

2021/8/29
阅读更多

问题根源是什么?

<p>一件关于思维的小事,值得记录。</p>

2021/8/19
阅读更多

Pybind11 hands on

<p>To accelerate the execution of some performance critical code, we can write the code in C++ with the help of <a href="https://github.com/pybind/pybind11" target="_blank" rel="noreferrer">pybind11</a> and export the C++ code as shared library<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>. Then we can import the shared library as a module and enjoy speed boost.</p>

2021/8/16
阅读更多

给 Hugo even 主题添加 utterances 评论系统

<p>建立博客以来,试用了多款评论系统,不过最终还是用了 disqus,但是 disqus 令人讨厌的是默认添加很多烦人的广告,牛皮癣一样,而且在国内无法加载,必须翻墙才能显示。<a href="https://utteranc.es/" target="_blank" rel="noreferrer">utterances</a> 是一款基于 github issues 的评论系统,简洁,避免了 disqus 的广告以及加载问题。这篇文章总结如何给 <a href="https://github.com/olOwOlo/hugo-theme-even" target="_blank" rel="noreferrer">Hugo-even</a> 主题添加 utterances 评论系统。</p>

2021/8/15
阅读更多

macOS Operation Not Permitted?

<p>Some permission related issue on macOS.</p>

2021/8/15
阅读更多

Setting up Sumneko Lua Language Server for Nvim-lsp

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202202020047792.jpg" width="600"> </p> <details> <summary><font size="2" color="red">Update log</font></summary> <ul> <li><font color="blue">2022-08-13: update nvim lsp config for lua-language-server.</font></li> </ul> </details> <p>In this post, I will share how to set up <a href="https://github.com/sumneko/lua-language-server" target="_blank" rel="noreferrer">sumneko lua</a> for <a href="https://github.com/neovim/nvim-lspconfig" target="_blank" rel="noreferrer">nvim-lspconfig</a>.</p>

2021/8/11
阅读更多

Is GitHub Down Today?

<p>update:</p> <ul> <li>On 2021-11-28, we expericence another GitHub outage which lasts more than two hours, see <a href="https://www.theverge.com/2021/11/27/22805076/github-down-outage-service-issues" target="_blank" rel="noreferrer">here</a>.</li> </ul> <p>On 2021-08-10 23:30 CST, I observed that I cannot push to my GitHub repo even with <code>--force</code>. After checking the <a href="https://www.githubstatus.com/" target="_blank" rel="noreferrer">GitHub status site</a>, it seems that the GitHub API is down<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>.</p> <p>It is not the first time that GitHub is down. <a href="https://www.infoq.com/news/2020/03/github-february-incidents/" target="_blank" rel="noreferrer">There</a> <a href="https://devclass.com/2020/03/02/github-outages-its-the-database-stupid/" target="_blank" rel="noreferrer">has</a> <a href="https://techmonitor.ai/techonology/software/github-outage-impacts-millions-of-developers-issue-found-fix-coming" target="_blank" rel="noreferrer">been</a> <a href="https://www.theregister.com/2020/07/13/github_takes_some_downtime_availability/" target="_blank" rel="noreferrer">several</a> failure reports last year (2020), due to MySQL and other issues.</p> <p>At this moment, I have realized how much I and other developers around world are relying on this free service.</p>

2021/8/10
阅读更多

macOS 上常用工具

<details> <summary><font size="2" color="red">点击查看更新记录</font></summary> <ul> <li>2022-03-07:增加 shotrr</li> <li>2022-02-10: 增加 wezterm 介绍</li> </ul> </details> <p>记录我在 macOS 下常用到的工具。</p>

2021/8/9
阅读更多

Configure Windows Terminal in 2021

<p>After updating my Windows system to the latest version, I can finally use the new <a href="https://github.com/microsoft/terminal" target="_blank" rel="noreferrer">Windows Terminal</a>.</p>

2021/8/5
阅读更多

How Does The YouTube Content ID System Work?

<p>Google introduced the <a href="https://support.google.com/youtube/answer/2797370?hl=en" target="_blank" rel="noreferrer">content ID system</a> in 2007 to cope with the unauthorized use of copyrighted music and video content. The content ID system has successfully helped the copyright owners to find the pirated content and paid billions of dollars to the copyright owners<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>.</p>

2021/8/1
阅读更多

基于内容的视频检索/视频指纹的应用

<p>基于内容的视频检索(或视频指纹),是指根据视频内容,从数据库中找到和当前视频在画面上重复高的视频。</p>

2021/7/24
阅读更多

向量搜索引擎/工具

<p>无论是推荐还是检索任务,都离不开向量检索引擎,当向量数量巨大(上千万或者上亿规模)的时候,使用精确搜索(exhaustive search)的时间成本对于用户来说无法接受,这时我们必须用到近似最邻近搜索(approximate nearest neighbor, 简称 ANN)。本文总结了一些常见的实现了 ANN 搜索的向量搜索引擎/工具。</p>

2021/7/24
阅读更多

Show Git Diff When Doing Git Commit

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20210724122638.jpg" width="800"> </p> <p>I saw on YouTube <a href="https://www.youtube.com/watch?v=xv9cp7NyK5Y" target="_blank" rel="noreferrer">a video</a> made by <a href="https://github.com/tjdevries" target="_blank" rel="noreferrer">TJ DeVries</a> on how to contribute to the <a href="https://neovim.io/" target="_blank" rel="noreferrer">neovim project</a>. There is a scene where he commit via <code>git commit</code>, and whoa, a Neovim instance appeared with three split, with top left the commit message area, top right the git-status area, and on the right the git-diff info, which is really cool.</p>

2021/7/24
阅读更多

Delete Keys Matching A Pattern with py-redis-cluster

<p>We have a Python web service where we store some <code>key-val</code> pairs in redis. Occasionally, I want to delete some of the keys matching a certain pattern. Current, we are using <a href="https://github.com/Grokzen/redis-py-cluster" target="_blank" rel="noreferrer">redis-py-cluster</a> for redis-related operations.</p>

2021/7/20
阅读更多

Migrating from vim-plug to Packer.nvim

<details> <summary><font size="3" color="red">Update log</font></summary> <ul> <li><font color="blue">2022-03-27: fix a typo in requiring lua modules</font></li> <li><font color="blue">2022-02-08: change fastgit URL</font></li> <li><font color="blue">2022-02-05: add new autocmd for auto-running command <code>PackerCompile</code>.</font></li> </ul> </details> <p>Over the past two years, I have been using <a href="https://github.com/junegunn/vim-plug" target="_blank" rel="noreferrer">vim-plug</a> as my plugin manager for Nvim. Vim-plug is powerful, fast and amazing, especially considering that all its features are contained in a single vim script. It uses the old way to manage plugins, i.e., it will manage the loading of plugins directly.</p>

2021/7/11
阅读更多

快排(quick sort) C++ 实现

<p>快排是一种快速排序算法,原理是从数组中选择一个 pivot,数组中小于等于 pivot 的元素放到左边,大于 pivot 的元素放到右边。然后对左边和右边数组分别递归进行快速排序,最后整个数组就成为排序好的数组。</p>

2021/7/10
阅读更多

A CheatSheet of C++ Container/Adapter and Common Structure

<p>I use Python in my work, and rarely need C++. So I need to compile this C++ cheatsheet for common STL containers/adapters, just in case I need them.</p>

2021/7/4
阅读更多

Static and Dynamic Linkage in C++

<p>In C++, we can build a library either statically or dynamically. In this post, I want to summarize how to build a static and a shared/dynamic library<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>.</p>

2021/7/3
阅读更多

Pretty Output Format in C++

<p>Although <code>std::cout</code> in C++ is powerful, it lacks the ease of use of <a href="https://docs.python.org/3/tutorial/inputoutput.html#the-string-format-method" target="_blank" rel="noreferrer">format string</a> in Python. Fortunately, the 3rd party package <a href="https://github.com/fmtlib/fmt" target="_blank" rel="noreferrer">fmt</a> provides a similar feature for C++.</p>

2021/7/3
阅读更多

Install LLVM/Clangd from Source on CentOS 7

<p><a href="https://clangd.llvm.org/" target="_blank" rel="noreferrer">Clangd</a> is a language server for C++/C etc. I try to use clangd 12 for C++ code auto-completion on CentOS 7.</p>

2021/7/2
阅读更多

Empty Entry in LD_LIBRARY_PATH May Lead to Security Issues

<p>When I want to build glibc using the provided configure script (<code>./configure --prefix=xxx</code>), I saw the following error message:</p>

2021/7/2
阅读更多

A Guide on Squashing Commits with git-rebase

<p>In this post, I would like to share how to squash commits using <a href="https://git-scm.com/book/en/v2/Git-Branching-Rebasing" target="_blank" rel="noreferrer">git-rebase</a>.</p>

2021/6/28
阅读更多

小米9 MIUI 12 系统开机界面无限重启

<p>最近更新到了 MIUI 12.5 系统,晚上手机突然开始不停重启(bootloop),手机在不停重启,进入 MIUI logo,然后又开始重启,有时候能进入到系统,但是还没等到我开始设置,又开始重启了。</p>

2021/6/23
阅读更多

电视盒子:当贝 B3 Pro 使用体验

<p>在 <a href="https://jdhao.github.io/2021/06/13/android_tv_box_reviews/" target="_blank" rel="noreferrer">之前的文章</a> 中,我介绍了几款试用的安卓外贸盒子,由于做工以及试用中发现的问题,最终都没有入手。其实品牌电视盒子,也有一个不错的选择,就是当贝 B3 Pro,趁着京东 6.18 活动,最终以 699 价格入手了这款盒子。</p>

2021/6/20
阅读更多

Nifty Nvim/Vim Techniques That Make My Life Easier -- Series 10

<p>This is the 10th post of my post series on nifty Nvim/Vim techniques that will make my editing experience easier.</p> <details> <summary><font size="3" color="red">Click here to check other posts in this series.</font></summary> <ul> <li>Series 11: <a href="https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/</a></li> <li>Series 9: <a href="https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/</a></li> <li>Series 8: <a href="https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/</a></li> <li>Series 7: <a href="https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/</a></li> <li>Series 6: <a href="https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/</a></li> <li>Series 5: <a href="https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/</a></li> <li>Series 4: <a href="https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/</a></li> <li>Series 3: <a href="https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/</a></li> <li>Series 2: <a href="https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/</a></li> <li>Series 1: <a href="https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/</a></li> </ul> </details>

2021/6/16
阅读更多

安卓外贸电视盒子体验

<p>家里有一台闲置的电视,想平时用来看 YouTube,看电影,于是决定入手一款电视盒子。试用了几款价格比较低的品牌电视盒子(小米、当贝),发现都无法轻松观看 YouTube,安装安卓应用也经常装不了。在寻找合适的电视盒子过程中了解到外贸盒子这种品类,外贸盒子的特点是配置高,但是通常做工一般。最近一个月也试用了两款电视盒子,实际上手体验的确不佳。</p>

2021/6/13
阅读更多

Serving Concurrent Requests for LibreOffice Service

<p>We have set up a server to convert pptx files to pdf files using LibreOffice (version: 6.0.7.3 ). Libreoffice is started using <code>subprocess.run()</code> command in Python. The external command I use is something like the following<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>:</p>

2021/6/10
阅读更多

Excel Processing using Pandas

<p>A brief summary of how to read and write excel files using Pandas package.</p>

2021/6/10
阅读更多

How to Merge PDF/images to Generate a Single PDF

<p>I have several PDF files/images that I want to merge to one file. Each page in the PDF is actually an image. Here is what works best for me.</p>

2021/5/31
阅读更多

健康的公司和员工关系

<p>加入公司快三年了,当初一起入职的同事最近几个月走了许多,我们组也有几位同事离职了,频繁的人事动荡多少也给其他人带来了冲击,正好来谈谈最近一直在思考的公司如何对待员工的问题。</p>

2021/5/22
阅读更多

当贝盒子 H1 使用体验

<p>给老家的电视配了一个小米盒子 4s(安卓 6.0 系统,2g内存+8g存储,参考<a href="https://m.mi.com/commodity/detail/12924" target="_blank" rel="noreferrer">这里</a>),感觉可以,回深以后也想给这边的电视配一个盒子。京东上当贝盒子 H1 的评价不错,就入手了当贝盒子 H1,以下是我的使用感受。</p>

2021/5/9
阅读更多

How to Use The Git-tag Feature

<p>My notes on using tag feature of Git.</p>

2021/5/7
阅读更多

小米盒子 4s 初体验

<p>小米盒子 4s 是小米在 2020 年推出的最新款盒子产品,颜值高,使用起来效果也不错。</p>

2021/4/30
阅读更多

广州之行

<p>在周末跟着团队来广州团建,第二次来广州玩。</p>

2021/4/18
阅读更多

Notes on FFmpeg (1)

2021/4/15
阅读更多

Post Nested Data Structure to the Server Using Requests

<p>In this post, I will share how to post complex data and decode it in the server side in Python.</p>

2021/4/8
阅读更多

菜谱: 茄子肉沫,糖醋排骨

2021/4/5
阅读更多

Why Are Some Logging Messages Missing in Python?

<p>In my project, I use the <a href="https://docs.python.org/3/library/logging.html" target="_blank" rel="noreferrer">Python logging package</a> for logging service.</p>

2021/4/1
阅读更多

Creating Beautiful Bash Prompts

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20210331231139.jpg" width="400"> </p> <p>This post summarize how to change the Bash shell prompt to a better look. The end result is shown in the title image.</p>

2021/3/31
阅读更多

How To Install Latest Version of Git on Linux

<details> <summary><font size="3" color="red">Update log</font></summary> <p><font color="blue">2021-12-10: update endpoint rpm link for git</font></p> </details> <p>The version of the default git bundled with the Linux system is often too old, and lacks certain features, which may <a href="https://github.com/lewis6991/gitsigns.nvim/issues/103" target="_blank" rel="noreferrer">break some tools</a>. This post summarizes how to install newer versions of Git on Linux.</p>

2021/3/27
阅读更多

Notes on Docker -- s3

<p>Personal notes on docker usage.</p>

2021/3/25
阅读更多

Better Zsh history

<p>My notes on setting up history-related features for zsh.</p>

2021/3/24
阅读更多

菜谱;芹菜牛肉,清炒生菜

<p>个人菜谱备忘。</p>

2021/3/21
阅读更多

Set up true color for nvim and tmux in Zoc terminal and xshell

<p>In my daily work, I often ssh to a remote server using a terminal emulator. My local machine is a Windows 10 desktop. In this post, I want to share how to make <a href="https://gist.github.com/XVilka/8346728" target="_blank" rel="noreferrer">true color</a> work across terminal emulator, nvim and tmux.</p>

2021/3/17
阅读更多

print message not shown in nohup.out?

<p>When starting a long-running Python program, I often run it under <a href="https://en.wikipedia.org/wiki/Nohup" target="_blank" rel="noreferrer">nohup</a> so I can redirect all the output to <code>nohup.out</code> for easier inspection. I use <code>nohup python test.py&amp;</code> to run the process in the background. Then I can run <code>tail -f nohup.out</code> to monitor the output message from this program.</p>

2021/3/16
阅读更多

Why is Wrong Stacktrace Printed for My Code?

<p>The other day, when I was updating the source code with the project running, I noticed that the exception stack trace printed is not right, i.e., the printed error line is actually not the line that is triggering the exception.</p>

2021/3/13
阅读更多

腊汁肉制作

<p>本文总结简易家庭版腊汁肉夹馍中的腊汁肉制作。</p>

2021/3/7
阅读更多

如何制作一碗美味的豌杂面

<p>作为北方人 and 面食爱好者,周末尝试做了四川美食豌杂面,本文总结家庭版豌杂面的制作。</p>

2021/3/6
阅读更多

Vim 实现的输入法体验

<p>文接<a href="https://jdhao.github.io/2021/02/25/nvim_ime_mode_auto_switch/" target="_blank" rel="noreferrer">上回</a>,Vim 虽然贵为编辑器之神,有一个没有解决好的问题就是输入中文,以及中英文的切换问题。最近也尝试了一些试图利用 Vim 提供的功能,在 Vim 中实现输入法的插件。本文做一总结点评。</p>

2021/2/26
阅读更多

如何让 Neovim 中文输入时自动切换输入法

<details> <summary><font size="2" color="red">更新日志</font></summary> <ul> <li><font color="blue">2023-06-18:增加 macism 以及 im-select.nvim 使用。</font></li> <li><font color="blue">2022-11-07:针对 macbook M1 CPU 设置添加说明,添加 smartim 插件使用。</font></li> </ul> </details> <p>Vim/Neovim 下输入中文最大的痛,就是在 Normal 模式下,需要频繁从中文模式切换到英文模式,来输入 Vim 的各种命令。本文总结几款插件,可以帮助我们在 macOS、Windows 下,进入 Normal 模式的时候自动切换到英文输入。</p>

2021/2/25
阅读更多

Set up Inverse Search for LaTeX with VimTeX and Neovim

<p><font size="5" color="red">2022-01-19: With the release of <a href="https://github.com/lervag/vimtex/releases/tag/v2.8" target="_blank" rel="noreferrer">VimTeX v2.8</a>, all the hack here may not be needed anymore.</font></p> <details> <summary><font size="2" color="red">Update log</font></summary> <ul> <li><font color="blue">2021-10-22: Update the script to write server name.</font></li> <li><font color="blue">2021-10-10: Fix typo and minor tweak.</font></li> </ul> </details> <p>Since <a href="https://github.com/neovim/neovim/issues/1750" target="_blank" rel="noreferrer"><code>--remote</code> option hasn&rsquo;t been restored by Neovim</a>, it is actually not very straightforward to set up inverse search for PDF files when we are editing large LaTeX files with the help of <a href="https://github.com/lervag/vimtex" target="_blank" rel="noreferrer">VimTeX</a>.</p> <p>I spend some time figuring out how to do it on both Windows and macOS and succeed. I thought it would be helpful for people looking for the solution.</p>

2021/2/20
阅读更多

Git Learning Notes (3)

<p>Git learning notes.</p>

2021/2/17
阅读更多

如何制作饺子馅

<p>如何制作美味的饺子馅。</p>

2021/2/13
阅读更多

记录我的 2020

<p>用文字记录生活,给自己的生命留下印迹,我的 2020。</p>

2021/2/11
阅读更多

Using Proxy in Python Requests package

<p>If we need to access the internet via a proxy server, we should set proxy properly when making HTTP/HTTPS requests using the <a href="https://requests.readthedocs.io/en/master/" target="_blank" rel="noreferrer">Requests</a> package.</p>

2021/2/7
阅读更多

How to Get or Set Clipboard Text in Python

<p>There are several Python packages by which we can get and set the system clipboard.</p>

2021/2/3
阅读更多

Bracketed Paste Mode in Terminal

<p>A note on bracketed paste mode in terminal and Neovim.</p>

2021/2/1
阅读更多

Tmux Cheatsheet

<p>In this post, I collect some useful tips for using Tmux.</p>

2021/1/25
阅读更多

Better Git log

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20210125233412.png" width="600"> </p> <p>Some of the settings to make <code>git log</code> better.</p>

2021/1/25
阅读更多

Anaconda Python 和 pip 国内源/镜像

<p>使用国外的源下载 Python 发行版和各种 Python 库,速度实在是太慢了😭😠,国内的源速度会快很多,权宜之计。</p>

2021/1/17
阅读更多

Install Python3 in Ubuntu Docker

<p>Build a Ubuntu docker with Python3 and pip support.</p>

2021/1/16
阅读更多

Cross the Wall

<p>To cross the fucking firewall, we need some handy tools.</p>

2021/1/10
阅读更多

解决 GitHub 资源无法下载的问题

<details> <summary><font size="2" color="red">更新记录</font></summary> <ul> <li>2022-02-08: <a href="https://t.me/fastgitchannel/81" target="_blank" rel="noreferrer">fasgit hub 被 GFW 封了</a>,换一个地址。</li> </ul> </details> <p>GitHub 虽然没被封,但是阻断严重,下载 GitHub 资源速度奇慢无比,总结一些验证可行的方法。</p>

2021/1/8
阅读更多

Nifty Nvim/Vim Techniques That Make My Life Easier -- Series 9

<p>This is the 9th post of my post series on nifty Nvim/Vim techniques that will make my editing experience easier.</p> <details> <summary><font size="3" color="red">Click here to check other posts in this series.</font></summary> <ul> <li>Series 11: <a href="https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/</a></li> <li>Series 10: <a href="https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/</a></li> <li>Series 8: <a href="https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/</a></li> <li>Series 7: <a href="https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/</a></li> <li>Series 6: <a href="https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/</a></li> <li>Series 5: <a href="https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/</a></li> <li>Series 4: <a href="https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/</a></li> <li>Series 3: <a href="https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/</a></li> <li>Series 2: <a href="https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/</a></li> <li>Series 1: <a href="https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/</a></li> </ul> </details>

2021/1/7
阅读更多

Copy from Remote Server to Local Clipboard via OSC 52 in Neovim

<p>In my daily work, I usually log into a remote server via a terminal emulator and do my development work there. Sometimes, I need to copy text from remote server to my local machine&rsquo;s clipboard. Previously, I use mouse to select and copy the text, which I find to be quite cumbersome.</p>

2021/1/5
阅读更多

Using Concurrent.futures in Python

<p>My notes on using <a href="https://docs.python.org/3/library/concurrent.futures.html" target="_blank" rel="noreferrer"><code>concurrent.futures</code></a> in Python.</p>

2020/12/29
阅读更多

Git Directory and Work-Tree Explained

<p>Git has two option <code>--git-dir</code> and <code>--work-tree</code>. What is the use for them?</p>

2020/12/25
阅读更多

Linux Tips and Tricks -- s3

<h1 class="relative group">Calculate the stat of a column of numbers <div id="calculate-the-stat-of-a-column-of-numbers" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#calculate-the-stat-of-a-column-of-numbers" aria-label="Anchor">#</a> </span> </h1> <p>Suppose we have a file where each line a number, and we want to the get stat of these numbers on the command line.</p> <h2 class="relative group">Use python <div id="use-python" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#use-python" aria-label="Anchor">#</a> </span> </h2> <p>If Python is installed in the system, we can use the following command:</p>

2020/12/22
阅读更多

Introducing better-esacape.vim: My First Vim/Neovim Plugin

<p>After using and learning Neovim for over 2 years, I have finally published my first plugin &ndash; better-escape.vim.</p>

2020/12/18
阅读更多

Build C++ Project with CMake -- A Simple Example

<p>For small projects, people tend to directly invoke the compiler with the suitable options to build the program. While it is feasible, it is tedious to type those compilation options and flags. For projects with multiple source files and header files, it becomes inefficient to build by hand. On Linux, people may write <a href="http://web.mit.edu/gnu/doc/html/make_2.html" target="_blank" rel="noreferrer">Makefile</a> and build with <a href="https://www.gnu.org/software/make/" target="_blank" rel="noreferrer">make</a>. On Windows, people may use Visual Studio for writing and build their project.</p>

2020/12/12
阅读更多

Why Are Some Libraries Linked by Default in GCC?

<p>Different behavior of linkage between Clang and GCC.</p>

2020/12/10
阅读更多

Building OpenCV from Source on Linux

<p>In this post, I will summarize how to build OpenCV from source, and introduce how to use it when writing C++ programs.</p>

2020/12/7
阅读更多

Get Pinyin Initials of Chinese characters

<p>To get a reasonably large collection of traditional and simplified Chinese characters in use toady, we may use <a href="https://zhon.readthedocs.io/en/latest/" target="_blank" rel="noreferrer">zhon</a>:</p>

2020/12/4
阅读更多

Setting up Neovim for C++ Development with LSP

<details> <summary><font size="2" color="red">update log</font></summary> <ul> <li><font color="blue">2022-02-08: update fastgit URL</font></li> </ul> </details> <p>In this post, I would like to share how to set up Neovim for writing simple C++ programs.</p>

2020/11/29
阅读更多

A Better Mapping to Leave Insert Mode than jk

<p><font color="blue">Update 2021-01-14: I ended up writing a plugin called <a href="https://github.com/jdhao/better-escape.vim" target="_blank" rel="noreferrer">better-escape.vim</a> which aims at solving this issue.</font></p> <p>A <a href="https://vi.stackexchange.com/q/300/15292" target="_blank" rel="noreferrer">very popular insert mode mapping</a> for Neovim/Vim is to map <code>jk</code> or <code>kj</code> or <code>jj</code> to <code>&lt;ESC&gt;</code> for quicker escaping from the insert mode. I have used the following mapping for quite some time:</p> <div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-vim" data-lang="vim"><span class="line"><span class="cl"><span class="nx">inoremap</span> <span class="nx">jk</span> <span class="p">&lt;</span><span class="nx">ESC</span><span class="p">&gt;</span></span></span></code></pre></div></div>

2020/11/23
阅读更多

The Correct Way to Create List of Empty List in Python

<p>TL;DR: do not use list multiplication to initialize an empty list of list, or you will end up wasting hours debugging your program.</p>

2020/11/22
阅读更多

几种中文分词工具对比

<details> <summary><font size="2" color="red">Update log</font></summary> <ul> <li><font color="blue">2021-10-23: fix typo,更新链接。</font></li> </ul> </details> 对几种中文分词工具进行了调研,简单总结一下。

2020/11/20
阅读更多

Pillow/PIL 缩放索引图像时的一个问题

<p>今天遇到了<a href="https://www.v2ex.com/t/726518" target="_blank" rel="noreferrer">一个有趣的问题</a>,有人在 v2ex 上说自己的图片,经过 <a href="https://python-pillow.org/" target="_blank" rel="noreferrer">PIL</a> 缩放到 800x600 以后,非常模糊,有什么办法可以解决。</p>

2020/11/18
阅读更多

Set up Fuzzy Completion for Vim-lsp

<p><font color="red">Update 2021-07-15: Note that pyls has been deprecated. There is new fork of it called <a href="https://github.com/python-lsp/python-lsp-server" target="_blank" rel="noreferrer">pylsp</a>, which is maintained by the community.</font></p> <p>In my <a href="https://jdhao.github.io/2020/11/04/replace_deoplete_jedi_for_LSP/" target="_blank" rel="noreferrer">older post</a>, I have shared how to set up auto-completion for vim-lsp with the help of deoplete. One annoyance is that I can not use fuzzy matching for auto-completion: the completion items in the pop-up completion menu seems to be selected base on prefix matching.</p>

2020/11/16
阅读更多

A Beginner's Guide on Creating Your Own Text Objects from Scratch in Neovim/Vim

<p>Shortly after I started using <a href="https://github.com/neovim/neovim" target="_blank" rel="noreferrer">Neovim</a>, I learned about the concept of <a href="https://neovim.io/doc/user/motion.html#text-objects" target="_blank" rel="noreferrer">text objects</a>. For example, when the cursor is inside a pair of <code>[]</code>, we can use <code>ci]</code> to change text inside them. This is definitely one of the greatest moments on my road of learning Vim. However, I haven&rsquo;t really thought about how does text object really work.</p>

2020/11/15
阅读更多

Nifty Nvim/Vim Techniques That Make My Life Easier -- Series 8

<p>This is the 8th post of my post series on nifty Nvim/Vim techniques that will make my editing experience easier.</p> <details> <summary><font size="3" color="red">Click here to check other posts in this series.</font></summary> <ul> <li>Series 11: <a href="https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/</a></li> <li>Series 10: <a href="https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/</a></li> <li>Series 9: <a href="https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/</a></li> <li>Series 7: <a href="https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/</a></li> <li>Series 6: <a href="https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/</a></li> <li>Series 5: <a href="https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/</a></li> <li>Series 4: <a href="https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/</a></li> <li>Series 3: <a href="https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/</a></li> <li>Series 2: <a href="https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/</a></li> <li>Series 1: <a href="https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/</a></li> </ul> </details>

2020/11/11
阅读更多

Notes on Using Python Regex Package

<p>Some notes on using regular expressions in Python.</p>

2020/11/9
阅读更多

Set Up Lisp Dev Environment in Neovim

<p>A quick summary on how to set up Lisp Development environment in Neovim.</p>

2020/11/8
阅读更多

Profiling Python Code with line_profiler

<p>To profile Python code line by line, we can use <a href="https://github.com/pyutils/line_profiler" target="_blank" rel="noreferrer">line_profiler</a><sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>.</p>

2020/11/5
阅读更多

Flake8 Config in Pyls for Code Linting.

<p><font color="red">Update 2021-07-15: Note that pyls has been deprecated. There is new fork of it called <a href="https://github.com/python-lsp/python-lsp-server" target="_blank" rel="noreferrer">pylsp</a>, which is maintained by the community.</font></p> <p>In my <a href="https://jdhao.github.io/2020/11/04/replace_deoplete_jedi_for_LSP/" target="_blank" rel="noreferrer">previous post</a>, I have go over the basic setup to make vim-lsp work. However, I haven&rsquo;t touch on an important part of writing code: linting. It turns out that configure it correctly is harder than I thought.</p>

2020/11/4
阅读更多

Replace Deoplete-jedi with LSP Finally

<p><font color="red">Update 2021-07-15: Note that pyls has been deprecated. There is new fork of it called <a href="https://github.com/python-lsp/python-lsp-server" target="_blank" rel="noreferrer">pylsp</a>, which is maintained by the community.</font></p> <p>After using deoplete along with deoplete-jedi for more than two years, I have finally decided to try something new for code completion. Yeah, you guess it, the <a href="https://langserver.org/" target="_blank" rel="noreferrer">Language Server Protocol</a> (LSP in short).</p>

2020/11/3
阅读更多

解决不蒜子 (busuanzi) 文章计数出错问题

<p>一个月之前,就发现自己的博客用的计数系统<a href="https://busuanzi.ibruce.info/" target="_blank" rel="noreferrer">“不蒜子”</a>对每篇博客访问量的统计出现了问题,刚写的博文,访问量都是几十万,显然不正常,但是很神奇,整个博客的访问量统计似乎并没有问题。当时也在 <a href="https://v2ex.com/t/707052#reply7" target="_blank" rel="noreferrer">v2ex</a> 发帖咨询了,不过没有人给出合理的答案,今天偶然间<a href="https://github.com/flysnow-org/maupassant-hugo/pull/121" target="_blank" rel="noreferrer">发现了原因</a>,发文记录。</p>

2020/10/31
阅读更多

杨振宁的一个采访

<p>在 YouTube 上看到了<a href="https://en.wikipedia.org/wiki/Yang_Chen-Ning" target="_blank" rel="noreferrer">杨振宁</a>在 2006 年的<a href="https://www.youtube.com/watch?v=6d3hZ8jnqXg" target="_blank" rel="noreferrer">一个采访</a>,挺不错。</p>

2020/10/29
阅读更多

Edit Multiple Files at once in Neovim

<p>When I was in a folder and tried to edit multiple files using glob pattern with the following Neovim command:</p> <div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-vim" data-lang="vim"><span class="line"><span class="cl"><span class="p">:</span><span class="nx">edit</span> *.<span class="nx">vim</span></span></span></code></pre></div></div> <p>I was surprised to find that Neovim gives the following error message:</p> <blockquote><p>E77: Too many file names.</p> </blockquote>

2020/10/27
阅读更多

Bash Emacs-style Shortcut Cheatsheet

<p>In Bash shell, when editting in the command line. There are two different modes, <a href="https://unix.stackexchange.com/q/85390/221410" target="_blank" rel="noreferrer">vi mode or Emacs mode</a>. Emacs-mode is the default mode. Below are some of the handy shortcuts in Emacs-mode.</p>

2020/10/26
阅读更多

Switching Buffers in Neovim with mapping

<p>I usually use <code>{num}Ctrl-6</code> to switch buffers in Neovim, where <code>{num}</code> is the number of buffer (see <a href="https://jdhao.github.io/2018/09/29/Switching_buffers_quickly_Neovim/" target="_blank" rel="noreferrer">this post</a>). Since Neovim has built-in <code>gt</code> mapping to switch between tabpages, I thought it might be a good idea to use <code>gb</code> as buffer switching shortcut avoid strech when pressing <code>Ctrl-6</code>.</p>

2020/10/16
阅读更多

How to Insert Unicode Characters in Neovim/Vim

<p>Except for the ASCII characters, it is often not straightforward to insert Unicode characters into Vim/Neovim. Below I will summarize a few ways to enter Unicode characters inside Neovim/Vim.</p>

2020/10/7
阅读更多

美国普罗米修斯--奥本海默传

<p>最近一个月读了 Kai bird 和 Martin J. Sherwin 的<a href="https://www.goodreads.com/book/show/80571.American_Prometheus" target="_blank" rel="noreferrer">《American prometheus》</a>,这本书是著名物理学家奥本海默的传记,详细讲述了奥本海默的一生。为了写这本书,作者花了 25 年的时间,做了很多采访,查看了很多 FBI 关于奥本海默的资料。这本书是关于奥本海默的权威著作,2005 甫一问世, 2006 年就获得了<a href="https://www.pulitzer.org/winners/kai-bird-and-martin-j-sherwin" target="_blank" rel="noreferrer">普利策奖(传记类)</a>。</p>

2020/10/2
阅读更多

Nifty Nvim/Vim Techniques That Make My Life Easier -- Series 7

<p>This is the 7th post of my post series on nifty Nvim/Vim techniques that will make my editing experience easier.</p> <details> <summary><font size="3" color="red">Click here to check other posts in this series.</font></summary> <ul> <li>Series 11: <a href="https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/</a></li> <li>Series 10: <a href="https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/</a></li> <li>Series 9: <a href="https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/</a></li> <li>Series 8: <a href="https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/</a></li> <li>Series 6: <a href="https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/</a></li> <li>Series 5: <a href="https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/</a></li> <li>Series 4: <a href="https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/</a></li> <li>Series 3: <a href="https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/</a></li> <li>Series 2: <a href="https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/</a></li> <li>Series 1: <a href="https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/</a></li> </ul> </details>

2020/9/22
阅读更多

Highlight Groups Cleared after Starting Neovim

<p>I want to use a custom highlight group for <a href="https://neovim.io/doc/user/lua.html#lua-highlight" target="_blank" rel="noreferrer">yank highlighting</a>. Initially, I use the predefined highlight group <code>IncSearch</code>. I thought it a bit dim and want something brighter. So I defined the following highlight group:</p>

2020/9/22
阅读更多

Grammar Check in Neovim with LanguageTool

<p>As a Neovim user who writes frequently, I want to use Neovim to check my grammar before posting it in my blog. In this post, I will compare several plugins used for grammar checking. Under the hood, they all use the opensource tool <a href="https://languagetool.org/" target="_blank" rel="noreferrer">languagetool</a>.</p>

2020/9/20
阅读更多

Find Line History in Git

<p>When we are working on a real project, we may want to know from which commit a particular line is introduced.</p>

2020/9/14
阅读更多

Tqdm Issues and Tips

<p><a href="https://github.com/tqdm/tqdm" target="_blank" rel="noreferrer">Tqdm</a> is a popular package to show a progress bar. Here are a few tips when using tqdm.</p>

2020/9/4
阅读更多

A List of Common Git-branch Operations

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202202021114754.jpg" width="800"> </p> <details> <summary><font size="2" color="red">Update log</font></summary> <ul> <li><font color="blue">2022-08-20: Add how to remove remote tracking branches that does not exist anymore</font></li> </ul> </details> <p>This post summarizes some commonly used Git commands related to branch operations.</p>

2020/9/3
阅读更多

My Settings for the Fuzzy-finder LeaderF

<p><a href="https://github.com/Yggdroot/LeaderF" target="_blank" rel="noreferrer">LeaderF</a> is Vim/Neovim plugin to fuzzy-search files, colorschemes, tags etc. quickly. It works across different platforms flawlessly. Here are some of its settings to address minor issues.</p>

2020/8/26
阅读更多

从产品猜测设计

<p>关于产品设计的一些想法。</p>

2020/8/23
阅读更多

Measuring Code Running Time with contextmanager

<p>In Python, context manager is a great way to handle the closing of resources. It makes sure that resources are correctly closed after their use.</p>

2020/8/18
阅读更多

Create Outline Text in Python with Pillow

<details> <summary><font size="2" color="red">update log</font></summary> <ul> <li><font color="blue">2022-04-12: add warning about dangers of omitting stroke_fill parameter.</font></li> </ul> </details> <p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20200818221311.png" width="400"> </p> <p>Sometimes, we may want to add outline color to text strokes with Pillow. Prior to version 6.2.0, we can not do this in Pillow. Fortunately, starting from version 6.2.0, pillow supports text outlines natively in its <a href="https://pillow.readthedocs.io/en/stable/reference/ImageDraw.html#PIL.ImageDraw.ImageDraw.text" target="_blank" rel="noreferrer"><code>ImageDraw.text()</code></a> method.</p>

2020/8/18
阅读更多

The Warmup Trick for Training Deep Neural Networks

<p>Warmup is a training technique often used in training deep neural networks. In this post, I will try to explain what is warmup, and how does it work.</p>

2020/8/14
阅读更多

MIUI 12 输入法无法复制文本到剪切板

<p>MIUI 12 更新以后,新增了更加细致的权限管理和隐私保护功能。</p> <p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20200806235442.jpeg" width="200"> </p>

2020/8/6
阅读更多

Note on font size

<h1 class="relative group">Relationship between point and pixel size <div id="relationship-between-point-and-pixel-size" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#relationship-between-point-and-pixel-size" aria-label="Anchor">#</a> </span> </h1> <p>In digital typography, the size of text is commonly specified in points (pt). What is a point? A point is 1/72 of an inch (25.4 mm), i.e., 0.3528 mm (25.4/72). Therefor, point is a physical unit that has absolute value.</p> <p><a href="https://en.wikipedia.org/wiki/Pixel" target="_blank" rel="noreferrer">Pixels</a> are the smallest unit on screen to display images and graphics. It is not a physical unit. So there is no fixed relationship between point and pixel.</p>

2020/8/4
阅读更多

pip bad interpreter issue

<p>I am using pip installed via <a href="https://docs.conda.io/en/latest/miniconda.html" target="_blank" rel="noreferrer">minconda</a>. I installed it under <code>~/miniconda3</code> and then move the installation directory to <code>~/tools/miniconda3</code>. After that, I changed the <code>PATH</code> accordingly. However, when I use pip, I am seeing the following error:</p>

2020/7/29
阅读更多

Using Multiprocessing in Python

<p>One way to achieve parallelism is to use multi-processing, where we can execute tasks in different cores of the CPU to reduce the total processing time. Python provides the <a href="https://docs.python.org/3/library/multiprocessing.html" target="_blank" rel="noreferrer">multiprocessing</a> package to facilitate this.</p> <p>This post summarizes some of the questions I have when I learn to use multiprocessing in Python.</p>

2020/7/27
阅读更多

Linux Tips and Tricks -- s2

<p>A list of Linux command for common operations.</p>

2020/7/22
阅读更多

Why Cannot I Get the Value of A Env Variable in Python?

<p>I found a strange issue when I wanted to get the value of an env variable from Python script.</p>

2020/7/15
阅读更多

Note on Using requests package

<h1 class="relative group">How to check request header and body? <div id="how-to-check-request-header-and-body" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#how-to-check-request-header-and-body" aria-label="Anchor">#</a> </span> </h1> <p>When making requests, we may want to see exactly what are being requested. With requests, it is easy do access the request header and request body:</p> <div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">requests</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">url</span> <span class="o">=</span> <span class="s2">&#34;http://httpbin.org/post&#34;</span> </span></span><span class="line"><span class="cl"><span class="n">payload</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&#34;apple&#34;</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">&#34;pear&#34;</span><span class="p">:</span> <span class="p">[</span><span class="mi">20</span><span class="p">,</span> <span class="mi">30</span><span class="p">],</span> <span class="s2">&#34;img&#34;</span><span class="p">:</span> <span class="s2">&#34;http://example.com/demo.jpg&#34;</span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">post</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">json</span><span class="o">=</span><span class="n">payload</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&#34;request headers: </span><span class="si">{</span><span class="n">r</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">headers</span><span class="si">}</span><span class="s2">&#34;</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&#34;request body: </span><span class="si">{</span><span class="n">r</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">body</span><span class="si">}</span><span class="s2">&#34;</span><span class="p">)</span></span></span></code></pre></div></div> <p>A sample output is:</p> <div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">request headers: {&#39;User-Agent&#39;: &#39;python-requests/2.19.1&#39;, &#39;Accept-Encoding&#39;: </span></span><span class="line"><span class="cl">&#39;gzip, deflate&#39;, &#39;Accept&#39;: &#39;*/*&#39;, &#39;Connection&#39;: &#39;keep-alive&#39;, &#39;Content-Length&#39;: </span></span><span class="line"><span class="cl">&#39;69&#39;, &#39;Content-Type&#39;: &#39;application/json&#39;} </span></span><span class="line"><span class="cl">request body: b&#39;{&#34;apple&#34;: 10, &#34;pear&#34;: [20, 30], &#34;img&#34;: &#34;http://example.com/demo.jpg&#34;}&#39;</span></span></code></pre></div></div> <p>Ref:</p>

2020/7/9
阅读更多

Set the Number of Threads to Use in PyTorch

<p>In this post, I will share how PyTorch set the number of the threads to use for its operations.</p>

2020/7/6
阅读更多

如何找到技术问题根源?

<p>在实际编程中,我们总会遇到各种各样的代码运行问题,如何快速发现问题的根源需要一些系统的方法,构造一个最小的能够复现错误的环境至关重要,也就是所谓的 <a href="https://stackoverflow.com/help/minimal-reproducible-example" target="_blank" rel="noreferrer">MWE</a>,minimal working example。</p>

2020/7/4
阅读更多

Switch Command with update-alternatives on Ubuntu

<p>To build different projects, we may need to install different versions of the same software. To use a specific version, we may need to create a sym link to that version of the executable.</p>

2020/7/2
阅读更多

uWSGI Install and Use Issues

<p>My notes on several issues when installing and running <a href="https://uwsgi-docs.readthedocs.io/en/latest/" target="_blank" rel="noreferrer">uWSGI</a>.</p>

2020/7/1
阅读更多

Downloading Images Faster with requests Sessions

<p>In my <a href="https://jdhao.github.io/2020/06/17/download_image_from_url_python/" target="_blank" rel="noreferrer">previous post</a>, I write about how to download an image from URL using <a href="https://github.com/psf/requests" target="_blank" rel="noreferrer">requests</a>. In this post, I want to share ways to make the download speed faster.</p>

2020/6/21
阅读更多

IrfanView Settings

<p><a href="https://www.irfanview.com/" target="_blank" rel="noreferrer">IrfanView</a> is a lightweight, fast and powerful image viewer for Windows. Here are some settings to make it more useful.</p>

2020/6/19
阅读更多

Duplicate Logging Messages in Python

<p>When I am working on a project, I find that the same message is printed twice. The following minimal code can reproduce this issue:</p>

2020/6/19
阅读更多

How to Download Image from URL using Python

<p>Recently, I want to download some images using Python. This is what I&rsquo;ve learned after the survey.</p>

2020/6/17
阅读更多

Tmux: Open Terminal Failed in Kitty Terminal

<p>I have several terminal emulators installed on my Mac: <a href="https://sw.kovidgoyal.net/kitty/" target="_blank" rel="noreferrer">kitty</a>, <a href="https://github.com/alacritty/alacritty" target="_blank" rel="noreferrer">Alacritty</a> and <a href="https://www.iterm2.com/" target="_blank" rel="noreferrer">iterm2</a>. When I start a Tmux session in Alacritty and try to create another tmux session in kitty, I noticed this strange error that I have never met before:</p>

2020/6/14
阅读更多

Serving Flask Applications with uWSGI

<p>In my <a href="https://jdhao.github.io/2020/04/06/build_webapi_with_flask_s1/" target="_blank" rel="noreferrer">older post</a>, I have shared how to run the built-in development server to serve Flask web service. For production, we need to use more powerful web servers. Flask complies to the <a href="https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface" target="_blank" rel="noreferrer">WSGI</a> specification and can work with any web server that conforms to WSGI.</p> <p>In this post, I want share how to run Flask applications using <a href="https://uwsgi-docs.readthedocs.io/en/latest/" target="_blank" rel="noreferrer">uWSGI</a> &mdash; a popular WSGI-compliant server.</p>

2020/6/13
阅读更多

Virtual Environment Management with Conda

<p><a href="https://docs.conda.io/projects/conda/en/latest/" target="_blank" rel="noreferrer">Conda</a> is the default package and environment management tool shipped with <a href="https://www.anaconda.com/products/individual" target="_blank" rel="noreferrer">Anaconda</a>.</p> <p>This post logs my cheatsheet and notes for working with virtual environments with conda.</p>

2020/6/10
阅读更多

Set Timezone inside Docker Container

<p>After running a Ubuntu docker container, I found that the default time zone is UTC. I want to change it to my local timezone.</p>

2020/6/10
阅读更多

How to Use Asyncio with Flask Applications

<p>I was using <a href="https://docs.python.org/3/library/asyncio.html" target="_blank" rel="noreferrer">asyncio</a> inside a view function for Flask to run some asynchronous functions and met an error.</p>

2020/6/7
阅读更多

Markdown Writing Tricks

<details> <summary><font size="2" color="red">update log</font></summary> <ul> <li><font color="blue">2022-02-08: Add sections on using CSS with Markdown.</font></li> </ul> </details> <p>In this post, I share some of the tricks that will Make the Markdown file better and more beautiful.</p>

2020/6/1
阅读更多

Why You Should Use Snippets in Vim/Neovim

<p>If you find yourself repeatedly type some similar-structured text in Vim/Nvim, you need to ask yourself if there is a better way to do it.</p>

2020/5/27
阅读更多

Highlight Yanked Region in Nvim/Vim

<p><strong>update (2020-09-19): update the settings for Nvim to reflect the latest changes in API.</strong></p> <p>In Vim or Neovim, showing the yanked region in color gives use visual feedback on what we have copied. Here is how you can highlight yanked region in Vim or Neovim.</p>

2020/5/22
阅读更多

AI 的噱头

<p>人工智能 (AI)甚嚣尘上,动则称颠覆,各家公司纷纷推出了自己的 AI 产品,但是这些产品真的有那么多人用吗?</p>

2020/5/22
阅读更多

Justmysocks 支持 v2ray 协议了!

<p>two meetings 即将或者正在召开,上个谷歌也越来越难,最近墙对各种工具的阻断非常严重,连之前<a href="https://jdhao.github.io/2020/04/25/shadowsocks_obfs_setup/" target="_blank" rel="noreferrer">使用了 obfs 的 ss</a> 都不行了,最近一段时间也处于时断时续的状态。</p> <p>Justmysocks 之前一直用的都是 shadowsocks 协议,对墙的反制能力不行,每到关键时候就显露疲态。好消息是,justmysocks 终于在最近推出了基于 <a href="https://www.v2ray.com/en/" target="_blank" rel="noreferrer">v2ray</a> 协议的线路。</p>

2020/5/21
阅读更多

Space for CJK Languages (CJK 语言中的空格)

<p>I was doing some typograph for Chinese text and want to insert a space equal to the width of a Chinese character.</p> <p><font color="red">最近在做一些中文排版的工作,有一个需求是在中文字符之间插入空格,并且空格的宽度等于中文字符的宽度,在某些情况下这样排版显得更加美观。</font></p>

2020/5/16
阅读更多

如何高效使用搜索引擎解决技术问题

<p>之前感叹过<a href="https://jdhao.github.io/2020/01/22/why_use_english_and_google/" target="_blank" rel="noreferrer">使用中文搜索经常找不到想要的结果</a>,这篇文章总结我对于如何有效搜索的一些想法。</p>

2020/5/8
阅读更多

Git Learning Notes (2)

<p>My Git learning notes.</p>

2020/5/6
阅读更多

Kitty Terminal Config on Mac

<details> <summary><font size="2" color="red">Changelog</font></summary> <ul> <li><font color="blue">2021-08-21: Update the part on how to open URLs since some options are removed.</font></li> </ul> </details> <p><a href="https://github.com/kovidgoyal/kitty" target="_blank" rel="noreferrer">Kitty</a> is a fast and lightweight terminal emulator for Mac and Linux. In this post, I will summarize some of its settings.</p>

2020/5/5
阅读更多

Docker 学习系列 --- 2

<p>本文总结一些 Docker 使用以及 Docker 镜像构建过程中遇到的问题。</p>

2020/5/2
阅读更多

Docker 学习系列 --- 1

<p>Docker 是一种类似虚拟机的机制,允许我们在 host 机器创建一个隔绝的小型操作系统环境,并且可以保存下这个环境(称为 Docker 镜像),把这个 Docker 镜像部署到其他 host 机器,各个机器上的环境完全一致。这样我们就不需要每次在部署新环境的时候,重复执行安装程序、配置环境的流程,大大简化了我们的工作,提升了工作效率。</p>

2020/5/2
阅读更多

Bash Script Note 1

<h1 class="relative group">Writing robust scripts <div id="writing-robust-scripts" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#writing-robust-scripts" aria-label="Anchor">#</a> </span> </h1> <p>We should use the following options in our bash script for better quality:</p>

2020/4/27
阅读更多

解决 Windows 下文件管理器中右键单击无响应问题

<h1 class="relative group">引子 <div id="引子" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e5%bc%95%e5%ad%90" aria-label="Anchor">#</a> </span> </h1> <p>最近使用工作电脑的时候,不知道为什么,在文件资源管理器里面鼠标右键单击打开菜单(也叫<a href="https://en.wikipedia.org/wiki/Context_menu" target="_blank" rel="noreferrer">context menu</a>)的时候,系统很大概率会卡顿,鼠标指针开始转圈,文件管理器白屏,然后会提示&quot;未响应&quot;,过一会儿,右键菜单才会出现。以至于我每次点击右键之前,都很烦躁,希望不要出现卡顿的情况。</p>

2020/4/26
阅读更多

Shadowsocks 配置 obfs

<p>最近几个月在手机上使用 justmysocks,感觉速度很慢,经常断流,连接不上。通过搜索,发现原因是使用的线路问题。为了学习之用,我们可以通过配置 <a href="https://github.com/shadowsocks/simple-obfs" target="_blank" rel="noreferrer">obfs</a> 增强服务稳定性。</p>

2020/4/24
阅读更多

How to Use Unified Logging Config Across Your Project

<p>When we are working on a project, we often need to log some message for easier debugging. How do we configure logging once and use it across the project?</p>

2020/4/23
阅读更多

Git Learning Notes (1)

<p>This is my personal note on learning Git.</p>

2020/4/22
阅读更多

Set up for C++/C Development in Neovim

<p>This post summarizes how to set up various plugins needed for C++/C code editing, linting and formatting.</p>

2020/4/19
阅读更多

Get Current Time with Time Zone Info in Python

<p>I am trying to generate a custom time format using the Python <code>datetime</code> package. My original code is:</p> <div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">&#34;%Y-%m-</span><span class="si">%d</span><span class="s2"> %H:%M:%S%z&#34;</span><span class="p">))</span></span></span></code></pre></div></div>

2020/4/17
阅读更多

Build Web API with Flask --- Work with JSON-like Dict

<p>This is a simple post about how to send JSON-like Dict data to a Flask server via <a href="https://requests.readthedocs.io/en/master/" target="_blank" rel="noreferrer">requests</a> package.</p>

2020/4/13
阅读更多

Build Web API with Flask -- Post and Receive Image

<p>In this post, I want to write about how to build a simple image processing web API that returns the size of an image. The topics include how to build this web API with Flask and how to post image to this web API and get response.</p>

2020/4/12
阅读更多

Build A Web API Service Using Flask -- The Basics

<p>Web API is a kind of web application. Simply put, web APIs are built for other applications to get info from the web server. For Python, <a href="https://flask.palletsprojects.com/en/1.1.x/" target="_blank" rel="noreferrer">Flask</a> can be used to build web applications. In this post, I want to share how to build web APIs with Flask.</p>

2020/4/6
阅读更多

Convert PPTX Document to JPEG Images on Ubuntu

<details> <summary><font size="2" color="red">Changelog</font></summary> <ul> <li><font color="blue">2020-12-24: Add how to convert pptx to pdf using unoconv.</font></li> </ul> </details> <p>In this post, I will share how to convert PPTX file to images. There are two steps. The first step is to convert PPTX to PDF, and the second step is to convert PDF to JPEG.</p>

2020/3/30
阅读更多

Conversion between base64 and OpenCV or PIL Image

<p>When we are building web services using Python, we often send or receive images in <a href="https://docs.python.org/3/library/base64.html" target="_blank" rel="noreferrer">base64</a> encoded format. However, when we are doing image processing tasks, we need to use PIL or OpenCV. In this post, I will share how to convert between OpenCV or PIL image and base64 encoded image.</p>

2020/3/17
阅读更多

腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名)

<p>本文主要分享腾讯云对象存储开启 CDN 的方法,不需要购买额外的域名。</p>

2020/3/15
阅读更多

Search and Replace in Multiple Files in Vim/Neovim

<p>In Sublime-Text and other editors, we can press <code>Ctrl-Shift-F</code> to invoke the search and replace UI. We can also accomplish this task easily in Vim or Neovim with the built-in features. Here is how.</p> <p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/8KSiBq.png" width="800"> </p> <p>There are two steps involved in this task. The first step is to find the files containing the search pattern under the current project or directory. The second step is to perform replacement for each file found in 1st step.</p>

2020/3/14
阅读更多

Change Table Column Width in LaTeX

<p>When we <a href="https://jdhao.github.io/2019/08/27/latex_table_with_booktabs/" target="_blank" rel="noreferrer">create tables in LaTeX</a>, the table column width will be automatically decided based on the content in the table cell. Sometimes, maybe we are not satisfied with the default column width and want to customize the column width. In this post, we will explain how to it in LaTeX.</p>

2020/3/8
阅读更多

Image or Table Side by Side in LaTeX

<p>When we are writing articles using LaTeX, we often need to create side-by-side images or tables. In this post, I summarize several methods to achieve that.</p>

2020/3/7
阅读更多

LaTeX 并排显示图像或表格

<p>使用 LaTeX 写文章的时候,经常需要并排显示图片或者表格,本文总结几种实现方法。</p>

2020/3/7
阅读更多

Tips on Writing Papers in LaTeX

<p>Some useful tips on writing papers in LaTeX.</p>

2020/3/6
阅读更多

Point to Line Distance in 2D Plane

<p>Suppose that we have a straight line formed by point B and C, and we have another point A. What is the distance from point A to line BC?</p>

2020/2/23
阅读更多

解决 Matplotlib 使用中文乱码问题

<p>注:这是一篇<a href="https://jdhao.github.io/2017/05/13/guide-on-how-to-use-chinese-with-matplotlib/" target="_blank" rel="noreferrer">旧文</a>的中文翻译版本。</p> <p>前不久,我在使用 Matplotlib 画图的时候,发现一些 Unicode 字符(例如,汉字) 无法正常显示:在生成的图片中,汉字是乱码的,显示为一个方框。经过大量的查找和阅读,我终于明白了如何在使用 Matplotlib 时,正确渲染 Unicode 字符<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>。</p>

2020/2/22
阅读更多

疫情时期的食物

<p>新型冠状病毒疫情已经持续了差不多一个月,一切还没有恢复正常,3 号从家里回到深圳,正是疫情严重的时刻,大家都如临大敌。住处附近的餐馆都关了门,想在外面吃饭也不行了。为了减少外出,降低感染的风险,于是尽量从网上买菜。疫情之前,已经开始用<a href="http://www.dingdongmc.com/" target="_blank" rel="noreferrer">叮咚买菜</a>和<a href="https://www.pupumall.com/" target="_blank" rel="noreferrer">朴朴超市</a>,不过用的频率不高,疫情来了,更依赖这些在线服务,感谢这些疫情期间仍然开张的在线服务和送菜的小哥们。</p>

2020/2/21
阅读更多

Ripgrep Searching CheatSheet

<p><a href="https://github.com/BurntSushi/ripgrep" target="_blank" rel="noreferrer">Ripgrep</a> is a command line tools that searches patterns under your current directory, like the good old <a href="https://en.wikipedia.org/wiki/Grep" target="_blank" rel="noreferrer">grep</a>, but <a href="https://blog.burntsushi.net/ripgrep/" target="_blank" rel="noreferrer">with faster speed</a>. In this post, I list some of the commonly-used flags for ripgrep.</p>

2020/2/16
阅读更多

Mac 系统如何远程连接控制 Windows 电脑

<p>本文简单总结 macOS 系统远程连接 Windows 系统需要的工具以及简单设置。</p>

2020/2/9
阅读更多

为什么要用英语以及谷歌?

<p><a href="https://www.v2ex.com/" target="_blank" rel="noreferrer">V2ex</a> 是一个程序员聚集的论坛,也是我经常访问的一个论坛,经常有人在论坛上提问技术问题。前两天遇到<a href="https://v2ex.com/t/637584" target="_blank" rel="noreferrer">一个帖子</a>,问的是 vscode 如何取消按下点以后自动补全第一个候选项。</p>

2020/1/22
阅读更多

Missing Level 1 Header in TOC in Latest Hugo

<p>After updating Hugo to the latest version (v0.62), apart from the issue of <a href="https://jdhao.github.io/2019/12/29/hugo_html_not_shown/" target="_blank" rel="noreferrer">missing HTML code</a>, I have also observed that level 1 header written in Markdown is not rendered in the generated <abbr title="Table of Content">TOC</abbr>.</p>

2020/1/19
阅读更多

Vim 和 Neovim 的前世今生

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/202202021242998.jpg" width="800"> </p> <h1 class="relative group">引子 <div id="引子" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e5%bc%95%e5%ad%90" aria-label="Anchor">#</a> </span> </h1> <p>从完全使用 <a href="https://neovim.io/" target="_blank" rel="noreferrer">Neovim</a> 进行日常<a href="https://jdhao.github.io/2018/12/24/centos_nvim_install_use_guide_en/" target="_blank" rel="noreferrer">项目开发</a>与<a href="https://jdhao.github.io/2019/01/15/markdown_edit_preview_nvim/" target="_blank" rel="noreferrer">文档写作</a>到现在,已经过去大约一年半的时间。一年半以前,我对 Vim 的了解还处在非常初级的阶段,甚至还不知道 Neovim,经过长时间的<a href="https://jdhao.github.io/categories/Nvim/" target="_blank" rel="noreferrer">使用与学习</a>,目前已经达到了熟练使用的程度。当然,Vim 的知识过于庞大,即便我已经使用了一年半的时间,还有很多 Vim/Neovim 的特性或者知识仍然有待了解与发掘。</p> <p>在使用 Neovim 的过程中,我对 Neovim 和 Vim 的历史以及它们之间的<em>恩怨情仇</em>也产生了兴趣,散布在互联网上各处的博客、视频以及论坛讨论让我对过去的历史有了一定了解。</p> <p>P.S., 我建立了一个 <a href="https://t.me/nvim_zh" target="_blank" rel="noreferrer">nvim 中文用户 tg 群</a>,有兴趣可以加入。</p>

2020/1/12
阅读更多

Hugo Post Missing (Hugo 博客文章缺失问题)

<p>Recently, when I was trying to generate my blog site using <a href="https://gohugo.io/" target="_blank" rel="noreferrer">Hugo</a>, I found that all my posts were successfully rendered, except for one new post. This was rather strange.</p> <p><font color="red">最近在使用 <a href="https://gohugo.io/" target="_blank" rel="noreferrer">Hugo</a> 生成博客文章的时候,发现有一篇新写的文章无法生成,而其他博文都可以成功渲染,非常奇怪。</font></p>

2020/1/11
阅读更多

我的 2019 阅读清单

<p>2019 年年末的这三个月过得很快,最近一个月都在紧张忙碌中度过,以至于错过了年末的时间,没有写一篇 2019 年的阅读总结。</p>

2020/1/11
阅读更多

Doing Number Arithmetics in Vim/Neovim Substitutions

<p>In this post, I want to share how to do number arithmetic quickly and get what you want in specified format. More specifically, the topic is:</p> <blockquote><p>How do we add, subtract, multiply or divide a value to each number in a range?</p> </blockquote>

2020/1/10
阅读更多

Regex Keyword and Python Interpolation in Ultisnips

<p><a href="" >Vim-snippet</a> provides a lot of useful Ultisnips snippets for various filetypes. For example, for Markdown, to insert level 1 header, the snippet trigger is <code>sec</code>, and for level 2 and 3 header, the triggers are <code>ssec</code> and <code>sssec</code> respectively. These triggers are non-intuitive and hard to remember and type.</p>

2020/1/5
阅读更多

Firenvim: Neovim inside Your Browser

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/firenvim.gif"> </p> <details> <summary><font size="2" color="red">Update log</font></summary> <p><font color="blue">2022-08-15: update firenvim conf; add install setting for packer.nvim </font></p> </details> <h1 class="relative group">Introduction <div id="introduction" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#introduction" aria-label="Anchor">#</a> </span> </h1> <p>Last year, I have written <a href="https://jdhao.github.io/2019/05/11/nvim_text_input_browser/" target="_blank" rel="noreferrer">a post</a> on how to edit texts inside the browser using Vim/Nvim or browser extensions that have Vim emulations. However, none of them is good enough, since they are either not convenient to use or lacking features compared to real Neovim empowered by various plugins.</p>

2020/1/1
阅读更多

Content inside HTML tags missing in Latest Hugo?

<p>Due to Markdown&rsquo;s inability to center and resize image properly, I use the raw HTML tags inside markdown file to include images:</p> <p><font color="red">由于 Markdown 格式无法很好居中和设定图像尺寸,我使用 HTML tags 来添加图像(图像可以很好居中以及设定显示大小):</font></p>

2019/12/29
阅读更多

Creating Markdown Front Matter with Ultisnips

<h1 class="relative group">Introduction <div id="introduction" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#introduction" aria-label="Anchor">#</a> </span> </h1> <p>Currently, I write my blog posts in Markdown and build the blog using <a href="https://gohugo.io/" target="_blank" rel="noreferrer">Hugo</a>. Hugo supports <a href="https://gohugo.io/content-management/front-matter/" target="_blank" rel="noreferrer">front matter</a> for Markdown so that you can attach metadata for a post, such as title, date, tags, categories, etc.</p>

2019/12/22
阅读更多

Labelme JSON 标注格式转 voc XML 格式

<p>Labelme 是一款常用的计算机视觉任务标注工具,可以用来标注分类,检测,分割等任务的数据。对于检测任务,labelme 生成的标注文件是 json 格式,每个图像对应一个相应的 json 文件。但是很多任务都使用 PASCAL VOC 的 xml 格式标注,例如 <a href="https://github.com/facebookresearch/maskrcnn-benchmark" target="_blank" rel="noreferrer">maskrcnn-benchmark</a> 任务中的 <a href="https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/maskrcnn_benchmark/data/datasets/voc.py" target="_blank" rel="noreferrer">voc 数据集</a>。</p>

2019/12/21
阅读更多

Nifty Nvim Techniques That Make My Life Easier -- Series 6

<p>This is the 6th post of my post series on nifty Nvim/Vim techniques that will make my editing experience easier.</p> <details> <summary><font size="3" color="red">Click here to check other posts in this series.</font></summary> <ul> <li>Series 11: <a href="https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/</a></li> <li>Series 10: <a href="https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/</a></li> <li>Series 9: <a href="https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/</a></li> <li>Series 8: <a href="https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/</a></li> <li>Series 7: <a href="https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/</a></li> <li>Series 5: <a href="https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/</a></li> <li>Series 4: <a href="https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/</a></li> <li>Series 3: <a href="https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/</a></li> <li>Series 2: <a href="https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/</a></li> <li>Series 1: <a href="https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/</a></li> </ul> </details>

2019/12/21
阅读更多

macOS 下如何为视频制作字幕

<p>几周之前,在 YouTube 上看到了 Vim 创始人 Bram Moolenaar 在 <a href="https://vimconf.org/2018/" target="_blank" rel="noreferrer">Vim Conf 2018</a> 上的<a href="https://www.youtube.com/watch?v=ES1L2SPgIDI" target="_blank" rel="noreferrer">主题报告</a>,介绍了 Vim 的历史以及可能要添加的一些新特性,萌生了给这个视频配字幕的想法。</p>

2019/12/15
阅读更多

Running Command Asynchronously inside Neovim

<h1 class="relative group">Introduction <div id="introduction" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#introduction" aria-label="Anchor">#</a> </span> </h1> <p>When I am writing some prototyping code inside Neovim, I want to run the script without going to the terminal and typing <code>python toy_script.py</code>. Of course, we can use <code>:!python %</code> in the command line to run the script (see <code>:h :!</code>). The problem is that running external command will block Nvim/Vim, and we can not move the cursor until the script finishes running.</p>

2019/12/9
阅读更多

Resolving Merge Conflict after Git Stash Pop

<p>Sometimes, when we are working with our local changes in a Git repo, we may want to pull the latest updates from the remote repository. To avoid code conflict between remote files and local files. We can use <code>git stash</code> to store the unfinished local work temporarily.</p>

2019/12/2
阅读更多

Pylint: command not found?

<p>The system I am currently using has Anaconda pre-installed by root under system locations.</p>

2019/11/27
阅读更多

A Hands-on Experience with Neovim's Built-in LSP Support

<details> <summary><font size="2" color="red">update log</font></summary> <ul> <li><font color="blue">2021-07-15: use pylsp instead of pyls since pyls is obsolete.</font></li> <li><font color="blue">2021-04-08: update post based on latest version of Neovim-lsp.</font></li> <li><font color="blue">2020-09-14: update lsp config to reflect the latest changes and add more plugins.</font></li> </ul> </details> <p>Just a few days ago, the built-in <a href="https://microsoft.github.io/language-server-protocol/" target="_blank" rel="noreferrer">Language Server Protocol</a> support <a href="https://github.com/neovim/neovim/pull/11336" target="_blank" rel="noreferrer">has been merged</a> into Neovim master.</p> <p>This post is a hands-on experience of setting up LSP support for Python with the <a href="https://github.com/python-lsp/python-lsp-server" target="_blank" rel="noreferrer">python-lsp-server</a>.</p> <p>Note that settings here may be obsolete due to rapid evolving of the built-in lsp.</p>

2019/11/20
阅读更多

How to Convert PDF to Images with Imagemagick

<p>Previously, I have talked about how to convert PDF to images using pdftoppm <a href="https://jdhao.github.io/2019/11/14/convert_pdf_to_images_pdftoppm/" target="_blank" rel="noreferrer">here</a>. In this post, I want to share how to accomplish this task with <a href="https://imagemagick.org/index.php" target="_blank" rel="noreferrer">Imagemagick</a>.</p>

2019/11/20
阅读更多

互联网上常用缩略语集锦

<p>上 <a href="https://www.reddit.com/" target="_blank" rel="noreferrer">Reddit</a> 或 GitHub 时,在讨论中,经常会碰到一些缩略词,作为一名非 native speaker,我经常有点摸不着头脑,不知道这些缩略语啥意思。这篇文章总结一些常用缩略语以及中文含义。</p>

2019/11/18
阅读更多

File Backup in Neovim

<p>There are several options related to file backup behavior in Vim/Nvim.</p> <ul> <li><code>backup</code></li> <li><code>writebackup</code></li> <li><code>backupdir</code></li> <li><code>backupcopy</code></li> <li><code>backupext</code></li> </ul> <p>In this post, I will explain how these options are related to each other.</p>

2019/11/16
阅读更多

Converting PDF Pages to Images with Poppler

<p>In this post, I want to share how to convert PDF to images using the command line tool <a href="https://www.xpdfreader.com/pdftoppm-man.html" target="_blank" rel="noreferrer">pdftoppm</a>.</p>

2019/11/14
阅读更多

Nifty Nvim Techniques That Make My Life Easier -- Series 5

<p>This is the 5th post of my post series on nifty Nvim/Vim techniques that will make my editing experience easier.</p> <details> <summary><font size="3" color="red">Click here to check other posts in this series.</font></summary> <ul> <li>Series 11: <a href="https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/</a></li> <li>Series 10: <a href="https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/</a></li> <li>Series 9: <a href="https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/</a></li> <li>Series 8: <a href="https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/</a></li> <li>Series 7: <a href="https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/</a></li> <li>Series 6: <a href="https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/</a></li> <li>Series 4: <a href="https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/</a></li> <li>Series 3: <a href="https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/</a></li> <li>Series 2: <a href="https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/</a></li> <li>Series 1: <a href="https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/</a></li> </ul> </details>

2019/11/11
阅读更多

Neovim Configuration for System-wide Use

<p>I have been using Neovim for personal projects for over a year. Recently, I want to set up Neovim system wide so that other users in the server can also use my config if they want. In this post, I will summarize the necessary configurations.</p>

2019/11/10
阅读更多

How to sort a list of tuple or list in Python -- lambda or itemgetter?

<p>In Python, when we want to sort a list of tuples or lists, we may want to sort it based on certain element in each sub-list, for example, sort the list based on the first element in each sub-list.</p>

2019/11/6
阅读更多

Building A Vim Statusline from Scratch

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20191103144006.png"> </p> <p>I have been using <a href="https://github.com/vim-airline/vim-airline" target="_blank" rel="noreferrer">vim-airline</a> to customize my statusline ever since I started using Neovim. It works great. Recently, I started <a href="https://github.com/jdhao/minimal_vim" target="_blank" rel="noreferrer">a repo</a> named <code>minimal_vim</code> to create a minimal configuration without external plugins for both Vim and Neovim. During the process, I learned how to build a custom statusline from scratch.</p>

2019/11/3
阅读更多

人类第一颗原子弹爆炸始末

<p>花了差不多两个月时间,于上周看完了《The making of the atomic bomb》(中文名叫<a href="https://book.douban.com/subject/3449736//" target="_blank" rel="noreferrer">《原子弹秘史》</a>),这本书是 1988 年美国普利策非虚构类最佳图书奖获奖作品。整本书很长,上百万字,作者在书中全景式展现了人类第一颗原子弹爆炸的完整历史,把原子物理学、核物理发现,犹太人的历史,原子弹的制造,还有科学家的成长历程,融为一体讲述,考证详实,虽然有大量的历史细节,读起来却很过瘾,一点也不枯燥。</p>

2019/11/2
阅读更多

Distributed Training in PyTorch with Horovod

<p><a href="https://github.com/horovod/horovod" target="_blank" rel="noreferrer">Horovod</a> is the distributed training framework developed by Uber. It support training distributed programs with little modification for both TensorFlow, PyTorch, MXNet and keras.</p>

2019/11/1
阅读更多

Learning Expect Programming

<p>In <a href="https://jdhao.github.io/2018/10/08/server_autologin_with_expect/" target="_blank" rel="noreferrer">my previous post</a>, I talked about how to automate the server login process with the help of Expect programming language. This post continues my learning process.</p>

2019/10/28
阅读更多

Essential Knowledge about SSH

<p>Although I use SSH (secure shell) every day, I seem to know little about it except the fact that I can use <code>ssh</code> command to log into my remote servers. Recently, I found myself some time to learn how does it work.</p>

2019/10/27
阅读更多

Nifty LaTeX Techniques -- Series 1

<h1 class="relative group">Change font size <div id="change-font-size" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#change-font-size" aria-label="Anchor">#</a> </span> </h1> <p>By default, LaTeX provides several command to change the font size to predefined size. Those command include <code>\scriptsize</code>, <code>\large</code>, <code>\Huge</code> etc. However, even the font size provided by the <code>\Huge</code> command may not be large enough.</p>

2019/10/22
阅读更多

更改 Adsense 邮寄地址,重新寄送 PIN

<p><a href="https://jdhao.github.io/2019/09/22/google_adsense_hugo_config/#%E5%85%B6%E4%BB%96" target="_blank" rel="noreferrer">之前的文章</a>提到过,当 Adsense 帐号的收入达到 10 美元阈值的时候,谷歌会向你注册 Adsense 登记的地址发送一封邮件,里面有验证的 PIN 码,只有验证了 PIN 码,后续才能收到谷歌的付款。</p>

2019/10/21
阅读更多

Mintty Tips and Configurations

<p>In this post, I want to share some useful tips and configurations about <a href="https://github.com/mintty/mintty" target="_blank" rel="noreferrer">mintty</a>.</p>

2019/10/16
阅读更多

Generating Table of Contents for Markdown with Tagbar

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20191015001602.png"> </p> <p>I have been using Vim plugin Tagbar for viewing and navigating tags inside my source file. However, for Markdown files, there is no support out of the box. In this post, I would like to share how to set up tagbar to show tags for Markdown.</p>

2019/10/14
阅读更多

Convert Python Script to Exe on Windows with Pyinstaller

<h1 class="relative group">Introduction <div id="introduction" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#introduction" aria-label="Anchor">#</a> </span> </h1> <p>I have a use case where I want to convert my Python script to standalone executable so that I do not need to type <code>python</code> before it to run the script. On Linux, it is easy to achieve with the help of <a href="https://stackoverflow.com/questions/6908143/should-i-put-shebang-in-python-scripts-and-what-form-should-it-take" target="_blank" rel="noreferrer">shebang</a>. However, on Windows, it does not work. Then I thought I might convert the script to Windows executable.</p>

2019/10/14
阅读更多

Ubuntu on Windows Missing after Windows Update

<p>I have been using Ubuntu on Windows via WSL for about a year and it works quite well.</p> <p>The terminal I use for Ubuntu on Windows is <a href="https://github.com/mintty/wsltty" target="_blank" rel="noreferrer">wsltty</a>, which is a thin wrapper around <a href="https://github.com/mintty/mintty" target="_blank" rel="noreferrer">mintty</a> and other tools for starting WSL sessions. Recently, when I start clicking the WSL Terminal icon, it start a Window and then quit silently.</p>

2019/10/11
阅读更多

使用代理加速 Mac 终端下载速度

<p>在 Mac 的终端 (terminal) 下载文件或者 clone git 仓库的时候,明显感觉速度特别慢,即使把梯子的全局模式打开也无济于事,需要在终端设置代理才能加快下载速度,本文简要总结需要的配置。</p>

2019/10/10
阅读更多

My Experience with Several Zsh Plugin Managers

<p>In this post, I share my experience and opinions on several popular Zsh plugin managers.</p>

2019/10/7
阅读更多

深圳租房小记

<p>作为深漂,大概每个人都要为租房费一番功夫。</p>

2019/10/2
阅读更多

How to Install zplug inside Docker Container

<p>In the past few days, I tried to dockerize my development environment and put my daily programming tools inside <a href="https://www.docker.com/resources/what-container" target="_blank" rel="noreferrer">container</a>. I tried to install zplug inside docker container and met some issues. In this post, I want to share how to install <a href="https://github.com/zplug/zplug" target="_blank" rel="noreferrer">zplug</a> and other plugins inside the Docker container.</p>

2019/9/30
阅读更多

Why don't settings inside bashrc or bash_profile take effect?

<p>In this post, I would like to share causes and solutions to a few issues related to login shell.</p>

2019/9/29
阅读更多

Setting Up Locale in Linux

<h1 class="relative group">Introduction <div id="introduction" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#introduction" aria-label="Anchor">#</a> </span> </h1> <p>When I logged into a Ubuntu server, the system interface and messages are all shown in Chinese. I want them to be displayed in English. After some searching, I found out that we can change the <a href="https://en.wikipedia.org/wiki/Locale_%28computer_software%29" target="_blank" rel="noreferrer">locale</a> settings.</p>

2019/9/27
阅读更多

谷歌 Adsense 申请及在 Hugo 中的配置

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/GA-L.jpg", width="600"> </p> <p>我的博客目前利用 GitHub pages 服务托管,不需要付费,但是博客的图床选用了腾讯云的对象存储,每个月还需要付一笔流量费用。为了保持收支平衡,也为了好玩,决定申请谷歌的 Adsense 一试。本文记录申请 Adsense 以及在 Hugo 博客中配置 Adsense 的过程。</p>

2019/9/22
阅读更多

How to Write Algorithm Pseudo Code in LaTeX

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20190921212617.png"> </p> <p>In this post, I want to summarize what I have learned about creating algorithmic pseudo code in LaTeX.</p>

2019/9/21
阅读更多

Nifty Nvim Techniques That Make My Life Easier -- Series 4

<p>This is the 4th post of my post series on nifty Nvim/Vim techniques that will make my editing experience easier.</p> <details> <summary><font size="3" color="red">Click here to check other posts in this series.</font></summary> <ul> <li>Series 11: <a href="https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/</a></li> <li>Series 10: <a href="https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/</a></li> <li>Series 9: <a href="https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/</a></li> <li>Series 8: <a href="https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/</a></li> <li>Series 7: <a href="https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/</a></li> <li>Series 6: <a href="https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/</a></li> <li>Series 5: <a href="https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/</a></li> <li>Series 3: <a href="https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/</a></li> <li>Series 2: <a href="https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/</a></li> <li>Series 1: <a href="https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/</a></li> </ul> </details>

2019/9/17
阅读更多

A Few Grammar Questions in Writing

<p>A few grammar-related questions in writing scientific papers.</p>

2019/9/16
阅读更多

How to Read and Write Images with Unicode Paths in OpenCV

<p>The other day, when I was using OpenCV to read some images and print the image shape, I got an error:</p> <blockquote><p>&lsquo;NoneType&rsquo; object has no attribute &lsquo;shape&rsquo;.</p> </blockquote><p>I was confused and do not know why since the image path is valid. It tooks me a while to understand the cause.</p>

2019/9/10
阅读更多

Tips on Writing Papers in LaTeX

<p>In this post, I want to share some tips on writing papers using $\LaTeX$.</p>

2019/8/28
阅读更多

Creating A Professional Table in LaTeX with booktabs

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20190827223626.png"> </p> <p>The default table style provided by LaTeX is not good-looking and professional. In this post, I would like to talk about how to create professional table with the help of <a href="https://ctan.org/pkg/booktabs?lang=en" target="_blank" rel="noreferrer">booktabs</a> package. We will create the table shown in the title image.</p>

2019/8/27
阅读更多

How to Create Proper Folding for Vim/Nvim Configuration

<p><figure><img class="my-0 rounded-md" loading="lazy" decoding="async" fetchpriority="low" alt="Folded config" src="https://blog-resource-1257868508.file.myqcloud.com/20190817223054.png" ></figure> </p>

2019/8/16
阅读更多

Linux Tips and Tricks -- s1

<p>In this post, I list some of the often-used Linux command in my daily life.</p>

2019/8/8
阅读更多

JPEG Image Orientation and Exif

<p>The other day I came across a strange bug during work. My colleagues gave me some photographs taken with a smartphone. On their machines (Windows 7), all the photos were shown correctly in landscape mode. However, when I checked those photos, I found that some of those photos were shown in portrait mode (rotated 90 or 270 degrees) or upside-down (rotated 180 degrees).</p> <p>I was curious what happened and learned about <a href="https://en.wikipedia.org/wiki/Exif" target="_blank" rel="noreferrer">Exif</a> and all its related stuff.</p>

2019/7/31
阅读更多

How Do I Show the Current File Path In Neovim?

<p>I saw on <a href="https://vi.stackexchange.com/questions/104/how-can-i-see-the-full-path-of-the-current-file/20768#20768" target="_blank" rel="noreferrer">StackExchange</a> that someone asked about how to see the full path of current file in Vim. I think it would be helpful to write about how I do it.</p>

2019/7/31
阅读更多

JPEG Image Quality in PIL

<h1 class="relative group">Introduction <div id="introduction" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#introduction" aria-label="Anchor">#</a> </span> </h1> <p>The other day, I was haunted by a bug and found that it was an issue with the image quality saved by <a href="https://pillow.readthedocs.io/en/stable/" target="_blank" rel="noreferrer">Pillow</a> after spending a few hours debugging the code.</p>

2019/7/20
阅读更多

Difference between view, reshape, transpose and permute in PyTorch

<p>PyTorch provides a lot of methods for the Tensor type. Some of these methods may be confusing for new users. Here, I would like to talk about <a href="https://pytorch.org/docs/stable/tensors.html#torch.Tensor.view" target="_blank" rel="noreferrer"><code>view()</code></a> vs <a href="https://pytorch.org/docs/stable/torch.html#torch.reshape" target="_blank" rel="noreferrer"><code>reshape()</code></a>, <a href="https://pytorch.org/docs/stable/torch.html#torch.transpose" target="_blank" rel="noreferrer"><code>transpose()</code></a> vs <a href="https://pytorch.org/docs/stable/tensors.html#torch.Tensor.permute" target="_blank" rel="noreferrer"><code>permute()</code></a>.</p>

2019/7/10
阅读更多

Convert PIL or OpenCV Image to Bytes without Saving to Disk

<h1 class="relative group">Introduction <div id="introduction" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#introduction" aria-label="Anchor">#</a> </span> </h1> <p>Sometimes, we may want an in-memory jpg or png image that is represented as binary data. But often, what we have got is image in OpenCV (Numpy ndarray) or PIL Image format. In this post, I will share how to convert Numpy image or PIL Image object to binary data without saving the underlying image to disk.</p>

2019/7/6
阅读更多

Fast Movement and Navigation Inside Vim or Neovim

<h1 class="relative group">Introduction <div id="introduction" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#introduction" aria-label="Anchor">#</a> </span> </h1> <p>One key spirit of Vim is to accomplish something in as fewer key strokes as possible. When we repeat a command several times to perform an action, we need to ask ourselves if there is a better way to do it. Only in this way, can we make progress in mastering Vim. For example, to delete five lines of texts, if we press <code>dd</code> five times, we are certainly doing it the wrong way. After looking up the Vim manual, we know that we can use <code>5dd</code> or <code>d4j</code>: only three keystrokes are needed instead of ten!</p>

2019/6/26
阅读更多

Unintuitive Behaviour of Case Sensitivity in Python glob

<p>tl;dr: <code>glob.glob()</code> is case sensitive in Linux, but case insensitive in Windows.</p> <p>Recently, I was bitten by the unintuitive behaviour of <code>glob.glob()</code>. I think it would be beneficial to write down what I have found.</p>

2019/6/24
阅读更多

Binding Keys in Zsh

<p>In this post, I want to share how to use <code>bindkeys</code> command to solve a few issues when using Zsh.</p>

2019/6/13
阅读更多

几把机械键盘试用体验

<p>6.18 快到了,加上在家里使用的 IKBC C87 青轴声音太大,敲击费力,所以动了换一把更加静音,触发力度更小的键盘的心思。在京东和淘宝上入手了多款键盘试用,不得不说,一把好的键盘真的是难选啊。自从去年双十一入手了一把 Leopold 红轴键盘以后,其他的键盘真的很难入我的眼睛了。试用过的几把键盘以及感受如下:</p>

2019/6/10
阅读更多

Nvim Autocompletion with Deoplete

<p><strong>Note: this post is deprecated, I use <a href="https://github.com/hrsh7th/nvim-cmp" target="_blank" rel="noreferrer">nvim-cmp</a> for auto-completion now.</strong></p> <p><a href="https://github.com/Shougo/deoplete.nvim" target="_blank" rel="noreferrer">Deoplete</a> is a good auto-completion plugin for Neovim. In this post, I introduce how to set up auto-completion for Nvim with the help of deoplete.</p>

2019/6/6
阅读更多

Converting Markdown to Beautiful PDF with Pandoc

<details> <summary><font size="2" color="red">update log</font></summary> <ul> <li><font color="blue">2022-07-19: Add build method via neovim</font></li> </ul> </details> <p>本文的中文版本参见 <a href="https://jdhao.github.io/2017/12/10/pandoc-markdown-with-chinese/" target="_blank" rel="noreferrer">这里</a>。</p> <p>Over the past few years, I have been using some dedicated note-taking software to manage my notes. However, all these tools I have tried are unsatisfactory: they are either slow or cumbersome in terms of note searching. Finally, I decided to take my notes in Markdown and convert them to PDF using Pandoc for reading. In this post, I will summarize how I do it.</p>

2019/5/30
阅读更多

Exclusive and Inclusive Motion in Neovim/Vim

<h1 class="relative group">Introduction <div id="introduction" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#introduction" aria-label="Anchor">#</a> </span> </h1> <p>Suppose that we have the following text in normal mode (cursor is indicated by <code>^</code>):</p> <div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">hello world </span></span><span class="line"><span class="cl">^</span></span></code></pre></div></div> <p>If we use <code>dw</code>, we delete <code>hello&lt;Space&gt;</code><sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup> and only <code>world</code> is left; if we use <code>de</code>, <code>hello</code> is deleted and <code>&lt;Space&gt;world</code> is left. Have you ever wondered about why <code>dw</code> do not delete <code>w</code> while <code>de</code> will delete the <code>o</code> in <code>hello</code>? It seems that motion <code>e</code> and <code>w</code> are somewhat inconsistent in their behaviours. It turns out that it has something to do with the exclusivity of motions in Vim.</p>

2019/5/17
阅读更多

Nifty Nvim Techniques Which Make My Life Easier -- Series 3

<p>This is the 3rd post of my post series on nifty Nvim/Vim techniques that will make my editing experience easier.</p> <details> <summary><font size="3" color="red">Click here to check other posts in this series.</font></summary> <ul> <li>Series 11: <a href="https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/</a></li> <li>Series 10: <a href="https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/</a></li> <li>Series 9: <a href="https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/</a></li> <li>Series 8: <a href="https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/</a></li> <li>Series 7: <a href="https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/</a></li> <li>Series 6: <a href="https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/</a></li> <li>Series 5: <a href="https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/</a></li> <li>Series 4: <a href="https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/</a></li> <li>Series 2: <a href="https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/</a></li> <li>Series 1: <a href="https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/</a></li> </ul> </details>

2019/5/14
阅读更多

Why Doesn't Jedi Autocompletion Work for Some Methods

<p>Currently I am writing all my Python code using Neovim and <a href="https://jdhao.github.io/2018/12/24/centos_nvim_install_use_guide_en/#plugin-install-and-settings" target="_blank" rel="noreferrer">a couple of plugins</a> to provide auto-completion, linting, etc.</p>

2019/5/13
阅读更多

Vim-like Editing inside Browser

<p>Vim/Nvim has powerful ability in editing texts. But if you are in a browser and want to input some text, can we somehow utilize the editing power of Vim? In this post, I would like to share several ways to use Vim or Vim-like editing when you are working inside a browser.</p>

2019/5/11
阅读更多

Markdown 生成 HTML 时汉字之间出现多余空格问题

<p>在过去很长一段时间,我都在<a href="https://jdhao.github.io/2017/03/04/Sublime-Windows-Markdown/" target="_blank" rel="noreferrer">使用 Sublime Text 来编辑 Markdown 文件</a>,Sublime Text有一个非常实用的功能,<a href="https://stackoverflow.com/q/25900954/6064933" target="_blank" rel="noreferrer">可以设定 <code>wrap_width</code> 和 <code>word_wrap</code> 选项</a>,自动在设定的 80个字符长度处 softwrap 文本。所以即使一个段落写成一行,编辑起来或者看起来都不违和。</p>

2019/5/4
阅读更多

小米 9 安装谷歌商店(Google Play Store)与相关配置

<p>五一假期入手了<a href="https://zh.wikipedia.org/wiki/%E5%B0%8F%E7%B1%B39" target="_blank" rel="noreferrer">小米9</a>,在安装谷歌 Play 商店以及启用过程中遇到了一些问题,特此记录解决方法。</p>

2019/5/4
阅读更多

Create Mappings That Take A Count in Neovim

<p><figure><img class="my-0 rounded-md" loading="lazy" decoding="async" fetchpriority="low" alt="Mappings" src="https://blog-resource-1257868508.file.myqcloud.com/20190503204410.png" ></figure> </p> <p>Many normal mode commands accept a <code>count</code>, which means to repeat the motion <code>count</code> times. For example, <code>3j</code> moves the cursor 3 lines below the current line and <code>4w</code> will move the cursor four words forward. Usually, the user-defined mappings can not take a count. Even if they can, they will most probably not work the way you expect them to. In this post, I will describe what I have learned to make a fairly complex mapping repeatable with a count.</p>

2019/4/29
阅读更多

Spell Checking in Nvim

<details> <summary><font size="2" color="red">Update log</font></summary> <ul> <li><font color="blue">2021-10-17: add <code>spellsuggest</code> option.</font></li> </ul> </details> <p>In this post, I want to talk about how to enable the built-in spell checking feature in Nvim.</p>

2019/4/29
阅读更多

English Words Completion inside Neovim/Vim

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20190430093054.png" alt=""> </p> <p>Some words are hard to type, it is handy if Neovim can provide auto-completion for the words we are typing. We can achieve word completion in Neovim in two ways.</p>

2019/4/25
阅读更多

How to Use Python Inside Vim Script with Neovim

<h1 class="relative group">Introduction <div id="introduction" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#introduction" aria-label="Anchor">#</a> </span> </h1> <p>I have been using <a href="https://github.com/vim-airline/vim-airline" target="_blank" rel="noreferrer">Vim-airline</a> for a while to customize my statusline. We can change the theme used for statusline with the many themes available in <a href="https://github.com/vim-airline/vim-airline-themes" target="_blank" rel="noreferrer">vim-airline-themes</a>. Not all these themes looks good since it depends on the background color you use for Neovim and certainly your aesthetics.</p>

2019/4/22
阅读更多

Nifty Little Nvim Techniques to Make My Life Easier -- Series 2

<p>This is the 2nd post of my post series on nifty Nvim/Vim techniques that will make my editing experience easier.</p> <details> <summary><font size="3" color="red">Click here to check other posts in this series.</font></summary> <ul> <li>Series 11: <a href="https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/</a></li> <li>Series 10: <a href="https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/</a></li> <li>Series 9: <a href="https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/</a></li> <li>Series 8: <a href="https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/</a></li> <li>Series 7: <a href="https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/</a></li> <li>Series 6: <a href="https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/</a></li> <li>Series 5: <a href="https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/</a></li> <li>Series 4: <a href="https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/</a></li> <li>Series 3: <a href="https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/</a></li> <li>Series 1: <a href="https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/</a></li> </ul> </details>

2019/4/16
阅读更多

Setting up Ultisnips for Neovim

<p>If you have used Sublime Text before, you may be familiar with its <a href="http://sublimetext.info/docs/en/extensibility/snippets.html" target="_blank" rel="noreferrer">snippet</a> feature. <a href="https://en.wikipedia.org/wiki/Snippet_%28programming%29" target="_blank" rel="noreferrer">Snippets</a> let us type a trigger word and expand it to some boilerplate code or texts that we do not want to repeat typing. We will increase our efficiency dramatically with the help of snippets.</p>

2019/4/16
阅读更多

Mac 上罗技 M590 鼠标设置

<p>本文简单总结 Macbook Pro 上<a href="https://item.jd.com/4462453.html" target="_blank" rel="noreferrer">罗技 M590 鼠标</a>的设置。</p>

2019/4/1
阅读更多

Nifty Little Nvim Techniques to Make My Life Easier -- Series 1

<p>This is the 1st post of a series posts on nifty techniques that make my editing experience in <a href="https://github.com/neovim/neovim" target="_blank" rel="noreferrer">Neovim</a> smoother.</p> <details> <summary><font size="3" color="red">Click here to check other posts in this series.</font></summary> <ul> <li>Series 11: <a href="https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/11/22/nifty_nvim_techniques_s11/</a></li> <li>Series 10: <a href="https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/06/17/nifty_nvim_techniques_s10/</a></li> <li>Series 9: <a href="https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/" target="_blank" rel="noreferrer">https://jdhao.github.io/2021/01/07/nifty_nvim_techniques_s9/</a></li> <li>Series 8: <a href="https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/11/11/nifty_nvim_techniques_s8/</a></li> <li>Series 7: <a href="https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/" target="_blank" rel="noreferrer">https://jdhao.github.io/2020/09/22/nifty_nvim_techniques_s7/</a></li> <li>Series 6: <a href="https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/12/21/nifty_nvim_techniques_s6/</a></li> <li>Series 5: <a href="https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/11/11/nifty_nvim_techniques_s5/</a></li> <li>Series 4: <a href="https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/09/17/nifty_nvim_techniques_s4/</a></li> <li>Series 3: <a href="https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/05/14/nifty_nvim_techniques_s3/</a></li> <li>Series 2: <a href="https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/" target="_blank" rel="noreferrer">https://jdhao.github.io/2019/04/17/nifty_nvim_techniques_s2/</a></li> </ul> </details>

2019/3/27
阅读更多

A Complete Guide on Writing LaTeX with Vimtex in Neovim

<details> <summary><font size="2" color="red">Update log</font></summary> <ul> <li><font color="blue">2021-02-20: Add inverse search settings on Windows and macOS</font></li> </ul> </details> <p>Previously, I have written <a href="https://jdhao.github.io/2018/03/10/sublime-text-latextools-setup/" target="_blank" rel="noreferrer">a post</a> on how to write and compile LaTeX source code in Sublime Text. Now that I am familiar with Neovim, I want to do everything related to text editing inside Neovim. In this post, I would like to share how to configure Neovim for LaTeX editing and previewing.</p> <p>My complete config for vimtex can be found <a href="https://github.com/jdhao/nvim-config/blob/master/core/plugins.vim" target="_blank" rel="noreferrer">here</a> (search vimtex) on my nvim-config repo .</p>

2019/3/26
阅读更多

Manipulating Images with Alpha Channels in Pillow

<p>In image processing, <a href="https://www.makeuseof.com/tag/alpha-channel-images-mean/" target="_blank" rel="noreferrer">alpha channel</a> is usually used to control the transparency of an image. In itself, the alpha channel is just a gray level image<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>. In this post, I want to talk about how to add an alpha channel to RGB image and show it using the Pillow package.</p>

2019/3/7
阅读更多

Sublime Text Regular Expression Cheat Sheet

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20190304221654.png" width="800"> </p> <p>A cheat sheet about regular expressions used in <a href="https://www.sublimetext.com/" target="_blank" rel="noreferrer">Sublime Text</a>.</p>

2019/2/28
阅读更多

Cropping Rotated Rectangles from Image with OpenCV

<p>In computer vision tasks, we need to crop a rotated rectangle from the original image sometimes, for example, to crop a rotated text box. In this post, I would like to introduce how to do this in OpenCV.</p>

2019/2/22
阅读更多

Boosting Your Productivity on Terminal with Zsh and Plugins

<p>In my <a href="https://jdhao.github.io/2018/10/13/centos_zsh_install_use/" target="_blank" rel="noreferrer">previous post</a>, I have introduced how to build Zsh from source and install <a href="https://github.com/robbyrussell/oh-my-zsh" target="_blank" rel="noreferrer">oh-my-zsh</a> to enhance your terminal experience. In this post, I&rsquo;d like to show you how to manage plugins with <a href="https://github.com/zplug/zplug" target="_blank" rel="noreferrer">zplug</a> and a few more plugins to boost your productivity.</p>

2019/2/18
阅读更多

最新版 Rime 输入法使用 (2022 更新)

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20190217233344.png" width="800"> </p> <details> <summary><font size="2" color="red">更新日志</font></summary> <ul> <li><font color="blue">2022-11-06: 更新基本概念,以及一些不清楚的地方。</font></li> </ul> </details> <p>之前一直听说过 <a href="https://rime.im/" target="_blank" rel="noreferrer">Rime</a> 这个神级输入法的大名,一直迟迟没有试用,一方面现有的各种输入法用着可以,另外,对于 Rime 没有 GUI 界面的配置感觉发怵。之前一直使用的是 QQ 输入法,最近一次升级,造成 <a href="https://www.v2ex.com/t/535393" target="_blank" rel="noreferrer">Chrome 浏览器频频崩溃</a>,是可忍孰不可忍,正好趁此机会卸载 QQ 输入法,试试 Rime 了。关于 Rime 的配置,网上能够找到的资料实在是过于丰富,为了使文章不过于冗长,一些简单的设置我将不再重复。</p> <p>值得注意,Rime 的官方文档并不是很详细,所以网上的很多配置不一定是正确的,注意自己分辨和试验。</p>

2019/2/17
阅读更多

Display Image with Pillow inside Ubuntu on Windows

<p>With the help of <a href="https://docs.microsoft.com/en-us/windows/wsl/about" target="_blank" rel="noreferrer">Windows Subsystem for Linux (WSL, for short)</a><sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>, we can use the <em>nearly full</em> Linux environment on Windows system. In this post, I would like to share how to display images inside Ubuntu on Windows, which is one of the popular distrubtions.</p>

2019/2/16
阅读更多

Faster Directory Navigation with z.lua

<p>If you work with terminals extensively, you may be tired of typing <code>cd</code> to go to directories, especially when directory names are very long. <a href="https://github.com/skywind3000/z.lua" target="_blank" rel="noreferrer">z.lua</a> is such a tool to make your life easier by jumping to the desired directory <em>smartly</em>.</p>

2019/2/14
阅读更多

Cmder Advanced Configurations

<p>In this post, I summarize some of the advanced configurations of <a href="https://jdhao.github.io/2017/12/29/cmder-usage/" target="_blank" rel="noreferrer">Cmder</a>.</p>

2019/2/3
阅读更多

Nvim-qt Settings on Windows 10

<p>To run Neovim on Windows, you can either <a href="https://jdhao.github.io/2018/11/15/neovim_configuration_windows/" target="_blank" rel="noreferrer">use the terminal Neovim</a> or use a GUI for Neovim. If you use terminal Nvim, you may encounter various annoying issues. Based on my experience, I recommend you using a GUI client for Nvim instead of the terminal one.</p>

2019/1/17
阅读更多

Tmux Plugin Install and Management

<p>In this post, I want to share how to manage tmux plugins with <a href="https://github.com/tmux-plugins/tpm" target="_blank" rel="noreferrer">Tmux plugin manager</a> (i.e., tpm) and also mention a few useful plugins.</p>

2019/1/17
阅读更多

How to Debug Python Code in Terminal

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20190116225245.jpg" width="600"> </p>

2019/1/16
阅读更多

Markdown Writing and Previewing in Neovim -- A Complete Guide

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20200214144759.png" width="600"> </p>

2019/1/15
阅读更多

Line Number Settings for More Efficient Movement in Neovim

<p>In this post, I would like to share line number settings in Neovim to move the cursor more efficiently.</p>

2019/1/11
阅读更多

两个大规模中文语料库介绍以及处理

<p>目前进行的工作需要大规模的语料库来生成中文文本图像,因此查找资料,找了一些中文语料库。本文介绍其中的两个最大的语料库,THUCNews 语料库和中文维基百科语料库,以及如何对原始语料库文件进行简单预处理。</p>

2019/1/9
阅读更多

Windows 系统下几款程序员不可不用的神器

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/listary_search_file_apps.gif" width="800"> </p> <p>工欲善其事,必先利其器,好的工具能使人效率倍增,这篇博客介绍本人常用的一些提升效率的工具,希望能够帮到读者。</p>

2019/1/7
阅读更多

我的 2018 阅读清单

<p>2018 年对于我来说,是变化很大的一年,我很高兴自己能够下定决心做一些决定。这一年读书的数量并不多,因为有几部比较大部头,读完花费了相当多的时间。年初寒假的时候,买了最新款的 <a href="https://goo.gl/g2rYKZ" target="_blank" rel="noreferrer">Kindle Oasis2</a>,替换了几年前买的 Kindle Paper White<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>。最值得高兴的事情是现在可以完全无压力阅读英文原版书籍,没有阅读的障碍。</p>

2018/12/24
阅读更多

A Complete Guide to Neovim Configuration for Python Development

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/Xnip2020-04-04_21-39-49.jpg" width="600"> </p> <details> <summary><font size="3" color="blue">Change log</font></summary> <ul> <li><font color="blue">2022-01-29: Add deprecation notice</font></li> <li><font color="blue">2021-01-17: Install nvim via tar ball instead of appimage</font></li> <li><font color="blue">2020-12-01: Add detailed guide on installing Neovim on Linux</font></li> </ul> </details> <p>TL;DR: My complete nvim configuration is <a href="https://github.com/jdhao/nvim-config" target="_blank" rel="noreferrer">here</a>. Follow the guide there on how to use it. Most of the config below also applies to Windows and Mac. For how to configure Neovim on Windows, you may also be interested in <a href="https://jdhao.github.io/2018/11/15/neovim_configuration_windows/" target="_blank" rel="noreferrer">this post</a>.</p> <p><strong>2022-01-29: Note that this post is written more than three years ago. Some of the plugins mentioned here may not be maintained or may not be the best fit for Neovim, or even not needed, e.g., <a href="https://jdhao.github.io/2020/05/22/highlight_yank_region_nvim/#neovim-only" target="_blank" rel="noreferrer">highlighted yank is builtin in Neovim since May 2020</a>. I have shared some of the plugin changes in <a href="https://jdhao.github.io/2021/12/31/using_nvim_after_three_years/#what-remains-what-has-changed-and-some-new-plugins" target="_blank" rel="noreferrer">this post</a>.</strong></p>

2018/12/23
阅读更多

How Is Newline Handled in Python and Various Editors?

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20181208223253.png" width="800"> </p> <p>Every programmer knows newline character, but may be not so familiar. In this post, I want to share what I have learned about newline handling in various cases.</p>

2018/12/8
阅读更多

Two Issues Related to ImageFont Module in PIL

<p>In this post, I want to write about two issues related to the <a href="https://pillow.readthedocs.io/en/5.1.x/reference/ImageFont.html" target="_blank" rel="noreferrer">ImageFont</a> module in the <a href="https://github.com/python-pillow/Pillow" target="_blank" rel="noreferrer">PIL</a> package.</p>

2018/12/4
阅读更多

在 Listary 中调用 GoldenDict 或欧路词典查单词

<p><a href="https://github.com/goldendict/goldendict" target="_blank" rel="noreferrer">GoldenDict</a> 是一款开源字典应用,功能强大,支持多种字典格式,同时也支持网络资源。<a href="https://www.eudic.net/v4/en/app/eudic" target="_blank" rel="noreferrer">欧路词典</a> 是一款国产的查词软件,产品做得也很不错,同样支持多种字典格式。本文介绍 GoldenDict 以及欧路词典的配置, 以及如何在Listary 中调用它们实现查词功能。</p>

2018/12/4
阅读更多

Reading and Writing Text Files on Windows

<p>If you are using Python 3 on Windows, you may have seen a Unicode decoding error when opening files in UTF-8 format:</p> <blockquote><p>UnicodeDecodeError: &lsquo;gbk&rsquo; codec can&rsquo;t decode byte 0xaf in position 5: illegal multibyte sequence</p> </blockquote><p>If you read the same file on Linux or macOS, you will find that this file can be opened without any error. Why is there a difference? It has something to do with the default encoding Python chooses to use on different platforms.</p>

2018/12/3
阅读更多

The Mathematics behind Font Shapes --- Bézier Curves and More

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20200223203853.png"> </p>

2018/11/27
阅读更多

快速识别图片字体:字体识别工具介绍

<p>在日常工作中,有时候,我们可能需要知道图片中的文字用的是哪种字体,本文介绍几种在线字体识别工具(从图片识别所用的字体),并且给出一些提高字体识别准确率的方法。</p>

2018/11/22
阅读更多

Deoplete Failed to Load at Startup after Updating Python neovim Package

<p>Today when I use <code>:checkhealth</code> to check if there are anything wrong with my Neovim and related packages. I got an info that <a href="https://github.com/neovim/pynvim" target="_blank" rel="noreferrer">Python <code>neovim</code> package</a> is not up to date. So I tried to update neovim with <code>pip install --upgrade neovim</code>. This is the start of a disaster which wastes me several hours.</p>

2018/11/19
阅读更多

What Is The Difference between pip, pip3 and pip3.6 Shipped with Anaconda3?

<p>On Windows system, if you install Python3 via <a href="https://www.anaconda.com/download/#windows" target="_blank" rel="noreferrer">Anaconda</a>. Under Anaconda root directory, there is a directory named <code>Scripts</code>, in which <code>pip.exe</code>, <code>pip3.exe</code> and <code>pip3.6.exe</code> all exist. When we want to install a package, a natural question arises, is there any difference if I use <code>pip install PACKAGE</code> or <code>pip3 install PACKAGE</code>?</p>

2018/11/19
阅读更多

Windows 10 系统下 Neovim 安装与配置

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20190119221237.png" width="600"> </p> <p>本篇文章介绍如何在 Windows 系统下安装并配置终端上的 <a href="https://github.com/neovim/neovim" target="_blank" rel="noreferrer">Neovim</a>。关于如何配置 Neovim 的 GUI 客户端 <a href="https://github.com/equalsraf/neovim-qt" target="_blank" rel="noreferrer">nvim-qt</a>,可以参考 <a href="https://jdhao.github.io/2019/01/17/nvim_qt_settings_on_windows/" target="_blank" rel="noreferrer">这篇博客</a>。</p>

2018/11/15
阅读更多

How to Use shutil.move() on Windows and Linux

<p>Today when I try to move a file using <a href="https://docs.python.org/3/library/shutil.html#shutil.move" target="_blank" rel="noreferrer"><code>shutil.move()</code></a> on my Windows machine, I encounter an error message:</p> <blockquote><p>PermissionError: [WinError 32] The process cannot access the file because it is being used by another process</p> </blockquote><p>In this post, I will write about what I have learned from this error.</p>

2018/11/15
阅读更多

Neovim configuration on Windows 10

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20190119221237.png" width="600"> </p> <p><font color="blue">update: 2020-11-15, add detailed instruction for Neovim config location.</font></p> <p><strong>TL;DR</strong>: After nearly one year of using Neovim on Windows, I find that the best experience one can get on Windows is to use GUI Neovim client such as <a href="https://github.com/equalsraf/neovim-qt" target="_blank" rel="noreferrer">Nvim-qt</a> or <a href="https://github.com/yatli/fvim" target="_blank" rel="noreferrer">fvim</a>, not the terminal Nvim<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>.</p> <p>In this post, I want to share how to install and configure Neovim on Windows 10<sup id="fnref:2"><a href="#fn:2" class="footnote-ref" role="doc-noteref">2</a></sup>. For configurations of <a href="https://github.com/equalsraf/neovim-qt" target="_blank" rel="noreferrer">nvim-qt</a> on Windows, check <a href="https://jdhao.github.io/2019/01/17/nvim_qt_settings_on_windows/" target="_blank" rel="noreferrer">this post</a>.</p>

2018/11/15
阅读更多

Commonly-used Building Options Explained

<p>On Linux system, if we do not have root priviledge, we can not use package managers to install a package to its default location (usually under <code>/usr</code>). Besides, the packages installed by the package managers are often too old to have the latest features. Or, even if we have root priviledge, we do not want to mess up with the system-wide packages and just want to experiment with a package locally. On these ocassions, we may want to install the package to a custom location.</p>

2018/11/7
阅读更多

Fzf Installation and Usage

<script id="asciicast-218493" src="https://asciinema.org/a/218493.js" async></script>

2018/11/5
阅读更多

Execellent Development Experience with Cygwin and Mintty Terminal on Windows 10

<p>Linux is great for programming compared to Windows. If you miss the experience you get on Linux, maybe you should try <a href="https://www.cygwin.com/" target="_blank" rel="noreferrer">Cygwin</a>, which set up a Linux-like environment on Windows platform. In this post, I want to talk about how to configure Cygwin and how to use mintty terminal on Windows 10 to get excellent programming experience.</p>

2018/10/23
阅读更多

Tmux Questions and Trouble Shootings

<p>In this post, I will summarize a list of questions related to Tmux during the process of learning how to use it.</p>

2018/10/22
阅读更多

File Sharing between Android and Mac Wirelessly without Pain

<p>If you connect your Android device to a Macbook, you will notice that your phone is not recognized. Unlike Windows, Apple&rsquo;s Mac is not so friendly to Android devices. Of course, you can install <a href="https://www.android.com/filetransfer/" target="_blank" rel="noreferrer">Android File Transfer</a> provided by Google and connect your phone to Mac. But it is kinda cumbersome and does work so well. In this post, I want to share several ways to transfer files between Android and Mac wirelessly.</p>

2018/10/21
阅读更多

博客图床从七牛云存储迁移到腾讯云存储

<p>去年建立博客的时候,选择了<a href="https://www.qiniu.com/" target="_blank" rel="noreferrer">七牛</a>对象存储来存放博客的图片,最近收到了七牛的邮件,之前一直在用的域名只是一个测试域名,再过一阵就要回收了,到时必须使用自己的域名。大概看了一下,申请自己的域名还要涉及注册和备案,我仅仅是需要存储图片,这样太费周章,所以决定把博客的图片从七牛迁移出来。</p>

2018/10/20
阅读更多

Setting up True Color Support for Neovim and Tmux on Mac

<details> <summary><font size="2" color="red">Update log</font></summary> <p><font color="blue">2021-11-23: update tmux and nvim version to the latest and fix other issues.</font></p> </details> <p>In this post, I want to share how to set up true color support in Tmux, Nvim and the shell to make them work nicely together.</p>

2018/10/18
阅读更多

An Introduction to Lookaround Regular Expression in Neovim/Vim

<p>Today I want to use some regular expressions for searching and replacing in my files. But I found that Nvim/Vim regular expression engine has its own flavor, which is different from the regex engine used by Sublime Text<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>. I ended up learning some of the basics of Nvim-style regex. In this post, I want to share about how to use lookaround<sup id="fnref:2"><a href="#fn:2" class="footnote-ref" role="doc-noteref">2</a></sup> in Nvim.</p>

2018/10/18
阅读更多

Building and Install Tmux from Source on Linux

<p>Tmux is a great terminal multiplexer. Tmux installed via the package manager is often too old. So I decided to install the latest version of Tmux that supports true colors from source. Since I do not have root privilege on the system, I have to build Tmux and install it under my <code>HOME</code>. If that is also what you want, keep reading.</p>

2018/10/16
阅读更多

Building Zsh from Source and Configuring It on CentOS

<p><strong>Update</strong>: this is my first post on Zsh install and configuration. For a list of useful plugins I use to boost my productivity, see <a href="https://jdhao.github.io/2019/02/19/zsh_advanced_configuration/" target="_blank" rel="noreferrer">this post</a>.</p> <p><a href="http://www.zsh.org/" target="_blank" rel="noreferrer">Zsh</a> is a powerful shell with better auto-completion and richer features. There are also various plugins to enrich your experience of using Zsh. In this post, I will give a brief summary on how to install and set up zsh.</p>

2018/10/13
阅读更多

Mechanical Keyboard Set up For Mac

<p>Recently I bought a MacBook Pro 2018. While it is a good design overall, its built-in keyboard is not so great AFAIK. So I bought a mechanical keyboard <a href="http://www.ikbc.com.tw/c87" target="_blank" rel="noreferrer">ikbc c87</a>. The mechanical keyboard is designed for the Windows operating systems. I have to make a few tweaks to make my typing experience smooth.</p>

2018/10/12
阅读更多

A Simple Guide on How to Use the Python Logging Module

<p>In the past, I use plain <code>print()</code> to display some statistics during training process of my models. However, it is not convenient to save the statistics in a file for later inspection. Once the program is finished, we do not have an overview of the training process. I am aware that there are packages such as <a href="https://github.com/lanpa/tensorboardX" target="_blank" rel="noreferrer">tensorboardX</a> and <a href="https://github.com/facebookresearch/visdom" target="_blank" rel="noreferrer">visdom</a>, which are specifically designed for inspecting the various statistics during training. Right now, I would rather keep the program plain simple and usable. So I decided to give <a href="https://docs.python.org/3/library/logging.html" target="_blank" rel="noreferrer">Python logging package</a> a try.</p>

2018/10/12
阅读更多

Set up the Default Value for Boolean Option in Argparse

<p>TL;DR</p> <p>If you want to set a parameter&rsquo;s default value to <code>True</code> using argparse, use</p> <div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">parser.add_argument(&#39;--param&#39;, action=&#39;store_false&#39;)</span></span></code></pre></div></div> <p>Otherwise, use</p> <div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">parser.add_argument(&#39;--param&#39;, action=&#39;store_true&#39;)</span></span></code></pre></div></div>

2018/10/11
阅读更多

把博客从 Hexo 迁移到 Hugo

<p>这个博客于 2017 年 2 月开始搭建运行,最初使用的是 <a href="https://hexo.io/zh-cn/" target="_blank" rel="noreferrer">Hexo</a> 搭建,配合精美的 <a href="https://github.com/theme-next/hexo-theme-next" target="_blank" rel="noreferrer">NexT</a> 主题,经过<a href="https://jdhao.github.io/tags/Hexo/" target="_blank" rel="noreferrer">鼓捣</a>,差不多算是做出了让自己满意的博客。不过每次安装 Hexo,要配置的东西太多了,总觉得不是很简洁,另外,随着文章数量的增加,Hexo 生成博客的速度也慢了下来。怀着尝鲜的心态,我把 Hexo 博客迁移到了 <a href="https://gohugo.io/" target="_blank" rel="noreferrer">Hugo</a>。</p>

2018/10/10
阅读更多

Fixing the nerdtree Window Problem with `bd` Command in Nvim

<p>If you have a nerdtree file navigation window on the left of the current buffer and use <code>:bd</code><sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>, you will find that the nerdtree window will occupy the whole window. When you open another buffer, you have to manually resize the nerdtree window to a smaller size, which is super annoying.</p> <p>How to prevent this behaviour?</p>

2018/10/9
阅读更多

Server Autologin with Expect

<p>I use a Windows 10 machine and need to connect to Linux servers. After using several <a href="https://www.slant.co/topics/149/~best-ssh-clients-for-windows" target="_blank" rel="noreferrer">ssh clients</a> for connecting to the server, I finally settled for <a href="https://www.cygwin.com/" target="_blank" rel="noreferrer">Cygwin</a> and <a href="https://github.com/mintty/wsltty" target="_blank" rel="noreferrer">Wsltty</a>, which is open-sourced and use the well-known <a href="https://github.com/mintty/mintty" target="_blank" rel="noreferrer">mintty terminal</a>.</p> <p>But one feature I miss from the SSH tools such as MobaXterm or Xshell is that these tools can save the server IP, port, user name and even password, so that you can log into the server with just a click.</p> <p>With mintty terminal, I have to manually ssh to my server each time, which is tedious and time consuming. Fortunately, I have found the <a href="https://en.wikipedia.org/wiki/Expect" target="_blank" rel="noreferrer">Expect</a> scripting language which is pretty powerful for this task.</p>

2018/10/8
阅读更多

The Fastest Way to Search A Keyword across the Project in Neovim

<p>When we want to find out where a method is used across the whole project, how do we do that in Nvim? Various tools are available, for example, <a href="https://beyondgrep.com/documentation/" target="_blank" rel="noreferrer">ack</a>, <a href="https://github.com/ggreer/the_silver_searcher" target="_blank" rel="noreferrer">ag</a> or <a href="https://github.com/BurntSushi/ripgrep" target="_blank" rel="noreferrer">rg</a>.</p> <p>These are the 3 most popular tools to use. In the following post, I will introduce how to install and use these packages in Neovim (Nvim).</p>

2018/10/7
阅读更多

Vim-like Settings for Tmux

<p>I am a <a href="https://neovim.io/" target="_blank" rel="noreferrer">Neovim</a> (or Nvim in abbreviation) user. In Nvim, we use <code>Ctrl-W</code> as prefix for window-related operations. However, the default prefix is <code>Ctrl-B</code> in Tmux. As a result, I often mistakenly press <code>Ctrl-W</code> when trying to change panes inside Tmux, which is annoying. Why not change tmux prefix to be more vim-like?</p>

2018/9/30
阅读更多

How to Switch between Buffers Quickly in Neovim/Vim

<p>When working on real projects using Neovim, we often open several files in a window. Each file corresponds to a buffer. How to switch between these buffers quickly?</p>

2018/9/29
阅读更多

How to Use Tagbar in Neovim

<p>If you have a source file with hundreds or thousands of lines of code. How to you see its structure and go to some classes or methods quickly in Nvim? The solution is to use <a href="https://github.com/majutsushi/tagbar" target="_blank" rel="noreferrer">tagbar</a>.</p>

2018/9/28
阅读更多

写给初学者的 Markdown 教程

<p>这是一篇帮助初学者快速入门 Markdown 的文章,看完此篇,你应该就可以使用 Markdown 写出格式规范的文章了。</p>

2018/9/21
阅读更多

Use Pylint for Code Checking inside Neovim

<p>Pylint is a popular static code checker which can effectively find the possible bugs in your source code. It is easy to install pylint with conda or pip:</p>

2018/9/20
阅读更多

Intro to Nvim File Explorer Plugin Nerdtree

<p><a href="https://github.com/scrooloose/nerdtree" target="_blank" rel="noreferrer">Nerdtree</a> is a file explorer for Vim/Neovim. It will generate a file navigation window just like an IDE. We can operate on files easily in the nerdtree window. In this post, I will summarize some of its configurations and usages.</p>

2018/9/10
阅读更多

为什么 .bash_profile 里面的设置不生效?

<p>最近安装了 <a href="https://github.com/neovim/neovim" target="_blank" rel="noreferrer">Neovim</a>,并且在 HOME 目录下的 <code>.bash_profile</code> 中设置好了 Neovim 可执行程序对应的 PATH 变量。奇怪的是,每次在 SSH 客户端打开一个新的服务器连接 session,登录服务器,进入自己账号以后,位于 <code>.bash_profile</code> 中的 PATH 设置命令没有生效,导致我无法启动安装的 Neovim,每次登录以后,我还必须手动 source 一下 <code>.bash_profile</code> 文件,然后才能使用 nvim 命令,非常让人恼火。本文记录我排查问题的过程以及最终的解决方案。</p>

2018/9/5
阅读更多

Linux 下 Neovim 配置 Python 开发环境指南

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/Xnip2020-04-04_21-39-49.jpg" width="800"> </p> <p>我的完整 Neovim 配置可以点<a href="https://github.com/jdhao/nvim-config" target="_blank" rel="noreferrer">这里</a>查看。</p> <p><strong>2022-01-29: 本文写于三年以前,其中提到的一些插件已经不再维护,或者对于 Neovim 不是最佳选择,甚至还有一些插件被 Nvim 自带的功能所替代,例如,<a href="https://jdhao.github.io/2020/05/22/highlight_yank_region_nvim/#neovim-only" target="_blank" rel="noreferrer">从 2020.05 开始,highlighted yank 开始内置</a>。我在 <a href="https://jdhao.github.io/2021/12/31/using_nvim_after_three_years/#what-remains-what-has-changed-and-some-new-plugins" target="_blank" rel="noreferrer"> 这篇博文</a> 分享了一些插件迁移的事情。</strong></p> <p>Vim 是一款主要流行于 *nix 系统上的强大的编辑器,另外一款可以与之媲美的编辑器是 Emacs,这两款编辑器广泛流行于程序员群体,<a href="https://en.wikipedia.org/wiki/Editor_war" target="_blank" rel="noreferrer">关于谁是编辑器之王的争论经久不息</a>。Vim 的功能虽然强大,但是作为一款「古老」的编辑器<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>,也不是没有缺点:随着 Vim 代码量的增加,维护变得日益困难,不利于快速增加新功能;另外,它的主要开发者目前只有一个人,<a href="https://en.wikipedia.org/wiki/Bram_Moolenaar" target="_blank" rel="noreferrer">Bram Moolenaar</a>,也不符合当今开源社区多人协作的习惯。为了克服 Vim 的这些缺点,保留 Vim 的优点(最大程度兼容 Vim),让 Vim 的开发能有更快的迭代速度,<a href="https://neovim.io/" target="_blank" rel="noreferrer">Neovim</a> 项目诞生了。本文介绍如何安装 Neovim 并配置 Python 开发环境(在以下叙述中,Neovim 和 Nvim 含义相同,不再加以区分)<sup id="fnref:2"><a href="#fn:2" class="footnote-ref" role="doc-noteref">2</a></sup>。</p>

2018/9/5
阅读更多

How to Replace A Page of PDF File with Another PDF

<p>In this post, I want to write about how to replace one page of existing PDF files with a new PDF image.</p>

2018/6/4
阅读更多

How to Change Intersection Point of X and Y Axis in Matplotlib

<p>In this post, I will share how to position the intersection of x and y axis at a specific point using Matplotlib.</p> <!-- more --> <h1 class="relative group">The spines <div id="the-spines" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#the-spines" aria-label="Anchor">#</a> </span> </h1> <p>In order to re-position x and y axis, we need to understand an important concept in Matplotlib &mdash;<a href="https://matplotlib.org/api/spines_api.html#module-matplotlib.spines" target="_blank" rel="noreferrer">spines</a>. According to Matplotlib documentation:</p> <blockquote><p>Spines are the lines connecting the axis tick marks and noting the boundaries of the data area. They can be placed at arbitrary positions. See function:set_position for more information.</p>

2018/5/21
阅读更多

利用母版视图在 PowerPoint 中制作个性化页脚页眉

<p>本文简要总结一下如何在 PowerPoint 中使用母版视图制作个性化的页脚页眉<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>,先上效果图:</p> <p><img src="https://blog-resource-1257868508.file.myqcloud.com/18-5-19/53063122.gif" title="示例幻灯片" style="float: middle;"></p> <!-- more --> <h1 class="relative group">背景介绍 <div id="背景介绍" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e8%83%8c%e6%99%af%e4%bb%8b%e7%bb%8d" aria-label="Anchor">#</a> </span> </h1> <p>假如张三是哈佛(哈尔滨佛学院,简称「哈佛」)的一个学生,他要作一篇报告,题目为“论马克思主义在人工智能时代的指导作用”,除了 PPT 的首页之外,其余每张幻灯片(slide)页脚要标明作者,报告的题目,时间,以及当前幻灯片的编号和所有幻灯片的数目;在页眉部分,右边要有哈佛的一个标志。如何来实现上述要求?</p>

2018/5/19
阅读更多

How to Push Local Git Repo to Remote Repo in GitHub

<p>There are two basic cases when we push our local repo to remote repo. These two cases differ in their settings. But sometimes, we are easily confused.</p> <!-- more --> <h1 class="relative group">First scenario <div id="first-scenario" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#first-scenario" aria-label="Anchor">#</a> </span> </h1> <p>The first case is that you have created a local repo and want to store it on GitHub later. In this case, your usual work flow for local repo is:</p>

2018/5/16
阅读更多

How to Read and Write CSV Files in Python

<details> <summary><font size="2" color="red">update log</font></summary> <p><font color="blue">2022-09-30: change order of read and write section; other small fixes.</font></p> </details> <p>In this post, I will share the most convenient way to read and write CSV files (with or w/o headers) in Python.</p> <!-- more --> <h1 class="relative group">Read CSV files <div id="read-csv-files" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#read-csv-files" aria-label="Anchor">#</a> </span> </h1> <h2 class="relative group">Use the builtin CSV module <div id="use-the-builtin-csv-module" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#use-the-builtin-csv-module" aria-label="Anchor">#</a> </span> </h2> <p>Python has a built-in <a href="https://docs.python.org/3/library/csv.html#module-csv" target="_blank" rel="noreferrer">CSV module</a> that deals with CSV files. CSV module provides <a href="https://docs.python.org/3/library/csv.html#reader-objects" target="_blank" rel="noreferrer">a CSV reader</a>, which we can use to read CSV files. The CSV reader is an iterable object. We can use the following snippet to read CSV files:</p>

2018/5/13
阅读更多

回忆汶川地震

<p>今天是 5 月 12 日,对于 2008 年以后的中国人来说,这是一个特殊的日子:十年前的今天,四川省汶川县等区域发生了 8 级大地震,造成了重大的生命损失与伤痛。今天也来写一下我个人对地震的记忆与恐惧。</p>

2018/5/12
阅读更多

使用 Microsoft Word 撰写论文常见问题总结

<p>本文总结一些使用 Microsoft Word 2016 撰写论文时遇到的一些问题以及解决办法。</p> <!-- more --> <h1 class="relative group">Word 如何插入分节符? <div id="word-如何插入分节符" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#word-%e5%a6%82%e4%bd%95%e6%8f%92%e5%85%a5%e5%88%86%e8%8a%82%e7%ac%a6" aria-label="Anchor">#</a> </span> </h1> <p>「分节符」是 Word 中一个非常重要概念,很多设置都会涉及到分节符。分节符,顾名思义,就是把文档从某处分节(节的英语为 section)的标志。常用的分节符类型有「下一页」(即从当前位置的下一页开始新的一节),「连续」(即从当前位置开始新的一节)。具体如何插入分节符见下图(以插入「下一页」分节符为例):</p>

2018/5/10
阅读更多

A Tutorial on Creating GitHub Pull Requests

<p>Today I make <a href="https://github.com/theme-next/hexo-theme-next/pull/275" target="_blank" rel="noreferrer">my first ever GitHub pull request</a> to the great <a href="https://github.com/hexojs/hexo" target="_blank" rel="noreferrer">Hexo</a> theme <a href="https://github.com/theme-next/hexo-theme-next" target="_blank" rel="noreferrer">NexT</a>. I will summarize how to make a pull request in following post.</p> <!-- more --> <h1 class="relative group">Creating a fork <div id="creating-a-fork" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#creating-a-fork" aria-label="Anchor">#</a> </span> </h1> <p>According to GitHub documentation:</p> <blockquote><p>If you don&rsquo;t have write access to the repository where you&rsquo;d like to create a pull request, you must create a fork, or copy, of the repository first.</p>

2018/5/6
阅读更多

如何在新版 MX 播放器中加入对 AC-3 音频支持

<p>最近在使用 1.9.19 版本的 <a href="http://mx.j2inter.com/" target="_blank" rel="noreferrer">MX 播放器</a>播放视频的时候,提示不支持 E-AC-3 (全称为 Enhanced Audio Codec 3,是<a href="https://en.wikipedia.org/wiki/Dolby_Digital" target="_blank" rel="noreferrer">AC-3</a> 的升级版)音频格式。稍微查了一下,原因是由于版权问题,新版的 MX 播放器默认不包含 AC-3 解码器,我们需要自己下载安装解码器。下面简单介绍如何加入对 AC-3 音频的支持。</p>

2018/4/24
阅读更多

读《众病之王:癌症传》有感

<p>刚读完<a href="https://book.douban.com/subject/5336588/" target="_blank" rel="noreferrer">《众病之王:癌症传》</a>(英文名字叫《The emperor of all maladies: a biography of cancer》),“意外”发现这本书是一本的融合科普与历史的精品图书。</p>

2018/4/16
阅读更多

How to Use Putty on Windows

<p><a href="https://www.chiark.greenend.org.uk/~sgtatham/putty/" target="_blank" rel="noreferrer">Putty</a> is a powerful and slim ssh tool with rich features. It is widely used to connect to the remote servers. I will summarize some of its settings and usages in this post.</p>

2018/4/11
阅读更多

How to Plot Unicode Characters with Matplotlib

<p>This is a post which follows up my previous post on <a href="https://jdhao.github.io/2017/05/13/guide-on-how-to-use-chinese-with-matplotlib/" target="_blank" rel="noreferrer">how to use Chinese characters with Matplotlib</a>.</p>

2018/4/8
阅读更多

Set Default GPU in PyTorch

<p>You can use two ways to set the GPU you want to use by default.</p>

2018/4/2
阅读更多

How to Use Chinese with LaTeX

<p>The original LaTeX do not have good support for Chinese. With the development of LaTeX, we can now easily use Chinese in LaTeX document. In this post, I would like to introduce several ways to work with Chinese in LaTeX.</p>

2018/3/29
阅读更多

全面总结如何在 LaTeX 中使用中文 (2020 最新版)

<p>LaTeX 最初对中文的支持并不友好,只支持 ASCII 字符,后来才逐渐变得好起来,加入了对 Unicode 字符的支持。本文总结一下几种在 LaTeX 中使用中文的方法,以期能够帮助读者快速使用 LaTeX 对中文内容进行排版。</p>

2018/3/29
阅读更多

A Complete Guide on Writing and Building C++ Programs in Sublime Text

<p>In this post, I will show how to write and run simple C++ programs in <a href="https://www.sublimetext.com/" target="_blank" rel="noreferrer">Sublime Text 3</a>.</p>

2018/3/28
阅读更多

使用 Endnote 为论文每个章节制作单独的参考文献列表

<p>毕业季到了,如果使用 Word 来写毕业论文,论文写作中的参考文献处理也是一个非常重要的问题,在 Word 管理参考的比较好的方式是通过 <a href="http://www.ioa.cas.cn/xwzx/zhxw/201410/P020141013364219434960.pdf" target="_blank" rel="noreferrer">Endnote</a>。Endnote 是一个非常方便的可视化管理参考文献的工具,本文介绍如何使用 Endnote 结合 Microsoft Word 给每个章节分别设置参考文献列表。</p>

2018/3/24
阅读更多

Set up Sublime Text as Your Ultimate LaTeX Editor

<p>There are a lot of <a href="https://en.wikipedia.org/wiki/Comparison_of_TeX_editors" target="_blank" rel="noreferrer">front-end editors</a> for writing LaTeX source, for example, <a href="http://www.xm1math.net/texmaker/" target="_blank" rel="noreferrer">Texmaker</a>, <a href="https://github.com/texstudio-org/texstudio/releases" target="_blank" rel="noreferrer">TeXstudio</a>, <a href="http://www.winedt.com/" target="_blank" rel="noreferrer">WinEdt</a>. I have used TeXstudio for a while, but its user interface is a little dull. So I decided to give <a href="https://www.sublimetext.com/" target="_blank" rel="noreferrer">Sublime Text</a> a shot. In this post, I want to share the configurations necessary to write and compile LaTeX source code and to preview the produced PDF files.</p>

2018/3/10
阅读更多

Set up X11 Forwarding with Git for Windows (git-bash)

<p><a href="https://jdhao.github.io/2017/12/29/cmder-usage/" target="_blank" rel="noreferrer">As I have posted earlier</a>, Cmder is a better option if you use Windows command line frequently. The full installation of Cmder comes with <a href="https://gitforwindows.org/" target="_blank" rel="noreferrer"><em>Git for Windows</em></a>, which is handy to provide a Linux-like environment. In this post, I will write about how to use Git for Windows to connect to a remote CentOS server and set up X11 forwarding to use the GUI applications on that server.</p>

2018/3/1
阅读更多

Customize Favicon for Hexo Blog in Theme NexT

<p><a href="https://en.wikipedia.org/wiki/Favicon" target="_blank" rel="noreferrer">Favicons</a> are used widely in websites. Since you come to this post purposefully, I assume that you have a basic understanding of what favicon is. With <a href="https://github.com/hexojs/hexo" target="_blank" rel="noreferrer">Hexo</a>, we can easily customize the favicon of our blog site. In this post, I will describe how to set up a custom favicon in <a href="https://github.com/theme-next/hexo-theme-next" target="_blank" rel="noreferrer">theme NexT</a>.</p>

2018/2/8
阅读更多

如何从 PowerPoint 幻灯片导出没有多余白边的图像或者 PDF 文件

<p>PowerPoint 是一个方便的绘图工具,可以完成一些简单的绘图工作,并且支持将 slide 导出为图片或者 PDF 格式,方便插入到其他文档中,但是默认导出的图片或者 PDF 文件 通常会有大量冗余的白边。如何设置,才能使得导出的文件中的白边尽可能少呢?本文将 给出一种办法。</p>

2018/2/6
阅读更多

把 Hexo 的评论系统切换为 gitment

<p>好几个月前就知道有人用 GitHub 的 issue 功能为 Hexo 制作了一个评论系统 <a href="https://imsun.net/posts/gitment-introduction/" target="_blank" rel="noreferrer">gitment</a>,决定尝试一下 gitment 。</p>

2018/2/1
阅读更多

Character set, Encoding, Locale, Font and More...

<p>It is almost destined that at some point of our programming years, we will meet the issue of character set, encoding and all the related stuff. There are tons of articles which explains the meaning of <code>Unicode</code>, <code>UTF-8</code>, <code>UTF-16</code> etc. I am not going to repeat that here. In this post, I will write about what confused me when I tried to understand all this stuff.</p>

2018/1/28
阅读更多

LaTeX Equation Numbering Done Right in Hexo

<p>Recently I plan to transplant one of my old post from other site to this new site (you can find the new post <a href="https://jdhao.github.io/2016/01/19/back-propagation-in-mlp-explained/">here</a>). The old post contains quite a lot of equations in LaTeX format. With so much equations in one post, I find it really hard to refer to some equations without using proper numbering. So I decide to figure out how to use LaTeX equation numbering properly in my post.</p>

2018/1/25
阅读更多

How To Put Legend outside of Axes Properly in Matplotlib?

<p>When we want to put legend somewhere in a figure using Matplotlib, most of the time, the option <code>loc='best'</code> will produce the desired results. However, sometimes, we may want to have finer control over where the legend should be in the image. For example, we may want to put the legend outside of the axes, which is impossible using <code>loc='best'</code>.</p>

2018/1/23
阅读更多

Working with Fonts in Matplotlib

<p>This post continues my <a href="https://jdhao.github.io/2017/11/16/matplotlib-plotting-notes/" target="_blank" rel="noreferrer">previous post</a> on various tips and tricks collected during the process of using Matplotlib.</p> <p><img src="https://blog-resource-1257868508.file.myqcloud.com/18-1-18/39303776.jpg" title="Different math symbols produced by Matplotlib and LaTeX" style="float: middle;"></p>

2018/1/18
阅读更多

Cmder --- The Ultimate Command Line Tool for Windows

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/18-1-1/79824514.jpg" title="A glimpse of Cmder"> </p>

2017/12/29
阅读更多

纯文本做笔记 --- 使用 Pandoc 把 Markdown 转为 PDF 文件

<p><img src="https://blog-resource-1257868508.file.myqcloud.com/18-1-7/731510.jpg" title="生成的 PDF 截图" style="float: middle;"></p> <details> <summary><font size="3" color="red">update log</font></summary> <ul> <li><font color="blue">2021-06-27: 补充标题如何生成的说明。</font></li> </ul> </details> <p>For English version of this post, click <a href="https://jdhao.github.io/2019/05/30/markdown2pdf_pandoc/" target="_blank" rel="noreferrer">here</a>.</p> <p>本文主要写如何使用 Pandoc 从 Markdown 文件生成格式精美的 PDF 文件,也包含了一些遇到的问题的解决办法。</p>

2017/12/9
阅读更多

Matplotlib Plotting Notes -- Series 1

<p>This post records my collected notes on various tricks in using Matplotlib.</p>

2017/11/16
阅读更多

Notes on PyTorch Tensor Data Types

<p>In PyTorch, <a href="http://pytorch.org/docs/master/tensors.html#torch-tensor" target="_blank" rel="noreferrer"><code>Tensor</code></a> is the primary object that we deal with (<code>Variable</code> is just a thin wrapper class for <code>Tensor</code>). In this post, I will give a summary of pitfalls that we should avoid when using Tensors. Since <code>FloatTensor</code> and <code>LongTensor</code> are the most popular <code>Tensor</code> types in PyTorch, I will focus on these two data types.</p>

2017/11/15
阅读更多

Understanding Computational Graphs in PyTorch

<p>PyTorch is a relatively new deep learning library which support dynamic computation graphs. It has gained a lot of attention after its official release in January. In this post, I want to share what I have learned about the computation graph in PyTorch. Without basic knowledge of computation graph, we can hardly understand what is actually happening under the hood when we are trying to train our <em>landscape-changing</em> neural networks.</p>

2017/11/12
阅读更多

How to Resize, Pad Image to Square Shape and Keep Its Aspect Ratio in Python

<p>When we are using convolutional neural networks, most of the time, we need to fix the input image size to feed it to the network. The usual practice is to resize the input image to the given size (the image aspect ratio is no longer kept) and then crop a fixed size patch randomly from the resized image. This practice may work well for image classification where fine details may not be necessary. But for Image retrieval, we want to keep the image aspect ration unchanged. In this post, I will summarize ways to resize an image to square shape with padding and keep its aspect ratio.</p>

2017/11/6
阅读更多

Similarity Measurement in Image Retrieval

<p>For image retrieval and other similarity-based tasks such as <a href="https://arxiv.org/abs/1610.02984">person re-identification</a>, we need to compute the similarity (or distance) between the query image and database images. Then we can rank the database images based on their similarity to the query image. In this post, I want to briefly introduce two measures widely used in image retrieval tasks.</p>

2017/10/24
阅读更多

对 Stack Overflow 的爱与恨

<p>一直以来,在搜索编程、技术相关的问题时,Stack Overflow 上的答案经常高居谷歌返回结果前列,这个网站上有一些质量很高的答案,能够真正解决我的疑问。大约一年以前,我正式注册了 Stack Overflow 的会员,也开始试着回答别人的提问。解答别人的问题也让我受益匪浅,但最近发生的一件事却让我对 Stack Overflow 有了更深的认识。</p>

2017/10/24
阅读更多

Writing Your Own Custom Dataset for Classification in PyTorch

<p>In this post, I&rsquo;d like to talk about how to create your own dataset, process it and make data batches ready to be fed into your neural networks, with the help of PyTorch.</p>

2017/10/23
阅读更多

Sublime Text Tips and Tricks That Will Make Your Life Easier

<p>In this post I will share some tips on how to use Sublime Text on Windows. These tips are collected over time and will be updated frequently (hopefully).</p>

2017/10/21
阅读更多

几道算法问题解答

<p>记录一下做的几道算法问题的解答。</p>

2017/10/19
阅读更多

Why Doesn't Visdom Work Fine on CentOS?

<p>Today, I came across the open source project <a href="https://github.com/facebookresearch/visdom" target="_blank" rel="noreferrer">visdom</a> and hope to use it in my future <a href="http://pytorch.org/" target="_blank" rel="noreferrer">PyTorch</a> project. I installed it on my Linux server and met with an issue that I have no way to deal with. I would like to share it in case someone also meet it.</p>

2017/10/16
阅读更多

What Is the Correct Way of Loop Through C++ Vector Using Index?

<p>It might seem naive to ask how to loop through a C++ vector using index. However, it is not: even experienced programmer may write buggy code to loop through a vector.</p>

2017/10/7
阅读更多

Remainder Operator(%) in C++

<p>What is value of <code>a</code> and <code>b</code> in the following statement according to the rules of C++ 11?</p> <div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cpp" data-lang="cpp"><span class="line"><span class="cl"><span class="kt">int</span> <span class="n">a</span> <span class="o">=</span> <span class="o">-</span><span class="mi">5</span> <span class="o">%</span> <span class="mi">2</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kt">int</span> <span class="n">b</span> <span class="o">=</span> <span class="mi">5</span> <span class="o">%</span> <span class="o">-</span><span class="mi">2</span><span class="p">;</span></span></span></code></pre></div></div> <p>If you can not clearly tell the result, then you should update your knowledge about % operator in C++.</p>

2017/10/7
阅读更多

Hexo 书写 LaTeX 公式时的一些问题及解决方法

<p>在写作博文的时候,有时候需要输入一些数学公式,如果公式过长,我们通常希望把方程分成多行显示,在 LaTeX 中,我们可以使用 <code>aligned</code> 环境来书写多行公式,但是写出来的 Markdown 经过 Hexo 的处理以后显示不正确,原因何在?原来这与 Hexo 的渲染引擎有关系。</p>

2017/10/6
阅读更多

堆排序是如何工作的?

<p>本文将介绍堆 (heap)的概念,进一步介绍如何把普通数组变成最大堆,并在此基础上进行堆排序。</p>

2017/10/6
阅读更多

When Does the Stability of Sorting Algorithms Matter?

<p>In this post, I will write about the stability of sorting algorithms and why it is important.</p>

2017/9/30
阅读更多

1x1 Convolutions Demystified

<p>In the early development of convolutional neural networks (CNNs), convolutions with kernel size <span class="math inline">\(3\times 3\)</span>, <span class="math inline">\(5\times 5\)</span>, <span class="math inline">\(7\times 7\)</span> or even <span class="math inline">\(11\times 11\)</span> are often used. In the more recent literature, however, <span class="math inline">\(1\times 1\)</span> convolutions are becoming prevalent. In this post, I will try to explain what <span class="math inline">\(1\times 1\)</span> convolutions are and discuss why they are used in CNNs.</p>

2017/9/29
阅读更多

善用佳软---我常用的 Android 应用

<p>本文介绍一些我常用的 Android Apps,希望你也能喜欢。</p>

2017/9/24
阅读更多

小米 2018 校招算法工程师编程之字符串匹配

<p>这是一道小米 2018 校招算法工程师的编程题目,类似与正则表达式匹配,但是该题不能使用 Python,因此需要自己实现这个简单的匹配,题目如下:</p>

2017/9/21
阅读更多

Some Programming Questions Related to Operations with Big Integers

<p>The C++ standard library doesn&rsquo;t support big integer operations such as addition and multiplication. In this post, I will show how to solve such problems in C++.</p>

2017/9/21
阅读更多

How to Compile and Install Latest Version of GCC on CentOS 7

<p>The default GCC that comes with the CentOS 7.2 is GCC 4.8.5, which does not support the complete C++11 standard, for example, it does not fully support <a href="http://en.cppreference.com/w/cpp/regex" target="_blank" rel="noreferrer">regular expressions</a>. In order to use regular expression functions, <a href="https://stackoverflow.com/a/8061172/6064933" target="_blank" rel="noreferrer">we need to install at least GCC 4.9.0</a>. The following installation procedure is applicable to CentOS 7 and are not tested on other Linux systems. Also you have to make sure that you have root privelege.</p>

2017/9/4
阅读更多

Find Longest Subarray Whose Sum Is Divisible by K

<p>The problem is as follows:</p> <blockquote><p>Given an array $A$ of length $N$, $A[i] \ge 0$ ( $0 \le i \le N-1$) , and a number $K$. Find the longest subarray whose sum is divisible by $K$, if there are no such subarray, return 0;</p> </blockquote>

2017/8/31
阅读更多

从二分搜索实现中的一个 bug 说起

<h1 class="relative group">一道二分搜索问题 <div id="一道二分搜索问题" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e4%b8%80%e9%81%93%e4%ba%8c%e5%88%86%e6%90%9c%e7%b4%a2%e9%97%ae%e9%a2%98" aria-label="Anchor">#</a> </span> </h1> <p>下午做了<a href="https://leetcode.com/problems/first-bad-version/description/" target="_blank" rel="noreferrer">一道 Leetcode 的编程题目</a>,牵扯出了二分搜索实现中需要特别注意的一个问题,题目如下</p>

2017/8/27
阅读更多

CentOS 7 系统安装 Shadowsocks 并且开启多用户模式指南

<p>据说墙升级了,本来用得很流畅的服务也不行了,时不时断掉,让人很恼火。有必要升级一下梯子了,于是我也研究了一下利用 VPS 自建梯子的方法。本文总结一下安装中遇到的问题和解决办法,只针对 CentOS 7 系统,其他 Linux 系统配置方法是类似的。</p>

2017/8/6
阅读更多

How to Plot Only One Colorbar for Multiple Plot Using Matplotlib

<p>In some situations, we have several subplots and we want to use only one colorbar for all the subplots. How to do this in Matplotlib?</p>

2017/6/11
阅读更多

How to Set the Aspect Ratio of Image (or Axes) in Matplotlib?

<p>In Matplotlib, <a href="https://matplotlib.org/api/axes_api.html"><code>Axes</code></a> is the primary place where we put plot elements, such as lines, texts and legends. However, for a long time, I failed to grasp the meaning of aspect ratio in Matplotlib, thus was constantly frustrated by the behavior of Maplotlib every time I attempted to change the aspect ratio of a plot. This post is the result of my attempt to understand it and my findings. Hope it can help you too.</p>

2017/6/2
阅读更多

A Guide on Using Unicode Characters in Matplotlib

<p>A few days ago, I found that Matplotlib can not show some Unicode characters (some Chinese characters) using its default settings. In the rendered output image, Chinese characters are shown as blank boxes. After reading a lot of posts on this issue, I am finally clear about how to use Unicode characters properly in Matplotlib.<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>

2017/5/13
阅读更多

Install feh Image Viewer from Source on CentOS 7

<p>On my CentOS system, I usually use <a href="https://github.com/GNOME/eog" target="_blank" rel="noreferrer">eog</a> to view images in the console. But I am a little upset by its speed of opening an image. I do not need such functionality besides viewing an image. So I decided to find another lightweight replacement.</p>

2017/5/6
阅读更多

申请香港通行证

<p>这个月中旬,ICME Workshop 的投稿结果公布,我投的论文被接收了,忙完 camera-ready 论文的提交和注册,我开始办理香港签证相关的东西。</p>

2017/4/30
阅读更多

如何使用 Android 文件管理器在电脑与手机之间无线传输文件

<p>最近换了一台新的手机 OnePlus 3T,这个手机简洁是简洁,预装的应用非常少,自带的文件管理功能不是很全,所以我研究了一下 Android 上常用的一些文件管理 APP。</p>

2017/3/26
阅读更多

Sublime Text 3 使用相关问题及解决办法

<p>这篇文章集中写一些在使用 Sublime Text 3 时遇到的问题以及解决办法,某些问题在不 同系统的解决办法可能都是一样的,但是未经测试,所以使用的时候请先验证。</p>

2017/3/19
阅读更多

Some Loss Functions and Their Intuitive Explanations

<p>Loss functions are frequently used in supervised machine learning to minimize the differences between the predicted output of the model and the ground truth labels. In other words, it is used to measure how good our model can predict the true class of a sample from the dataset. Here I would like to list some frequently-used loss functions and give my intuitive explanation.</p>

2017/3/13
阅读更多

Why Did XeLaTeX Suddenly Run Insanely Slow?

<p>Today I found that compiling LaTeX source is insanely slow(took me several minutes to compile a simple file). After a lot of trial and error, I found the reason.</p>

2017/3/6
阅读更多

Sublime Text 3 Markdown 写作设置

<h1 class="relative group">引子 <div id="引子" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e5%bc%95%e5%ad%90" aria-label="Anchor">#</a> </span> </h1> <p>由于受不了 VSCode 打开文件的龟速,我决定换一个编辑器,以前就大致了解有三款评价不错的编辑器,分别是 <a href="https://atom.io/" target="_blank" rel="noreferrer">GitHub Atom</a>, <a href="https://www.sublimetext.com/" target="_blank" rel="noreferrer">Sublime Text 3</a> 以及微软的 <a href="https://code.visualstudio.com/" target="_blank" rel="noreferrer">VSCode</a>。</p>

2017/3/4
阅读更多

An Introduction to Listary: A Blazing Fast Search Tool

<p>I came across this amazing tool called <a href="http://www.listary.com/" target="_blank" rel="noreferrer">Listary</a> yesterday and found that it is just an amazing piece of software that will change my experience on Windows fundamentally!</p>

2017/3/1
阅读更多

Hexo 使用,博客写作相关问题及解决方法

<p>本文主要总结 Hexo 博客使用,博客写作以及更新 Hexo 和 NexT 主题的内容。关于如何安装配置 Hexo 和 NexT 主题,可以参考<a href="https://jdhao.github.io/2017/02/26/hexo-install-use-issue/" target="_blank" rel="noreferrer">这篇文章</a>。</p>

2017/2/26
阅读更多

How to Install Hexo and Theme NexT from Scratch on Windows

<p>In this post, I will describe the complete step to install both <a href="https://hexo.io/" target="_blank" rel="noreferrer">Hexo</a> and theme <a href="https://github.com/theme-next/hexo-theme-next" target="_blank" rel="noreferrer">NexT</a> on Windows.</p> <!-- more --> <h1 class="relative group">Install Hexo and deploy your post <div id="install-hexo-and-deploy-your-post" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#install-hexo-and-deploy-your-post" aria-label="Anchor">#</a> </span> </h1> <p>First, we need to install the Hexo framework. The main steps are as follows:</p> <h2 class="relative group">Install Node.js and Cmder <div id="install-nodejs-and-cmder" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#install-nodejs-and-cmder" aria-label="Anchor">#</a> </span> </h2> <p>We need to install <a href="https://nodejs.org/en/download/" target="_blank" rel="noreferrer">Node.js</a> and <a href="https://git-scm.com/download/win" target="_blank" rel="noreferrer">git for Windows</a>. You can skip installing git for Windows if you choose to install <a href="http://cmder.net/" target="_blank" rel="noreferrer">Cmder</a>(highly recommended on Windows). Choose the Full package if you decide to install Cmder (only the full package contains git for Windows).</p>

2017/2/26
阅读更多

在武汉过春节

<p>1 月 26 日大清早起床赶到北京西站,坐上了早上八点半左右的火车,前往武汉,晚上大约七点半到达武昌火车站。在武汉呆了整整一周,2 月 3 号中午坐车回的北京。谈谈我对武汉的印象。</p>

2017/2/25
阅读更多

A New Start

<p>去年的时候还是前年,在谷歌上搜索东西,看到了很多人的博客都是用 GitHub 托管的,使用 GitHub 提供的 <a href="https://pages.github.com/" target="_blank" rel="noreferrer">GitHub Pages</a> 功能。我一看就喜欢上这种开源并且简洁的方式,却没有立即行动。</p>

2017/2/24
阅读更多

关于「尊严」

<p>前一段时间和一个同学谈到了尊严,就用 A 来表示吧。A 认为人在弱小的时候,谈不上尊严,你只有放弃自己的尊严,才能活下来,强者才有尊严,或者说强者的尊严比弱者多。A 的话,让我想到了&quot;弱肉强食&quot;这个词:如果你弱小,那么不要谈尊严,你只是别人盘里的菜而已,尊严对你来说太奢侈了。</p>

2017/1/5
阅读更多

关于神经网络优化的一些思考

<p>优化的方法有很多种,在深度学习中,占有绝对主导地位的还是 stochastic gradient optimization (简称 SGD) 以及它的一些变种,如 SGD with momentum,Adam 等。 SGD 是一种基于一阶梯度信息的优化方法,仅从优化的速度上来讲,效率不是最高的,一些利 用二阶信息的优化方法,理论上优化速度更快,但是,SGD 反而是在深度学习的优化中使 用的最多的优化方法,为什么其他类型的优化方法在深度学习中不经常使用呢?它们相比 SGD 有什么缺点?或者说 SGD 有什么优点呢? 这篇文章试图对这个问题给出自己的思考 与总结。</p>

2016/11/25
阅读更多

关于孩子

<p>坐火车回北京,我坐在过道边,过道另一边是一个老人家带着她的孙子,小孩子约一岁,能说模糊不清的字。小孩子一路上都在吵吵闹闹,一刻不停歇,写作此文时候的举动是把前面座位上贴的布给扯掉,扔在地上,他的奶奶似乎无动于衷,也不批评,也不行动,过了一会儿,打扫卫生的人员过来了,把布捡起来,又贴在了原位置。小孩子仍然不满足,继续进行他的游戏,又把布扯掉扔在地上,奶奶似乎也有点不满意了,把布捡起来粘在了原处,然后小孩和他的奶奶重复这个回合若干次,奶奶并未对孩子讲这样做有什么不对,只是寄希望于小孩别再拽掉那块可怜的布了。</p>

2016/9/5
阅读更多

「汉奸走狗」与「关我*事」

<p>公元 2016 年,真是一个多事之年啊,各种事件接踵而至,纷至沓来,仿佛排演好的一般,不断在现实与虚拟空间制造着冲突、对抗,也制造着话题。</p>

2016/7/16
阅读更多

I Am Awaken

<p>你可能不信,人的想法转变可能是一瞬间的。</p>

2016/5/30
阅读更多

我们的焦躁与不安

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20190528010725.png" width="800"> </p> <p>从乡下搬到市里不到一年,时间不是很长,注意到了两个事情,让我总是想写点什么来说一说。</p>

2016/4/18
阅读更多

从「禁摩限电」说起

<p align="center"> <img src="https://blog-resource-1257868508.file.myqcloud.com/20190528010420.png" width="800"> </p>

2016/4/11
阅读更多

你饿不饿?来吃点东西好吗

<p>想起了一个很好笑的笑话,有人在网上提问:“老婆怀孕了,但是隔壁邻居家里有wifi,我该怎么办,在线等,急!”有人回答:“送邻居一个仙人掌,能防wifi。”生活中,你也经常听到有人对你说,新买的手机必须完全放电,然后才能充满电,必须重复这样几次;还有人对你说,手机电池必须用到快没有电再去充电才行,否则会损伤电池。</p>

2016/3/26
阅读更多

Commonly-used Methods in Python OS Package

<p>In this post I summarize the commonly-used methods in Python os package.</p>

2016/3/17
阅读更多

神经网络中误差反向传播(back propagation)算法的工作原理

<p>神经网络,从大学时期就听说过,后面上课的时候老师也讲过,但是感觉从来没有真正掌握,总是似是而非,比较模糊,好像懂,其实并不懂。</p> <p>为了搞懂神经网络的运行原理,有必要搞清楚神经网络最核心的算法,也就是<a href="https://en.wikipedia.org/wiki/Backpropagation">误差反向传播算法</a>的工作原理,本文以最简单的全连接神经网络为例,介绍误差反向传播算法的原理。</p>

2016/1/18
阅读更多

Windows 系统下 Python 以及 Pip 的安装和使用

<p>本文主要介绍在 Windows 系统下,如何安装 Python 和 Pip, 以及 Pip 的简单使用。</p>

2015/10/21
阅读更多

LaTeX 中参考文献管理以及注意事项

<p>LaTeX 写作中,参考文献一般单独放在一个 <code>*.bib</code> 文件中,每个文章对应该文件的一个 条目,每个文章有一个独一无二的 Key,在文章中使用 key 来引用对应的文章。 <code>bibtex</code> 可以根据 <code>*.bib</code> 文件产生 LaTeX 可以识别的引用条目,然后我们才可以在 LaTeX 中引用相关的文献。 本文主要写一些和文献管理以及引用相关的注意事项。</p>

2015/10/16
阅读更多

How to Insert LaTeX Equations in Microsoft Office Word and PowerPoint

<p>In this post, I would like to share how to insert beautiful latex equations into Microsoft Office Word and PowerPoint.</p>

2015/10/13
阅读更多

Windows 下 LaTeX 手动安装宏包(package)以及生成帮助文档整套流程

<p>本文简单介绍如何手动安装一个 LaTeX 宏包。</p> <!-- more --> <p>一般来说,下载的 TeX 发行版已经自带了很多宏包,可以满足绝大部分需求,但是偶尔我们也可能碰到需要使用的宏包碰巧没有安装的情况,这时我们就需要自己下载安装宏包了。</p>

2015/9/23
阅读更多

有所恃的与无所恃的

<p>有一句俗话说“两鸟在林不如一鸟在手”,讲的是抓在手里的东西才会让人踏实,如果手里什么也没有,所谓“无所恃”,大多数人就会变的着急,会恐慌;还有一句相对的话叫“恃宠而骄”,范围过于狭窄,应该叫“恃物而骄”,马克思主义哲学的物质观告诉我们,世界是物质的,物质具有客观实在性,因此这物就是广义的了,财富,权力,荣誉&hellip;&hellip;这句话说的是人一旦有所恃,除却个别精神十分平淡的人,其余的人都会有“飘飘乎”而不知自省的状态。</p>

2013/10/22
阅读更多

2013 上半年

<p>大三下学期似乎没有什么大事,平淡中度过。</p>

2013/9/17
阅读更多

当你在玩《三国杀》,你在玩些什么?

<p>我了解《三国杀》这个游戏,还是刚升入大学那会儿,那时我们和隔壁宿舍已有几位熟悉玩法的爱好者。大一初始,隔壁宿舍就是他们厮杀的战场,经常是几个人一玩到深夜。我那时对这个游戏虽有兴趣但又觉得规则、技能太多,难于记忆,便没玩,所以当他们玩的正酣时,我却在宿舍睡觉呢。</p>

2013/7/16
阅读更多

Which Teacher Do You Respect Most?

<p>有一次看到问题,“which teacher do you respect most?”。走在上课的路上,脑子里回味着这个问题,答案却未能蹦出来。</p>

2013/6/19
阅读更多

倏忽一年:2012 下

<p>新学期从暑假开始,热气满盈的培训教室,三国杀乐趣多,《国家干部》、《万历十五年》以及《亲爱的安德烈》,通宵达旦的数模比赛之夜,开学前两周的酱油生活,《那些回不去的年少时光》与《你好旧时光》,又闻桂花香,国庆登岳麓,编程趣味多,二食堂三楼很火呐,酱油的传感和检测实验以及课程,“蹭”了一个学期课的《电机拖动》,勤勉的略带苦口婆心的安老师,缺乏激情、乏味的“现控”课,起于十月中旬的托福单词,讲《误差理论》的认真负责的彭老师,“cut the rope ”一个有趣的游戏,充满智慧的《线性代数》公开课,“倾倾百老汇”成周末习惯,过生日与生日礼物,那些无名烦躁,自习圣地A座414,粉冶自习人,一直坚持的跑步,后湖小区的包子不错,《因为痛所以叫青春》,再读《成长》,练习汇编程序编写,“耿耿于怀”的传感考试,自省,为班级宣传拍视频,某某某乃真屌丝,a crisis in the end of 11,我逃课我喜欢,《肖申克的救赎》为何让我流泪,对外文教材的无来由崇拜,为课设不断看书,《半生缘》与《倾城之恋》,轻松过关的体育测试,干涸了一整个学期的人工河,打酱油于优秀班级答辩,后湖那还不错的杂酱面,我终究没能完成,惭愧的课设,《最美的时光》,坑爹的检测考试,写报告的不眠之夜,雪中漫步,考试前爆满的三教,据说图书馆很火爆,教室的空调能规律点否,元旦吃火锅,考完现控的后悔与令人揪心的微机,本学期网购的书可不算少,重游铁道,激战三国杀,只是“吃饭”的聚餐,托福单词完结,are you a changed man ?</p>

2013/2/17
阅读更多

自嘲与自省

<p>有时候觉得自己对人生的许多道理都懂了,给别人讲的时候都是很有气势,自己遇到了呢?人生中的有些事是不是真的别去想就好了?恐怕不是吧,不去想一些事有时是自信不足的表现,想要像鸵鸟一样把自己蒙蔽起来,不去想,不去看,问题就没了?当然不会的。有时候很害怕去解剖自己,这带来的一个后果就是在意旁人的看法,好像还没有那么强大,可以完全只注意自己的内心,就譬如别人说你很强大或者不行,你就真的是那样了?你会在意别人的看法么?甚至你会不会自嘲一下自己,把自己贬的体无完肤,但是内心确是无比的清醒,知道自己的位置,毫不迷糊茫然?</p>

2012/9/5
阅读更多

2012 上半年

<p>华硕ASUS,严肃的模电老师,模电好困难,不抛弃不放弃,其实张教主挺好(至少无可指摘)的,平和的数电老师,一个陌生女生的信息,胃酸真的挺痛苦,这医生太坑人了!木有听懂自控老师的课啊::&gt;_&lt;:: 自救者天救,初次物理实验的谨慎、认真看来是可笑的,新闻英语与晦涩的英美名篇选读,爱默生的《self-reliance》,社会时事和人生感悟,这个朱老师不一样!鸡肋物理实验and 自控实验,写报告真是一件奇葩的事,拿什么拯救你我们变质的实验?一口湖南话的毛邓老师,干净利索的复变老师,六级单词的完结,选修课老师有点“重口味”^<em>^,自习圣地不再(A座415),忙碌的物联网杰哥,南校操场的跑步,清明岳阳楼之行,学习的观念(《成长》),百里毅行,做收音机,少吃辣椒了,二食堂二楼也不那么难吃的,三楼开始不错唉,后来……偶尔的焦虑与烦躁,人要理智一些!五一“美妙的”月亮岛之行@</em>@,夜爬岳麓山,电工实践有点意思,我跟锋哥的组合天下无敌!读书:《追随智慧》,《联想风云》,《成长》,《中国的新革命》。更能承受了,成长了吗?</p>

2012/7/24
阅读更多

2011 下半年

<p>分班,新班级,二辉诗贤转专业,新班级聚会吃饭,申请奖学金,申请表,被扣德育分(不通人情的辅导员老师),国庆岳麓山,博物馆,电路自习,六级单词(新东方),看《西征记》,金工实习,一波三折的锤子,EC被刷,晚上睡觉很迟,梁中武看电视剧,电子电工实验,网络逃课,概率论乱七八糟,电路陈宁挺好,英语没怎么认真学,逃听力课,奋力去做数据库,漫长的自习(圣地A座415~_~),杰哥的认真学习,一位不曾说过话的自习人,为什么都去图书馆,概率论考试给我打击,bbc 英语,一种内在的焦躁,无聊的马克思,令人发狂的电路,二食堂一楼四楼吃饭,偶尔二楼,跑步没有坚持住,书包丢了,悲催的物理学习(蒋亦民,彭政),新的个性同学,岳麓山越野,宿舍的冷战与对峙,我对某些事的冷静态度,搞笑的人。</p>

2012/1/11
阅读更多

最近的一些感想

<h2 class="relative group">心态 <div id="心态" class="anchor"></div> <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"> <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e5%bf%83%e6%80%81" aria-label="Anchor">#</a> </span> </h2> <p>总是在追逐,在忙碌,却没有停下脚步,问问自己:&ldquo;你在做什么?”心里不安静,受外物干扰太深,各种念头太多,易激动,易手忙脚乱。为何不能平静地地做事呢?任何时候都尽量不去生气,不去发怒,想办法去解决。一颗平静的心能帮你拨开那层层的雾霭,看见光明。</p>

2011/12/8
阅读更多

尝试积极 -- 国庆节感想

<p>这几天,就是国庆节了,没有去旅游,每天都在宿舍,早上睡到很晚才起来,中午有时磨磨蹭蹭,一阵消磨,真是 kill time。</p>

2011/10/6
阅读更多

No Sane Person Will Ever Do That -- 关于大学傻逼的查寝

<p>来到大学,一年多了,的确看到了许多同学因失去了高中时的严加束缚而整日放浪形骸,好多同学由于玩游戏、不上课导致挂科、重修。可能正是因为辅导员老师经历了许多类似的事,因此才制定了「查寝」的政策,完全可以理解辅导员老师的一片苦心,希望信息院的孩子都能努力学习嘛。刚开始我对此是不屑一顾的,因为我自己肯定是不会躲在宿舍打游戏的,何况我没有电脑。没有自行车,要去新校区,得走二十分钟,好浪费时间;去三教吧,人又那么多,人挤人的学习氛围给人不舒服的心情,所以我就选择了在宿舍自习。在宿舍,一个人,打开一盏台灯,倒一杯开水,氤氲的水汽,给人温馨的感觉。有多少个夜晚,在这样宁静的空间里,静静地思考,累了就听一首歌,或者到阳台上眺望一下校区的夜景,多么理想的自习之地。上个学期,我一直在宿舍自习,期间当然遇到了好多查寝的同学,我也记不清被查到了多少次,那时的我一直是问心无愧的,我只是在宿舍学习而已,有错吗?</p>

2011/9/30
阅读更多

欣赏奇妙的世界2

<p>人的心理真是太微妙了,这是我这些天一直在考虑的问题。在两个人的交往中就可以窥见这种微妙,起初两个人并不熟识,然后突然有一天你很有兴趣跟某个人说话,这种愿望好象是闯入脑子里的,没有任何征兆。回忆一下和你认识的人的交往,其发端似乎都很微小,以致于我难以想起为什么两个人彼此认识了。</p>

2011/1/20
阅读更多

科学家是怎么样炼成的?

<p>我在少年时做过许多梦,其中一个最远大的梦(相信也是许多同学的梦)就是成为一名科学家。小时候对如何做科学家毫无概念,只知道科学家很伟大,可以想做什么就做什么,而且还能享受到极高的荣誉。</p>

2011/1/8
阅读更多

两个世界的碰撞

<p>~~前一阵子,早上起得自以为还挺早,于是每天都能听到在公交车终点站对面有一群人在念英语,一般模式是一个人带头,其他人跟着念,念得很大声,很有激情。</p>

2010/12/9
阅读更多

欣赏奇妙的世界

<p>几天,我在操场上跑步时,不知不觉想到了世界的和谐与奇妙。这个世界如很多人所说,由于技术——无线通讯,互联网——的联通而变小了,但这个世界其实还是很宏大的。想想我们所生活的地球,这个地球上有多少人啊,每个人都在创造属于自己的生活。每一天每个人就那样生活,生活在自己的圈中,而自己或许并未认识到。</p>

2010/12/4
阅读更多

关于郑星

<p>我听说郑星,也是在高二的时候了,记得那时有一次跟师胜锋在一起走路聊天,忽然听师胜锋叫了一句:“郑星!”我停住脚一看,见到一个瘦瘦的,个子中等,留着一头短发,脸上略微有一些雀斑的学生正拿着一沓书往大讲堂走,我一想就明白肯定是去听竞赛课&mdash;那大概是我第一次听说有“郑星”这么一个人。</p>

2010/10/16
阅读更多

听舒曼《梦幻曲》

<p>——我是在去年暑假时听到舒曼的《梦幻曲》的,听过之后就再也忘不掉了。我不想说它的只想说它带给我的感觉,因为我可以说是一个乐盲—丝毫不懂音乐知识。</p>

2010/10/9
阅读更多

关于哭

<p>好些天以前,在宿舍里,大家不知不觉就谈到了哭,好像是讨论哪部电视剧使他们感动得哭了。那次讨论使久藏心中的一个话题再一次被激活,可是我终究没能写点什么。现在我觉得有写的必要了,一是因为实在有些抑制不住了;二是因为明天要考语文,就当是练习写作吧<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>。</p>

2010/10/7
阅读更多

上大学了

<p>长沙的天气确实不留情,算上今天,已经是我第五次在半夜被热醒了……索性下床喝了点水,洗了个脸,然后睡意全没了,那就随便写点什么吧。</p>

2010/9/19
阅读更多

卖饭姑娘

<p>忽然想起了在新校餐厅吃饭时认识的一位卖饭姑娘,其实并不真认识,只是见了认识而已,甚至没说过什么话。不知怎么地,有时就会想起她。</p>

2010/7/21
阅读更多

Privacy Policy

1990/1/1
阅读更多