About Me

My photo
Charleston, South Carolina, United States
Computer Science undergraduate student (Senior) at the College of Charleston.

Labels

Thursday, February 24, 2011

Fixing the code exercises

I'm going to quickly point out a new feature that I have added to the blog.  At the top of the page there are now two labels to choose from, "OpenMRS" and "Other". Posts labelled "OpenMRS" will include information specific to my progress in contributing to OpenMRS.  Posts marked "Other" will pertain to other things that I am doing for class which do not pertain to OpenMRS.  This post will be an "Other" post.

  
My current assignment deals with gaining experience with fixing/submitting code and using patches.  The first part of this assignment is to play around with the diff command and to note the differences between using the -u flag and not using the -u flag.  Here is the file that I used to play with.

/* hello.c - a simple program to print out hello
 * to the screen
 */

#include <stdio.h>

int main() {
    printf("Hello, World.\n");
    return 0;
}


The only change I made to this file was to change the period after 'world' to a exclamation point.  Here is the output of running a diff command on these two files with the -u flag.

--- hello.c.punct    2011-02-24 10:12:22.211431001 -0500
+++ hello.c    2011-02-24 10:12:12.931431005 -0500
@@ -5,7 +5,7 @@
 #include <stdio.h>

 int main() {
-    printf("Hello, World.\n");
+    printf("Hello, World!\n");
     return 0;
 }


Here is what the output looks like without the -u flag.

8c8
<     printf("Hello, World.\n");
---
>     printf("Hello, World!\n");



So clearly, the -u flag makes the output of the diff more readable.  Without the -u flag, you are only shown the line that changes.  With the -u, you are shown the context of the changed line (the function it is in).  The -u flag also uses intuitive symbols like the '+' to indicate that the line was added/changed and the '-' to indicate that the line was deleted/changed.  It took a little bit of research for me to understand that the "8c8" indicates the line number of the change.  The '<' symbol indicates that the line was removed and likewise the '>' symbol indicates that the line was added.

Next up for this assignment is to "create a patch file that represents a new file, foo being created with the contents bar."  The way to do this is to use /dev/null as one of the files you're diffing in creating the patch file.  So here is the diff command

diff -u /dev/null hello.c > new-feature.patch

Once this patch file has been created, you can apply the patch and a new hello.c will be created matching the contents of the hello.c that was used in the diff.  If there already is a hello.c in the directory where you are trying to apply this patch you will get an error of sorts that looks like this...

The next patch would create the file hello.c,
which already exists!  Assume -R? [n] Y
Apply anyway? [n] Y
Skipping patch.
1 out of 1 hunk ignored

 

So, a new hello.c was not created and the old one was not modified in any way.  The final part of this assignment is to create a patch for an actual project.  The project being used is Coreutils ("basic file,shell and text manipulation utilities of the GNU operating system").  The assignment pretty much holds your hand through this task so it was pretty easy but I guess it was worth it to create a patch for an actual project.

 






 


 
 

Thursday, February 17, 2011

Computer Science Alumni Symposium

Yesterday, I attended the CofC Computer Science Alumni Symposium.  The event consisted of nine alumni each giving a three minute talk to the students.  The talks were followed by a question and answer session.  The alumni discussed their experiences, their advice for job hunting, and some other miscellaneous issues such as cloud computing.  A couple of the alumni who had created their own start-ups even gave advice on starting a business.

