How to verify a Mastodon account with a WordPress.com website

If your website is hosted on WordPress.com, it can be a bit tricky to verify your Mastodon account. Here are the steps that worked for me:

Configure your rel=”me” for Mastodon on WordPress.com

  1. Log in to WordPress.com.
  2. Follow these instructions for adding a Social Icons Block to the home page of your WordPress.com site.
  3. Add “Mastodon” as one of your Social Icons (see instructions in step 1).
  4. While editing the Social Icons Block, click on the “Mastodon” social icon. An input field will appear below the icon that says “Enter address”. Paste your Mastodon URL into that input field and press the return key. (My Mastodon URL is https://mastodon.social/@vabarger so that’s what I pasted into the field).
  5. Now look on the right side of the WordPress edit page. If your “Mastodon” social icon is still selected, you should see “Mastodon” under the “Block” tab (see partial screenshot below). Expand the “Advanced” section and enter “me” in the “LINK REL” field.
  6. Click the “Update” button to save your edits on WordPress.com.

Add your WordPress.com website to your Mastodon profile

  1. Now log in to your Mastodon instance.
  2. Click on “Edit profile” (to the right of your avatar).
  3. Scroll down to “Profile metadata”. Enter “Website” as one of your labels and paste your WordPress.com URL for the corresponding “Content”.
  4. Click “Save Changes”.

That’s it! Now when people view your Mastodon profile, they should see your website address in green with a green checkmark next to it.

Helpful resource: How to get verified on Mastodon?

Printing the elements of a vector one per line in R

You know how R prints the elements of a vector horizontally?

> 1:5
[1] 1 2 3 4 5

Today I needed the elements printed one per line. After a bit of searching and hair-pulling, I stumbled upon the cat command:

> cat(1:5,sep="\n")
1
2
3
4
5

This is particularly useful when you need a line-by-line list of the variables in a data frame, which you can get with:

cat(names(dataframe),sep="\n")

To output the list directly to a file, use write instead of cat.

Pasting SPSS charts into iWork Pages

If you select a chart in SPSS, copy it, and then paste it into a Pages document, you’ll likely see a series of blank lines in place of the chart. This is due to SPSS copying the chart in multiple formats, one of which is “Plain Text”. Unfortunately, “Plain Text” is the format Pages elects to use when you paste the chart. SPSS Copy Special Dialog Box

To get around this problem, choose “Copy Special…” from the Edit menu in SPSS. A dialog box will appear, in which you can uncheck “Plain Text” and “Rich Text (RTF)” and check “Images”. Now when you paste the chart into Pages, the chart graphic should appear. To retain this behavior for subsequent uses of the “Copy” command, check “Save as default for this session”.

Seamless integration of Papers and DEVONthink

Two of my favorite programs on the Mac are Papers and DEVONthink Pro Office. Papers provides a terrific interface for storing and organizing journal articles, and DEVONthink Pro Office offers powerful indexing and searching of PDF files.

Recently I was thrilled to find an easy way to use the two programs together. If Papers is configured to store your PDF files in its library (the default), DEVONthink can index these without duplicating them in its database. To configure:

  • Launch DEVONthink
  • Open an existing DEVONthink database or create a new one
  • Choose “Index…” from the “File” menu
  • Locate and select the folder where your Papers library is stored (by default the folder is called “Papers” and it’s stored in the “Documents” folder in your home directory)

If you have a large number of papers, it may take a while for DEVONthink to index them. Once indexing is complete, you’ll see a folder structure that mimics the structure of your Papers library. You can now search your PDF files in DEVONthink!

To update your DEVONthink index (e.g., after adding articles to your Papers library), click on the “Papers” folder in your DEVONthink database and choose “Synchronize” from the “File” menu.

Raising a matrix to a power in R

A surprising deficiency in R is the absence of an operator or built-in function for matrix exponentiation. I had to deal with this today when porting a function from MATLAB to R. Here is my quick-and-dirty solution:

mpower = function(M,p) {
	A = as.matrix(M)

	if (dim(A)[1] != dim(A)[2]) stop("not a square matrix")

	# M^{-1} = the matrix inverse of M
	if (p==-1) return(solve(A))

	# M^0 = I
	if (p==0) return(diag(1,dim(A)[1],dim(A)[2]))

	# M^1 = M
	if (p==1) return(A)

	if (p < -1) stop("only powers >= -1 allowed")
	if (p != as.integer(p)) stop("only integer powers allowed")

	R = A
	for (i in 2:p) {
		R = R %*% A
	}
	return(R)
}

Not the most efficient method, perhaps, but it works. If you know of a better alternative, please add a comment to this blog entry. One possibility might be to port MATLAB’s expm function, as defined in expm1.m in the MATLAB demos directory, to R.

For a detailed review of methods for computing the exponential of a matrix, see:

Moler, Cleve and Charles Van Loan (2003), “Nineteen dubious ways to compute the exponential of a matrix, twenty-five years later,” Society for Industrial and Applied Mathematics, 45 (1), 3-49.

Switching from MATLAB to R

If you’re an experienced MATLAB user and you want to get up to speed quickly on R, these reference guides may prove helpful:

Similarly, R users may wish to refer to these when using MATLAB.