The Internet is my snippets database

January 3, 2010

Like everyone who codes for a living I will lift a snippet of code from a website. Usually it’s very generic code — as most code is — and I never give it a second thought. There are only so many ways to iterate an object. A good portion of my Internet code searching is to look for code I need not because I don’t know how to do it from scratch but because I don’t want to have to figure out how to do it from scratch in yet a new language.

Although there is no reason for most programmers to ever write a sort since sorting is built in to everything these days, a sort would be a good example. Back in the day a programmer would find him or herself needing to sort things all the time and you could not make a decent living typing out a brand spanking new quicksort every time you needed one. So you figured out how to write any particular sort only once per language and saved the code for later reuse.

A more modern example would be something like this:

    defaultHandler=function(defaults,params) {
      var i;
      for (i in params) {
          defaults[i]=params[i];
      }
      return defaults;
    }

This powerful little bit of Javascript can be dropped anywhere you need a list of default parameters to be merged with a list of user submitted settings. If you are being efficient about your work you are not going to re-type that code every time you use it; you are going to cut and paste it.

So, like many older professional coders, I have a database with reusable code snippets that I have built up over the course of more than two decades in the business. I have snippets for every sort algorithm you can name: the quicksort, heap sort, bubble sort, merge sort, selection sort, insertion sort ; name and address validators/formatters; date/timezone transformations; list processing; form validation; dynamic tables; and cool tricks. When I need to do something which I have done already a dozen times I simply copy and paste from my vast snippets database, never wasting time re-writing the same code more than once.

That was then; this is now. The problem is that I have all these snippets archived in @formula language, LotusScript, VB, and a bit of Javascript whereas today I need PHP, Perl, Java, and advanced Javascript frameworks like jQuery. I could find the code in my snippets database that does the same thing and then port it over to the new language but why do that when almost any code snippet can be found in under a minute with a deft Google search? I haven’t even used my snippets database in half a decade. The Internet is now my snippets database. I found the above Javascript snippet here, for example, while looking for some sample JavaScript to pass different object types as function parameters.

I haven’t carried a technical reference book to work in almost ten years. I don’t even use them at home anymore. The Internet is now my technical reference library.

  • Share/Bookmark

He who controls the spice controls the universe

March 5, 2009

(Editors note: This piece was originally written in Sept 2007 but was never published; it evidently moved off the front page as a draft and was forgotten. Since the material is  still relevant, I decided not to let a bit of content go to waste. )

*  *  *  *  *

Cory Doctorow in the Guardian on free data sharing:

Since the 1970s, pundits have predicted a transition to an “information economy”. The vision of an economy based on information seized the imaginations of the world’s governments. For decades now, they have been creating policies to “protect” information: stronger copyright laws, international treaties on patents and trademarks, treaties to protect anti-copying technology.

The thinking is simple: an information economy must be based on buying and selling information. Therefore, we need policies to make it harder to get access to information unless you’ve paid for it.

The world’s governments might have bought into the old myth of the information economy, but not so much that they’re willing to ban the PC and the internet.

Cory Doctorow is an activist, science fiction author and co-editor of the blog Boing Boing.

It’s a good article explaining why the Internet was no bubble for a lot of people but I think his premise is off. It’s not so much that the government bought into the “old myth” of how information needs to be secured instead of shared, it’s that they need it to be that way.

The old myth is not a myth. In a spice economy, he who controls the spice controls the universe. In an information economy, he who controls the information controls the universe.

  • Share/Bookmark

The Internet is Dead

August 24, 2007

The Internet is Dead. So says Dallas Mavericks owner and erstwhile internet tycoon Mark Cuban.

We have reached a point of diminishing returns with today’s internet. The speed of broadband to your home wont increase much more in the next five years than it has in the last five years. That is not enough to work as a platform for new levels of applications that will require much, much higher levels of bandwidth.

I think we may have a slight case of sour grapes here and what Cuban really means is that he has come to the realization that his business efforts surrounding the Internet are dead. Ironically, later in the article we found out the Internet is about as dead as the telephone:

Answering questions by email from the Cayman Islands, where he was vacationing with his family and recovering from hip-replacement surgery, Cuban also shared his views on Rupert Murdoch’s acquisition of the Wall Street Journal, Yahoo versus Google, day-trading, his personal investment strategy, and why he won’t pull the plug on his much-criticized business journalism operation, Sharesleuth.com, in which he shorts companies that the site plans to trash-hoping to turn a tidy profit on his pre-publication insider knowledge.

Yes Mark, there are other things to do with the Internet than make Billions of dollars on a gimmick. I could have told you five years ago streaming hi def video to the home was not going to be doable any time soon. Not because I am so smart or anything, but because it is just common sense to look at the size of file that contains a full length movie and then look at the pipe available to shove it through and anyone can see that it will take forever.

  • Share/Bookmark

What a tease

August 23, 2007

It was all just a wet dream. What was I thinking; it’s August, not December.

The cable guy finally showed at about noon yesterday for the “easy install”. He did a good job hooking me up from the pole but left me hangin’ three hours later with me waiting for a phone call from the office letting me know the configuration has been corrected. It was a phone call that never came. Sometimes after four I dozed off for a bit while listening to John Gibson drone on about The Big Story. By the time I called CMA Cable, whose number I had to look up in the regular paper-based phone book, I was informed by the answering service they close up shop at 4:30.

That’s damn inconvenient.

Like I trusted the cable people to be able to roll up in here and deliver high speed cable Internet on the first try. Finally giving up on cable for the day I switched my router back over to DSL. It didn’t work, of course, but it didn’t work the same way it always doesn’t work so I knew I would at least have connectivity to the Internet this morning because in the morning my DSL miraculously starts working. Then like clockwork it goes out every evening. But there is nothing wrong with it I’ve been told.

Anyway, I’m rehashing. Maybe CMA gets it figured out today, maybe not. So far their customer service rating is not looking good.

  • Share/Bookmark