diff two files and output lines not seen in file 2

Problem

You need two diff two files and only output what is unique to file one.

text file 1 contains:

1 2 3 4 5

text file 2 contains:

6 7 1 2 3 4 Solution $ awk ‘FNR==NR{a[$0]++;next}!a[$0]‘ file1 file2 6 7

Explanation of how the code works:

If we’re working on file1, track . . . → Read More: diff two files and output lines not seen in file 2

Using lzop on Windows

I wanted a fast way to backup an AppDynamics MySQL database directory on windows. The answer was lzop.

Tools GoW 0.8.0 (GNU on Windows) lzop for Windows Setup Set your Enviornment PATH

After installing GoW and extracting lzop.exe set your environment PATH to include the directory where you extracted lzop.exe

Stop AppDynamics Controller and Database . . . → Read More: Using lzop on Windows

Active Directory Password Expiration Date

To find out the password expiration date for an Active Directory user you must first determine your domain’s password expiration policy and then when the password was last set.

Find your Domain Password Expiration Policy import-module activedirectory Get-ADDefaultDomainPasswordPolicy

Property MaxPasswordAge will tell you the default password expiration policy

Determine Date User Password Was Last Set . . . → Read More: Active Directory Password Expiration Date

IIS7 SNI Rewrite – Howto

Problem

Windows XP Users with IE8 are unable to connect to your Server Name Indication (SNI) enabled Amazon CloudFront distribution.

Solution

Do not rewrite URLs to CloudFront if the user agent indicates a system that does not support SNI.

Example (IIS 7)

Be sure to have the URL Rewrite module installed

URL Rewrite rule precondition . . . → Read More: IIS7 SNI Rewrite – Howto

iis7 insert rewrite rule web.config

To insert a rewrite rule in to a web.config for deployment purposes you need to modify Web.Release.Config

Example <system.webServer> <rewrite xdt:Transform=”Insert”> <outboundRules> <rule name=”Add Cross Origin Access”> <match serverVariable=”RESPONSE_Access_Control_Allow_Origin” pattern=”.*” /> <conditions> <add input=”{REQUEST_URI}” pattern=”.*\.(ttf|otf|eot|woff|svg)\?*.*$” /> </conditions> <action type=”Rewrite” value=”*”/> </rule> </outboundRules> </rewrite> </system.webServer>

Cloudfront IIS7 CORS Fix

Problem

You keep getting Control Allow Origin errors on fonts that are pulling from your CloudFront CDN

Solution

You need to make changes at CloudFront and your IIS 7 Server

CloudFront Changes

Modify the origin behaviors:

Navigate to the CloudFront Distributions Panel Select your Distribution Click Behaviors Tab Select Behavior from list items Click Edit . . . → Read More: Cloudfront IIS7 CORS Fix

iis 7.5 The format of the specified network name is invalid – IIS Error 0x800704BE

Problem IIS 7.5 is holding on to an IP and you cannot get it to listen to the right IP.

You might see this error message:

The format of the specified network name is invalid – IIS Error 0x800704BE Solution

You will need to remove and add the listening ip via netsh (see below)

Determine . . . → Read More: iis 7.5 The format of the specified network name is invalid – IIS Error 0x800704BE

backup perfmon counters

How to backup your perfmon counters

The easiest way to backup your perfmon counters is to use the lodctr tool

Lodctr

Registers new Performance counter names and Explain text for a service or device driver, and saves and restores counter settings and Explain text.

Syntax lodctr [\\ComputerName] FileName [/s:FileName] [/r:FileName] Example lodctr /s:”perf backup1.txt” . . . → Read More: backup perfmon counters

Block Countries Behind ELB

To block countries behind an ELB (Elastic Load Balancer) you should use Maxmind’s GeoIP Country Database.

Problem

You are unable to use iptables or ipset to block countries because of your Amazon Elastic Load Balancer

Solution

Use Maxmind’s GeoIP Country Database in conjunction with Apache or NGINX

Example

This example is for Ubuntu 12.04 (Precise)

. . . → Read More: Block Countries Behind ELB