Posterous
Arthur is using Posterous to post everything online. Shouldn't you?
3286618267_3db31c4cec_o_thumb
 

Arthur Chang

Under the Waterfall

Found a video on my harddrive taken by my girlfriend Issa while I was taking a picture of the underside of the Staubbach waterfall in Lauterbrunnen, Switzerland.  It's pretty wet, can't believe the flip mino didn't give way.  My camera did fine, it was actually getting hit by a constant stream of water, but the lovely weather sealing of the nikon didn't even flinch.  Below you'll see the photo I took and then a video of us up there.  I'll probably be posting a few of these videos along with the corresponding pictures as well in the next few days.  I'm editing these videos slightly with iMovie '09.  It's pretty neat so far.

 

Nikon D700 | Nikon 20mm F/2.8 | HiTech GND 1.2 | Hoya Circular Polarizer PRO1-D | Feisol CF Tripod | Manfrotto Ballhead | Northface ski jacket

Staubbach

 

Flip Mino HD | Girlfriend | Water everywhere | Church bells in the distance

Posted July 22, 2009
// 0 Comments

The best weekends are those spent helping others

I had a great weekend helping out at the Los Gatos, CA Relay for Life event.  I'm happy my friend Win (Rearden Commerce) and Sonny (Apple) came to help out and volunteer with me.  Between helping out, I was able to take some pictures!  Today, the tear down and cleanup was the hardest.  Going to sleep last night at 4am after getting home shortly before from the event, and then waking up at 7am today to go back out there for the closing ceremony and cleanup, that was tough!  Now everything's cleaned up and stowed away, so I'm going to spend some time looking up some more Natural Language Processing stuff, as well as posting some pictures for you guys to see =)  I must be in a little kid shooting mode, because that's mostly what I took pictures of! You should view all my pictures from the event on Flickr here.

 

 

Survive

 

 

 

Thank goodness little babies can't stand by themselves for long, otherwise these expressions would not exist!

 

 

 

hope in the most sincere innocence

 

 

 

run

 

 

girl

 

 

 

Support

 

 

sweet

 

 

fight back

Tagged  //   photography   relay for life  
Posted July 19, 2009
// 0 Comments

Using GTalk and XMPP to get online friends

Inviting a friend to join you in some real time application is an easy concept, but hard to do from the perspective of that real time app.  You need near instant response from a friend, and what better way than to find a friend who's online and available through protocols used by chat applications?

For a web application that only requires one request to find all online users, and then another request to send an invitation, a full fledged chat client is overkill.  Why build out a fully working client that scales with millions of connections, just to get a buddy list of all your online contacts?  Unless you're building Meebo you really don't need this.

I was trying to solve that very problem, invite online friends!  Google Contacts Data API did give me all the people in a Google contact list, but provided me nothing other than a last update sort.  Last updated contacts wasn't going to cut it.  So I turned to writing a XMPP type request.

Since I'm using the Ruby on Rails framework for this application, I decided to use the XMPP4R gem.  It's probably the most currently developed and up to date gem out there for XMPP and Ruby.

The Roster Helper that is bundled with XMPP4R has a handy way to get your initial buddy list, online and offline users alike.  The problem is, the XML response will not include presence updates.  The roster helper does do some kind of presence updates of it's own, but it was too inconsistent to use.  The correct way to deal with presence as an XMPP client would be to wait on a callback for presence updates.  The initial update would send you all of your online buddy's statuses.

First set up the Jabber client in order to connect to the GTalk XMPP server:

 

        cl = Jabber::Client.new(Jabber::JID::new(email))

        cl.connect('talk.google.com', 5222)

        cl.auth(password)

 

This above creates a new client connection with Google Talk.  The connect command accepts a server, which for GTalk is 'talk.google.com', and the port 5222.  5222 is the standard for most XMPP servers.  Next is the tricky part where you want to write a callback for presence updates:

 

# get the roster

        roster     = Jabber::Roster::Helper.new(cl)

        mainthread = Thread.current

        roster.add_presence_callback { |item,oldpres,pres|

  # code I left out in here populates the name, jid, and presence stuff

  # see the xmpp protocol response docs for specifics on how to get the info

          @list  << {:name => name, :jid => jid, :presence => pres.show.to_s}

        }

 

The roster is first initialized, and we set up a presence callback.  In this callback, we just populate a list of buddies represented as a hash.  Name is their nickname you've given your buddy, the jid is the jabber id.  In GTalk, the jid is actually just their email address.  Presence hash that I put together is actually their availability status, which can be one of the following: away, do not disturb, extended away, nil.  Nil is just available and online.  

Notice that we also save the current thread as our main thread, this is important because we're going to block this thread until we get a few seconds worth of initial presence updates:

        # send initial presence

        cl.send(Jabber::Presence.new.set_show(:dnd))

 

        # continue thread after timeout

        t = Thread.new { sleep XMPP_REQUEST_TIMEOUT; mainthread.wakeup;}

 

        # block thread

        Thread.stop

To get GTalk to start calling the callback function, send an initial presence of the current user.  In this case I'm sending do not disturb using the :dnd symbol.  The next section is where I create a new Thread, that sleeps for a specified number of seconds, then wakes the main thread up.  What does this all mean?  Well keep looking, right after I have that new thread created, I block the current one.  The current thread is the main thread, the one that's doing the fetching of online buddies.  The client's browser is still waiting until the mainthread starts up again.  Notice that we just wait for some amount of seconds before continuing, with NO indication of how many or if we have gotten all of our online buddies.  That is the shaky part.  I noticed that waiting 2 - 3 seconds gets all of my online friends, and using some "loading" graphic on the browser page keeps people from bailing out.  Each callback has it's own thread, so to keep them from spawning over and over again, we need to kill the client connection.

