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.
2022-05-26   schedule 33 s  
[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.
2022-03-22   schedule 1 min 21 s  
[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.
2021-09-06   schedule 2 min 53 s  
[R] Use trelliscopejs to arrange plots
Trelliscope is an R package which interfacing a Javascript library trelliscopejs. This library provides an visulization of data by splitting them into subsets, also called ‘Trellis Display’ or “small multiples”. The R package provides some high-level functions such as facet_trelliscope() which can directly replace the function ggplot2::facet_wrap() when making plots. The advantage of the former is that it can create multiple pages of plots when there are many, but facet_wrap() will put them into one plot.
2021-08-12   schedule 2 min 3 s  
[blogdown] Enable Disqus comment in Hugo website
To enable disqus in a blog website, one need do setting in the configuration file ‘config.toml’. Depending on the theme used by the website, one need set up the parameter ‘disqusShortname’, in the top level of the config file, or under ‘[params]’ section. The best place to check this is to read the theme’s github page for configuration. For the theme ‘diary’, it need be under ‘[params]’, as below: 1 2 [params] disqusShortname = "fortune9-netlify" To get ‘disqusShortname’, one need visit https://disqus.
2021-06-10   schedule 24 s  
[Linux] How to preserve environment variables in `sudo`
When one runs sudo, he actually starts a new environment as the root user, so any environment variables in current shell environment will not be transferred to the new root user environment. To transfer current environment variables to the new environment, one can run the following command: 1 2 3 curVar="variable in current environment" sudo -E echo $curVar # output: "variable in current environment" Here the option -E lets the sudo to preserve user’s environment, so the variable curVar is visible in sudo.
2021-06-09   schedule 1 min 11 s  
[R] fix and update blogdown hugo theme
Today, I fixed one big issue in my blog – the missing ‘google fonts’, from which I learned a lot, and I will share here and hope the experience to help others. The issue As you will see from the two pictures below, the left one shows the google fonts as their words (see the items in the red loop), such as ‘chevron_right’ and ‘brightness_7’. And the picture on the right is correct.
2021-06-07   schedule 3 min 8 s  
[Blog] theme lost in Netlify deployment
Yesterday, I wrote a blog in Rmarkdown and pushed it to github for automatic deployment in Netlify.com. Although the website was displayed correctly, it was not in the deployed website – the text were shown in disorder and the theme seemed not used. I guess that the following issues may cause the problem: in that Rmarkdown post, I used javascript code to change the page layout (adding a footer).
2021-06-06   schedule 45 s  
[R] Add a footer to the outside of rmarkdown html main-container
Normally, in the html output of an Rmarkdown document, the <body>...</body> tag encloses a <div>...</div> with class ‘main-container’ which hold the main content. When one add a footer with the following YAML header, it will appear at the bottom of the page as expected: 1 2 3 4 output: html_document: includes: after_body: resource/footer/banner.html However, this may lead to problems when the main-container is in a frame or a mini-page: the added footer will fill to the width of the frame, but not to the width of the page.
2021-06-06   schedule 1 min 17 s  
A new test post
Netlify deployment lost my theme, so I want to see whether this post can trigger a new deployment to recover it.
2021-06-06   schedule 5 s