Use WordPress on HTTPS site with load balancer

WordPress by default uses a pretty simple test to check if your site is running on https or http.

In wp-includes/load.php we find the following method:

In short, if either server variable HTTPS is “on” or “1” or if server variable SERVER_PORT is “443”, assume the site is running on https.

In a load balanced environment, this check might return false, even if the site is running on https.

Use phpinfo() to find what server variable is set instead. In my case, the server set server variable HTTP_X_PROTO to “https”. You might findĀ X_FORWARDED_PROTO or other variants.

To get WordPress to understand that it is running on https, I added the following code toĀ wp-config.php:

I use rules in .htaccess to forward anyone accessing the http address to https. I’m effectively blocking access to my http adress.

Therefore I can even skipĀ the check of server variables altogether and simply write this in wp-config.php:

Xamarin: Reload an iOS CallKit call directory extension from the app

I you want to make a call directory extension for iOS, for identifying or blocking certain phone numbers, you need a way to reload the extension every time you want to add or remove from the list of phone numbers you are blocking.

To reload the extension, you can either get your users to open their phone’s settings and disable the extension and re-enable it or you can reload it programmatically from your app.

To reload the extension manually, follow this procedure:

  1. Open the iPhone’s settings
  2. Go toĀ “Phone”
  3. Go to “Identify phone numbers”
  4. Switch your extension off, then on again

To reload the extension programmatically from your app, use this code:

Here is Apple’s documentationĀ for the error codes :
https://developer.apple.com/reference/callkit/cxerrorcodecalldirectorymanagererror.code/

The most common one I have come across is 6, Extension Disabled.

How to create an iOS call directory extension in Xamarin for blocking thousands of phone numbers

AĀ call directory extension is used to block or identify phone numbers on an iPhone, phone numbers the user don’t have in their contact list.

TL;DR: Because iOS app extensions have very limited resources, it is difficult to load many thousand phone numbers into the call directory without the extension crashing. This is my attempt to get around this issue.

Continue reading “How to create an iOS call directory extension in Xamarin for blocking thousands of phone numbers”

Visual Studio Code and AutoHotkey

2016-02-10 Update: This post is about how to get around a bug in Visual Studio Code. This bug is now fixed, and my automatic text replacement (described in this blog post), works just as well in Visual Studio Code as in other applications.

In my previous post,Ā Use automatic text replacement to speed up your coding and typing, I explained how I use AutoHotkey on Windows and equivalent software on OS X to speed up my typing and coding.

The idea is to use software to replace some easy-to-hit keys like “->” with a special symbol like “ā†’”.

Continue reading “Visual Studio Code and AutoHotkey”

Use automatic text replacement to speed up your coding and typing

In programming, and probably in mostĀ other lines of work where you work with text on a computer, there are some symbols and special characters that you use a lot, but that are quite difficult to type. Perhaps you need to hit a combination of keys to produce the symbol, or even more time-consuming, you might need to open a menu or tool to insert the symbol.

Continue reading “Use automatic text replacement to speed up your coding and typing”

Live preview of website when editing in Visual Studio Code

VSCode, being extremely lightweight (at least compared to Visual Studio), does not come with its own web server. This can be a bit confusing for those of us used to just hitting F5 in Visual Studio and getting our website launch in a browser.

When using VSCode, you have to rely on the power of Node.js instead.

This is a tutorial of how to start a really small project, containing only a single HTML file in VSCode and edit it with live preview in a browser.

Continue reading “Live preview of website when editing in Visual Studio Code”

Getting started with TypeScript in Visual Studio Code

This is a super short introduction to start writing TypeScript in Visual Studio Code. This tutorial is written for Windows users, but it should be roughly the same procedure for Linux and OS X users, since all these tools are cross platform.

This post is not actually about writing TypeScript, it’s just a guide to set up VSCode correctly to be able to write and compile TypeScript. Continue reading “Getting started with TypeScript in Visual Studio Code”

Use Subversion revision number as version number with MSBuild

(And handle revision numbersĀ larger thanĀ 65534)

When using a system forĀ continuous integrationĀ to automatically deploy your application, it is important to know what version of your code is deployed. This tutorial will show you how to automatically set the version number of the deployed .dll.

In a .NET project, the version number is definedĀ in AssemblyInfo.cs, on the format 1.0.0.0. The numbers are MajorVersion.MinorVersion.Build.Revision. The two latter, build and revision numbers, should be set automatically by your CI system on each deploy.

Content of this tutorial

  • How to create an MSBuild target to automatically insert the revision number on build
  • What to do when your revision numbers are too large to use as .NET revision numbers
  • How to use Bamboo to get the latest revision number from Subversion and use thisĀ as an input parameter to MSBuild

Continue reading “Use Subversion revision number as version number with MSBuild”