The World Through the Eyes of John Brennan
I’ve been using Prototype + Scriptaculous for my current project. It surprises me that I haven’t encountered this problem until just now though.
I noticed some funky behavior today when I tried iterating over an array of values. I have loved Prototype for some time. It’s elegant style, ease of DOM manipulation, and ummm.. it’s style!
However, the behavior I just encountered I don’t care for. I know that Prototype modifies (extends) the builtin objects of Javascript, namely Array and Object. I like the added bang for the buck that I get. But look at this test:
var l_a = ["A","B","C"]; var l_r = ""; for(var l_x in l_a){l_r += l_x + " ";} alert((l_r == "0 1 2 ") + "\n" + l_r);
What do you think that prints out? Chances are you’re wrong. Read the rest of this entry »
A few months ago I built a bookmarklet for the app I’m currently developing for the government. A bookmarklet is essentially JavaScript embedded in a link and placed in your browser’s bookmarks folder or toolbar.
The bookmarklet I build is meant to enable analysts to clip content from the web and add it to a “notebook.” These notebooks are used by analysts to organize information and collaborate. We are also leveraging a triple store backend to connect similar keywords and make assertions which will ultimately allow these analysts to find more relevant information and catch the bad guy. But enough of what I do, let’s get back to the bookmarklet stuff.
So I had originally had all the code inside the link. The real problem with this is that new versions require an “install” and that is not what the web was about. So after some thinking I realized that I could just embed a file in the bookmarklet, so updates can be made seamlessly (or once the file cache expires).
While I was going through this process I came across some strange behavior when trying to attach the script element to the BODY. Another caveat to this approach was that if some arcaic website is still using FRAMESET there actually won’t be a BODY tag. More of a reason to attach it to HEAD.
Code is below:
javascript:function loadScript(scriptURL) { var scriptElem = document.createElement('SCRIPT'); scriptElem.setAttribute('language', 'JavaScript'); scriptElem.setAttribute('src', scriptURL); document.getElementsByTagName('head')[0].appendChild(scriptElem); } loadScript('http://localhost/bookmarklet.js');
San Francisco was great! I got to take part in a great conference, network with other people facing similar challenges and catch up with some of my old friends in the area.
It’s amazing how many people are doing “startups” in that area. I put startups in quotes though because a startup isn’t anything less than a great idea that hasn’t been fully executed yet. Second, I should clarify “amazing” too. Obviously Silicon Valley is the mecca for high-tech startups in the world, but you don’t actually realize what that means until you start to talk to people there. Here in San Diego I can count the number of people I know working on startups on one hand. Ok, maybe 2 hands if you count people wanting to get involved, but haven’t made that first step yet.
While I was catching up with Sameer and Shirin over dinner they were telling me how the majority of their friends (aside from working at Google) work in startups.
That said, here’s a summary of what I got from the Velocity conference. I had a great time and Steve Souders and the O’Reilly team really did a great job putting this together. My only suggestion for next time would be to show some more real examples. For example, I know that in order to scale you need to shard, partition and replicate the databases. You need to profile and test, then profile and test again. Maybe I was looking for more of a workshop, but it was very informative and I hope you return next year!
Code. Design. Explore. is the blog of John Brennan, a web developer/designer, entrepreneur, and avid world traveler. I currently live in San Diego, CA, USA.
My first passion is to create. I want to be part of a successful startup that will empower others. I believe in designing for the user and appreciate other web apps that design for usability.
My second passion is to help. My heart lies in philanthropy and helping others that are just as able, but haven't been afforded the same opportunities only because they were born at a different coordinate on this Earth.
This blog will mostly be around building cool things, although I will surely include my travel experiences when I am abroad. Feel free to subscribe to a specific category if that is only what interests you. And please connect with me. I always enjoy meeting new, interesting people!