My Ubuntu 14.04 LTS installation

Here’s how I install and configure Ubuntu 14.04 LTS. My main application right now is writing and running R programs. Additionally, I use Dropbox to share files across systems and Crashplan for off-site backup.

  1. Down the 64-bit CD, burn it to a disk, and install. Agree to use the proprietary software. Give the system a unique name.
  2. Install and configure Dropbox.
    1. Go to the Dropbox website, download the deb, and install it.
    2. Configure selective sync to sync only: github-clones, keepas, todo.
  3. Fix the ipv6 problem. This will cause software center and other apt-get operations to run slowly.
    1. Search for “connecting to archives.ubuntu.com takes too long”
    2. Follow the instructions to disable ipV6. You can copy and paste the commands into a terminal. Follow the directions to allow sites that prefer ipV4 to use ipV4. Also disable ipv6 (though that doesn’t seem to work).
  4. Use the Ubuntu Software Center to install
    1. KeepassX (not Keepass2)
    2. Chromium web browser
    3. vim
    4. git
  5. Install R. Visit r-project.org/bin/linux/ubuntu/README and follow the instructions.
    1. Pick a repository; e.g., the one in Maryland
    2. set the deb. See instructions on r-project website.
    3. Install software r-base and r-base-dev using sudo apt-get install PACKAGE.
  6. Once the Dropbox sync completes,
    1. install the dot files in Dropbox/git-hub-clones/dotfiles/.
    2. start sync of other Dropbox files you want to work on.
  7. Install tmux: sudo apt-get install tmux
  8. Map CAPS LOCK key to another ESCAPE. This makes VIM much more usable.
    1. Install via ubuntu software center: gnome tweak.
    2. Use the “Typing” preference to map the CAPS LOCK to another ESCAPE.
  9. Install CrashPlan. Visit the website, download, install, configure.
  10. Configure Chromium to use my account.
  11. In System Settings > Software & Updates > Other Software, enable software from Canonical Partnersh.
  12. Auto hide the panel (on the left of the screen) and enable workspaces. System Setting > Appearance > Behavior.
  13. Install pathogen.vim. Search and follow directions.
Posted in Uncategorized | Leave a comment

Simple unit testing in C++

There are many complex frameworks available, include cxxtest and the Boost test frameworks. However, a simple approach can also be effective.

In our simple approach, we define a static public method for each class: static void unit_test(). This method runs all the unit tests associated with the class. It throws if it finds an error; otherwise it returns.

As the start of a main program that uses classes, I run a series of tests on each class. The tests look like
CLASS_NAME::unit_test();

In writing the unit_test() methods, there is some repetitive code. For example, I do a lot of scientific computing, and its useful to test if two floating point values a and bare close enough. For this, I defined a function bool close(T a, T b, T tolerance). All these function are static methods in the class Unit_test.

Posted in C++ | Leave a comment

gnu screen how to’s

The GNU screen manual

Setup the ~/.screenrc file such that many lines of stdout are saved, because by default, screen throws away the output. Put these lines in .screenrc
defscrollback 10000

ssh to remote system

Either start a new screen session or reconnect to a prior session
screen #start new session and attach to it
screen -list #list all available session and whether attached or not
screen -dr [pid.sessionname] # connect attached session to me
screen -r [pid.sessionname] # connect detached session to me

Once you are attached to a session, never use the session command by itself, or you start yet another session. It’s easy to get confused.

Once attached to a session, you can open windows (= virtual terminals).

To create a new window and switch to it and start recording in a file everything that displays on the window:
C-a c  # create window and switch to it
C-a ” # list current window numbers for use in script command below
script window-N-MM-DD-HH-MM-PURPOSE.script #save stdout in unique file name

With a screen session, to switch to a different window
C-a N # switch to window N
C-a p  # switch to previous window
C-a n  # switch to next window

To scroll a window, switch to it and enter copy mode (which allows scrolling using the arrow keys)
C-a ESC #start copy mode
<scroll with arrow keys, if running Terminal, can copy to clipboard>
ESC #stop copy mode

NOTE: DO NOT create another screen session from within a screen session. If you do, then follow Marco’s advice

Problem with screen w/in a screen is that there is no way to send
the C-a to the nested screen.  The best way to sort out the problem
is to connect to the nested screen directly using

screen -rd <id of screen>

the ‘d’ parameter will detach the nested screen then in the other
‘nesting’ screen you will have the terminal back.

Posted in linux/unix | Leave a comment

Using the servers

Server names (partial list): juno, monk

To see load on servers, while on campus  browse to
horatio.cs.nyu.edu/ganglia

From home, must login twice and its best to always run screen
ssh lowrance@access.cims.nyu.edu
ssh lowrance@SERVER.cs.nyu.edu
screen [-r]

My ubunutu vm (or the mac os logon) has a script to sync the generated-data
rsync -aP repp-generated-data lowrance@access.cs.nyu.edu:~/

Posted in linux/unix | Leave a comment

Git remote repositories

To clone a remote repository
git clone ssh://roy@metm.org/home/repp/repo.git repo.git

To retrieve changes from the remote and merge into a local branch
git pull REMOTE  LOCAL_BRANCH

To send changes in current branch to the remove
git push

Posted in git | Leave a comment

Branching in git

To create a new branch from the current branch
git branch BRANCH_NAME

to list all branches
git branch

To work in a branch
git checkout BRANCH_NAME

To merge commits in BRANCH_NAME into the master branch
git checkout master
git merge BRANCH_NAME

To delete a branch
git branch -d BRANCH_NAME

To rename a branch
git branch -m CURRENT_NAME NEW_NAME

Posted in git | Leave a comment

Using git as a front-end for Subversion

Source: http://www.viget.com/extend/effectively-using-git-with-subversion/

Checking out a subversion repository to a git repository in your LOCAL_DIR
git-svn clone URL_TO_SUBVERSION LOCAL_DIR

Edit and commit with git as normal. In particular, you can create a new git branch with
git checkout -b FEATURE_BRANCH_NAME [OLD_BRANCH_NAME]
and later merge it back to the master with
git checkout master
git merge FEATURE_BRANCH_NAME

To update and commit back to Subversion
git-svn rebase
git-svn dcommit

Posted in scm | Leave a comment