Refactor: Create and use interface from a class using resharper

June 23, 2013 Leave a comment

Press ‘ctrl + shift + R’ to bring up the refactor options for the class.

  1. select ‘extract interface’ – This will extract out interface for the class.
  2. select ‘use base type where possible’ – To replace usages of class with interface.

Username and password specifications : what to avoid

January 11, 2013 Leave a comment

Allow or better promote users to use email address as usernames.

Getting back to windows 7 from ubuntu 12.04 – The good, the bad and, the ugly.

September 29, 2012 Leave a comment
 I just started working as a developer in a windows phone dev. team. The first consequence of this is getting back to windows. After spending nearly four years on ubuntu without dual booting windows, I had to shift back to Windows 7 as my primary OS. Its been more than two weeks, so I can share my experiences and observations so far:

The Good:
  • Better application support
    Starting from note taking application Evernote to backup and folder syncronization applications such as google drive and windows skydrive, their presence on windows is definitely a positive thing. Even though I primarily use command line for git, the client provided by github covers some basic actions.
  • Folder/Files search
    I am impressed with the default search provided by windows through GUI.
  • Better battery life
    Ubuntu sucks the battery out of my thinkpad. Even with applications like Powertop to extend battery life, windows win on this point.
  • A little better wifi support
    I don’t have any complaints with the wifi support on newer Ubuntu versions but some wifi activities such as detecting new network and reconnecting work more seamlessly on windows
The Bad:
  • HUD
    Lots of people using ubuntu have not shifted to unity, but I am a huge fan of unity and with the heads up display support, I never need to lift my hands off keyboard to click on any menu item..
  • Multi pane in files explorer
    It is interesting to see that a tiny feature provided by nautilus of opening extra pane (shortcut: F3) can make your life so much easier. I wish somebody writes that for windows too.
And, the Ugly
  • Command line aka Terminal
    Even after trying hard to avoid command line on windows to do anything, every now and then I find myself on command line (either for using some advanced feature of git or some other thing). And then, I couldn’t do anything except wondering why microsoft can not atleast attempt to provide better command line support (Powershell is equally bad)
Tags: ,

Migrating thunderbird settings/configurations

July 10, 2012 Leave a comment

Recently, I needed to configure thunderbird on my ubuntu. Thunderbird on my
windows partition was already configured. So, I thought all I need to do
is do some kind of export from thunderbird in windows and then, import that. But
I couldn’t find any such feature. I googled and tried to find some alternate. Well,
as it turned out there is a great way to go about this.
Thunderbird keeps a directory suffixed with “.profile” which store everthing
related to a user account. You just need to move/copy that directory.

Step 1:
Copy directory from already configured thunderbird

Users/dushyant.bansal/AppData/Roaming/Thunderbird/Profiles/t14ua45w.default/

Step 2:
Copy directory to ubuntu

/home/dushyant.bansal/.thunderbird/

Modify profiles.ini

[Profile0]
Name=default
IsRelative=1
Path=t14ua45w.default

Start thunderbird and see the magic.

PS: I didn’t like the decision to stop thunderbird development.

ASPLOS, 2012

March 21, 2012 Leave a comment
Last week, I travelled to London to present a poster on our work at ASPLOS, 2012.

People presented their brilliant work in talks and posters. So, I decided to write a post to talk about some of the papers presented there, which I found quite interesting (I would summarise my whole trip in a separate blog post :)). Well, of course my interest in a particular topic is highly related to my understanding in that field.

  • ELI: Bare-metal Performance for I/O Virtualization. Abel Gordon (IBM), Nadav Amit (Technion), Nadav Har’El (IBM), Muli Ben-Yehuda (Technion & IBM), Alex Landau (IBM), Assaf Schuster (Technion) and Dan Tsafrir (Technion)

    Everyone who has worked in virtualization knows that there is a performance overhead which exists with virtualization. While lots of work has been done to reduce computation overhead of virtualization, I/O overhead is still a big issue. As implied by the title, this paper aims to bring I/O performance in a virtualized environment close to bare-metal.
  • Scalable Address Spaces Using RCU Balanced Trees.Austin Clements (MIT), Frans Kaashoek (MIT) and Nickolai Zeldovich (MIT)

    When we study about parallel programming, our focus lies completely on underlying algorithm assuming perfect parallel execution of memory operations. This paper targets the bottleneck due to kernel virtual memory operations which limits the scalability of applications written to take advantage of parallel execution.
  • Understanding Modern Device Drivers. Asim Kadav (University of Wisconsin) and Michael M. Swift (University of Wisconsin)

    If you are intrigued by Linux Kernel, then you will find this paper quite interesting which studies various aspects of device drivers code. It talks about drivers’ interaction with kernel, buses and devices and analyses similarities between various drivers’ code.

