Jan 242015

This caused me a bit of grief but the solution is somewhat anticlimactic for how long it took me! When I tried to mex compile some C++11 code with the “out of the box” mex compiler I ran into the following errors of the following type:

  1. warning: rvalue references are a C++11 extension [-Wc++11-extensions]
  2. warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  3. no type named ‘shared_ptr’ in namespace ‘std’

And all sorts of weird stuff even though it compiled fine with clang++ on the command line. Essentially it came down to make the following adjustments to the mexopts file:


by adding adding -std=c++11 -stdlib=libc++ to CXXFLAGS:

And then forcing mex to use that file with -f and specifically including the path of the mex.h header file with -I:

Let’s see it in action with Lambda’s, introduced in C++11. Suppose the following is contained in lambda_hello_world.cpp.

Then inside MATLAB we execute the following:

Some references:

  1. http://www.cprogramming.com/c++11/c++11-lambda-closures.html
  2. http://stackoverflow.com/questions/16939734/matlab-mex-clang-c11-thread-undefined-symbols-error
  3. http://www.shawnlankton.com/2008/03/getting-started-with-mex-a-short-tutorial/
Jan 242015

Selenium requires launching a browser on whatever machine is running the tests. Having a display connected to every machine you wish to run Selenium tests on is incredibly cumbersome. To get around this, you can do headless Selenium testing using a program called Xvfb which is a display server implementing the X11 display server protocol. I realize that there is a Xvfb plugin for Jenkins. However, I’ve experimented with it and found it wasn’t completely stable.

First we install Xvfb:

I made a previous post about installing a command line tool as a Linux service, so you could go that route. But if you’d prefer to just use it on the fly then you could do the following:

Add an init.d file to start Xvfb on a particular display variable, in this case 99:

Add the following to the xvfb file:

Then change the permissions on the script and see if it works!

Then in the Manage Jenkins menu, we add an environment variable DISPLAY with it’s value set to :99 in the Jenkins system configurations. I believe by default these variables are inherited by every Jenkins project unless you choose otherwise. If you wish, you can also add ‘/etc/init.d/xvfb start’ to /etc/rc.d/rc.local in order to have it start a server on DISPLAY=:99 every time the machine is rebooted.

Jan 112015

There are scenarios out there where you’d like to run a command as a linux service. Maybe you have a script you would like to run every time Linux is started, who knows. In my case, I had written a Python package which started a web server to listen for HTTP posts and then did something specific with them. It needed to be started every time the machine was restarted. I was using Fedora 16 at the time, not sure how this will hold up on other Linux distros!

Luckily, Linux has a special command, chkconfig,to take some of the pain way. Straight out of the man page:

chkconfig provides a simple command-line tool for maintaining the
/etc/rc[0-6].d directory hierarchy by relieving system administrators
of the task of directly manipulating the numerous symbolic links in
those directories.

There was some debate about what RC actually stands for, https://bbs.archlinux.org/viewtopic.php?id=13052 , but it seems the consensus is run commands. Here is essentially the script that I ended up using, but of course replacing name_of_service and my_command. The important thing is that my_command is visible to root, i.e., my_command is located somewhere like /usr/bin.  In the script we have:

Provides: name_of_service

I’m not sure if it’s necessary, but I also chose this as the name of the script.

The first thing you need to do is place a script like the one above in /etc/init.d./name_of_service

Since I knew what I chose for “my_command” was unique and would only ever be run once, the way I defined stop() works fine. However I don’t like it and I think I’ll refactor that soon. There should be no guess work into what running “service name_of_my_service stop” will actually end up doing. After a bit of digging, there is a way using the PID generated by the service:


I also knew that there was possibilities of my tool exiting with an error when attempting to start/stop/restart (things like permissions, etc), which is why RETVAL=$? is called after each command. If any of those 3 commands are called and exit with a non-zero status, then the entire call will indicate a fail.

Moving forward, we have Linux manage the service:

Done! You could now run:

But if you wanna learn a bit more about these portions:

Check out the references. Essentially we have what we would like to be loaded by the operating system prior to starting our service, and then define the default run levels of the service.


  1. http://www.thegeekstuff.com/2012/03/lsbinit-script/
  2. http://linuxcommand.org/man_pages/chkconfig8.html
Jan 112015

Edit Oct 25, 2017: Thank you to Andy for the latest solution in the comments and for n3rdly confirming this works on Jenkins 2.86

As much as I adore the butler it’s always fun to customize things. The simplest way I found to change the logo is to use a theme plugin:


You can write a CSS template, say theme.css:

and then place pumpkin.png and theme.css into userContent folder in the home directory.

Once the plugin is installed, you will have access to some extra configuration settings in “Configure System” under “Manage Jenkins” that you will need to update:


Jan 072015

So I’ve decided to take the plunge and have begun making repositories for my projects (old and new). I can’t believe I used to code without version control, it’s insanity! During grad school I had a neat project from my course in sparse matrix computation on Google Pagerank that I’m sharing on Github now. In my quest for making cool project names, I’ve dubbed this project LRPR(Low Rank Page Rank) and it can be found here: https://github.com/bee-rock/LRPR. Though it contains only one type of low rank approximation at the moment, perhaps that will change in the future.

The project report can be found here: The inner-outer solver for Pagerank combined with a subsampling scheme

The project starts out with a short introduction to Pagerank, formulated as en eigenvalue problem:

 Ax = x .


We investigate what the effect of a low rank approximation for the transition matrix has on the power method and an inner-outer iteration for solving the Pagerank problem. The purpose of the low rank approximation is two fold: (1) to reduce memory requirements (2) to decrease computational time. We show that we see an improvement in storage requirements and a decrease in computational time if we discard the time it takes to perform the low rank approximation, however at the sacrifice of accuracy.

Jan 042015

I used to have some code that would extract a sample view count from the site: http://circle.ubc.ca/handle/2429/46448. The UBC Thesis collection, namely cIRcle: http://circle.ubc.ca/ is a large collection of dissertations, thesis, etc that students need to submit in order to satisfy a requirement for their degree. On each submission, there is a collection of statistics that monitors how many people have viewed and downloaded your thesis and from which country this was done from. UBC has since changed the way they show the statistics so it stopped working! So I changed the code around a bit so I could still provide a neat little script to do some datamining from a webpage.

I’ll be using two extremely useful Python libraries. One is called Requests, which essentially makes communicating with the internet websites a breeze. The second one is called Beautiful Soup, which makes the data extraction from web pages extremely simple.

I was always a bit confused about when and where try/catch blocks should go. Well, as a rule of thumb:

You should include in your try block a sequence of statements such that, if one of those statements fails, the rest of the sequence should be abandoned. No more and no fewer statements than that.