ASRock CIR (Nuvoton) and Windows 8.1

Unlike most semi modern hardware, the CIR module provided by Nuvoton does not work out of the box in Windows 8. Additionally, the Windows 8 drivers (version 2.5.1003) that are linked to on all of ASRock’s motherboard pages do not work in Windows 8.1. The driver installation fails silently, giving the cryptic “This operation requires an interactive window station” error in Device Manager. Fortunately, there is a Windows 8.1 driver, its version is 2.9.1007 and you can find it on the driver’s page for ASRock’s VisionX series mini PC.

-John Havlik

[end of transmission, stay tuned]

Controlling Breadcrumb NavXT Settings From the Network Settings Page

Update 2015-10-30: Updated to reflect the default behavior change in Breadcrumb NavXT 5.3.

Starting with Breadcrumb NavXT 5.0, the oft-requested feature for a Network Settings Page for controlling the setting on all subsites in a WordPress multisite setup is now available. Since now there will be a combination of Network Settings and sub site settings, some extra intelligence is needed to pick settings appropriately. Given that the desired behavior will vary depending on use case, a few new globals have been added to switch between settings behavior modes.

Force Network Settings on All Sites (default behavior for 5.0-5.2)

Versions 5.0 through 5.2 used this mode as the default behavior for settings. In this mode, rather than default to the individual site settings (as they were the only ones that existed in WordPress multisite setups prior to Breadcrumb NavXT 5.0). Note, for 5.0 through 5.2, that all other BCN_* defines must be either not set or set to false to select this mode. Note that in 5.0.1 and later you should manually specify this mode:

define('BCN_SETTINGS_USE_NETWORK', true);

Force Individual Site Settings Only (pre-5.0 behavior, default behavior for 5.3+)

In 5.3 the default behavior was reverted to the pre-5.0 behavior of using only the individual sub site settings for Breadcrumb NavXT in a WordPress Multisite setup. Note, for 5.3 and later, that all other BCN_* defines must be either not set or set to false to select this mode. The following must be placed in your wp-config.php (or site specific plugin):

define('BCN_SETTINGS_USE_LOCAL', true);

Favor Individual Site Settings Over Network Settings

In Breadcrumb NavXT 5.0 this settings will merge the local (individual site’s) settings into the network settings (network settings are the ‘defaults’ for the wp_parse_args function). Use the following to enable this mode:

define('BCN_SETTINGS_FAVOR_LOCAL', true);

Note that the behavior of this mode is subtle and likely will look more like the local (individual site’s) settings than the network settings. In the future this mode may change slightly.

Favor Network Settings Over Individual Site Settings

In Breadcrumb NavXT 5.0 this settings will merge the network settings into the local (individual site’s) settings (local site settings are the ‘defaults’ for the wp_parse_args function). Use the following to enable this mode:

define('BCN_SETTINGS_FAVOR_NETWORK', true);

Note that the behavior of this mode is subtle and likely will look more like the network settings than the local (individual site’s) settings. In the future this mode may change slightly.

-John Havlik

[end of transmission, stay tuned]

OpenVPN Tips And Tricks

Setting up your own VPN server and getting everything working can be a real pain to do. Over the past few months I’ve been off and on trying to get one working. While I had attempted to get other methods, which did not require software to be installed in Windows, to work, I ended up settling on using OpenVPN. Here are a few notes and resources I found useful.

Gentoo Forums :: View topic – Howto Openvpn – The quick easy wayhttp://forums.gentoo.org/viewtopic-t-117709-view-next.htmlI’ve read through a lot of howto’s for openvpn, and a lot of them didn’t seem to work, I could follow them line for line and I kept running into problems. Here is my HOWTO on openvpn, which i find was the simpliest way of setting it up.

I used the above guide to begin my setup of a OpenVPN server on my server running Funtoo (a Gentoo variant). While the guide is pretty good, I have a few notes:

  • The line remote <vpn server ip> 9900 for the Linux client config is wrong, in the example configs the port should always be 9000
  • Since the writing of the guide, easy-rsa has been split off into it’s own package, install it by running emerge -av easy-rsa
  • The directory the easy-rsa files go to has changed, they are now located under /usr/share/easy-rsa/ you will want to copy these somewhere else (e.g. /etc/openvpn/easy-rsa) to prevent them from being overwritten when updating easy-rsa
  • Easy-rsa contains several OpenSSL config files, you’ll either need to update the server.cnf file to match the installed OpenSSL version, or create a symlink with openssl.cnf pointing to the appropriate openssl-.cnf file.
  • If you do not have $OPENSSL defined, you’ll run into issues running ./build-dh. You should be able to edit line 7 of build-dh replacing $OPENSSL with openssl

