| |
July 2nd, 2008
If you’ve ever worked in IT, watch The Website Is Down. It’s one of the funniest videos I’ve seen in a while. If it’s not funny to you, you’ve never worked in IT.
July 2nd, 2008
I’m trying a neat workout program, called one hundred pushups. Right now I’m on week 3 of the program. It’s pretty neat so far — only needs about 5 minutes, 3 days a week. If you’ve been thinking about getting in better shape, definitely take a look at this. Literally, if all you’ve ever done is *think* about exercise, this plan is for you. There’s a version for people who can only do 5 pushups, so you’ll definitely be covered.
I’ve also been running between 1 and 2.5 miles every weekday morning. The whole day just cruises by after, and I feel like I’m getting lots more done, just because of a morning workout. I hate waking up early, but I just force myself to get over it, because of how awesome the rest of the day will be. Plus, I can listen to some tunes, or a podcast. Although, I’ve noticed if I start with the podcast, I end up thinking too much and ruining the run.
July 2nd, 2008
As a follow-up to my previous post about how to create comma separated strings from arrays, here’s another array tip.
Let’s take the previous example of the Tags array. Except this time, Tags contains the IDs, which correspond to the textual string.
Tags[0] = 23
Tags[1] = 42
Tags[2] = 314
Rather than write a for-loop to look up each value, let’s pretend we’ve already got a function getTagTextByID(), which accepts the tag ID, and returns the tag text.
Tags = Tags.map(getTagTextByID)
Now tags has the text for the tags.
Map is a fairly common function for operating on arrays. As with the previous tip, Map is available in many languages. PHP offers array_map(), and JavaScript offers Array.map(). Check your favorite language for this function, it makes code cleaner.
As an added bonus, Map has a starring role in MapReduce, Google’s favorite technique. Shouldn’t you get to know Map too?
July 2nd, 2008
I recently realized how much of the art of programming is just lots of little tricks that you pick up along the way. I’m resolving to share these little tricks, in the hopes that others will do the same, either on their blogs or in the comments here.
Here’s one involving an array and building a string of comma separated values.
Let us pretend you have an array called Tags. It contains the tag names as strings.
Tags[0] = "awesome"
Tags[1] = "groovy"
Tags[2] = "existential"
You want to display these as CSV
awesome, groovy, existential
How do you do it? You might think “well, I want to print a tag, then a comma, then the next tag, and so on until I’m done”
for(i = 0; i < Tags.length; i++) {
print Tags[i] + ', '
}
You probably see what’s wrong already. The above code prints
awesome, groovy, existential,
OK. Maybe you could get clever:
first = true;for(i = 0; i < Tags.length; i++) {
if(!first) { print ', ' }
print Tags[i]
}
or
for(i = 0; i < Tags.length; i++) {
if(i == Tags.length - 1) { print ', ' }
print Tags[i]
}
But ouch. Don’t do that.
Many languages provide a built in function for converting arrays into CSV strings. PHP calls it implode(), Javascript calls it Array.join(). Simply put, it returns a string consisting of the values of the array, with a delimiter in between the values.
Tag_string = Tags.join(', ')
Done.
July 2nd, 2008
The confirmation that the iPhone will only be activated in AT&T stores is a sign that a definite concession that was made to get the price cut made. I enjoyed activating my phone from the comfort of my home — it was nice. So, it does reduce the user experience which they’re always going on about.
But, that’s a one-time deal, and it’s not an outrageous expectation of the customers. No one buys a phone because they like the activation process, and it’s not a bolt out of the blue to activate in-store.
Plus, for the long-term, it gets more of the iPhones out to market, while still ensuring a profit in the short-term, and thus continuing to establish Apple as a leading player. Portable computing is obviously where we’re headed, and Apple wants to use its current goodwill to put them in front of the upcoming wave. Overall, it’s a good move for them.
I think the lesson to take away from this is that while short-term luxuries are nice, don’t let that which is not needed prevent you from making a good long-term move.
July 2nd, 2008
Finally installed the very excellent reCAPTCHA plugin for WordPress. I like it when my posts get comments, I don’t like it when the comments are spam. So, if you look at the comment field on this blog, it’s got the reCAPTCHA interface hanging out, keeping us safe. Also, reCAPTCHA helps decode books. Awesome!
You should post a comment — try it out! 
July 1st, 2008
I was coworking at Stardust today, and we got to talking about Agile Development, and the concept of velocity.
Disclaimer: I hate buzzwords. But, these terms have specific meanings, and although it sometimes sounds cheesy, there really is something to this Agile movement.
Basically, velocity is an Agile concept that is a self-calibrating method for estimating how much work can be done in a unit of time.
The trick is that velocity doesn’t really measure the work done, it measures how much estimated time it takes to fill an actual week of working. The trick behind velocity is that you track (per task) the estimated time of completion, and the total amount of estimated work completed in a unit of time (usually a week). As long as the developers who are on the project are always the same ones handling estimates, if they have a tendency to overestimate or underestimate, it will be canceled out after the first week or two. Make sense?
If you haven’t tried Agile development processes, I strongly recommend it. There’s a game that was created to help explain how Agile/XP works, calld The XP Game. It’s a reasonably entertaining way to learn business stuff (better than a pointy haired lecture!), and doesn’t take long.
I’ve still got lots to learn about the finer aspects of applying Agile/XP, but I’m happy to talk with anyone about these ideas — I might learn something new 
July 1st, 2008
I wanted to cover a nifty-looking service that’s just launched — Gnip.
It’s a simple premise: instead of asking every social networking service what’s going on, Gnip will tell you what’s up (they’ll even POST it to your website). They’re going to be — Atlas-style — lifting a huge weight off of social networking providers. I hope they do well.
Of course, in the interests of disclosure, I know Eric.
June 30th, 2008
I came across an article on BBC talking about advances in health care in the past 60 years. Honestly, 60 years isn’t that long, considering the changes that have occurred were previously unknown to humanity. So, a lot of assumptions about things have to change. Getting in a car accident; getting shot; damage to organs; lots of things are becoming undoable. This increases risk taking, and as every investor knows, increases rewards.
60 years ago, you didn’t have people jumping the Great Wall of China on a skateboard. It’s not that it wasn’t physically possible. They had the wood and bits of plastic back then. No laws of physics have changed. But 60 years ago, no one was able to get to this level without killing themselves.
Athletes have always pushed their bodies to the edge. But it used to be that if you crossed the line, there was no going back. You don’t really get a second chance if you break your neck. Or, at least, you didn’t. Now we routinely have people rehabilitating after a broken neck. We’ve given athletes the ability to take bigger risks, make bigger mistakes, and come back smarter and stronger.
And all these because some doctors figured out a few neat tricks. It’s amazing to see how growth in one area improves performance in another.
I can’t wait to see what’s next. It never was like this before.
June 30th, 2008
I’ve been writing a lot of JS lately, and I wanted to take this opportunity to drop some knowledge right here.
Lots of languages have support for some type of for-each-looping. This is great for looping over associative arrays, and even regular arrays, since it’s a bit cleaner than the standard for-loop. Sadly, Javascript doesn’t totally support this. There is a for-each equivalent in JS, but it’s a bad choice to use, since in JS, everything is an object, and objects can be accessed with different notations — you can either do thing.property or thing[”property”]. This notation should throw a hint as to why looping for-each isn’t the same as other language — if you try and loop over everything in an Array, you’ll also get methods that have been assigned to the Array object. Fortunately, Javascript isn’t totally foolish, you won’t get every single method, but you can definitely get some noise. Here’s Mozilla’s explanation of Javascript for-each:
Although it may be tempting to use this as a way to iterate over an Array, this is a bad idea. The for...in statement iterates over user-defined properties in addition to the array elements, so if you modify the array’s non-integer or non-positive properties (e.g. by adding a "foo" property to it or even by adding a method or property to Array.prototype), the for...in statement will return the name of your user-defined properties in addition to the numeric indexes. Also, because order of iteration is arbitrary, iterating over an array may not visit elements in numeric order. Thus it is better to use a traditional for loop with a numeric index when iterating over arrays.
It’s a shame, because a nice for-each is some of my favorite sugar in a programming language. But, I like Javascript enough that I will forgive it for this. I have a suspicion that with some type checking, a more traditional for-each might be possible, but that’s for another time.
I also found the site of a very cool dude, Kent Brewster. Just one example of his awesomeness is found in his article on hardened Javascript. I also really like that he makes notes and lists and saves information; it’s probably one key to his success.
|