Tahir Hassan's Blog

My Technical Notes

Work Blog

Monday, 11 July 2016

Getting rid of Woolly Aphid

  • Use a hose and blast them
  • scrub them with a brush dipped in soapy water
  • Wipe with methylated spirits

Thursday, 7 July 2016

Adding User to Local Administrators Group using Powershell

The following script, which needs to be run as administrator, adds a user to the administrators group using Powershell:

Replace `<domain>` with the domain and `<username>` with the username.

The following script will add the user to the administrators group, if they are not already a member, and then logoff:

To run this script as a desktop shortcut, we set the target to:

It will automatically resolve the `powershell.exe` to the full path of the Powershell executable.

Lastly, we can set the icon of the shortcut to an icon found in:

Friday, 1 July 2016

TheSage - Dictionary and Thesaurus App for Windows

Check out TheSage, which is more than a dictionary and thesaurus combined.

Thursday, 30 June 2016

Browser Sync Extension for Visual Studio 2015

Use Control-Alt-Enter to:

  • move all browsers to the same page
  • move all browsers to the same scroll position if they are on the same page

Wednesday, 22 June 2016

Log4net: Simple Console Application that Uses MemoryAppender

This simple example uses log4net version 2.0.3 to write to a `MemoryAppender` which is the read to produce a string at the end of all the log messages.

Installing Log4net

We first download and install log4net version 2.0.3 using NuGet Package Manager Console:

Configuring Log4net via config file

We place the following configuration in our app/web.config file. It declares an appender called `MemoryAppender` which we will access through the C# code later. It also adds a config section under `configSections` so that log4net is configured.

Invoking Log4net's XML Configurator

Follow this post to invoke log4net's XML Configurator.

Converting Logs to a String

To get a string representation of all the logged statements, we use the following code. Note that the `result` variable will be set to the log data.

Log4net: Invoking XML Configuration

This can be done in two ways. We either add an assembly attribute:

or we invoke it through code: