Parameters string and the Prototype Ajax.Request method

I just noticed something that's a little funny about Prototype 1.6>. I've successfully deployed a number of projects with v1.5 of the library, with all of the improvements I've been reading about with v1.6, I decided to keep up with the times and use the newest version for a project that is very DOM Scripting intensive.

While making a request with either new Ajax.Request or new Ajax.Updater something kept going wrong.

Though the Prototype API Docs were giving examples such as this:

JavaScript:
  1. new Ajax.Updater('products', '/some_url', { method: 'get' });

Firebug was throwing me an error. Hooray for Firebug for doing it's job. Well, that's what I thought at first, until it was time to see what this error was about. Long story short, Google returned nothing...

CODE:
  1. pair has no properties
  2. http://projectname.localhost/js/prototype.js
  3. Line 417
  4.  
  5. [Break on this error]  if ((pair = pair.split('='))[0]) {

It turns out that this error was being thrown by Prototype's toQueryParams method. toQueryParams was being called by Ajax.Base's initialize method...

JavaScript:
  1. if (Object.isString(this.options.parameters))
  2.     this.options.parameters = this.options.parameters.toQueryParams();
  3. else if (Object.isHash(this.options.parameters))
  4.     this.options.parameters = this.options.parameters.toObject();

I said to myself (in the third person) "Nater, you're not passing any params, the request URL is specified elsewhere, AND it's 'friendly' anyway... this seems silly". Looking up a couple of lines it turns out that the default Ajax.Base.options.parameters key is set to an empty string by default. Since toQueryParams() is not happy when it's passed an empty (albeit default) string, what else can we do? The simple answer is to pass an empty object instead!

JavaScript:
  1. new Ajax.Updater('products', '/some_url', { method: 'get' ,parameters:{}});

Voila! Since this seems like it's something that's way too easy to come across, I haven't yet figured out if it's a bug or I'm just missing something that's even more basic.

working with a googleAPIKey and subdomain of localhost

Though all googleAPIKeys work when you run your code at http://localhost or http://localhost/any/sub/directory/, I ran into a bit of a problem with my development server's key once I tried running the site we're developing at http://projectname.localhost/.

It turns out, that Google wanted me to register for an API key for my localhost subdomain.

Now by adding this else if everything is working swimmingly.

PHP:
  1. if ($_SERVER["HTTP_HOST"] == "projectname.dev.naterkane.com"){ //for development server
  2. $googleAPIKey = "ABQIAAAAXDA3g3QE28o3DpCEOJaK7RRbiuQmYjiTrMm7iJcFkjKKtES62BTJwMA8r_9--PPf1lirxSLFF7AjoA";
  3. } else if ($_SERVER["HTTP_HOST"] = "projectname.localhost"){ //for local development subdomain
  4. $googleAPIKey = "ABQIAAAAXDA3g3QE28o3DpCEOJaK7RQd8-PxSvU34sqHMt5i1yPetZP44hRjKyK727DILgg9wBKEDitvz4a0tg";
  5. } else { //catchall for "localhost" and default production domain
  6. $googleAPIKey = "ABQIAAAAzIcwHNZqp-D2TJm3qjeWyxQjCl-yVJ0Kz7eVNz89X4I7MZtKDxSog71ziTBuu1ICptxfQLN7rq9Xag";
  7. }

I can’t figure out how to accept friend requests on this thing

Ning is a pretty neat idea... on paper.
Social Networks Logos
It's a site where you can "roll your own" social networking site targeted at any weird or random idea you can come up. There's enough random stuff out there, and this is the only proof I need.

In the age of there being so many of those already, it seems like putting the creation of a network site into anyone's hands seems like it's ripe for over-saturation and misuse unuse.

As I've been tooling around with Kenny Miller's Interlinky network on Ning, I've started to think to myself... "what's the point of having 83475345 redundant web relationships?"

party peopleLiving in New York, it's easy to find social industry events most nights of the week, there are tons of social groups that exist offline, besides all of the ones you can find on meetup.com. But what do we actually do with all of this networking? When we get together face to face to do stuff drink, we sometimes end up making friends who we talk about work with. Sometimes we make friends who we don't have to talk about work with (but can). And even sometimes a business contact is made and/or a business relationship is formed. Most of the time, it's just social silliness, high-school style, minus the big grass field and the paranoia about the cops coming at any moment.

Some social services do make sense cents

LinkedIn is an example of one of those few sites out there that does actually serve a purpose. I have use it to reconnect with ex-coworkers from 10 years ago, and other people have used it to get in touch with me about hiring me or NaterKane (the business) for interactive work. Since LinkedIn is all about business, work, your professional reputation and trust... folks don't tend to add others as contacts who they don't know, or haven't already worked with.

Many of the other big sites however, have little if no quality control.

I actually wish that facebook kept their business model around targeting college kids. I know the world would be different, however I wouldn't have to deal with people throwing virtual sheep at me for no reason (thanks to the assholes who write useless and what I consider abusive software over at Slide.com) or the unsolicited Vampire/Zombie/Seamonsterboogieman invites reminiscent of those Underworld movies.

Getting Clicky with it

getclicky.com

The other day I just switched from using Google's urchin.js to their slightly shinier ga.js, which I was very happy to see produces less javascript warnings than it's predecessor. There's now only six warnings from the Google folks, which still isn't anything to be excited about.

Coincidently my buddy Florian just pointed me to Clicky, a pretty cool analytics suite put together by Sean and Noah over at Roxr Software Ltd.. After taking a look at Clicky's claims, I'm now thinging about giving Cicky a run for it's money. And by money I mean either free, or the great price of about $2 a month for their "Premium" account. And who in this world needs and can use good analytics software and can't afford a lousy two bucks?

Taking on the Medium Dogs

Clicky claims to crush some of the other popular non-enterprise level players: Google Analytics, SiteMeter, StatCounter, Mint and FeedBurner. I'm just wondering really how valuable some of the features are.

Don't get me wrong, most of these features are pretty badass. But is "Clean, simple, straight forward" a feature that you can really claim you have over your competition? Um.. not really. Additionally they offer "View popular data in a TagCloud instead of boring tables and charts", and though I don't think that's really much of a feature, tagclouds don't really do it for me anyway, so whatever.

I wish I had enough traffic here that making the decision to choose one analytics software package over enough was important. So for me this is what matters most...

Filesize

Clicky comes in at approx 2k, and Google's ga.js comes in at 8k. 'Nuff said.

Well written javascript

Since I try my best to write all of my javascript so it passes JSLint w/o issues, I expect the same out of my libraries. On a related note I've started using the supercool DOMAssistant over Prototype for a number of my client projects, but that's for another post.

As I mentioned before. Google is now only giving me 6 warnings. Three for closeurs that don't return anything and three for referencing undefined properties. I get only one from Clicky, and it's only because they used a ternary operator, which is something I do myself, no biggie.

Javascript-less-ness

Here's the kicker... does it work without javascript being available to the client? Yes!

It seems to me that it's a pretty smart idea to use the old school "load an image if javascript doesn't work" technique. If someone decides to access your content through an interface that doesn't support javascript, whether it be for a security policy, a mobile device, whatever, I'll know! And be able to still get basic tracking/stat information. Good job guys.

Name Taken?

Back in 2005 Damien Katz wrote a little javascript link tracking library called Clicky, though I'm not sure if it has anything to do with the folks at Roxr Software Ltd.

Still adding support for Collections in Flickr

I updated my post about pulling Collections info from a Flickr account. I started to originally post about it a month ago, but had completely forgot as the idea got abandoned from one of my projects. For those who are curious you can find the update here: http://www.naterkane.com/blog/2007/12/01/adding-support-for-collections-in-the-flickr-api/

Clearing the contents of a DOM Element

Sometimes we get lazy, we decide not to care about a couple of K of our user's RAM and we do silly things like replacing the content of a DOM Element with innerHTML. It's not a huge deal, in fact I'm a fan of using the AHAH method of inject pre-formatted XHTML into my document when memory consumption is small or not an issue. AHAH is easy. You can take advantage of all the fancy parsing resources you have with with serverside development, expose no actual data to the client. It's quick and dirty, and that's often times ok. Thing is, when you are writing an application that may ping a webservice and update content on a regular basis (whether it's an AIR application or just something that runs in a browser) it's not cheap. Since you can't have quick, cheap and dirty, you end up paying for the repeted injection of chunks and use of innerHTML through memory loss, and browser performance suffers.

