Archive for the ‘Technology’ Category
Login as multiple users simultaneously for testing

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.
Disabling form post in google chrome and safari

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|
Testing Cookies in Rails
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!
What should a good iteration contain
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/
Cisco VPN client setup on ubuntu
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:
Detecting Ubuntu Version
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!
mysql user management idiosyncracies
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!
Twittering my blogs using twitter-tools
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!
Hosts file on Windows Vista
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
Stick with ERB or move to Haml
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.
- 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.
- 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: