Broken clipboard in Windows

My clipboard on my Windows 8 install suddenly stopped working. At first, I thought Visual Studio blew a fuse, but it turned out to be system wide. Running this in a shell fixed it:

echo off | clip

UPDATE: Well, this works for a little while, and then copy/paste stops working all together. It seems the problem is related to RDP – or Remote Desktop if you will. Open Task Manager and slay rdpclip.exe or RDP Clipboard Manager. You’re welcome.

Leave the first comment

Windows hates long filenames

.. which is kind of a bummer, since the Node package manager really loves them. I thought Windows was kidding me, but apparently you can manage to paint yourself into a corner where you have a perfectly valid, browse-able directory structure – except you can never delete it.

I try to rename the offending folder and I get this:

Every possible offending application has of course been closed. If I didn’t have such a massive love for life, I’d be stabbing myself in the face by now.

After running CHKDSK.EXE, Windows gives me this:

Windows hates long filenames

This is where I decide that a reboot is the way to go. If I said I was surprised when I saw this, I’d be lying. It’s just that kind of day:

One reboot later, nothing has changed. My directory structure looks like this:

Now, coming from a Linux/Max/Unix world, this would be no problem at all, which is probably why I’m shocked that Windows thinks so. After a lot of trial and error, it looks like I’ve found the horrible bastard of a solution: start from the leaf directories and traverse the tree upwards towards the root, renaming each directory to a one character name in the process. At one point the directory structure becomes “unlocked” again, and you can delete it. Sort-of-deleting-them-and-instead-moving-them-to-the-recycle-bin will probably yield this result:

Which is pretty weird, since Windows is now asking me to ask myself for permissions. Hitting shift+delete instead of just delete seems to solve that.

I’ll update this post if I ever find less bizarre way of solving this issue.

UPDATE: So, Windows has a hard limit of 260 characters in the total length of the path, including separators and a terminating null. Microsoft claims thie is a feature, not a bug, and will not fix it. And here is where it gets weird, because they sort of have already. There are two APIs for accessing the file system – one with a 260 character limit, and one that offers unicode and a 32K character limit. Node seems to use the newer API, and as a result does not have any trouble creating deep directory structures. Something inside the belly of the Windows beast itself still uses the old API, which is why it breaks when you try to remove a structure created by something like Node. This takes stupid to a whole new level.

“Do you have a cleaner way to fix this” you ask. Yes. If Node and possibly Gulp is why you got into this mess in the first place, you should install a plugin like gulp-clean and use that to remove folders like node_modules and bower_components. I suggest a task name like dist-clean. Linus would love that.

Leave the first comment

Relocate NPM packages on CentOS/Redhat

NPM by default installs packages in /usr/lib/node_modules and links binaries to /usr/bin. I’ve seen at least one system binary overwritten by something installed by NPM, so I decided to relocate everything installed by NPM to /usr/local/opt/npm. Here is the magic:

First step was to brutally remove everything node:

rpm -ev npm
rpm -qa | grep ^node | xargs rpm -ev
rm -rf /usr/lib/node_modules

At this point, you’d probably want to look in /usr/bin for symbolic links pointing to /usr/lib/node_modules/bin and remove them.

Now reinstall Node and NPM. Thanks to dependencies, installing NPM is usually enough:

yum install -y npm

Now tell NPM to relocate:

npm config -g set prefix /usr/local/opt/npm

And tell the various shells to add the binary path:

echo "PATH=\$PATH:$( npm config -g get prefix )/bin" > /etc/profile.d/

Now install something to see if it works:

npm install -g bower typescript tsd


source /etc/profile.d/
which bower

Leave the first comment

How to make Windows 8.0 Pro a little less KAPOW-SMACK-BOOM!

.. or how to make Windows 8.0 Pro look and feel a little more like Windows 7, and make the wife a little less frustrated in the process.

My wife is not ready for the Windows 8 plunge. Hell, I don’t think I am. I use Windows solely for running Visual Studio and building web solutions, so you can imagine exactly how many fucks I give about apps, the Metro interface and the rest of that sugary crap. Yep, you’re right – none.

Step 1: Upgrade to Windows 8.1 Pro.

It’s free, and probably has a handful less bugs than Windows 8. Also, Microsoft – probably by high demand – made it easier to get rid off all their extra bloat. Seriously, upgrade before continuing.

Step 2: Boot straight to desktop mode

Previously this required downloading a tool, but now you right-click the taskbar and go to Properties, Navigation, Start screen and check the box When I sign in or close apps on a screen, go to the desktop instead of Start. Screenshots and more info here.

Step 3: Staying in desktop mode

My wife is working on her masters degree, which involves a lot of website reading. Strangely enough, even though Windows in desktop mode, starting Google Chrome buts it right back in sugary Metro hell. Luckily you can ask it to relaunch on the desktop.

Studying also means reading PDF files now and then, and in Windows 8 that is done in a full screen Metro-mode app. Fix this by installing another desktop-mode application reader and make this the default application for PDF files. Right click a PDF file, pick Open with.. – you know the drill.

Step 4: Disable the Charms Bar

I’m not even sure what the Charms Bar is or how it got that name, but here is a piece on how to get rid of it.

More as we delve deeper into the abyss.

Leave the first comment

Recommended WordPress plugins

I’m hosting a handful of WordPress sites, some of which I very rarely update. I’ve assembled a list of plugins that keep security tight and automatically updates plugins, themes and the WordPress core.

