Myspace Data Availability in Ruby on Rails

August 22nd, 2008

Like Facebook Connect, Myspace Data Availability enables your site to take advantage of Myspace accounts. For example, you can have your users login to your site using their Myspace accounts, or list their Myspace friends on your own site.

I didnt find an easy step-by-step tutorial even on a basic thing like getting the myspace user id of the logged in user in the external website; so I figure I’ll write this post to help other Rails developers out there who are new to this.

This is an example. First, in your rhtml, you’ll want a link whereby if the user clicks on that, the user can login using his myspace account and then he can see his myspace user_id in your site (if you can get to this step, it’s easy to add more complicated social features).

<%= link_to ‘See my myspace_user_id’, {:action => ’see_my_myspaceuserid’} %>

Now, how to implement ’see_my_myspaceuserid’ ? You probably are looking at this tutorial here:

http://developer.myspace.com/community/myspace/dataavailability.aspx

Dont be daunted when you read over the ‘Access Delegation’ part. It’s actually a basic Oauth authorization mechanism, and the Rails ‘oauth’ gem will help us a lot. Read about the gem here: http://oauth.rubyforge.org/ , or as usual, the best documentation usually are inside the code itself (in my Windows computer it’s here: C:\ruby\lib\ruby\gems\1.8\gems\oauth-0.2.4\lib\oauth\consumer.rb).

So here’s how the controller looks like:

def see_my_myspaceuserid
@consumer = OAuth::Consumer.new(’your OAuth Consumer Key‘, ‘your OAuth Consumer Secret‘, {:site => ‘http://api.myspace.com’, :http_method => :get, :request_token_path => ‘/request_token’, :authorize_path => ‘/authorize’,:access_token_path=>’/access_token’})
@request_token = @consumer.get_request_token
redirect_to @request_token.authorize_url + ‘oauth_callback=display_myspace_user_id’
end

So once the user clicks on the link, he’ll be redirected to myspace to login there. After he logs in there, he’ll be redirected back to your site. Let’s say the callback url is called ‘display_myspace_user_id’, so here’s what it’ll look like:

def display_myspace_user_id
# You can save the @request_token from action ’see_my_myspaceuserid’ and use it here
response = @request_token.get_access_token.get(’/v1/user.xml’)
# Now use REXML::Document to parse response.body, and you’ll get the user_id !
end

How do I know that the parameter to access_token is ‘/v1/user.xml’ ?
Read here: http://developer.myspace.com/community/RestfulAPIs/resources.aspx

That’s it. You can use the access_token to do all sorts of REST API calls to Myspace now!
I hope this helps.

Estimating web development cost

July 26th, 2008

We have been approached by potential clients who ask, “How much for this project?”, or, “How long would this take?”

The problem is, some do not even have specs nor wireframes…

As a developer, what you should do?

First. You can ask clients to draw page sketches and some specs, otherwise you cant quote any fees.
Although this is a very reasonable and responsible approach, this can potentially drive clients away.
Irresponsible developers who can generate estimates based on a 100-word specs, or as simple spec as ‘a clone of site X’, is most probably, well, irresponsible; but they could be more attractive to clients who are shopping for developers

Two. You can be a consultant and together with the client, milk your ideas, and help draw page sketches and write some simple specs. Although this is very noble, this is most probably not good for you.
You have spent lots of time, and you may not get the deal after all.
You should write an NDA before giving up your ideas. After all, you dont want to draw specs, not getting the business, and have that specs sent to a cheaper developer :)

Three. Just like number Two, but charge the client for your consultation. I’m not sure yet if clients are open to this though.

Four. Find clients who already know what they want. In general they are the more serious & more solid budget-wise after all.

What do I suggest out of these four?

In general I suggest number (4). But if it’s not possible, the answer is ‘it depends’.
You should have a mechanism to know what type of client the person is.
Does he represent an established company with solid budget?
Is he a startup with an idea? If he is, does he have the necessary funding?

Note that albeit we want to help as many clients as possible, we have to be concerned about client’s budget. Most of the time, relationship goes messy because the client doesnt have anymore funding…

All in all, I suggest number (2), especially if you have the time and resources. Number (3) sounds an overkill; unless you can give a very good consultation.

Number (1) is good too, since if the client is serious and interested in you, he’ll draw some specs and get back to you. If he doesnt get back, follow up!

OK now with page sketches and specs, you can now answer “how much” and “how long” :)
Still an estimation though. Suggest for Agile Development, the client is probably interested…

Ethical firm (?)

July 22nd, 2008

We are recently contacted by a prospective client, saying:

I know that there are many developers which charge “$X/hour” or “$Y/project” but I am more interested in working with an ethical firm like yours

I’m flattered. In fact, we’re very glad to hear that, although when writing blogs or site contents, we are just being ourselves.

But that must be the impression prospective clients are getting. I remember getting this kind of response from another person too. It feels good!

Managers!

July 5th, 2008

I’m getting busier in both my professional and personal life; this is personal info but… I’m getting married at the end of the year!

Luckily, as the business has been running for more than two years now, we have more cash to hire great people; More importantly however, we have grown great people from within.

And thus we’re assigning managerial positions to these people. People who are not only good with programming, but has self initiatives and whose English communication skill is good

