Archive for the ‘Google’ Category

FormLess - style agnostic and auto-validating forms

Thursday, January 1st, 2009

Creating HTML forms can be a drag. Validating the form input is even worse. I wrote up a javascript utility to demonstrate how easy and enjoyable it could (should) be to create forms. Check out the demo. You create a form with:

new FormLess('form-container-element-id', items);

where items is an array of objects. Each item requires at least a name and a type, but could also take an array of options or a validation function that gets called to validate the value of that item.

items = [{
  name : 'Gender',
  type : 'select',
  options : ['None of your business', 'Male', 'Female'],
  validate : function(data) {
    return data && data != 'None of your business'
  }
}]

Each time an item’s value changes, the validation function gets called for that item. If a validation function returns false, the item gets marked as invalid. Valid and invalid items can be styled however you please:

.valid {
  background-color : green;
}

.invalid {
  background-color : red;
}

When the form is submitted, each item gets has its validation function called. If all validation functions pass, the submit function gets called along with a key-value object containing the items names and values. This tool has not been tested across browsers - it’s mostly a demonstration of how easy it should be to gather and handle user-entered data. Check out the demo Screenshot of FormLess demo application

Ajaxlights: TCP, bindings, jQ file tree, on-demand js

Thursday, July 3rd, 2008

“TCP sockets” in the browser:

  1. var conn = new TCPSocket(hostname, port)

  2. conn.onopen = function() { alert(‘connection opened!’) }
  3. conn.onread = function(data) { alert(‘RECEIVE: ‘ + data) }
  4. conn.onclose = function(data) { alert(‘connection closed!’) }

  5. conn.send(‘Hello World’);

If you like Cocoa bindings, keep an eye out for the opening of http://objective-j.org/. Check out the demo app, 280 Slides.

jQuery UI is looking more and more promising. A recent file tree component looks great.

Resource/packet management is still a bit of a drag in javascript. Here are two great candidates: module.js and ensure. Alex Russel used similar techniques to push initial dojo load size down to 6k!

Javascript is on the verge of being typed. Ecmascript 4 can now be converted into 1.2 javascript with Mascara. On a related note, here’s a nice writeup/example on the potential usefulness of typed js.

Oh, and on an unrelated note: if you haven’t checked it out yet, go get jott.com. I now twitter only by talking :P

My talk at Google

Thursday, May 22nd, 2008

That’s right - I got to give a lightning talk at the downtown Chicago offices tonight! 

My flash talk on gRavix at Google offices downtown Chicago

It was a flash 9 minute talk on my Google Summer of Code project gRavix with the Globus Alliance.

Thanks a bunch to Borja, Karl and Cord for organizing the event, as well as (of course) google.

Google’s Treasure Hunt Hint Hint

Sunday, May 18th, 2008

Google is hosting another great treasurehunt at http://treasurehunt.appspot.com/. A good friend (and awesome upcoming coder) Lauren and I are working at the library together and we just had a go at it. It turns out there’s a beautiful connection between the answer for any given n*m grid and Pascal’s triangle. Keep your eyes open for those numbers!

Kudos to Lauren for spotting the connection: “Wait isn’t this those, whaddumacallit, triangle numbers?”

                             1
                         1       2
                     1       4       4
                 1       6       12      8
             1       8       24      32      16
         1       10      40      80      80       32
     1       12      60      160     240     192       64
 1       14      84      280     560     672      448       128

Update: After a few premature victory celebrations, we finally got the answer in the form of a short Ruby script. With the following methods…

class Fixnum
  def factorial
    if self <= 0
      return 1
    else
      return self * (self-1).factorial
    end
  end

  def choose n
    ((self.factorial)/(n.factorial*(self-n).factorial))
  end
end

The solution is a simple one-liner.

I’ve Got Code Running on Google

Monday, May 12th, 2008

Google App Engine is awesome.

Repeat. Google App Engine is awesome.

A quick tutorial video, 30 minutes of tinkering and playing around, and I’ve got database code running on Google’s BigTable(!). Go check it out - leave a shout.

Oh, and it turns out - Ruby to Python isn’t that bad after all.

Google I/O Registration - Comes with App Engine Invitation

Monday, May 12th, 2008

I finally registered for Google I/O, and was happy to see that it comes with an invitation to App Engine. Tonight I’m meeting up with a Python friend to show me the ropes.

I’m now intending to port ShareWithMe from rails to python and BigTable for its first, long overdue release.