Category Archives: Posts

374891978230

PHP FizzBuzz Test

Read again about the FizzBuzz test on Joey Devilla’s Global Nerdy blog today and got thinking about the solution. By no stretch of the imagination do I consider my self an amazing programmer, but I thought I should figure out an easy way to do this, should the occasion permit itself to do the test someday.

The basic requirement follows:

“Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.”

If any language is kosher, I chose PHP, and this is what I came up with:

$numbers = range(1,100);
foreach($numbers as $number) {
	if( $number % 15 == 0 ) {
		echo 'FizzBuzz<br />';
	} elseif( $number % 5 == 0 ) {
		echo 'Buzz<br />';
	} elseif( $number % 3 == 0 ) {
		echo 'Fizz<br />';
	} else {
		echo $number . '<br />';
	}
}

After thinking about it, and to be a little closer to the requirements, you could rewrite it like this, just using a for loop. I’m filing this away as the theoretical best practice.

for($number = 1; $number <= 100; $number++) {
	if( $number % 3 == 0 && $number % 5 == 0 ) {
		echo 'FizzBuzz';
	} elseif( $number % 5 == 0 ) {
		echo 'Buzz';
	} elseif( $number % 3 == 0 ) {
		echo 'Fizz';
	} else {
		echo $number;
	}

}

Apple Never Invented Anything

So, yes, if we stick to the basic ingredients list, Apple didn’t invent anything… not the Apple ][, nor the Macintosh, not the iPod, the iPhone, or the iPad… to say nothing of Apple Stores and App Stores. We’d seen them all before, in one fashion or another.

And yet, we can’t escape a key fact: The same chef was involved in all these creations. He didn’t write the code or design the hardware, but he was there in the kitchen — the “executive chef” in trade parlance — with a unique gift for picking ingredients and whipping up unique products.

via Apple Never Invented Anything | Monday Note.

My Nerd Life Has Never Been More Confusing

Is the Nexus 7 an iPad killer? No.

Is it an iPad mini killer? No.

But it doesn’t have to be. Android has — in many people’s mind — offered an alternative to iOS for those who don’t want to be in Apple’s ecosystem.

As an Apple nerd, I ordered a Nexus 7 as an easy way to keep up with what Google’s up to. I didn’t expect to enjoy using it, but I have. I can’t tell if it’s the form factor, the fact that’s it’s still new, or Android 4.1, but I really haven’t found much that this thing can’t do in my normal workflow. I use my iPad for reading, surfing, email and Twitter. That’s about it. The Nexus 7 does all of these things well.

As a card-carrying member of the Apple Fanboy Brotherhood TM, I’ve never found my nerd life so confusing.

I feel the same. It just works. For years I have been tied into Google services, and they all work for me. I’ve also been tied into Apple too. The apps that I use often on my iPad, are there on my Nexus. (Twitter, Facebook, Extreme Skate 2 [Don't knock it. It's awesome], Google Reader, and Spotify)

What I really miss on the iPad is tying into my Apple TV and Airport. But, I hear there are some apps for that…

via On the Nexus 7: My Nerd Life Has Never Been More Confusing — 512 Pixels.

Aurora Shooting – We’ve Seen This Before

Great Op-Ed from Roger Ebert in the NY Times.

That James Holmes is insane, few may doubt. Our gun laws are also insane, but many refuse to make the connection. The United States is one of few developed nations that accepts the notion of firearms in public hands. In theory, the citizenry needs to defend itself. Not a single person at the Aurora, Colo., theater shot back, but the theory will still be defended.

I was sitting in a Chicago bar one night with my friend McHugh when a guy from down the street came in and let us see that he was packing heat.

“Why do you need to carry a gun?” McHugh asked him.

“I live in a dangerous neighborhood.”

“It would be safer if you moved.”

I have a gun. I will be getting rid of it as soon as possible. This is terrible.

via Aurora Shooting – We’ve Seen This Before – NYTimes.com.

Shit Cell Phone Users (Shouldn’t) Say

“BRB, CYA, 2moro, 2nite, GR8, J/K, L8R, LMAO, LOL, OMG, ROTFLMAO, WTF”

WHAT YOU’RE REALLY SAYING: I’m a seventh-grade girl.

THE FIX: Use your words.

THE POINT: You’re an adult addressing another adult. Take an extra three seconds to type out complete words and phrases. You’ll likely discover how generic (and imprecise) these anachronistic sentiments actually are.

Ever-evolving technology, though, must be accompanied by ever-evolving modifications to behavior and social grace. Be accountable. Your word is still your bond, ladies and gentlemen.

via Kempt – Shit Cell Phone Users (Shouldn’t) Say.

What do you tell recent journalism graduates or people trying to start a career in media?

I tell them that they should make stuff. The tools of production are at hand for everyone. I used to hire a lot of young people when I was the editor of Washington City Paper, and you used to have them show you the clips and see where else you worked. Show me what you’ve made with your own bare little hands. That, I think, is super important. People say, “You should’ve been here for the good old days.” I think that’s crazy. Yeah, it’s a little harder, but you have so many more tools at your disposal to story-tell. It’s cool to be in a business where you still learn. You don’t have to be able to code yourself, but you have to know what coding is. You should be able to work in Final Cut Pro. WordPress should be second-nature. I think, in generational terms, being able to produce and consume content at the same time.

Sounds a bit like my resume… ;)

via New York Times columnist David Carr talks media | TPMDC.