Sunday, July 15, 2012

Notifty when a computer is on

This function pings the givem IP once in every 10 mins. When ping succeeds it does echo and gives a bubble notification in ubuntu

function notify_when_on {
 ping -w1 $1 &> /dev/null
 RC=$?
 while [ $RC -eq 1 ]
 do
  sleep 600
  ping -w1 $1 &> /dev/null
  RC=$?
 done
 mesg="$1 is ON"
 echo ${mesg}
 notify-send -i /usr/share/icons/gnome/32x32/apps/gnome-terminal.png "${mesg}"
}
Add this function to .bashrc and use it as
notify_when_on 172.24.56.143

Saturday, July 7, 2012

openMPI compile static libraries

./configure --without-memory-manager --enable-static --prefix=$HOME/local


??--without-libnuma

Friday, July 6, 2012

tentative cmake static linking

set(BUILD_SHARED_LIBS FALSE)
set(CMAKE_EXE_LINKER_FLAGS "-static")

Endianness

bash
echo I | tr -d [:space:] | od -to2 | head -n1 | awk '{print $2}' | cut -c6
returns 1 on little-endian machine



python
python -c "import sys;print(sys.byteorder)"
prints little or big

Thursday, July 5, 2012

ssh completion

in .bashrc put
function _ssh_completion() {
    perl -ne 'print "$1 " if /^Host (.+)$/' ~/.ssh/config
}
complete -W "$(_ssh_completion)" ssh
and source it or restart the terminal

If not running interactively, don't do anything

# If not running interactively, don't do anything
[[ $- != *i* ]] && return