About
This is Zhenguo Zhang’s blog site created using the blogdown package. The theme was forked from @AmazingRise/hugo-theme-diary Thank the authors of these great tools.
About myself Name Zhenguo Zhang
Email zhangz.sci@gmail.com
Interest Statistics Programming Disease diagnosis and treatment Molecular evolution God
[Tips] Adding google calendar using endpoint in Thunderbird
I have used Thunderbird as my daily email and calendar tools for decades for its expandable features via addons. But sometimes, it suffers bugs, just like recently, it stops synchronization with google calender after I updated to version 102.8.0. This bug triggers me to explore potential solutions, and it leads to today’s topic – adding google calendar via endpoint.
Three methods to add google calendar When one wants to add google calendar to Thunderbird, the popup window shows three methods:
[Git] Git hooks - Part 1
Introduction Git hooks allows one to customize git operations automatically, such as checking the code before commit, notify others when committed, or test the code before pushing.
Basically, hooks can be any executable files put under the folder .git/hooks, and named according to the trigger event, such as .git/hooks/pre-commit (triggered when a commit is being generated). The executables can be written in bash, perl, python, R, or anything that can be executed.
[Github] Gist is essentially git repo
Gists are usually single pages, for users to show information such as manual, tutotials, etc.
Actually, they are git repos, too, so one can clone and push to it. To do so, one need to go to a gist page, for example: https://gist.github.com/fortune9/85cb4f128ee5537c4a8cfdf6f2497e84. And then choose “Clone via HTTPS” from the dropdown menu at the top right of the page (as shown in the below figure), and copy the URL after the selection.
[R] Need import S3 functions for a package to use
When developing an R package, it has been suggested to just put the dependent packages in Description file under Imports section.
However, I recently found that for S3 methods exported by a package, one need to import such functions explicitly in order to use them in the developed package. One example is the unique() function from the package data.table. This function can’t be called via data.table::unique(), because it is a S3 method.
[Thunderbird] Error: User is authenticated but not connected
Issue In last few days, my thunderbird striked: it frequently popped two error messages: “The service outlook.office365.com is disconnected” and “User is authenticated but not connected”.
Research After searching the website for a few days, I came to an solution, which was found here.
Solution Go to Settings -> Config Editor, and then search network.dns.disableIPv6 and click the toggle switch on the right to make it ‘true’. Finally close and reopen Thurderbird, and the problem should be resolved.
[AWS] How to use an IAM role via AWS CLI
There are situations that one may have multiple AWS accounts (or IAM roles) and need switch among them sometimes. This is doable via the AWS website by clicking the username button at the top-right and then click switch role.
How to do this in the command line?
To switch IAM roles via AWS CLI, one can do the following:
Edit the file ~/.aws/credentials The file ~/.aws/credentials stores the AWS credentials. It may include multiple profiles, in the following format:
How to disable Youtube shorts when uploading videos?
Recently, I need share a few videos via Youtube channel. However, the receiver said that the video continuously replayed itself.
The problem After some research, I noticed that the uploaded videos are short in length (less than 1 min), so these videos are marked as Youtube shorts video, and they automatically replay all the time.
Here is an example of short video with the URL https://www.youtube.com/shorts/nq-epMpa0E8
The fix As you can see in the URL, it has the format https://www.
[R] Include external script or child documents in Rmarkdown
When one Rmarkdown document is too big, one can consider split the file into smaller ones. In this post, I will introduce the ways for this purpose.
Include external R scripts There are two ways to include external scripts: using the functions source() or sys.source() or chunk option file.
Method 1: use source() or sys.source() 1 2 3 4 ```{r, include=F} source("external.R", local=knitr::knit_global()) # or sys.source("external.R", envir=knitr::knit_global()) ``` Note that one needs to provide local environment explicitly with knitr::knit_global(); otherwise it may report errors of objects not found.
[R] Automatic email sending with *blastula*
blastula is an R package that can be used to send emails automatically. In addition, it can render Rmarkdown documents into emails, which can be sent later. The main challenge is to setup smtp server. In this post, I will show how to setup smtp server and send emails afterwards.
One can find more on blastula at github.
Install blastula 1 install.packages("blastula") Setup smtp server Basically, one needs change settings in his email accounts to allow app-triggered actions, and this sometimes involves decreasing security levels, so may not be ideal.