CODE:
  1. var Someobject = {
  2.     clearElement : function(el){
  3.         if (!el) return false;
  4.         var el = (typeof el === 'string') ? document.getElementById(el) : el;
  5.         var i = 0;
  6.         while (el.hasChildNodes())
  7.         {
  8.           el.removeChild(el.firstChild);
  9.         }
  10.         delete el;
  11.         return true;
  12.     }
  13. };

Make sure you know what you're removing

If you're not using firebug or firebug lite, or a webkit nightly. You might want to be able to generate console-like output to give you a clue as to what elements you're actually removing from the DOM. If that's the case, you can just add something like this trace function to SomeObject.

CODE:
  1. var Someobject = {
  2.     trace : function(str){
  3.         if (window.console) {
  4.             return console.log(str);
  5.         } else {
  6.             if (!document.getElementById("clearElementOutput")){
  7.                 var output = document.createElement("div");
  8.                 output.id = "clearElementOutput";
  9.                 document["body"].appendChild(output);
  10.             }
  11.             // dirty
  12.             document.getElementById("clearElementOutput").innerHTML += str + "<br />";
  13.             return true;
  14.         }
  15.        
  16.     },
  17.     clearElement : function(el){
  18.         if (!el) return false;
  19.         var el = (typeof el === 'string') ? document.getElementById(el) : el;
  20.         var i = 0;
  21.         while (el.hasChildNodes())
  22.         {
  23.           //comment this out to suppress output
  24.           this.trace(i++ + "deleting " + el.firstChild.nodeName);
  25.           el.removeChild(el.firstChild);
  26.         }
  27.         delete el;
  28.         return true;
  29.     }
  30. };

