Saturday, December 29, 2012

Find CPU, RAM Size, Cache Size, etc., on Ubuntu Linux

cat /proc/cpuinfo to get the CPU info.
cat /proc/meminfo to get the RAM info.
lscpu to get the L1, L2 cache size.

Tuesday, August 21, 2012

Expected Primary Expression Before '>'

Using gcc 4.x, the above error may be encountered in template code. This discussion is useful for the case. 

Thursday, May 17, 2012

Starting Testing GAE Python App with Webtest

Recently I wanted to write automated tests for my GAE WSGI app (the app is written using web2py, but this detail may or may not be relevant to this post). Behavior-driven design, implemented by, e.g., Lettuce, seems to me as an ideal way to write tests---reasons seem to be well-described in this article by Scott Bellware. In python, Webtest is a good way to test WSGI apps. There are a couple of hurdles:

  • it seems that GAE app.yaml cannot be used to get a WSGI app needed to run Webtest-based tests. One get-around for this hurdle is to use WSGIProxy.
  • another (easier) problem is that Webtest redirects stdout and stderr streams, so the print function cannot be used for debugging. This problem can be circumvented using logging

Friday, May 4, 2012

Managing Multiple .bib Files

I am using latex for multiple papers and to merge the contents into a thesis. I have multiple .bib files, say one for each paper. Unluckily, this does not look like a good situation to be in. There should better be only one .bib file that I should use for all the papers, since then I do not need to worry about duplicates; for example, correction of an entry need not be redone if the entry is duplicated in other bib files.

To extract the subset of the consolidated bib file that a particular paper uses, it is possible to use JabRef.  

Here it is also worth to point out that a situation when a cited reference is missing from the bibliography can be detected using the following (assume "make" calls the latex command, namely: latex doc; bibtex doc; latex doc; latex doc):

make | grep -i "warning--" | less

This at best is a hack, but I could not find a better way till now. In particular, there seems to be no easy way to make missing bibentry as an error.  

Backing Up My Ubuntu Desktop Settings and Files

I am using the method at http://askubuntu.com/a/99171. Will shortly need to move my desktop and then I will update how it went. 

Friday, April 20, 2012

Easy way to install gcc-4.6 on Ubuntu 10.04


sudo apt-add-repository ppa:ubuntu-toolchain-r/test/ubuntu
sudo apt-get update
sudo apt-get install gcc-4.6
sudo apt-get install g++-4.6


From here. The alternative is to download gcc sources and install like this

Thursday, April 19, 2012

svn: making trunk identical to a branch

So, I created a branch, made changes within the branch over a period and periodically kept merging from trunk into the branch. 

Now I want to make the trunk identical to the branch. The best approach for this is as described at http://stackoverflow.com/a/1008805/19501, namely use the three-way merge option:
...you want to merge "FROM trunk@HEAD TO branch@HEAD" with the working copy pointing to trunk. In essence:
"Give me all the changes I'd need to make trunk identical to branch".

Thursday, April 5, 2012

Copy one sparse matrix into another in Python


Copying Xf into features. In this case, Xf is a scipy.sparse.csr_matrix and features is a dok_matrix.

        nz_indices = Xf.nonzero()
        for ix, jx in zip(nz_indices[0], nz_indices[1]):
            features[ix, jx] = Xf[ix, jx]

Notes: 

1. When I checked, the assignment of a 0 to an element of a dok_matrix resulted in a crash. So 0 assignments have to be avoided. 

Tuesday, March 20, 2012

Installing Graphite-Sim

I wanted to use a multi-core simulator for scalability testing of our parallelization. Graphite-sim seems to provide the functionality of simulation. However, there were a series of problems during the installation of Graphite-sim:

When I downloaded and tried to install the 32-bit version on my Ubuntu linux host, the compilation failed. It seems that contrary to the documentation, only the 64-bit version currently works, as can be seen on the forums. I tried to fix the compilation for a few times, but soon it became clear that the code was not fixable by me.


Next, I tried to work out if a 64-bit Debian guest VM can be installed so that the guest can contain Graphite-sim. Indeed this is the way that the Graphite-sim documentation seems to be tested. As per
http://ubuntuforums.org/showthread.php?t=1165598 I ran the command provided to ascertain whether my hardware can support a 64-bit vm. I installed virtualbox-ose package from synaptic.
I downloaded Debian-64 from http://www.debian.org/releases/lenny/debian-installer/ . Initially I tried installing ia64 businesscard version, but the VM would not recognize it as a boot iso. Later Ifound out on one of the forums that amd64 businesscard version should be used.

Next, I installed the debian on the virtualbox, but while doing so, I had to enable "Intel Virtualization Technology" in the BIOS settings to overcome an error "VT-x is enabled but is not operational". Besides, amd64 was not installing on the VMWare virtual machine but could install on Virtualbox.

To summarize, the following steps should work using a Ubuntu Linux host:

  • Install Virtualbox OSE (Open Source Edition). 
  • Enable "Intel Virtualization Technology" in the BIOS settings of the host machine.
  • Download the amd64 (64-bit) businesscard iso.
  • Install the iso as a guest on Virtualbox.
  • Follow up with the instructions at https://github.com/mit-carbon/Graphite/wiki/Getting-Started
and the following would not work (YMMV):
  • Installing on a 32-bit machine
  • Installing ia64 guest on VMware/Virtualbox OSE.
  • Installing amd64 on VMWare player. 
I can see that many of the exact specifications of my configuration are incompletely specified, such as the host hardware, VMWare player version, Virtualbox version, etc. Unluckily I do not have the time to find out and list these here right now.

Monday, March 19, 2012

Latex Issues

I faced an issue while using dvips + ps2pdf to generate pdf from latex. Seems to be this bug (prob in dvips):
http://bugs.ghostscript.com/show_bug.cgi?format=multiple&id=690427

As a getaround, I switched to using dvipdfm.