Notes

Table of Contents

#6FontAwesome in Docusaurus

Posted:

Easiest way I found to get FontAwesome to work with Docusaurus is to use an MDX file (.mdx extension).


import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faPen, faCode, faPlus } from '@fortawesome/free-solid-svg-icons'

<FontAwesomeIcon icon={faPen} size="med"/>

<FontAwesomeIcon icon={faCode} size="sm"/>

<button className={"button button--sm button--success"}
style={{padding:"2px", height: "50%", width: "50%"}}>

<FontAwesomeIcon icon={faPlus} size="lg"/>
</button>

<button className={"button button--sm button--success"}
style={{padding:"2px", height: "40px", width: "40px"}}>

<FontAwesomeIcon icon={faPlus} size="sm"/>
</button>

#5Backticks on mathematical operators in R

Posted:

The backtick in R is usually used for referring to objects with non-standard characters (reserved or illegal). But I recently discovered they can be used to wrap mathematical operators to be used as functions.

So 2 + 2 is the same as `+`(2,2).
And 3 >= 2 is the same as `>=`(3,2), both of which will return TRUE.

Nice to use this while piping in R. Say I want to make sure a dataframe has rows, I can pipe it to the inequality like this:

has_rows <- df %>%
nrow() %>%
`>`(0)

If df has at least one row, the above expression would be stored as TRUE

#4Fun with sed

Posted:

The sed command is always fun. Just did this to fix the image paths in my blog/ source files:

sed -i 's/: \/img\//: \/img\/blog\//g' ./*

#3Changing JPEG and Quicktime Modified Time based on Metadata

Posted:

After copying stupid iPhone photos through the stupid iCloud Windows app and copying it to a Linux system, you’ll likely lose all your modified times.

Here’s a handy way to rewrite the mtimes based on file metadata:

Using exiftool:

exiftool '-FileModifyDate<CreateDate' *.MOV

Using exiv2:

exiv2 -T rename *.JPG

How about fixing the date created metadata?

# Check file dates
exiftool -datetimeoriginal *

# Change all dates by subtracting 3 years and 8 months
exiftool -datetimeoriginal-='3:8:0 0' -P -overwrite_original *

# Change all dates by adding 2 years
exiftool -datetimeoriginal+='2:0:0 0' -P -overwrite_original

#2Adding a Hugo theme as a Git Submodule

Posted:

Some scratch notes on setting up a Hugo theme as a Git Submodule…

Go to your Hugo site’s themes directory and git clone the theme.

Then go to the root of your Hugo site and add the submodule:

git submodule add https://github.com/xxx/xxx.git themes/<name_of_theme>

Update the submodule with latest pushes with:

git submodule update --remote

If you want to change the branch of the git submodule, you can do that with:

git config -f .gitmodules submodule.themes/<name_of_theme>.branch <name_of_branch>

If you want to remove the submodule, just simply remove it. Optionally, delete the folder in the .git hidden directory. (Believe it not, this is the official recommendation).

git rm themes/<name_of_theme>
rm -rf .git/modules/themes/<name_of_theme>

#1How to Disable Password Authentication for SSH

Posted:

If you are already set up to login to your Linux server using SSH key authentication, you can increase the security of your server by disabling password authentication. To disable password authentication for SSH, do the following:

sudo nano /etc/ssh/sshd_config

Set the following settings, or change them to “no” if they already exist:

ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no

Save the file and restart the ssh server:

sudo systemctl restart sshd.service

Or on older non-systemd distros:

/etc/init.d/sshd restart