Ben Lobaugh Online

I think, therefore I am. I am, therefore I sail

Category: Computing Page 1 of 49

iMac on a desk

How to fix missing Calibri and Cambria fonts on Mac (Bonus: Segoe UI)

If you open Microsoft formatted documents on your Mac like I do then you have probably run across the annoying message saying the Calibri or  Cambria font is missing.

For years I have ignored this as an annoyance, but today I decided to do something about it. Turns out there is a very easy fix!

Richard Taylor of RMTWeb became fed up like me and put together a package of fonts to restore Calibri and Cambria fonts on the Mac.

Getting the fonts running is trivial:

That’s it.

Really.

You will no longer get that annoying message about missing fonts!

Thanks to Richard for providing this resource! His original instructions can be found at https://www.rmtweb.co.uk/calibri-and-cambria-fonts-for-mac

Bonus: Segoe UI Font

After posting the original fonts I ran across an issue with Segoe UI fonts missing. Microsoft provides a download for them at Segoe UI and Fabric MDL2 external icon font. The install instructions are the same as above!

Photo by Patrick Ward on Unsplash

Picture of tables

How to extract a single table from a MySQL sql file

Ever received a large MySQL dump file and only needed one table out of it?

I ran across just this issue. The full database took significant time to import and I only needed a small subsection of the DB, just one single table. Rather than waiting for it all to import, I pulled together a sed command that extracts a single table from the sql file. Check it out:

sed -n ‘/Records of TABLE_NAME/,/Table structure for/p’ FULL_SQL_FILE.sql > table.sql

Replace TABLE_NAME and FULL_SQL_FILE with the names of the table you want and the sql file to pull it from, respectively.

You will now have a table.sql file in your directory that is ready to be imported.

Photo by chuttersnap on Unsplash

WordPress: How to “properly” allow unfiltered uploads

If you are working with a WordPress site and getting the dreaded “Sorry, this file type is not permitted for security reasons.” message, fret no more!

WordPress has a config that allows you to enable unfiltered uploads

define( 'ALLOW_UNFILTERED_UPLOADS', true );

This, however, does not always work. Especially on Multisite, which may only allow unfiltered uploads for super admin users. No bueno.

Filters to the rescue!

Drop this code into your project (I put it in mu-plugins) and viola! You will have unfettered uploads.

add_filter( 'user_has_cap', 'unfiltered_upload' );

function unfiltered_upload( $caps )
{
    $caps['unfiltered_upload'] = 1;
    return $caps;
}

See also this StackExchange message

Cookies disappear after adding Set-Cookies in .htaccess? Here is how to get them back

I needed to set a cookie via .htaccess, to ensure it was always in the browser, regardless of what the website was doing. Setting a cookie is rather easy, it will look similar to:

Header set Set-Cookie "cookieName=value; Expires=Wed, 15 May 2222 07:28:00 GMT"

The next morning I attempted to login to the site and could not. It turned out the login cookies were not being set. The issue was insidious. Re-read the line above, at first glance it seems fine when you want to set a cookie, however if there are other cookies that need to run you need to add the cookie.

This three letter change resolved the issue and allows all the other cookies to operate properly:

Header add Set-Cookie "siglock=hello-world; Expires=Wed, 15 May 2222 07:28:00 GMT"

Canonical URL plugin for WordPress released!

Have you run into this scenario? You have content that needs to live on multiple sites but you are concerned about SEO issues duplicating said content?

As search engines crawl the web looking for pages to include in their search indexes they may run across content duplicated from another site. When that happens the search engine will first attempt to determine which site is the “source of truth”. The site with duplicated content will be penalized in rankings. If no source can be found both sites rankings will be penalized. An SEO nightmare.

Is it possible to distribute the same content to multiple sites without incurring this penalty? The answer is a resounding YES! All you need to do is let the search engine know where the real of the article is, the canonical article. This is done by including a tag in the html head area. It is for search engines, humans do not typically see it.

WordPress has some built in canonical abilities however in WordPress itself there is no way to set the canonical url. I tend to have articles published all over the web that I would like to copy to this site for posterity. Today I whipped up a little plugin that provides a simple url field to add the article’s canonical url in a search engine friendly way.

It is as simple as adding the url as you create the article!

Publish your post and WordPress will handle the rest.

Here is an example post that I wrote on team building for WebDevStudios.

9 Critical Concepts for Leading High-Performance Teams

You may notice there is also a brief disclaimer at the top of the article. That is optional and may be helpful to some readers and/or required by the site you are reposting from to comply with guidelines.

If you want to use this plugin on your own site simply head over to Github and download the plugin!

https://github.com/blobaugh/canonical-url-for-wordpress

Page 1 of 49