So the main thread blocks right where we say Thread.stop, and continues on to render the page after we wake the main thread up.  After we wakeup the thread, we immediately close the client connection, and go on to rendering the page with your populated list of online friends:

        # kill client connection

        cl.close

 

In the view code, we simply run through the array of friends and display their statuses.  We then allow people to click and invite their friends to the site immediately.

A lot of the code has been stripped out or simplified from what we've actually used, but you'll get the point.  If anyone has feedback, suggestions, or comments, please post them!  I'd love to see how to better solve this problem.

Tagged  //   code   xmpp   xmpp4r  
Posted July 13, 2009
// 4 Comments

More from Lake Como, Italy

Went through a few more pictures from Lake Como.  Nothing that amazing.  I'm getting bored of my old photos, I need to get my camera fixed so I can go shooting again.  Below you'll see a Villa where they filmed parts of Star Wars Episode II, where Queen Amidala is hiding with that whiny Anakin Skywalker.  Also seen in the last scene of James Bond Casino Royale, where Bond shoots Mr. White in the leg.  Cool huh?

 

Villa on the Lake

 

 

_DSC0758

 

 

_DSC0855

Posted July 12, 2009
// 0 Comments

Los Altos - Relay for Life 2009

Somehow I never uploaded these pictures I took at the Los Altos Relay for Life event!  I arrived early to help volunteer with some logistics.  They had everything so well organized that I barely had anything to do.  Then I just went around and took some pictures.  It was a hot morning, even at 9am, but there was a nice breeze coming through.  If you guys have never been to a Relay, I'd highly recommend dropping by a relay near you to help support the American Cancer Society and the cancer survivors and their loved ones.  It gives you a whole new perspective on life, and helps you and hopefully others become more aware of cancer.

 

Here are some photos I took: http://flickr.com/gp/kinetic/q11uF6

Teasers:

American Cancer Society, Relay for Life, Los Altos 2009

 

 

This is family support

 

 

Relay baby

 

 

"dude, check it, that dude's photographing us" "this may be a problem"

 

See all the photos here: http://flickr.com/gp/kinetic/q11uF6

Tagged  //   photography   relayforlife  
Posted July 11, 2009
// 0 Comments

iPhone Photos

After Melissa forwarded me to Greg Schmigel's photography, I wanted a try at it too.  I truly believe that photography isn't about equipment, it's about composition and the process of getting the picture.  You can't make a good picture out of nothing.  There's a difference between a photographer, and someone who wants to be a photographer: The photographer goes and gets the picture, while the other does nothing.  Anyway, I went to SF MOMA and I got a pretty good picture of Melissa looking at a cool painting with real butterflies:

 

sfmoma

 

The big problem I was seeing was editing jpg's, I'm just not good at it.  All my processing experience has been with RAW files, so I'm finding it very difficult to get the same results.  The details are also hard to get out of a JPG.  This one was fun because she's moving while the rest is in pretty stable focus.  Fun shot in black and white.  I love it.

Tagged  //   photography  
Posted July 6, 2009
// 0 Comments

Quick trip through Lake Como and Milan, Italy

After visiting Switzerland, Melissa and I headed over to Milan Italy, and Lake Como for a few days.  Have to go back, but here are a few of the pictures:

 

del porto

 

 

_DSC0427

 

 

_DSC0412

 

 

_DSC0341

Posted July 6, 2009
// 0 Comments

Javascript Closures

I had a good conversation today that brought up Javascript Closures, which was me mostly having no idea what closures were, and the concept just being pretty hard to explain right off the bat.  Anyway, that all lead me to go checkout what closures are.

In a nutshell, Javascript Closures are most likely used in everyone's code already, and the actual technical aspect is not new, it just has a name.  But knowing about closures can be a powerful tool to avoid using gnarly global variables and needing to keep track of variables, parameters, and such that aren't necessarily needed all the time, globally.

A closure can be seen as an inner function within an outer function, where the inner retains the local variables, parameters, and what not of the outer function, even after the outer function has returned.

Some other ways to see it is that the closure can be a stack-frame that's not deallocated when when the outer function returns.

Again, that might be totally confusing, but take a common occurance as an example (example is using JQuery helpers, got the example from here):

function SetClassOnHover(className){
  $
("td").hover(
   
function () {
      $
(this).addClass(className);
   
},
   
function () {
      $
(this).removeClass(className);
   
}
 
);
}

What happens is, when the td gets a hover state, you add and remove the class names that were parameteres initially set in the SetClassOnHover function.  SetClassOnHover has already returned, yet when the hover observer is fired off, you still know the className.  That's how closures work!  Hope that makes sense, leave any comments feedback that you have to help clarify or correct.

Tagged  //   code   javascript  
Posted July 2, 2009
// 0 Comments

Made some card designs for fun

Decided to not code for a bit tonight and made a few designs on Adobe Illustrator CS4.  I'm on my last use of Illustrator's trial period.  I wonder if I'll ever be able to justify buying a license in the future.  Anyway, these are just for fun designs!  Let me know what you think.

   
Click here to download:
Made_some_card_designs_for_fun.zip (62 KB)

Posted June 23, 2009
// 0 Comments

Friends who have my photo as their avatar!

Not a photo of me, but a photo I took of them.  It's fantastic to see them using it!  It means I took a picture of them that they really like =)

Posted June 21, 2009
// 2 Comments