Login LockDown
Prevents brute force login attempts, which is the most common way to gain access to a WordPress site.

Social Connect
A simple and very discreet social connect plugin. Allows users to login/register with Facebook, Google, Yahoo and Twitter accounts. Some of the social sites require registering the website first. Joining/linking accounts is not supported, but can be handled with a little SQL gymnastics in the wp_usermeta table. Google is my preferred way of logging in, as I usually forget my WordPress logins and passwords.

Better WordPress reCAPTCHA
The successor to the old reCAPTCHA plugin. Works as advertised. Personally I enable captcha verification on everything, including the login form. Requires registration on the reCAPTCHA website.

Advanced Automatic Updates
Automatically updates core, plugins and themes (if you allow it). I usually enable everything, including major version updates. You would want to exercise caution when configuring this.

Leave the first comment

LAN access to IIS Express

It looks like you can do this by editing IIS Express’ applicationhost.config file and modifying the bindingInformation attribyte of binding for specific sites. Setting the value to something like :9000: should make IIS Express site available on port 9000 on all interfaces. Unfortunately this requires that you fire up Visual Studio with Administrator priviledges, which probably isn’t such a great idea.

According to sites like this, binding to a specific interface address is premitted without extended privileges, but if you’re on a DHCP network, you may have to update your configuration once in a while.

IISExpressProxy is a proxy in front of IIS Express. It looks to be somewhat outdated but does the trick, allowing you to specify a custom application pool and port for each site defined in applicationhost.config.

Leave the first comment

Finding files in Visual Studio

Someone told me that ReSharper would make it easy to quickly locate files in Visual Studio. Unfortunately it has a rather hefty price tag, and it looks like SonicFileFinder does pretty much the same thing. Using the default keyboard shortcut (CTRL-SHIFT-Y), you get this popup:

Finding files in Visual Studio

Leave the first comment

The wonders of the SSL-enabled telnet connection

So you’ve set up a neat SSL-enabled service like SMTP, POP3 or IMAP, and now you wait to test it out from the command line. Don’t speak fluent SSL? No problem – OpenSSL to the rescue:

openssl s_client -connect

The output looks a little like this, giving you the opportunity to check the certificate as well as the service itself:

depth=0 C = DK, ST = My City, L = My City, O = My Company ApS, OU = My Service, CN =, emailAddress =
verify error:num=18:self signed certificate
verify return:1
depth=0 C = DK, ST = My City, L = My City, O = My Company ApS, OU = My Service, CN =, emailAddress =
verify return:1
Certificate chain
 0 s:/C=DK/ST=My City/L=My City/O=My Company ApS/OU=My Service/
   i:/C=DK/ST=My City/L=My City/O=My Company ApS/OU=My Service/
Server certificate
subject=/C=DK/ST=My City/L=My City/O=My Company ApS/OU=My Service/
issuer=/C=DK/ST=My City/L=My City/O=My Company ApS/OU=My Service/
No client certificate CA names sent
SSL handshake has read 1477 bytes and written 311 bytes
New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
Server public key is 1024 bit
Secure Renegotiation IS supported
Compression: zlib compression
Expansion: zlib compression
    Protocol  : TLSv1
    Cipher    : DHE-RSA-AES256-SHA
    Session-ID: ...
    Master-Key: ...
    Key-Arg   : None
    Krb5 Principal: None
    PSK identity: None
    PSK identity hint: None
    TLS session ticket:

    Compression: 1 (zlib compression)
    Start Time: ...
    Timeout   : 300 (sec)
    Verify return code: 18 (self signed certificate)
220 ESMTP Relay

And then you knock yourself out, showing off all your SMTP skills. Enjoy 🙂

Leave the first comment

The annoying thing with the WordPress OpenID Plugin

There’s a problem with the WordPress OpenID plugin, if you’re using a different home and site URL in your WordPress setup. This comes to show when you get a 404 error after you have authenticated with your OpenID provider, and it sends you back to your WordPress.

I usually install my WordPress files in /wp/ but prefer the home URL to be /. This way the WordPress-specific stuff is hidden away in it’s own directory. Something is broken in the OpenID plugin though, causing people authenticating with OpenID to end up at this URL:

Grepping through the files of the OpenID plugin, it looks like the problem can be fixed with a little tweak to the common.php file:

function openid_service_url($service, $scheme = null) {
	global $wp_rewrite;
	if (!$wp_rewrite) $wp_rewrite = new WP_Rewrite();

	if (!defined('OPENID_SSL') || !OPENID_SSL) $scheme = null;
	$url = site_url('/', $scheme); // Change site_url to home_url here!

	if ($wp_rewrite->using_permalinks()) {
		$url .= 'index.php/openid/' . $service;
	} else {
		$url .= '?openid=' . $service;

	return $url;

That’s it, I think. Strangely enough, most OpenID projects have been dead for years. I wonder if its dying out.

UPDATE: I’ve since stopped using this plugin and switched to Social Connect.

Leave the first comment

The annoying thing with Skype on 64-bit Fedora

If you’re getting “Problem with audio playback”, you probably need the 32-bit version of Video4Linux, PulseAudio and ALSA’s PulseAudio plugin. Here’s a one-liner for you:

sudo yum install \
  libv4l.i686 \
  pulseaudio-libs.i686 \
Leave the first comment