I’ll be the first to admit that I make plenty of mistakes – I like to say that I’m wrong more than I’m right. File this under “stuff I wished I’d known sooner“.
Recently the subject of personal privacy online, especially in the context of Facebook has come to the forefront of the public’s attention. Facebook has even acknowledged that it has allowed 3rd parties access to the platform users’ personal data, without their consistent. I find this uproar fascinating.
Search the Internet for “securing WordPress” and you will see no shortage of articles discussing various plugins that promise to make your website more secure.
Many of what you’ll find is valid – I even use a few such plugins. However, plugins can only do so much. Security-minded WordPress admins should also be wary of installing too many plugins, as doing so increases the surface area of attack. For these reasons, I prefer to use Nginx as an added security layer for my WordPress sites. Below are 5 helpful tips for hardening a WordPress site with Nginx.
When it comes to authentication on the web we’re pretty much all familiar with the password – king of the hill, infamous for both its flaws as well as its ubiquity. Outside of the password, you often run into authentication schemes such as token sharing (e.g., OAuth or RSA tokens).
Recently Motherboard carried a piece on The Rise and Demise of RSS – a fascinating account of how the web has changed over the past two decades. Underscored in the article is the shift to social media that has occurred over the past decade. Most young people consume their news from social media, so it is no surprise that the need for a turn-of-the-millennium technology like RSS might be waning.
Converting a single HTML file to an ePub is straightforward, with many free tools available for this purpose. But, if your goal is to convert multiple HTML files, and only a portion of each file, into an eBook with a proper table of contents, cover image, etc., what do you do?
All of these requirements are necessary for creating a professional ePub, but yet surprisingly no tool existed which could do all of these things without considerable manual effort. Like any good software developer, if no tool exists for a job, and the only other option is manual work, I took the laziest path and created a new tool to get the job done.
That new tool is called html2epub and is a command line app which can:
- Generate a professional looking ePub from a series of web pages
- Strip out unnecessary HTML
- Convert HTML into XHTML as to be compliant with the ePub spec
- Embed images
- Embed Gist code snippets
- Rewrite chapter to chapter links for proper ePub navigation
- Support for Table of Contents navigation
- Support forms-based authentication
I have tried to keep this utility as simple to use as possible, despite its many features. Let’s look at how to get started.
On macOS installing html2epub is greatly simplified by brew. Simply run:
brew install jwhitehorn/brew/html2epub
This will download and install htmlepub, and its dependencies, and register the command in your PATH. With that completed, you can generate an ePub as easily as:
html2epub --url https://www.datasyncbook.com \ --toc ./example/toc.xhtml \ --cover ./example/cover.png \ --contents ./example/contents.json \ --title "Data Synchronization" \ --subtitle "Patterns, Tools, & Techniques" \ --author "Jason Whitehorn"
The scenario might sound specific, but I am confident you’ve encountered something similar before. You need to construct an array, with a known number of duplicates of a string. Perhaps you’re constructing a template, and need a fixed number of placeholder elements, or you’re parameterizing a query and need a dynamic number of placeholders. In either case, you were probably left writing a rather ugly bit of logic in the middle of a routine that was otherwise focused on the task at hand.
Starting in .NET 3.5 is a feature called extension methods. Extension methods allow developers to extend classes with their own instance methods. This is a concept often called mix-ins in other languages.