Posts on this site are never sponsored.

Convert an IP address to binary

When I was learning the basics about computer networks, the Internet, etc., the concept of binary numbers was an essential building block in understanding concepts such as subnet masks and other nerdy stuff (admittedly, I don’t actually remember how subnet masks work, but that’s beside the point). IP addresses look something like this: but are actually represented by a number such as this: 11000000.10101000.00000000.00000001.

How the heck do they come up with that? Well, each binary string in an IP address has 8 numbers, which we will call “slots”. Slots are read from right to left. A “1” means that the slot is “open” or “on” and a “0” means that the slot is “closed” or “off”. 11111111 means that every slot is open. From right to left, the first slot’s value is 1, and each successive slot’s value is double the previous one (128, 64, 32, 16, 8, 4, 2, 1). To calculate the value of binary string, add up each open slot’s value.

00001100 represents the number 12. Why? The third slot (from the right) is open (because it has a 1) and has a value of 4. The fourth slot is open and has a value of 8. By adding up the value of all open slots, you arrive at 12.

Using only 0’s and 1’s, a set of 8 slots can represent every number between 0 and 255. Each number in an IP address can only be between 0 and 255.

Here’s a calculator to check whether you know how to convert normal IP addresses to binary numbers.

What the heck is Linkie Winkie?

Who knows… but it just crawled my site. There needs to be a Linkie Winkie entry in Wikipedia. By the way, has anybody noticed that Linkie Winkie has trouble with its and it’s:

“We’re not going to tell you much about it, except that its a very altruistic little site and loves to be talked about.”

No bikes allowed at the McDonald’s drive thru

Just so you know, bicycles aren’t allowed at a McDonald’s drive thru. Only motorized vehicles are allowed. Apparently it’s a safety issue. Motorcycles, however, are more than welcome at the drive thru. And does McDonald’s offer bike racks? This then gives the bike rider no choice but to leave his/her bike unattended outside (well, I suppose one could bring one’s bike inside, or are there safety rules against that to?).

Since I refuse to write a personal blog, let’s just say that “somebody” tried to get service at the McDonald’s drive thru while riding a bike and was denied. This made him/her a bit upset… and he/she concluded that not only is McDonald’s bad for one’s body, but also bad for one’s spirit.

Date countdown code in php

This was the first php script that I ever looked up sooooo many years ago. It’s really quite simple. You want to show visitors a countdown in days to a certain event in the future. Since PHP can provide the current time on the server to the very second, simply calculate the desired date (in seconds) and subtract from the server date. More complicated scripts can give a choice between hours, months, or days remaining, can compensate for a server time different than your current time, and can probably dress up the output a bit better.

I’ve spiced this code up a bit by making it a function (thus enhancing reusability), but otherwise, let’s go with simple, shall we?

Here’s the code:

function countdown( $event, $month, $day, $year )
    // subtract desired date from current date and give an answer in terms of days
    $remain = ceil( ( mktime( 0,0,0,$month,$day,$year ) - time() ) / 86400 );
    // show the number of days left
    if( $remain > 0 )
        print "<p><strong>$remain</strong> more sleeps until $event</p>";
    // if the event has arrived, say so!
        print "<p>$event has arrived!</p>";

// call the function
countdown( "Christmas", 12, 25, 2019 );

How about some more fun:

Christmas countdown

Update: I have since made a countdown plugin for WordPress that incorporates the basic concept.

Create pdfs for free

Contrary to what many people believe, you do not need to shell out hundreds of dollars to create PDFs. There are many benefits to having the full-featured Adobe Acrobat (such as the ability to edit a pdf) but if you’re just looking to create a PDF of your school report in Word, you can download a free PDF convertor such as CutePDF. Do a quick Google search for free PDF makers and you’ll find many others.

So what are you waiting for? Go explore the world of free PDF-ing!

And heck, Adobe Acrobat can’t even do things like convert to grayscale.