Monday, 10 June 2013

Moving data to S3

ssh into the S3

cd /mnt/externalSD    or so.

scp -r login@localipaddress:/home/me/files ./

works!  Reset the thing to update the list.  Hmmm.

Even better:


sudo sshfs -p 2222 root@192.168.16.20:/ /mnt/phone

Friday, 7 June 2013

Padding to get counter with constant field length


In  [1]: print '%06.0f' % 4
Out [1]: 000004

In  [2]: print '%06.0f' % 401
Out [2]: 000401



Wednesday, 5 June 2013

Adjusting matplotlib spacing vspace


# These prevent two line titles and axis labels overlapping.
matplotlib.rcParams['figure.subplot.hspace'] = 0.4 # 0.3 default.
matplotlib.rcParams['figure.subplot.wspace'] = 0.3 # 0.2 default.

Wednesday, 8 May 2013

--> FOAM FATAL ERROR: face 1 in patch 0 does not have neighbour cell face: 4(12 4 5 13)

This is was caused by topology errors.  I assumed Z was into the page.   See http://www.openfoam.org/docs/user/blockMesh.php

and number nodes accordingly.

screenshots in linux

Use xev to determine the keycode for printscreen.

Edit ~/.fluxbox/keys to include,

118 :execCommand /home/me/bin/screenshot scr

if keycode 118 is appropriate.  Create the following file, ~/bin/screenshot:



#!/bin/bash
# from http://gentoo-wiki.com/TIP_Make_a_Screenshot_with_PrintScreen_Key
# call as screenshot scr  or  screenshot win  or  screenshot area
# Saves to folder, ~/screenshots/,  making it if required.
# Map to printscreen key, keycode 111 by mapping it to F13 in ~/.xinitrc by adding, 
# xmodmap -e "keycode 111 = F13" before fluxbox is called.
# Then add the line, 'None  F13  :execCommand screenshot scr' to ~/.fluxbox/keys

DIR="${HOME}/screenshots"
DATE="$(date +%Y%m%d@%H%M%S)"
NAME="${DIR}/screenshot-${DATE}.png"
LOG="${DIR}/screenshots.log"

# Check if the dir to store the screenshots exists, else create it: 
if [ ! -d "${DIR}" ]; then mkdir "${DIR}"; fi

# Screenshot a selected window
if [ "$1" = "win" ]; then import "${NAME}"; fi

# Screenshot the entire screen
if [ "$1" = "scr" ]; then import -window root "${NAME}"; fi

# Screenshot a selected area
if [ "$1" = "area" ]; then import "${NAME}"; fi

if [[ $# = 0 ]]; then
  # Display a warning if no area defined
  echo "No screenshot area has been specified. Screenshot not taken."
  echo "${DATE}: No screenshot area has been defined. Screenshot not taken." >> "${LOG}"
else
  # Save the screenshot in the directory and edit the log
  echo "${NAME}" >> "${LOG}"
fi


Thanks blogger, for the mangling.  This was from the gentoo-wiki, 
as mentioned above.

Monday, 29 April 2013

executing shell commands from python

p = subprocess.call(['/bin/bash', '-c', 'ls *.pdf'], stdout=sub.PIPE, stderr=sub.STDOUT))

This is blocking.  For non-blocking use,

p = subprocess.Popen(['/bin/bash', '-c', 'ls *.pdf'], stdout=sub.PIPE, stderr=sub.STDOUT))


The p object has methods for interrogating the output from the command.

Python 2.7 has more options.  For < 2.7 use,


p = subprocess.Popen(['ls', '-l'], stdout=subprocess.PIPE).communicate()[0]
to get the output from the command.