Tatva-Artha

meaning of "it"

Archive for the ‘Technology’ Category

Login as multiple users simultaneously for testing

without comments

Ever wondered how to login as two different users at the same time? The situation manifests in any project where you want to be able to test a workflow involving several actors with different roles. The problem is that browsers allow only one login for a given domain at any one time. So, you are required to logout as current_user before logging in as another. One of the solution people use is install multiple browsers.

Read the rest of this entry »

Written by Sharad

May 26th, 2010 at 8:40 pm

Posted in Technology

Disabling form post in google chrome and safari

without comments


So, I found this issue with google chrome and safari web browser and I believe this applies to any webkit based browser. When a form submit is disabled by setting the submit button to disabled=true attribute, the browser is usually expected to prevent submission when the user hits “ENTER” on any of its text fields. This works fine in Firefor, my default browser.

In my rails app, I had to do this to work around this.

We use haml rendering engine for our project and my form looks like this:

- remote_form_for @product_search, :url => product_searches_path, |
  :html => {:method => :post, :id => 'product_search_form'} do |form|

Read the rest of this entry »

Written by Sharad

May 17th, 2010 at 5:36 pm

Testing Cookies in Rails

with one comment

Testing cookies in rails have a few quirks. Some of these are documented here nicely.

I ran into a different one today. In my case, I needed to set a few flashVars variables to pass to flex app (swf file) depending on presence of certain cookies. So, my test involved setting cookies on controller/request and then making sure they appear as flash variables. Here is what I did.

Test:

  should "render last_user_name and auth_token cookies as flashVars on new UserSession" do
    controller.request.cookies[:last_successful_username] = "vriuser1"
    controller.request.cookies[:auth_token] = "12345"
    get :new
    assert_equal "autoLogin=true&username=vriuser1", assigns(:flash_vars)
  end

Controller

  def new
    auth_token = cookies[:auth_token]
    last_username = cookies[:last_successful_username]
    @flash_vars = []
    @flash_vars << 'autoLogin=true' if auth_token
    @flash_vars << "username=#{last_username}" if (last_username)
    @flash_vars = @flash_vars.join("&")
    @user_session = UserSession.new
  end

Until I realized that setting cookies as symbols don’t work. Even though you can read cookies using symbolic-keys, you can’t set them as such in tests. I had to set them as strings.

  should "render last_user_name and auth_token cookies as flashVars on new UserSession" do
    controller.request.cookies['last_successful_username'] = "vriuser1"
    controller.request.cookies['auth_token'] = "12345"
    get :new
    assert_equal "autoLogin=true&username=vriuser1", assigns(:flash_vars)
  end

That did the trick!

Written by Sharad

August 6th, 2009 at 2:50 pm

Posted in Technology

What should a good iteration contain

without comments

Yes, by now, we all know that agile works and what an agile project feels like. It has a set of guidelines like individuals over processes, embrace change and working software. It also recommends process tools like scrum, iteration planning, retrospective. And for developers it is manifested as a set of tools like pair-programming, continuous integration, TDD etc.

I have been on about 10 different agile projects in last 2 years. As a hands on developer, the one area that is of special interest to me is what constitutes an iteration, what deliverables and progress metrics it contains? Sure they all contain a set of stories to be delivered and a working software in the end. However, the risk for over promising and under delivering or vice-versa always exists.

The goal is to promise enough (not under) and deliver on it while still taking on a few unknown. Or put it another way, minimize risk somehow. A quick search on internet couldn’t deliver a convincing set of traits that would do the same and I believe this area can use some refinement.

Here are a couple of things that, in my experience, constitutes a good mix of deliverables that minimizes risk and strives to deliver enough for a given iteration:

Deliverable user stories with varying estimates:
With experience, it is evident that delivering 5 stories worth 2 story-points (2+2+2+2+2=10) is very different from delivering 5+5=10. While 5 is usually broken into sub-stories, the crux here is to have a varying degree of complexity for stories in iteration. This allows for showing progress with long hanging fruits while dedicating more attention to relatively complex story. It also allows for shuffling items and pairs based to developers’ schedule during iteration.

Targeted research items or spikes:
Yes, the obvious here is to not take on too many research tasks. Such tasks have no promised outcomes and are hard to estimate. Here at pathfinder, we make strive to make such tasks as concrete as possible in terms of what approaches are planned and how much time we decide to dedicate for all the effort needed. The story point for such task depend on how much %age of iteration (in terms of time) such task is going to cost. A research task that takes 1 full day in a 2 week iteration will be worth 2 story points if iteration has 10 story points (assuming 10 working days in iteration). In short, identify concrete approaches and time-box such stories. And each iteration should have not more than one or two such stories.

