May 2008
6 posts
Let me enumerate the times…
Sometimes you have to iterate over a collection and count the steps you’ve taken. For example, let’s write a really simple function that returns the index of the leftmost occurrence of a given character in the given string.
def indexof(str, char):
i = 0
for c in str:
if c == char:
return i
i += 1
return -1
Or, we could write it as:
def indexof(str, char):
...
Is it OK to remove code you don't understand?
No.
Should be obvious but we all do it. People are merciless (or, dare I say, reckless) when trimming Other People’s Code. I was reminded of this fact by a recently well publicized occurrence of let’s-just-remove-the-line-that-warns.
First of all let me just say, yes, you should always check your warnings. They are great for catching your own suboptimal programming practices....
Switch to new iTunes Library
Just hold down the option key when launching iTunes and you will be given the option to to use a different music library (or create a new one).
One of my machines has an incomplete version of my music library, and I want to scrap the old library and get a full library from another machine. I first tried replacing the ~/Music/iTunes folder with the full library, but that resulted in some funky...
“No Dashes or Spaces” Hall of Shame →
Sacrificing usability at the altar of laziness.
Reading, it sure is crazy →
I want this shirt bad. Via Dinosaur Comics.