[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  
[Linux] How to tell a bash script is sourced or executed?
In bash, a script can be both executed and sourced. An example script as follows: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #!/bin/bash if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then echo "I am being executed" sourced=0 else echo "I am being sourced" sourced=1 fi # this variable setting has no effect if executed, because # the execution is in a sub-shell export VAR_SOURCE="Only effective if sourced" if [[ $sourced -gt 0 ]]; then echo "Done in source" return 0 else # call exit when sourcing a file will exit the terminal echo "Done in execute" exit 0 fi Distinguish between the two To tell whether a script is being sourced or not, one can use the test [[ "${BASH_SOURCE[0]}" == "$0" ]], where ‘${BASH_SOURCE[0]}’ is the current script filename, and ‘$0’ is the same if being executed but empty string "" if sourced, as shown in the above code.
2021-06-03   schedule 1 min 0 s  
[R] Install multiple versions of R
how to install multiple versions of R in a system
2021-06-02   schedule 3 min 40 s  
[github] store github credentials securely
As a developer, I tried to do things efficiently. One thing that I want to fix is avoid input the password (or personal access token) when push to github. Actually, this is not an easy problem because I did not find a comprehensive webpage to provide step by step guide on how to achieve this goal. After researching this issue for one day, finally I could push to github without inputting any password, and I want to share how I achieved this to help anyone who may struggle for this.
2021-05-07   schedule 3 min 57 s  
Installation of Atom on Windows 10
Atom is a very cool editor built with HTML, JavaScript, CSS, and Node.js. Due to this, one can customize Atom with the web tools. Atom runs on Electron, a framework for building cross platform apps using web technologies. Today, I just installed Atom, and here I would like to share some tips on the process. Installation There are two ways to install Atom version 1.55.0. Using exe file: Download the exe file, and then double click it to install as usual.
2021-04-07   schedule 1 min 22 s  
[R] Rmarkdown themes
Rmarkdown is a powerful tool to write documents once and can generate different kinds of output formats such as PDF, html, docx, etc. Along with it, there are many resources for using the rmarkdown. One of them is tons of themes for shaping the output style. For the html_document output, in addition to the default theme, there are other builtin ones, including: “cerulean”, “cosmo”, “flatly”, “journal”, “lumen”, “paper”, “readable”, “sandstone”, “simplex”, “spacelab”, “united”, and “yeti”.
2021-02-03   schedule 1 min 4 s  
[R] Arrange images in a table
library(knitr) library(kableExtra) Sometimes, we need arrange images into a grid. I know two approaches for this. One is to manually fill table cells with strings like ![](path/to/img), and the other is to use function column_spec(column, image=vector_of_files) from kableExtra. In this post, I am going to show both approaches. First, let’s generate some figures. Generating figures We will use the builtin dataset mtcars. figFiles<-file.path( c("scatter.png","hist.png", "boxplot.png","density.png", "barplot.png","line.png") ) i=1; width=5; height=5; unit="in"; dpi=300; png(figFiles[i], width=width, height = height, units = unit, res = dpi) with(mtcars, plot(mpg ~ cyl, main="scatter plot")) tmp<-dev.
2021-02-01   schedule 1 min 21 s  
[git] add flake8 and black hooks to git repository
PEP8 provides guideline on writing python code. To make the compliance to the guideline easy, one can automate this process. There are two ways to achieve this: pre-commit check and github actions. Today, we will talk about how to implement pre-commit check. pre-commit check installs hooks to a git repo, and when committing new code, the hooks will be triggered. Let’s start. Step 1. Install pre-commit package 1 pip install pre-commit After this, add ‘pre-commit’ to the ‘requirements.
2021-01-23   schedule 2 min 6 s