Ubuntu Linux Switch between Terminal and GUI

GUI –> Terminal: Ctrl+Alt+F1

Termial–>GUI: Alt+F7 

Posted in Uncategorized | Leave a comment

X11 Forwarding on OS X 10.8.2

X11 Forwarding on OS X 10.8.2 – Mountain Lion

January 8, 2013 at 10:41 am | Posted in OS X (Mac) | 4 Comments
Tags: 

To get X11 forwarding to work on Mac OS X 10.8.2, you first need to install the XQuarz X window system, which seems to have been omitted in this release of OS X.

After downloading the XQuarz package, simply install it by double clicking the package icon. After the package is installed, you need to log out and back into your OS X machine.

Add your remove server to host:

On your Mac in iTerm:

$ sudo xhost + remote.server.name

Connect to your remote system with ssh:

On your Mac in iTerm:

$ ssh -X username@remote.server.name

Test X11 by running xclock or another GUI application like gcalctool.

On remote server:

$ xclock

Note when upgrading to Mavericks

After the upgrade to Mavericks, my xhosts settings were reset, and X11 forwarding no longer worked. This fix this you simply need to re-run the xhost command:

$ sudo xhost + remote.server.name

 

Posted in Uncategorized | Leave a comment

set mem=512mb

https://wiki.ubuntu.com/Kernel/KernelBootParameters

Posted in Uncategorized | Leave a comment

Debug Makefile

http://blog.melski.net/2010/11/30/makefile-hacks-print-the-value-of-any-variable/

One of my favorite makefile debugging tricks is this rule for printing out the value of a variable:

 

print-%:
        @echo '$*=$($*)'

Throw this into a GNU make makefile and then print any make variable you like by invoking targets like print-MAKE_VERSION:

 

ericm@chester:/tmp$ gmake print-MAKE_VERSION
MAKE_VERSION=3.81

You can imagine how handy this is when diagnosing issues with your makefiles. Here’s how it works:

  1. print-% defines a pattern rule that matches any target that starts with the charactersprint-.
  2. In the context of a pattern rule, the $* variable expands to the stem of the target, that part which matched the % in the pattern. In my example above, that corresponds toMAKE_VERSION.
  3. GNU make variable expansion rules allow for variable references inside variable names, so$($*) expands first to $(MAKE_VERSION), and finally to the value of the MAKE_VERSIONvariable.

 

Makefile injection with -f

The print-% rule is a slick hack, but it’s a nuisance to have to modify a makefile just to use it. Worse, you might not even be able to modify the makefile. Fortunately, there’s a solution: the -fcommand-line option. You’re probably familiar with it — that’s how you tell gmake to use a different makefile than the default Makefile when it starts. For example, if you have a makefile namedbuild.mak:

 

gmake -f build.mak

What you may not know is that you can use multiple -f options on the command line. GNU make will read each file in turn, incorporating the contents of each just as if they were included with theinclude directive. We can create a simple makefile called printvar.mak containing nothing but our print-% rule, then inject it into any makefile we want like this:

 

gmake -f printvar.mak -f Makefile print-MAKE_VERSION

 

A shell script to save typing

The combination of the print-% rule and the -f command-line option is powerful, but it’s unwieldy — too many characters to type. The solution is a shell script wrapper:

 

#!/bin/bash

filename=""
if [ -f GNUmakefile ] ; then
  filename="GNUmakefile"
elif [ -f makefile ] ; then
  filename="makefile"
elif [ -f Makefile ] ; then
  filename="Makefile"
fi
if [ -n "$filename" ] ; then
  vars=""
  for n in $@ ; do
    vars="$vars print-$n"
  done
  gmake -f $filename -f printvar.mak $vars
else
  echo "No makefile found" 1>&2
  exit 1
fi

Save that in a file called printvars somewhere on your PATH and you can do things like this:

 

ericm@chester:/tmp$ printvars MAKE_VERSION COMPILE.cc
MAKE_VERSION=3.81
COMPILE.cc=g++    -c

 

Advanced make variable diagnostics

Beyond simply printing the value of a variable, GNU make 3.81 has three built-in functions that allow introspection on variables, which you can add to the print-% rule for additional diagnostics.

First is the $(origin) function, which tells you how a variable was defined. For example, if a variable FOO was inherited from the environment, $(origin FOO) will give the resultenvironment. Variables defined in a makefile will give the result file, and so forth.

Next is the $(flavor) function, which tells you the flavor of the variable, either simple orrecursive.

Finally is the $(value) function, which gives you the unexpanded value of the variable. For example, if you have variables like this:

 

FOO=123
BAR=$(FOO)

$(value BAR) will give the result $(FOO), rather than the fully-expanded 123 that you might expect.

With these additions, the print-% rule now looks like this:

 

print-%:
	@echo '$*=$($*)'
	@echo '  origin = $(origin $*)'
	@echo '  flavor = $(flavor $*)'
	@echo '   value = $(value  $*)'

And here’s how it looks in action:

 

ericm@chester:/tmp$ printvars MAKE_VERSION COMPILE.cc
MAKE_VERSION=3.81
  origin = default
  flavor = simple
   value = 3.81
COMPILE.cc=g++    -c
  origin = default
  flavor = recursive
   value = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c

 

 

Posted in Uncategorized | Leave a comment

O_DIRECT with mpicc on with

gcc -D_GNU_SOURCE

dd if=/dev/zero of=/ssd/xczhang/testfile10 bs=1048576 count=512000 oflag=direct conv=fsync

Posted in Uncategorized | Leave a comment

IEEE pdf checker

ps2pdf -dCompatibilityLevel=1.4 -dEmbedAllFonts=true -dPDFSETTINGS=/prepress
Posted in Uncategorized | Leave a comment

Cmake command

cmake . -DCMAKE_INSTALL_PREFIX=/directory-to-install

Posted in Uncategorized | Leave a comment