Wednesday, March 25, 2009

Growing up online

An article from the WSJ argues that the workplace environment will change due to kids experience and expectations that they gain from being online.

It's an interesting article and it brings up great points such as...
  • Leaders serve, don't preside
  • Tasks are chosen, not assigned
  • Power comes from sharing not hording
  • Contribution counts more than credentials
It seems these lessons won't be limited to the workplace. Even the slowest-moving arenas like education and politics would benefit, though it will likely require their respective monopolies to open up.

Even before spending a lot of time online, I suspect many people felt it should be this way but the existing authority kept the status quo in place. People were forced to learn in public schools, work as interns to get their first job, and slowly work their way up in politics. We're seeing many counter examples lately - charter schools, kids out of high school starting companies, President Obama's run for president - all examples of change.

Personally, I'm glad the old way of doing things is being challenged. The smaller, faster organization is not only more effective, but more natural. I suspect we'll see that it's less of a change or advance, and more of a return to normalcy.

Posting a Status Update to Twitter

I recently had a need to allow a user to send the a url to twitter as a part of the status update. It seemed like it would be a trivial thing to do (and it was simple), but it was tough to find any information on it online. Most information is about the Twitter API and there are many products that were more heavy-weight than I needed.

This is what I wanted.

1) User clicks on a link which pops up a new window
2) My application would build the update text and include a tiny_url
3) Redirect to Twitter, pre-filling the update field.

In Ruby on Rails, this is what I ended up with. It's not very complicated, so it's probably easier just to see the code. I changed it to a Post model object for this example.

def tweet
@post = Post.find(params[:id])

tiny_url = open("{url_for(@post)}") {|f| }
message = "#{@post.title} #{tiny_url}"

redirect_to "{CGI.escape(message)}"

There are a lot of good ways to update status on Twitter using the Twitter API, but for this project they were more than I wanted. Here are a few that I plan to check out. I haven't used TwitterAuth yet, and a friend recently brought my attention to the site MessagePub.

I plan to try out TwitterAuth for another feature soon.

Wednesday, March 11, 2009

Layering html elements without using 'position' attribute

In a project I was working on, we wanted to layer a small piece of information on top of an image, but we did not want to use positioning - this was due to bugs in IE7 and IE8 that were making it tough to position other items on top or do any scriptaculous effects - like blinds.

It turns out it's quite easy to do, at least in firefox and safari on a mac and IE7 on a PC.

Here's how:

<div style="border: 5px solid yellow; height: 90px; width: 100px; background-color: yellow; margin:0;">
<div style="height: 90px; width: 90px; background-color: blue; float: right; margin:0"></div>
<div style="height: 20px; width: 50px; background-color: red; margin:0; margin-top: -20px; float: right "></div>

The yellow is in the background - the blue div is nested. The red div is on the blue div - floated right (this is optional) with a negative margin.

Try it out on your own or view source.