code

There are only 10 types of people in this world...

Those who know binary and those who don't.



















(hee hee)

click here for the javascript binary clock source file

Jessica's Birthday Code

I can't sleep. My sister sent me an email about a site I made for her last year that simply displays whether or not it's her birthday and it got me thinking about why I got interested in computer languages to begin with. The code is so simple and elegant (it happens to be JavaScript - but that doesn't really matter). This is really basic stuff, but I'd thought I'd share the source with a simple explanation. It's really satisfying to me and hopefully someone else.

These four lines get the current month, day, and year (the + 1 at the end of the month is because January is represented by a zero (0) and February is one (1) etc.

var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()

This line writes the current date... month day and year separated by forward slashes "/".

document.write(month + "/" + day + "/" + year)

These four lines get the time. And we see our first IF THEN ELSE statement (there is no else in this case - the else is what it would have been anyway). If the minutes value is less than ten (10) then we add a zero before it (e.g. 12:07 instead of 12:7). This step and the next aren't really needed to generate the "yes" or "no" seen on the site, I just thought it was nice to generate and see the actual time of day in addition to the date.

var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
if (minutes < 10){
minutes = "0" + minutes
}

Here we print the time of day (proceeded by a pipe (|) plus "am" or "pm" based on another IF THEN ELSE statement (IF hours are greater than 11, print pm, ELSE print am - of course, this could easily be reversed... IF hours are less than 12, print am, ELSE print pm).

document.write(" | " + hours + ":" + minutes + " ")
if(hours > 11){
document.write("pm")
} else {
document.write("am")
}

If the month equals 11 and the day equals 23 (i.e. the 23rd of November - her birthday), we print "yes!" in big letters (surrounded by <h1></h1> tags - which translates to "headline 1" in people language).

if(month == 11&&day == 23) {
document.write("<br /><h1>yes!</h1>")
}

Else we write "no :(" Becuase that's sad.

else {
document.write("<br /><h2>no :(</h1>")
}

Link: Is it Jessica's Birthday? - Check it out soon. You only have 21 hours left to see the "yes!".

Nike + Is Bullshitting!

I don't have quite enough data to prove it yet. But I'm positive that the Nike + website is using a simple PHP counter to represent the number of miles run by its members. THAT'S BULLSHIT!.

I first suspected it a few weeks ago when I visited their (crappy flash) site after Stephanie bought one of their trackers. As a web developer, I know that most objects on a website (images, flash, or otherwise) are named one way or another. It just so happens that Opera (a browser) displays the description entered by the coder when you hover your mouse over the object.

What did I see when I hovered my mouse over their mile counter? "UNIX time"

They are using UNIX epoch time's counter to pretend it's the number of miles that have been run by their subscribers!

I just did a website for a company that has a near-real-time stat of their members. And it's REAL. Not something made up by the developers of the website. That's lame Nike.

**UPDATE**
If you go to their site, and refresh the page, it starts at the same counter each time: 146,075,553.

I still think their using UNIX Epoch Time to increment the counter, but probably using some lame math function to A) reduce it (by a million), then B) randomize the start time within a 24 hour period.

Still really lame. Maybe more so than I even originally thought.

Bottom line, incrementing the alleged miles run by your subscribers every second via a non related script (even if the average might be close) ≠ factual representation.

What are you doing RIGHT now?

I mean at the exact time this blog was posted. Nobody reading this, except maybe Viola (although that even seems unlikely), will ever see that again.

UNIX Time

Computers keep time using UNIX Epoch Time - simply described as the number of seconds that have passed since January 1st, 1970. This Friday (the 13th!) it will reach 1,234,567,890. What will happen!? The end of the world? The Second Coming!? To keep you posted, the following is the current UNIX Epoch Time. Stay tuned!

1280488414

Syndicate content