And we also have a resource development manager who takes care of developing newly hired engineeers.

I’m very excited. Looks like we can grow to more than thirty engineers by mid next year!

We’re planning to hire 24 engineers next year actually, in three batches of eight in January, May, and September. We’re gonna hire that many people because there must be employee turnarounds, and we’re also planning to create specialized teams like Facebook apps teams, Drupal and Wordpress teams, etc.

It’s a People business, not an IT business

May 23rd, 2008

Many times in the past several months, we have to turn down new prospective clients because we dont have enough resources. And after we do have the resources available, most of those clients have found someone else.

This is bad. And it is all because our company fails to attract enough talented people.

After much thought and soul searching, I realize that what we’re running is really actually a people business, more so than an IT business. Our company needs to be able to attract, grow, and retain the best talents.

So I started reading Workforce Wakeup Call, 30 Reasons Employees Hate Their Manager, How to Motivate Every Employee, etc. And I’m inspired. I implemented lots of HR strategies that have proven to motivate the employees, and to attract new great talents.

Yes, attract new people, even in this bad world economic weather! In fact, we’re in the process of hiring many more people than we need.

It’s a GREAT investment; even better than investing money in a bullish stock market!
And we never have to turn down new clients anymore!

Built to Last

April 26th, 2008

Everytime I read books / magazines, I am inspired and motivated. I think that’s what books for anyway. I should’ve written a blog for each book I read, but that wouldnt be appropriate to write in this Ruby on Rails outsourcing blog. I have a personal blog but most posts are written in Indonesian.

But I feel compelled to write what I got by reading the book I just bought: Built to Last (I know, it’s a 1990s book, I’m so late huh!)

Basically it says that every great companies have core ideologies and visions, which got me into thinking, what is Kiranatama’s core ideologies? Why does it exist in the first place? Why do we work? Every great company sets ambitious goals, what’s ours?

There must be reasons beyond money and profits…

So here you go. After days of soul searching, here is our Core Values, with ascending importance:
* Honesty and Integrity
* Strong desire to always learn
* Passion to educate and improve the employees, the customers, and the community

The third one is the most important, and that is also our core purpose of existence. We work because we want to improve the lives of other people. Employees receive bigger and bigger salary and nicer facilities; Clients see their businesses grow; that’s what we want.

I have not even told the employees about these ideologies and purposes (of course I will soon). From now on only those share the same values will be hired. And those who do not will be ejected like a virus!

I will also write this in the ‘Company’ section of our website. But I’m gonna wait as we’re redesigning the pages of Kiranatama.com. Next week the new designs should be up.

An overworked entrepreneur?

March 29th, 2008

When I was still in school I read one of Kiyosaki’s most popular books, Rich Dad Poor Dad.

Immediately I do not like the book because it persuades people to NOT work hard, but to get ‘Passive Income’.

But still I was influenced, not only by the book, but also by my friends who believe in the book; “You must become an investor, and let your business become a money generating machine without you actually work too much.”

As my Ruby on Rails outsourcing business grows,  so too the time needed for me for management. I was beginning to work at least 11 hours a day (starting from around 4 am), from Monday to Saturday. Most of my day is spent on managing people.

I am the boss, why should I work at all? Why not I hire professionals and let them do the work for me?

The answer is simple. Because I like my business, and just like many other entrepreneurs, I am an entrepreneur who actually LOVES working. And I’ve learned to enjoy managing people. And I’ve learned that it is FINE to do all the low level work. I’m still a small entrepreneur anyway. Be hardworking, dont follow Kiyosaki!

CSS Programming

March 15th, 2008

I’ve been depending upon an HTMLer to do the our HTML work.

Although he is good, it becomes apparent that we’re being too dependent, and the business just cant scale that way.

I believe everyone at Kiranatama should be empowered. I believe every engineers should be able to write Rails, write unit tests, do QA, deployment, caching, and also write HTML and CSS.

And so Kiranatama decides to train every engineers on HTML and CSS. Materials will come from Bulletproof Web Design.

This way, business can scale, and the skillset of our engineers improve.

Dynamically add method to ActiveRecord class

March 13th, 2008

If you have a Rails application that needs to include models from another Rails application, oftentimes you will want to add features to those methods, but you cannot since you cannot touch the other Rails app’s codebase.

If this is the case, you can use class_eval, which Neeraj explains nicely.

For example, if you want to add an after_save to a class Example :

Example.class_eval do
after_save :somemethod

def somemethod
end
end

Note that you dont wanna put that code under vendor/plugins/ . Instead, put it under a place where it’s executed everytime.

QA, PM, Trainer, etc

March 1st, 2008

I’m too busy. My biggest client has taken too much time out of me, and thus I have less and less time and energy to expand this RoR outsourcing business.

I used to do all the stuffs, from recruiting, training, project-managing, to refactoring code.

See, the problem is that there are several potential clients wanting engineers. We can give them engineers but without enough training, project-managing, and refactoring (QA), I’m just so worried we cant give the quality and productivity we strive for.

We are polishing our company everyday. We built our ‘How-to-Manage-for-Productivity’ doc, proper training procedure, and Ruby on Rails best practices and quality standard document. And, I’ve distributed the roles of training, QAing, etc to people in my company, and thus I’m hoping we can accept new clients in a faster rate!