A demo file can be found here.

agnostic and deliberate

When I was younger I did alot of talking and thinking and reading and exploring and all the typical stuff college kids do to find themselves. But unlike most college kids, I did most of this work to define my principles when I was in elementary and middle school.

Today i got an email from a guy who saw my profile on Facebook and asked me why I am agnostic. Typically I don't discuss anything that personal with anyone who I am not close with, but I decided to indulge him.

I'm not reposting my response to him to start a debate or conversation with anyone, it's just simply because it's my personal, subjective truth. And I think it says a little bit about who I am as a friend, a developer and a man.

i'm agnostic because i feel that it is self-righteous for a person to claim they know the truth about anything beyond scientific understanding and reasoning.

i do understand that all definitions of g-d have been a tool used by man to explain nature as well as an instrument in teaching morality and healthy ways to live.

all of our moderrn understandings and beliefs (within the past 5000+ years) about what g-d is (or could be) are taught through documents that were written (and rewritten as they saw fit) by men. (archeological record of the practice of hinduism has been traced back more than 10,000 (and in one case approx 30,000) years).

these modern beliefs can't possibly negate and be "more true than" the beliefs of those who lived before these modern beliefs existed.

and since proclaiming that there isn't a g-d or any other external higher being is equally self righteous, i am agnostic.

future of web conferences

This post which was originally written just after the FOWD NYC conference somehow got eaten by the wordpress monster... I have just now found it and decided to repost

