Corey Bieber

really simple IT examples and explanations
(and beyond)

Read this first

How to display and flush the DNS Resolver Cache on Windows

The DNS Resolver Cache is a temporary storage cache for DNS lookups on your local machine that allows for efficient resolution of recently accessed URLs to IP addresses.

To display the DNS Resolver Cache in Windows enter the following into the command prompt:

> ipconfig /displaydns

You will get an output that looks something like this:

> ipconfig /displaydns

Windows IP Configuration

   play.google.com
   —————————————-
   Record Name . . . . . : play.google.com
   Record Type . . . . . : 28
   Time To Live . . . . . : 118
   Data Length . . . . . : 16
   Section . . . . . . . : Answer
   AAAA Record . . . . . : 2607:f8b0:4009:802::200e
   …

To flush the DNS Resolver Cache in Windows enter the following into the command prompt:

> ipconfig /flushdns

You will get an output that looks like this:

> ipconfig /flushdns

Windows IP...

Continue reading →


How to display the IPv6 Neighbor Discovery Table in Windows

To display the Neighbor Discovery Table (ND Table) in Windows enter the following into the command prompt:

> netsh interface ipv6 show neighbors

On your local machine, windows maps IPv6 addresses to physical addresses (MAC addresses) in the Neighbor Discovery Table. This is similar to the Address Resolution Protocol cache (ARP cache) which maps IPv4 addresses to physical addresses.

Here we used netsh, a command-line utility that enables you to access and modify your local machine’s networking configurations, to access the Neighbor Discovery Table. Below is a sample output from netsh which identifies the IPv6 address and physical address of the router.

> netsh interface ipv6 show neighbors
Interface 16: Wi-Fi
Internet Address            Physical Address    Type
- - - - - - - - -           - - - - - - -       - - - - fe80::2a80:88ff:efcd:8a41   28-80-88-dc-6a-41...

Continue reading →


How to manually convert an IP address to binary

For IP Address: 182.167.10.48 the complete binary value is:

10110110.10100111.00001010.00110000

Each decimal number in an IP address is represented at a binary octet (8 binary digits). Using the table below for each decimal in the IP address complete the following steps:

Step 1: Start by writing the first number in the IP address (182) in the Decimal column. Divide the Decimal value (182) by 2. Write the dividend (91) in the /2 column. If 2 divides evenly into the first number (i.e., there is no remainder) write a 0 in the Remainder column.

Step 2: Write the dividend from the first row (91) in the Decimal column of the next row. Divide the Decimal value (91) by 2. Write the dividend (45) in the /2 column. Here, there is a remainder of 1. Write a 1 in the Remainder column.

Step 3: Continue this process until you reach the last decimal value.

Step 4: Order the Remainder’s from bottom...

Continue reading →


How to identify the length of time between two dates in R

If you are finding the length of time (in hours) between two columns of dates in a dataframe:

> df$yourLength <- round(int_length(interval( df$yourStartTime, df$yourEndTIme)) / 60 / 60, digits = 2)
[1] [interval lengths]

… or …

If you are finding the length of time (in hours) between two datetimes in standard text form:

> yourLength = round(int_length(interval(“2020-1-1 12:30:00”, “2020-1-2 2:45:00”)) / 60 / 60, digits = 2)
[1] 14.25

Note: This solution requires the lubridate package.

Explanation:

int_length returns the number of seconds between two dates in an interval. You must divide the number of seconds by 60 to get the number of minutes in the interval and again by 60 to get the number of hours in the interval. You could also get the number of hours by dividing the return value of int_length by 120.

Continue reading →


How to convert a Unix timestamp to POSIXct in R (i.e. 1532289300 = 2018-07-22 19:55:00)

If you are converting a column of Unix timestamps in a dataframe:

> df$Your.Times <- as.POSIXct(df$Your.Times, origin = “1970-1-1”)
[1] [POSIXct datetimes]

… or …

If you are converting a single Unix timestamp:

> yourtime = as.POSIXct(1532289300, origin = “1970-1-1”)
[1] 2018-07-22 19:55:00

Note: These solutions require the lubridate package.

Explanation:

In brief, as understood by Unix, time started on January 1, 1970 (the epoch date). The epoch date is represented as “0” Coordinated Universal Time (“UTC”) in Unix systems and all datetimes after the epoch date are represented as the number of seconds that have passed since the epoch date. Therefore, a Unix timestamp is the number of seconds since January 1, 1970 … approximately … leap seconds are not counted. as.POSIXct works be converting the number of seconds since January 1, 1970 into a readable datetime.

Continue reading →


How to read data from an Excel .xlsx file in R

To read directly from a .xlsx in the same directory as your R script:

> data <- read.xlsx(“yourdata.xlsx”)

… or …

To read from a workspace directory containing a .xlsx file:

> wdir = “C:/workspace/yourdirectory”
> data <- read.xlsx(paste(wdir, “yoursubdirectory”, “yourdata.xlsx”, sep=“/”))

… or …

To read from the second sheet of a .xlsx workbook:

> wdir = “C:/workspace/yourdirectory”
> data <- read.xlsx(paste(wdir, “yoursubdirectory”, “yourdata.xlsx”, sep=“/”), sheet = 2)

Continue reading →


How to convert Excel serial date to POSIXct in R (i.e. 42309 = 2015-11-01)

If you are converting a column of Excel serial dates in a dataframe:

> df$yourDates <- as.POSIXct(as.Date(df$yourDates, origin = “1899-12-30”)) [1] [POSIXct dates]

… or …

If you are converting a single Excel serial date:

> mydate = as.POSIXct(as.Date(42309, origin = “1899-12-30”))
[1] 2015-11-01

Note: This solution requires the lubridate package.

Continue reading →


How to get the number of rows in a dataframe in R

> nrow(dataframe)
[1] [number]

View →


How to check if a string contains numbers in R

> grepl(“[[:digit:]]”, yourstring)
[1] TRUE/FALSE

View →