Golang Naked Redirect WWW Middleware

It is important to make sure you site’s URL is either naked yoursite.com or with www. like www.yoursite.com. One should redirect to the other and you should keep is consistent for SEO.

If you redirect naked to www., and you use Go, you can use the following Go middleware to have all naked requests redirect with 301 to www.:

func RedirectNakedToWWW(handler http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		// if host doesn't have www. redirect
		if !strings.HasPrefix(r.Host, "www.") {
			http.Redirect(w, r, fmt.Sprintf("https://www.%s", r.Host)+r.URL.String(), http.StatusMovedPermanently)
			return
		}
		handler.ServeHTTP(w, r)
	})
}
Read on →

WireGuard a Fast, Modern, and Secure way to Connect to Your Home Network

There are many guides out there on how to use WireGuard to create your own personal VPN to route all your traffic through a VPS (Virtual Private Server) for privacy or other reasons.

This guide will focus on creating a VPN so you can connect to your home network on the go.

Read on →

Notes on MergerFS

Install mergerfs

sudo apt install mergerfs

Mount it

/mnt/data1:/mnt/data2 /mnt/usb fuse.mergerfs category.create=mfs,nonempty,defaults,allow_other,minfreespace=20G,fsname=mergerfsPool 0 0

Reboot to mount as drives may already be mounted/used

Read on →

OSX: Never Paste with Style

I never want to copy a chunk of text and then later paste that text with all of its styles and formatting. I personally found that I have no purpose for this. My styles are never aligned with the same styles that I am copying from.

Read on →

Robo Calling with Twilio

Every one hates to get political or an automated spam robo call; however, I recently had the opportunity to create one that people loved and it was stupid simple thanks to Twilio.

Read on →

Documentation for Magento Developers

I am excited to announce that I have a new book coming out!

Read on →

What RSS Feeds Does Mark Sanborn Read?

Ever wonder what RSS feeds I subscribe to? Here is a quick list of most of the feeds I subscribe to.

Read on →

Schedule a Tweet with One Comnand in Linux

Ever want to schedule a tweet to go out at the same time an article is published or an event is started? Want to do it without signing up to a service or some other complicated task? Well this post is for you. I am going to show you how to schedule a tweet from the command line in one line of code. You can schedule the tweet to take place ten minutes from now, 14 days, or whenever you wish.

Read on →

Two New Projects Launched: NixTutor and Faceoff Podcast

As you may have noticed posts have slowed a little here on MarkSanborn.net. This is due to my involvement in two new projects.

Read on →

Faceoff: Episode 2

Well we decided that podcasting was fun and many of our listeners enjoyed it so we continuing with the project.

We opened a website up at faceoffshow.com Although the site is not quite up yet, expect a full feature site with proper itunes compatible feeds soon!

In the mean time you can download the podcast directly from here:

Read on →

View all posts