Killing Processes In Disconnected Terminal Service Sessions

Usually it is best to configure your terminal service policy to log out disconnected sessions, however there may be cases where you only want to kill specific applications when the user disconnects.

This is easy to do with a PowerShell script that you run periodically as a scheduled task. The processes won’t be killed immediately when the user disconnects but will be killed shortly after.

This script will, by default, only kill the OUTLOOK processes in disconnected sessions after waiting 15 seconds for it to gracefully close. It is trivial to tweak the script to kill whichever processes you care about.

Continue reading

Crime Rates Are Dropping

We all know the news is biased. Media slants to the left or the right. Bias is natural and very difficult to avoid.

I don't read the news much but the recent public shootings in Aurora, Colorado and at the Sikh temple in Wisconsin have made my social media feeds flutter with the topic of gun control with points from all sides.

Today I listened to an episode of Common Sense with Dan Carlin, a podcast that I occasionally listen to and always enjoy. He does a good job, in my opinion, of thinking about situations from both sides of the fence.

Continue reading

PowerShell, batch files, and exit codes. Recipes & Secrets.

TL;DR;

Update: If you want to save some time, skip reading this and just use my PowerShell Script Boilerplate. It includes an excellent batch file wrapper, argument escaping, and error code bubbling.

PowerShell.exe doesn’t return correct exit codes when using the -File option. Use -Command instead. (Vote for this issue on Microsoft Connect.)

This is a batch file wrapper for executing PowerShell scripts. It forwards arguments to PowerShell and correctly bubbles up the exit code (when it can).

Continue reading

Syntax highlighting for Nginx in VIM

Thanks to Evan Miller, adding VIM syntax highlighting for Nginx config files is a breeze.

First, install VIM if you haven’t already. On Arch Linux, it goes like this:

> pacman -Sy vim

Create a folder for your VIM syntax files.

> mkdir -p ~/.vim/syntax/

Download the syntax highlighting plugin.

> curl http://www.vim.org/scripts/download_script.php?src_id=14376 -o ~/.vim/syntax/nginx.vim

Add it to VIM’s file type definitions. Make sure to adjust the path to your Nginx installation if you need to.

Continue reading

Storing your Raspberry Pi configuration in Git

Storing your Raspberry Pi’s configuration files in Git is a great way to protect yourself from really bad accidents. You get a backup of all your configs and revision control to rollback those nasty changes. Best of all, you don’t have to manually create backup copies of each individual file. (cp rc.conf rc.conf.bak anyone?)

I should note that I’m running Arch Linux ARM, but this should apply fairly equally to Debian and other distros.

Continue reading

Soft links, hard links, junctions, oh my! Symlinks on Windows, a how-to

First, a quick definition of terms. There are three kinds of “symlinks” on Windows.

  • soft links (also called symlinks, or symbolic links)
  • hard links
  • junctions (a type of soft link only for directories)

Soft links can be created for files or directories.

Hard links can only be created for files.

Both soft and hard links must be created on the same volume as the target. i.e. You can’t link something on C:\ to something on D:\.

Continue reading

Can't access network resources over VPN connection on Mac OS X?

So you have your shiny OS X connected to a VPN, good deal! The problem is, you can’t connect to any of the servers and workstations on the VPN. What could be wrong?

It could be that OS X is still trying to find those machines on the internet instead of looking for them on the VPN connection. We can tell OS X to check the VPN connection first by giving it a higher priority than the other network connections on your Mac.

Continue reading

Use AutoHotkey to remap your numpad keys to something useful

Are you tired of having to remember that ALT+0176 is the degree symbol ° ? Maybe there are other special characters that you want to be able to type easier.

Personally it was the degree symbol that got me, and since I never use my numpad, I decided it would be much more useful if those keys actually entered stuff that I cared about.

Here is a quick tutorial in using AutoHotkey to remap one of your numpad keys to the degree symbol. Of course you can expand on this beginning easily to solve whatever woes you are having.

Continue reading

What I miss in vanilla Visual Studio

For the past week or so I’ve gone without any Visual Studio enhancements. No ReSharper. No CodeRush. I knew that I didn’t leverage even a fraction of what these tools offer so I wanted to find out what I would miss.

Here’s what I’m missing the most. In no particular order.

  1. Detection of errors before I compile.

  2. Shortcut for moving a class to its own file.

    I like to build up features in the same file (for speed) and then refactor the classes into their own files later. A tedius process of copy/paste.

Continue reading

Tortoise SVN PowerShell helper function

Do you work from the command line? Use PowerShell? SVN?

While the SVN command line client is certainly usable, there are definitely times where a GUI is more convenient. Specifically during a commit where you want to easily check/uncheck files and view diffs.

I got tired of having to open an explorer window to get into Tortoise SVN’s commit screen so I wrote this helper function.

Put this into your profile and you can start typing tsvn commit (or just tsvn) to open the Tortoise SVN commit dialog. Enjoy!

Continue reading