Subnet CIDR Coverage Calculator

Oh no…. Not another CIDR calculator, because there really are a bunch.

Allow me to advocate for my app CIDRizer, focused on CIDR space coverage. If one has a CIDR block (account, VPC, etc.), and their engineers take a little slice here and there (of varying mask size and probably not consecutive), how can one actually see what’s left?

Example (CIDRizer input):

10.10.10.0/24   # Overall Account/VPC

10.10.10.32/29  # Jim's tests
10.10.10.128/29 # dev4a
10.10.10.160/28 # Ruth's team

… can be completely covered/represented as follows (CIDRizer output):

Account

CIDR2^(32-n)Avail.FirstLast
10.10.10.0/2425625410.10.10.010.10.10.255

Simplest Coverage CIDR Blocking (SCCB)

CIDR2^(32-n)Avail.FirstLast
10.10.10.0/27323010.10.10.010.10.10.31
10.10.10.32/298610.10.10.3210.10.10.39
10.10.10.40/298610.10.10.4010.10.10.47
10.10.10.48/28161410.10.10.4810.10.10.63
10.10.10.64/26646210.10.10.6410.10.10.127
10.10.10.128/298610.10.10.12810.10.10.135
10.10.10.136/298610.10.10.13610.10.10.143
10.10.10.144/28161410.10.10.14410.10.10.159
10.10.10.160/28161410.10.10.16010.10.10.175
10.10.10.176/28161410.10.10.17610.10.10.191
10.10.10.192/26646210.10.10.19210.10.10.255

Algorithm & Code

I have made the repository public, with an ISC license. This unit test file details what the core algorithm is doing (and can be run via npm test), the rest of the project’s code is simply enabling it as a NodeJS web app.

Run / Deploy

As usual npm start, but there’s a serverless.yml which is what I’ve used to deploy it to my domain CIDRizer.com.

That’s it. My contribution to the CIDR calculator space.

Britishized Slogans of American Companies

In a previous post, I had written (humorously, hopefully) on the contrast between American and European restaurant culture. Recently I’ve been digging through my Google drive and found a list I had written of corporate slogans and their respective translations into British parlance. The humor is all in the contrast IMHO, and how the British are quite particular and politic with any public messaging. My favorite British word: ‘sorted‘. I highly recommend giving it a try in your next professional conversation.

Nike

Original: Just do it

British: Say ‘sorted’ sooner

Apple

Original: Think different

British: Mind other potentially revealing perspectives

KFC

Original: It’s finger lickin’ good

British: So tasteful your fingers will be improperly dirty

Coca cola

Original: Open happiness

British: After opening, feel fresher

McDonald’s

Original: I’m loving it

British: Difficult to detest

Dunkin Donuts

Original: America runs on Dunkin

British: Enjoy an American size portion of caffeine, and with a donut

Autozone

Original: Get in the zone

British: Be immersed and focused with your automobile

Aflac (supplemental health insurance)

Original: Ask about it at work

British: You already have NHS

Quest Diagnostics

Original: The patient comes first

British: First the Queen, then wherever the patient is in queue. Please mind the queue.

Home depot

Original: More saving. More doing.

British: Be efficient with both your money and labor

Tractor Supply Company

Original: For life out here

British: For the Cotswolds or even further…

Wells Fargo

Original: Together we’ll go far

British: Banking so proper you won’t want to try anywhere else.

… how about the other way while we’re here …

Americanized slogans of British companies:

BT (British Telecom)

Original: It’s good to talk

American: Never miss an important post, DM, or stream. Ever.

Tesco (super and express markets)

Original: Every little helps

American: Everything you need, quickly

British Airways

Original: The world’s favorite airline

American: The best airline in the universe

Marks & Spencer (grocer and department store)

Original: The customer is always and completely right

American: We promise you won’t go wrong

Vodafone

Original: Make the most now

American: Grab life and do your thing

Jaguar

Original: Own a Jaguar at a price of a car

American: Get in a Jag now, we’ll figure out the financing (subject to terms and conditions, assuming an 84.7 month lease, medium-good credit score or verbally stated income stream(s), and variable interest financing adjusting every 39 days but not to exceed 200 basis points movement or fall below the predominant Greek 10 years bond rate whichever is higher, subject to cancellation and not available in the states of Idaho, Florida, or Reno Nevada due to ongoing litigation)

Advent of Code 2020: Day 18 Order of Operations (Arithmetic)

As I had written in a previous blog post, I participated in the Advent of Code, 25 programming problems to help improve my skills. I maintained really good momentum through day 20 before holiday activities forced me to pause. (Bonus: I have 5 really solid problems to play with for the next month.)

One of the best aspects of such a side activity is discussing the problems with some of my colleagues, and seeing the different approaches. It was important we treated the discussion as a open and safe space. Of course there are wrong answers, the underlying problem needs to be solved. But there are many different ways to approach and implement the solution including non-optimal ones. It was not meant to be a code golf challenge: rather by experimenting with unfamiliar aspects of our programming languages and solving abstract problems, we deepened our expertise.

I particularly enjoyed problem Day 18. Perhaps you remember your PEMDAS (order of arithmetic operations) from junior high. The Day 18 problem jumbled the notion of PEMDAS and asked to evaluate expressions if operations were evaluated “strictly left to right” or “addition comes before multiplication.” (The horror…)

My solution involved mapping the ‘depth’ of an expression wrt parentheses, then building a method to do the custom expression evaluation. Wrapping the two in iteration, I could then slice, divide, and conquer the expression to obtain the final result. Here’s an example of an expression, where the updated depth map is followed by the sliced expression selected for evaluation and finally replaced. This keeps drilling down until the entire expression has been evaluated:

### addition before multiplication ###

 (3+6+7+9)*(2+(4*7*6+9+3+5)+9+(2+3+7+4+3)+9)+8

"(3+6+7+9)*(2+(4*7*6+9+3+5)+9+(2+3+7+4+3)+9)+8"
 111111111011122222222222221112222222222211100
               4*7*6+9+3+5
               644
              ___
"(3+6+7+9)*(2+644+9+(2+3+7+4+3)+9)+8"
 11111111101111111112222222222211100
                     2+3+7+4+3
                     19
                    __
"(3+6+7+9)*(2+644+9+19+9)+8"
 11111111101111111111111100
  3+6+7+9
  25
 __ 
"25*(2+644+9+19+9)+8"
 0001111111111111100
     2+644+9+19+9
     683
    ___
"25*683+8"

line_value: 17275 

How did my colleagues approach this?

  • David – used a clever regex to find the ‘deepest’ pair of parentheses, then evaluated the contained expression, and repeat as long as there was a ‘(‘ character remaining in the expression.
  • Josh – employed a similar regex recognition, but wrapped his solution in a very tidy `map()` for an almost minified look. By using less memory, Josh is minimizing his electricity consumption and saving the environment!