So I'd really like to head down to Miami at the end of February for FOWA. IMHO web applications are more interesting that "web design" these days anyway. I have some friends down in Miami that I never get to see. I also generally like to run around and not work for a few days and be social with other geeks, attractive female designers who are too young for me to talk to, and friends 10 years older than me who usually can't guess my age if they don't know it already. (oops, did I just give something away?)

I've decided to make this year (2007-2008) the time for me to spend more of my personal money than I'd care to, to attend a number of conferences. This decision was made in August when I quit my job at Ultra16 and lept back into the world of consulting. So far I've hit the Ajax Experience (a very expensive social event with tons of smart people and good information, and catering) and the Future of Web Design (a $200 social event that was a bit of a mess, followed be Media Temple sponsored drunkenness which was great fun). I am considering FOWA, Web Directions North (a great chance to get some "better than Vermont" snowboarding in this winter, and I already have tickets to SXSW Interactive.

I was a little disappointed in the FOWD conference. I've been thinking about it and I've decided to tell you guys why. The following may read as a rant, or a bit of a slam. If it offends anyone, then I suggest they respond by organizing a conference that isn't thousands of dollars and is also worth attending for more than just having a chance to socialize.

the future of conference formats

FOWD logoA one day conference with one room and one stage sounds to me like more of an overbooked mid-90's style rock festival than a web conference. An enoromous room with tons of echo just adds to the sentiment.
Many of the speakers at FOWD either ran short or long. The notables I think were Josh Davis' dirty mouth (bravo), Jon Snook and the guys from VIRB who's names I can't recall at the moment Ryan Sims & D Keith Robinson. There was a bit more "evangelizing" than I think anyone needed. I can't believe people actually work as corporate technology evangelists. I have alot of respect for folks like Jon Resig, Kevin Hoyt, etc. But isn't having the word "evangelist" on a business card a little creepy? Sorry for the sidetrack...

It seems that a split format with some longer and some shorter sessions happening in parallel and in smaller spaces would have made FOWD a much more enjoyable and possibly more educational experience.

The food available was also pretty bad as well. It wasn't very expensive, however there were ZERO vegetarian options that I could find, so I ended up having to go hike a couple of avenues just to find food that I could eat anywhere near the Javits Center where it was held. Thank goodness we were in New York.

facebook email security

facebook-email-security

I just wanted to say thanks to facebook for spending three seconds to protect my email from potential spam. Using the old "send an encrypted string to a serverside script that generates an image" trick, my contacts on facebook are able to see all of my info, but it's still not succeptable to scraping.

CODE:
  1. <img src="/string_image.php?ct=AAAAAQAQJvT9BrR78jYrS6YLTQhkzgAAABOm0eP9WnzgwUOWanSASFCfsuBdruoGjUA%3D&fp=8.7&state=0&highlight=" border=0/>

generates this

I wonder when / if there will be a vcard/hcard export for your friend's info ala linkedin?

upgrading must be a relative term

Microsoft Windows VistaThis article seals the deal. Well, until I have enough extra cash laying around to get a macbook pro, I'm definately not going to be throwing any money at the purchase of anyone's operating system.

Vista, both with and without SP1, performed notably slower than XP with SP3 in the test, taking over 80 seconds to complete the test, compared to the beta SP3-enhanced XP's 35 seconds.

...

Microsoft admits that the launch has not gone as well as the company would have liked. "Frankly, the world wasn't 100 percent ready for Windows Vista," ...

http://www.news.com/2100-1016_3-6220201.html

On a side note, I wonder if I might be able to install Panther on my old G3 iMac without it running slower than it already does and then throwing and complete and utter hissy fit, probably not.


Nater Kane naterkane personal http://www.naterkane.com LinkedIn Profile Web Technologist personal nater@naterkane.com 1978-09-12 voice 845.234.6698 | fax 707.922.0593
964 Flushing Ave. Brooklyn, NY 11206