Guest Automation with QEMU/KVM

October 14, 2011 Leave a comment

Recently, working on some project, I had to do some benchmarking on qemu. This is nothing but a two step process:

1. run a guest VM with qemu,

2. run some benchmarks inside the guest and collect the results.

Naturally, I looked for options to automate this process. I tried out a bunch of things and it took me couple of days to get to the right tools.

Step 1:

By default, qemu uses SDL to display the VGA output. So, the first step is make this interaction with qemu through stdio. Qemu provides an option for this.

From qemu docs:

-nographic   Normally, QEMU uses SDL to display the VGA output. With this option, you can totally disable graphical output so that QEMU is a simple command line application. The emulated serial port is redirected on the console. Therefore, you can still use QEMU to debug a Linux kernel with a serial console.

So, all you have to do is invoke qemu with -nographic.

qemu -nographic -hda guest.disk

Step 2:

Now that you can interact with your guest (or qemu process) through command line, you have to automate this interaction. The obvious way to do this in python is start the qemu process (with -nographic) with subprocess module and then communicate with that process. But to my surprise, this just didn’t work out for me. So, I looked for some other way.

Later, I found out that the most awesome tool for this kind of jobs is Expect. It is an automation tool for interactive applications written in tcl.

This guide should help you in getting started with Expect. Here is the script to run a guest with qemu using Expect.

#!/usr/bin/expect -f

#starts guest vm, run benchmarks, poweroff

set timeout -1

#Assign a variable to the log file

set log     [lindex $argv 0]

#Start the guest VM

spawn qemu -nographic -hda guest.disk

#Login process

expect “login: ”

#Enter username

send “user\r”

#Enter Password

expect “Password: ”

send “user\r”

#Do whatever you want to do with in the guest VM. ( Run a process and write result to log )

#poweroff the Guest VM

expect “# ”

send “shutdown -h now\r”

Save this as automate_qemu.exp, mark this file as executable and then “./automate_qemu.exp qemu.log”

Tags: , ,

Mailman3, Archiver and Archiver-UI

August 19, 2011 1 comment

  • Mailman3: MM3 sends a message to a local Archiver instance via a subprocess call.
    Status: Updated archive_message() function.

        def archive_message(mlist, message):
        #        """See `IArchiver`."""
            command = 'python /home/dushyant/projects/Archiver/archiver.py -basedir 
                        ~/projects/Archiver/var -listname mlist.fqdn_listname add'
            proc = subprocess.Popen(
                command.split(), stdout= subprocess.PIPE, stderr=subprocess.PIPE,
                stdin = subprocess.PIPE,
                shell=False)
            stdout, stderr = proc.communicate(message.as_string())
            if proc.returncode <> 0:
                log.error('%s: archiver subprocess had non-zero exit code: %s' %
                          (message['message-id'], proc.returncode))
            log.info(stdout)
            log.error(stderr)

    Modifications in configuration schema and updation of pipermail docs needs tobe done.

  • Archiver: Archiver separated out from mm3, generates and maintains sqlite database and whoosh index from the archived messages.
    Status: Basic implementation is finished. Need to discuss with Barry about i18n and language preference of message. Also, requires some minor fixes and code clearing.
  • Archiver-UI: To view and search archives through web interface. This is built on pylons framework. All it needs is access to sqlite database and whoosh index maintained by Archiver.
    Status: More or less finished. Just requires a few improvements in UI.
Tags: ,