Beyond this guide, when trying to talk to a Samba server, a few things should be noted:

  • When using a VPN to connect to a network with the Samba server, you will have a IP address in a different network than the Samba server is in (e.g. 192.168.2.0 vs 192.168.10.0). Make sure to add your VPN network to the hosts allow property in your smb.conf.
  • Since Windows Vista, Windows tries to find a gateway to determine if the connected network is a home, office, or public network. You may need to add push "route 0.0.0.0 0.0.0.0 vpn_gateway 999" to your OpenVPN server’s config file.
  • If you want to use the Netbios name to access the Samba server, you will want to place push "dhcp-option WINS <SAMBA_IP_ADDRESS>" (where <SAMBA_IP_ADDRESS> is the IP address of your Samba server) in your OpenVPN server’s config file.

Lastly, you should note that if the network you are VPNing into has a server at the same IP address as the network you are VPNing from, it may be difficult to contact the server on the network you have VPNed into. So, it is probably a good time to move away from using 10.0.0.0, 172.16.0.0, or 192.168.1.0 as your network address.

-John Havlik

[end of transmission, stay tuned]

How to Add li and Other Tags to Breadcrumb Templates

Since Breadcrumb NavXT 4.3.0, all settings that can contain HTML are passed through wp_kses(). With this change, only a basic set of acceptable tags and properties within tags were allowed. Naturally, this restricted users more than they were used to. The restriction wasn’t the biggest problem, the lack of a filter to allow users to add their own tags in to the allowed HTML tag list. However, with Breadcrumb NavXT 4.4, a new filter bcn_allowed_html has been introduced to fix this issue.

The default set of allowed HTML tags in Breadcrumb NavXT 4.4 consists of: <a>, <img>, <span>, <h1>, and <h2>. For the purposes of this guide, let’s assume you don’t want to use the built in bcn_display_list() function to output breadcrumbs wrapped in <li> tags. The reason you would want to do this is if you need additional properties within the tag (Breadcrumb NavXT will by default add a class but that’s it).

In Breadcrumb NavXT 4.4, adding a tag to the allowed HTML list for Breadcrumb NavXT is really easy. Just create a function with one input argument ($allowed_html in this example). Within that function append, using the HTML tag name as the array entry key, assign an array of properties that tag is allowed to have, using the property name as the array entry key and a value of true. Then add your filter function to the ‘bcn_allowed_html’ filter hook. Below is an example of this for the <li> tag with a selection of properties.

function my_bcn_allowed_html($allowed_html)
{
	$allowed_html['li'] = array(
		'title' => true,
		'class' => true,
		'id' => true,
		'dir' => true,
		'align' => true,
		'lang' => true,
		'xml:lang' => true,
		'aria-hidden' => true,
		'data-icon' => true,
		'itemref' => true,
		'itemid' => true,
		'itemprop' => true,
		'itemscope' => true,
		'itemtype' => true
	);
	return $allowed_html;
}
add_filter('bcn_allowed_html', 'my_bcn_allowed_html');

To get started quickly, just copy and paste the above code into a site specific plugin and start playing.

-John Havlik

[end of transmission, stay tuned]

Using ImageMagick to Batch Convert Photos

Back when I posted my photoset from WordCamp Minneapolis 2013, rather than performing any post processing, I just uploaded the full images from my camera’s SD card. Normally, I would open up the Gimp and reduce the resolution by 50% and then crop to a 3:2 or 16:10 ratio depending on what was appropriate for the images. This produces small files that are easy for the server to handle.

Since WordPress generally does a good job generating the image sizes it needs, I didn’t worry about uploading the full, unreduced images. Normally, the end users would never see the full size images, so no harm, right? Wrong. At least if you use Jetpack.

If you use the tiled gallery feature in Jetpack (like I do on this site) you end up using the WordPress.com CDN. Unfortunately, Jetpack tries to load the full image size when caching for the tiled gallery. Trying to pull 50 or so images, at 1 MiB to 2 MiB a piece to cache didn’t work too well. Naturally, Jetpack could do things slightly more intelligently and request for the closest, already existing, image size to be used, but that’s a topic for another day.

To get things to play nicely I needed to reduce the ‘original’ file sizes. Thankfully, Weblogs.us has ImageMagick installed. Thus, fixing the issue was as simple as running:

convert P*.jpg -resize 50% \
-quality 88 \
-set filename:newsize '50_%t' '[filename:newsize].jpg';

Then, after inspecting the results, all that was left to do was to rename the 50_ prefixed files back to the original file name.

-John Havlik

[end of transmission, stay tuned]

Updated: