Area of Latitude/Longitude Rectangle using PHP

I went searching for how to calculate the area of a rectangle* on the surface of the earth using PHP and didn’t find one online.  Someone probably has one somewhere, but it was just as fast for me to adapt one as it was to continue searching, so here it is.  Enjoy.

This code is also available on GitHub if you prefer:

Continue reading

Windows 2012 Multihomed Domain Controller

In researching whether one can run a Windows 2012 domain controller with multiple network cards (aka “multihomed”) I ran into a lot of old posts referring to Windows 2003, Windows 2000 and even NT4 – but not a lot of new information.  All of them say something like a multihomed configuration “isn’t recommended” or “isn’t supported”; not many of the pages actually address whether it will work.  So here is my recent experience.

Yes, you can run a domain controller on a multihomed machine, but you need to make some configuration changes for it to work.

The reason that we wanted to do this was to physically split up the network traffic.  We were running a private network between all of our servers and the network attached storage, and didn’t want the clients to see this traffic at all, let alone have a badly behaving client overload the network hardware and impact the connection to storage.

For the purposes of demonstrating with an actual example, let’s assume that you have a machine with 2 network interface cards:

  • NIC 1: “PUBLIC” 192.x.x.x network (clients use this to reach the DC)
  • NIC 2: “PRIVATE” 10.x.x.x network (private network, only for servers or storage)

I’ve labelled the 192.x.x.x network as PUBLIC just so it’s clear that client machines use this to contact the DC, it doesn’t mean that the IP address is necessarily publicly routable.

Here are the changes needed:

1. [required] Prevent the DC from offering DNS services on the PRIVATE interface

  • Right-click the Windows menu and select Run
  • Type regedit and hit enter
  • Navitage to: HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters
  • Add a new string: PublishAddresses
  • For the value, put the PUBLIC (192.x) static IP address

2. [optional] Remove unneeded items from the PRIVATE connection

Some of these may vary depending on your setup.  You should know what you need on your own PRIVATE network; we only needed TCP/IPv4 so here is what we disabled:

  • Open the Network and Sharing Center
  • Click on the connection for the PRIVATE network
  • Click on Properties
  • Uncheck “File and Printer Sharing for Microsoft Networks”
  • Uncheck “Microsoft Network Adaptor Multiplexor Protocol”
  • Uncheck “Link-Layer Topology Discovery Responder”
  • Uncheck “TCP/IPv6”

3. [required] Stop the PRIVATE address from being added as a DNS entry for this host

  • Open the Network and Sharing Center
  • Click on the connection for the PRIVATE network
  • Click on Properties
  • Click on TCP/IPv4
  • Click on Properties > Advanced
  • In the DNS tab, uncheck the box “Register this connection’s addresses in DNS”

4. [required] Remove PRIVATE addresses that were already registered

  • Open Server Manager
  • Click on Tools > DNS
  • Click on the folder for each of your forward lookup zones, and anywhere that you find a PRIVATE address, right-click and remove it
  • Open the folder for each of your forward lookup zones, and in each of the sub-folders also remove any PRIVATE addresses that you find (examine the whole tree)

5. [required] Reboot the machine

This is needed for all of the above changes to take effect.

Corona SDK Volume Sliders

If you are developing mobile apps with Corona SDK that use volume controls, here’s a quick tip for implementing more natural feeling controls.  Assuming that the control is a slider with values from 0 to 100, all it takes is one line of code:

volume = (math.pow(3,sliderValue/100)-1)/2

But since I really like seeing things work myself, I’ve built a very small demo project that you can download and run:

If you would like to read more on why this formula works or why it’s even needed, this page may be interesting for you:

The Tragedy Of The Bug

Wing was sure picking up new things quickly. He was dedicated and he was a fast programmer, although being very fast doesn’t always mean also being very thorough. A few days into his summer job I went out for a coffee break, and immediately upon my return – barely after setting foot into the office door – I was greeted by a very distraught looking Wing.

“We have a problem. Big problem.”

Continue reading

The Second Day

The first day for the new summer student that we hired was fairly mundane: a welcome to the other staff, a walk through the building, handing over of keys and things like that. But the second day was another story – the second day laid the ground for what was to become a memorable summer.

Wing was from China, and had moved to Canada four years prior in order to take classes at a Canadian university. On day number two, Wing showed up to work at 8:52 a.m. By no later than 8:54 a.m. he was logged into his computer and ready to work, looking at my expectantly and awaiting his marching orders. I sighed, since I hadn’t even had a good run at my coffee yet.
Continue reading