Bug-fix and Refactoring items:
These are good low-cost items, meaning relatively more predictable in outcome. Refactoring stories are relatively easier to estimate accurately and act as filler tasks that can be performed while your pair is unavailable. Or you are sick working from home. Or can be postponed until end of iteration if things seem slipping into next iteration. Having a healthy supply of refactoring stories is not a bad thing, they can be picked up if iteration seems to be under-filled since they don’t require specifications or requirements and are targetted at improving quality of code.

Mid iteration demo and re-balancing:
Mid iteration demos are optional but we find those very helpful in showing on going progress. While scrums allow teams to be current about ongoing changes, mid-iteration demo is more for client update and re-balancing with clients. Showing progress with demo also helps with re-balancing of tasks with clients for the rest of the iteration.

Again the goal is to strive to be as concrete as possible in approach given the unknowns and minimize risk. What are some of the things in your experience that work?

Photo Credit: http://www.flickr.com/photos/27620885@N02/3018033419/

Written by Sharad

July 15th, 2009 at 4:41 pm

Posted in All, Technology

Cisco VPN client setup on ubuntu

without comments

There are a few gotchas when setting up cisco vpn client on ubuntu. For cisco vpn, you need 5 pieces of information from your server.

Host, groupId, groupPassword, Username, password

Usually these pieces of information is supplied by your company (or your vpn host) in the form of *.pcf file. This is a text file that you can open up and read. The passwords are usually stored in this file in encrypted format.

When setting up cisco vpn client on ubuntu, following steps are needed:

Read the rest of this entry »

Written by Sharad

July 3rd, 2009 at 5:39 am

Posted in All, Technology

Tagged with , ,

Detecting Ubuntu Version

without comments

The command is:

lsb_release -a

In order for this to work, you may need to install following package:

sudo apt-get install lsb-core

For any generic unix system, following commands can be used for other information such as machine, hardware, architecture, OS.

cat /proc/cpuinfo

cat /proc/version

uname -a #uname –help for more options

Enjoy!

Written by Sharad

July 3rd, 2009 at 1:26 am

Posted in All, Technology

Tagged with

mysql user management idiosyncracies

without comments

Ok, we are all used to adding new user in mysql with following command:

GRANT ALL ON [db].* TO [user].’%’ IDENTIFIED BY ‘[PASS]‘

So, what happens when you added user before creating the said database. Well, as I found out, mysql won’t complain. Oh well, so what happens if you create the database for the user after the fact. No, it won’t back fix the privileges.

So, I had to delete and recreate the user. Having not done this before, I just tried:

DROP USER [user]

and it worked! The only caveat here is if you added the original user for a particular host, you have to specify host when deleting, like this:

DROP User [user]@’[host]‘

Re-creating the user fixed the problem.

Enjoy!

Written by Sharad

June 5th, 2009 at 7:26 pm

Posted in All, Technology

Tagged with

Twittering my blogs using twitter-tools

without comments

Now that I have been using twitter regularly to post my random thoughts, I also wanted to hook it upto my blog so my new blogs get twitted automatically. As I realize there are tons of plugins for this for my wordpress blogging engine. Without any deeper feature comparision, I went with twitter-tools. I guess this is the most common twitter plugin for wordpress. It was as easy as to install and setup as it can be and seems to have most of the things I can think of. And yes, this is my first blog after that.

Happy blog twittering!

Written by Sharad

June 5th, 2009 at 3:40 am

Posted in All, Technology

Tagged with ,

Hosts file on Windows Vista

without comments

Getting hosts file (for DNS resolution) to work on Windows vista could be aggravating because of all the security and access control that it has in place. In my case, I couldn’t get it to honor the entries in my hosts file. Commonly proposed solutions modifying UAC, and flushing DNS cache didn’t work for me.

Today I found this. stopping/restarting dns cache service worked. Not sure how this is different from flushing-dns but it worked for me.

> net stop dnscache

> net start dnscache

Written by Sharad

June 4th, 2009 at 2:47 pm

Posted in All, Technology

Tagged with , ,

Stick with ERB or move to Haml

with one comment

Haml is gaining popularity in Rails community. It claims higher productivity compared to defacto ERB templating. Not everybody agrees though. I see 2 short-term problem with haml.

  1. ERB is similar to it pre-decessor and hence easier to learn. Compared to JSP etc. ERB is similar, you still see lots of HTML tag with interleaved ruby (or Java). Although verbose, it is closer to how your HTML would finally look like.
  2. If your team has a dedicated HTML programmer (Designer as we may call them). These folks are very good at plain HTML and don’t want the trouble of converting files and having all the plumbing around when working. It is not efficient for them.

Despite this, I see Haml as valid alternative for following reasons:

Read the rest of this entry »

Written by Sharad

June 3rd, 2009 at 3:03 pm

Posted in All, Technology

Tagged with , , ,