Here's a compilation of some of the advice given during the symposium
  • Interviewers like applicants who are clearly passionate about what they do
  • Interviewers can tell if you are passionate by asking things like...
    • how do you keep up with tech news?
    • who is your favorite tech author?
    • what was the last good tech book you read?
  • Have a side project
    • open source dev
    • mobile dev 
  •  Get an internship (of course)
    • When you are going to an interview, know your stuff b/c they will find out if you don't
    A speaker responded to this last tip - given by a fellow speaker - by stating the following....
    • If you have completed a college computer science program, then you know what you need to know to get a job.  The company who hires you can bring you up to speed on anything you need to know.
    • Don't just apply for every single job opportunity.  Apply for positions at companies that you believe you could be passionate for.
    • College gives you a breadth of knowledge.  Gain a depth of knowledge in an area that interests you (on your own).  And then apply for a job where you can apply that depth of knowledge. 

    Thursday, February 10, 2011

    A bug in our sights

    It's time to make a real contribution to OpenMRS.  My team is going to start by resolving a bug.  I started the search for the bug by querying JIRA for all bugs that were marked "ready for work".  This gave me 174 bugs.  So, I began to read through many of them and read the titles of all of them.  I found that the majority of the bugs required a deep knowledge of OpenMRS that no one in my team possesses.  I only found a handful of bugs which I could understand and seemed doable.  Here's the bug that we are currently going with (bug).

    The bug seems more like a feature request to me but I could be wrong.  The requirement is that when filling out a patient creation form, the user must select a preferred ID for the patient by selecting the corresponding radio button.  Well, after about 10 seconds of Googling I found a way to require a radio button to be selected via JavaScript.

    function checkRadio (patientForm, preferedRBs) {
    var radios = document[patientForm].elements[preferedRBs];
    for (var i=0; i <radios.length; i++) {
    if (radios[i].checked) {
    return true; }
    }
    return false;
    }

    function valFrm() {
    if (!checkRadio("frm1","OpenMRSIDs"))
    alert("You didnt select a preferred ID");
    else
    alert("You selected an id, good job");
    }

    The problem with this is that OpenMRS already has a mechanism in place for alerting the user when they leave a required field blank.  What we need to do is find the code that handles this.  I attempted this for several hours yesterday.  I viewed the source of the web page and viewed the java-script for the page.  Nothing jumped out at me.  The plan for now is to keep searching for how OpenMRS handles this and - if necessary - reach out to the OpenMRS dev team for help.  More on this to come...         

    Tuesday, February 8, 2011

    OpenMRS Bugs



    As I have previously mentioned, OpenMRS uses JIRA for bug tracking.  I had never heard of it before using OpenMRS but I am really liking it.  Its easy to navigate and it has some really nice graphics for statistics such as number of bugs reported vs bugs resolved over time.  So, for the first part of my bug tracking exercise I have been tasked with finding the oldest bug in the issue tracker that has not been resolved.  Here it is (bug).  I have little to no idea of what the bug actually is.  The entire bug description is fifteen words.  The bug was reported by Ben Wolfe.  From what I can tell, he is a key contributor to OpenMRS.  He's always in the IRC, he is often responding on the dev mailing list and I see his signature on many different OpenMRS contributions.  I have a feeling that when core developers write bug reports they write enough so that the other core developers will get the drift of what the issue is and no more.

    This bug was reported back in 2006 so why in the world hasn't there been any action on it?  The priority on it is even 'should'.  The bug report suggests that a research module be created (is this even a bug anyway?).  There are only two comments on it.  Here's an interesting one...

    "PIH has created a number of modules for specific research projects, double entry reconciliation, etc. Would be nice to review each of these and see what could be incorporated into a more generic module to support common research project needs."

    Upon some research, I found that PIH (Partners in Health) also creates electronic medical records systems.  So, the proposed solution is advising to reuse some already implemented code instead of making it from scratch.  Could be a good idea.  But there are no other comments below this one and the status is still marked 'ready for work'.  This bug seems doomed to linger indefinitely in JIRA limbo.

    The next part of the assignment was to create a bug tracker account.  I have had one since the beginning of the project so I'll just say that the process was simple and quick.

    Next up on my bug tracking adventure is to reproduce a bug in OpenMRS.  This one sounded easy enough(Chrome Problem).  The issue is that in chrome, an image which is supposed to be used as a link actually contains two links within the image.  If you click on the top portion of the image, then you will be taken to the correct link but if you click on the bottom portion of the image you will be taken to the link that is under the link that you intended to click on.  This was easy to recreate in chrome and it sounds like a fix is close at a hand.  The bug status is marked 'Code Review'.

    The final task I have is to attempt to triage five bugs in OpenMRS.  This may prove difficult as even the newest bugs have already been prioritized, commented, given a status, given a priority and some even have already been assigned to a developer.  This project seems to have many prolific contributors who jump on bugs quickly.  I'm going to attempt to watch the bug tracker for a little bit (refreshing the page periodically) and if a new bug pops up I will attempt to beat the other developers to it.

    DILIGENCE!

     

    Wednesday, February 2, 2011

    Building Freeciv

    Why in the world am I building a strategy game such as Freeciv?  Its not because I'm bored and enjoy playing Sid Meier's Civilization knock offs.  No, that is what I have Call of Duty for.  Its because its a class exercise/requirement.  Getting the code, building it and running the game took me a total of 58 minutes.  So this was relatively easy compared to readying my computer for contributing to OpenMRS.  Checking the code out was easy enough.  I already have subversion and have been using it often.  Installing the requirements for Freeciv (which were indicated in the install file) was the next step.  The only difficult part about this was figuring out the actual name of what I needed to install.  For example the file states that you need gtk+.  But the name of the actual package is libgtk2.0-dev.

    After getting all the side requirements I next attempted to run the configure script.  This failed a couple of times due to missing dependencies.  One such dependency was 'libcurl'.  So I attempted to sudo apt-get install libcurl but of course this didn't work.  Turns out that the actual name of the package is libcurl4-gnutls-dev.  This is one area where I really think OpenMRS has the right idea for building projects.  OpenMRS uses maven for building the code and it (I believe) handles dependency issues for you.  While building OpenMRS, I did not have to go out and download a single dependency, external to the maven build process.  So in this sense, building the OpenMRS project was more simple.  The hard part for me with OpenMRS was spending hours configuring MySQL and Tomcat.

    After successfully running the configure script I turned my attention to running the make command on the project.  The online reference book displayed a very powerful (and dare I say cool?) way of doing this.  Here is the command

    make 1>/tmp/freeciv-make.out 2>/tmp/freeciv-make.err &

    This command puts the process in the background, redirects error messages to freeciv-make.rr and redirects the rest of the output to freeciv-make.out.  This is such a useful command.  I'm used to scrolling through the terminal, attempting to find the error messages and decipher what went wrong.  I'll have to svn commit this to memory (ha, subversion humor).

    Tuesday, February 1, 2011

    Getting, Building, Running OpenMRS

    Our team is making some real progress in our efforts to contribute to OpenMRS.  One of our members has successfully made contact with an OpenMRS representative.  The rep inquired how many people we have to work on the project as well as what our time line is.  The idea being that he/she will be able to point us towards some work depending on these variables.

    I have successfully checked out the OpenMRS code, built it, and deployed OpenMRS on my local machine.  Setting up my computer to be ready to develop on OpenMRS involved installing many different things that I had no experience with.  Luckily, the OpenMRS website contains a plethora of great information on getting it up and running.

    The instruction guide led me to install a subversion plug-in for Eclipse called Subclipse.  Subclipse made it very easy for me to check out the OpenMRS code straight from Eclipse.  Building the project required the installation of a Maven plug-in for Eclipse called m2eclipse.  After installing the plug-in, I just needed to make a new Maven run configuration for the project with the goal "clean install -DskipTests".


    Installing and running the actual OpenMRS web app was rather difficult.  It involved installing and configuring MySQL as well as Tomcat6.  I had never used Tomcat before, so this part of the process was especially difficult.  But through the scientific process of Googling tomcat errors followed by reconfiguring, I was eventually able to get Tomcat up and going and then able to deploy OpenMRS on it.