Posts Tagged 'linux'

Pasting Excel Charts in Word via Crossover Linux

Pasting a chart from MS Excel 2007 to Word 2007 will yield a To insert a chart, you must first close any open dialog boxes or cancel editing mode in Microsoft Office Excel error.  This bug is found in Crossover Linux Pro v8.0.0.  I assume that this will also occur in publicly available versions of Wine.

An alternative solution aside from booting to Windows is to use the Paste Special feature. Paste it as a Picture (Enhanced Metafile). This will preserve the vector information of the chart so zooming in and out of the document object wont’ be a problem.

Adding git-svn support from source

Having workstations where you don’t have root access either means contacting support for installation or building your own software from source to get the latest version.

I started using git for code produced in my work. The build was successful with a simple “./configure; make ; make install” series of steps except for supporting access to subversion repositories. It was looking for the perl module SVN::Core to be able to function successfully. Googling about it will land you to the Alien::SVN CPAN module page. Its dependencies can be installed with the standard “install Module::Name” invocation in the CPAN shell. But the main package does not properly install in this environment. It is probably because of the tarball not containing the standard Makefile.PL. It has Build.PL instead. This script generates the Build that compiles the subversion library and its bindings. Then it generates a Makefile from Makefile.PL in the src/subversion/subversion/bindings/swig/perl/native directory. Below is the output of the script:

[Alien-SVN-1.4.6.0]$ ./Build
Running make
Running make swig-pl-lib
make: Nothing to be done for `swig-pl-lib'.
Running /usr/bin/perl Makefile.PL INSTALLDIRS=site
Writing Makefile for SVN::_Core
Writing Makefile.client for SVN::_Client
Writing Makefile.delta for SVN::_Delta
Writing Makefile.fs for SVN::_Fs
Writing Makefile.ra for SVN::_Ra
Writing Makefile.repos for SVN::_Repos
Writing Makefile.wc for SVN::_Wc
Running make
gcc -c  -I$HOME/local/include/apr-0
...

The command /usr/bin/perl Makefile.PL INSTALLDIRS=site generates a build environment to install in /usr. This is not favorable for installation in userspace since you do not have permission to write on that directory. So this command will be rerun /usr/bin/perl Makefile.PL PREFIX=$USERDIR, where $USERDIR is the destination directory you want to.

Now you can successfully clone subversion repositories!

Unix timer utility

Timer microbenchmark

Timer utilities performance on C and Perl of "echo -n"

The Unix time(1) command can only give a precision of 10 milliseconds by default. But being the engineer who goes insane after precision, I made my own script to be able to get differences in terms of microseconds. My first timer utility was made in C but I got stuck with the insane exec(3) family of functions since you need to fork the process to a child for the parent process to create successful timing. Hence I used Perl with the Time::HiRes library which is a wrapper to <time.h> and <sys/time.h>. Later on, I found out that C itself has the system(3) functioin in <stdlib.h>

Performance-wise you can see that C has a much faster runtime when the program was being invoked. But you can see in the graph above that Perl has much more consistent values so its standard deviation is lower than C. When I tested both programs for my data-intensive computing experiments, I get better results with the Perl utility! Perhaps I forgot to do all the magic the system function in Perl does in my C implementation?

Here is my Perl code:

#!/usr/bin/perl

use Time::HiRes qw ( tv_interval gettimeofday );

$start = [gettimeofday];
system @ARGV;

$elapsed = tv_interval ( $start );
print $elapsed, "\n";

Here is my C implementation:

#include 
#include 

#include 
#include 


int main(int argc, char* argv[])
{
	struct timeval start, end, diff;
	gettimeofday(&start, NULL);
	char* command = malloc( sizeof(argv) );
	int i;
	sprintf(command, "%s", argv[1]);
	for( i = 2; i < argc; i++ )
	{
		sprintf(command, "%s %s", command, argv[i]);
	}
	system(command);
	gettimeofday(&end, NULL);
	timersub(&end, &start, &diff);
	printf("%d.%06d\n", diff.tv_sec, diff.tv_usec);
	return 0;
}

Compiz’s Scale plugin in Hardy Heron

I recently upgraded my workstation and Asus EEE to Ubuntu 8.04. To save on screen space on my UMPC, the top button was set to autohide. The bottom panel was removed and replaced by the avant-window-navigator also in auto-hide mode so I can have larger window icons. The final step was modifying the behavior of the scale plugin to activate whenever I place my mouse cursor at the TopRight of the screen.

Compiz session activating the Scale plugin window picker

The Scale plugin of Compiz shows all the thumbnails of opened windows in the current workspace. It looks like something in Mac OS X. The screenshot below shows a sample activation of the Scale plugin window picker using the default Shift-Alt-Up:

To enabled the mouse gesture behavior of the plugin, simple open the gconf-editor program and go to /apps/compiz/plugins/scale/allscreens/options. The initiate_edge name-key pair is by default set as an array so that you can combine multiple-key definitions like Ctrl-Alt-BottomRight. But indicating only a mouse gesture does not work. The workaround I did was to unset the key. Aftewards, it will change from an array list into a text field. Then write TopRight or whatever mouse gesture you want to activate the window picker.

To unset the initiate_edge key-value pair, simple right click on the entry and choose the “Unset Key” option.

Rocks-4.3 kernel to support RTL8111b

To Beshr:

The vanilla install of Rockscluster 4.3 uses version 2.6.9-55EL of the linux kernel. Native support for the Realtek 8111B (r8168) did not come until 2.6.19.xx. I downloaded 2.6.23.13 from kernel.org. After rebuilding the kernel, you have to enable the kernel to map the hardware ID of the device to the correct module (r8169). Here is an archive of the files that I used to build the driver:

rocks-boot-drivers.tar.gz: I added the r8168 directory and modified the subdirs file to build this module for the kernel. It actually does not build anything since there are no entries in the SOURCE variable of the Makefile. Extract this tarball to your Rocks CVS tree ($ROCKS-SRC-ROOT/src/roll/kernel/src/rocks-boot/enterprise/4/images) The following entry was added to drivers/r8168/:


0x10ec 0x8168 "r8169" "RealTek RTL8168B/8111B, RTL8168C/8111C Gigabit Ethernet controller

Where 0x10ec 0x8168 is the hardware ID of my GigE controller.

Then I followed the instructions Creating a Custom Kernel RPM and Adding a Device Driver of the User Guide.

Good luck in building your cluster!

Realtek 8111B GE on Rocks 4.3

I am currently building a new Beowulf cluster using Rocks 4.3. It uses the linux kernel version 2.6.9-55EL. After building the master node, it is time to install on the compute nodes. In normal conditions where everything is smooth, the Rocks kickstart system boots the compute nodes from the network via a dhcp-tftp-kickstart combination. But our Rocks cannot load the network driver. Upon identification of the driver, I downloaded the Realtek 8111B (r8168) from the vendor’s site. I followed the instructions on how to add a custom device driver to the kernel in the rocks documentation. It basically creates an initrd.img file where the kernel modules is installed. But the boot sequence does not load the kernel module properly. I had a couple of email exchanges with Greg Bruno, one of Rock’s developers over the mailing list to diagnose the problem. But building a custom kernel module for the current kernel have not solved the missing module.

Upon further investigation, the driver for my NIC was incorporated into the r8169 module of the vanilla kernel. So I downloaded kernel version 2.6.23.13. First the kernel*.rpm packages must be built and installed in the /home/install rocks repository. Next, the rocks-boot package should be rebuilt in order to incorporate the new kernel. But since Centos uses an older version of the kernel, the hardware id of my NIC is not associated to the r8169 kernel module. So I created a dummy device driver in the rocks-boot repository. In the Makefile, I removed the source file to be compiled and simply added in an entry for my driver in the pcimap.

Now my compute nodes was able to grab the kickstart file and install an entire operating system in 10 minutes!

My Vi-based tools

Ever since I conquered the steep learning curve of the mode-based text-editing of vi (pronounced vee-eye), there is no other text editor for me. It completely binds my hands on the keyboard without the need to use the most (almost!). For those who are not yet into the religious practice of advocating text-editors, here is a short description of vi from Wikipedia:

vi is a screen-oriented text editor written by Bill Joy in 1976 for an early BSD release.

The name vi is derived from the shortest unambiguous abbreviation for the command visual in ex; the command in question switches the line editor ex to visual mode. The name vi is pronounced /vee-eye/,[1] though other pronunciations such as /vaɪ/ are also used.

vi is generally understood to be a modal editor: it operates in either insert mode (where typed text becomes part of the document) or command mode (where keystrokes are interpreted as commands that control the edit session). Typing ‘i’ while in command mode switches the editor to insert mode. Typing ‘i’ again at this point places an ‘i’ character in the document. How the ‘i’ keystroke is processed depends on the editor mode. (From insert mode, pressing the escape key switches the editor back to command mode.)

vi can process compound commands that embed text for insertion in the document. For example, the command:

20i Hello world!

would insert 20 lines in the document with the text ‘Hello world!’. Rather than grapple with the notion of two mode switches while executing this command, some users view vi as a stateful filter. After processing the third character, vi changes state and begins processing input as text to be added to the file. On processing the escape, vi returns to the state in which it is ready to receive a new command.

Whether viewed as modal or stateful, vi’s processing of the same keystroke in different ways depending on the history of the edit session distinguishes it from editors which are generally considered non-modal.

An advantage of a modal editor is that the use of keyboard chords (multiple keys pressed simultaneously, typically a modifier plus a letter key) is reduced or eliminated. Instead, in command mode, single keystrokes serve as commands. This results in the user’s hands not having to take up awkward positions, which some find results in faster work.

I mostly use ViM (Vi Improved), one of the most successful implementations of vi as my default text editor. Version 7 has new features that I have not yet explored such as tabbed buffers, spell check. I am currently reading Hacking Vim: A Cookbook to get the Most out of the Latest Vim Editor to get a deeper understanding of the text editor such as using Vimdiff and integrating tools such as subversion.

Of course it is inevitable that you have to go outside of the text editor such as web browsing (the normal way), programming using big IDEs, etc. For this I have my personal list of Vi plugin implementations:

  • VIMperator is a browser-addon for Firefox, which makes it look and behave like the ViM text editor. It has similar key bindings, and you could call it a modal web browser, as key bindings differ according to which mode you are in.  The shortcuts are very convenient specially if you are cycling through a couple of web pages.  For example 5gt will focus on the fifth tab window in the browser. 20G will jump to line 20 of the web page.  A noticable difference in using the plugin was that all pop-up windows are now opened as tabs.
  • It’s All Text! enables Firefox to edit textareas in an external editor.  Just simply right-click on the text area and select “It’s All Text!”.  Then I configured the plugin to use ViM as the text editor.
  • viPlugin adds vi(m) functionality as a layer on top of an open editor (e.g. CDT, RDT, Aptana, JDT, etc.)

Below is an overview screenshot of the above vi-related tools:

vi-enabled tools