Saturday, 13 May 2017

scout compass bearing game generator - python script

I made a script for generating post labels and bearing following instructions around paths in a compass bearing game, it is here:
https://github.com/Gaoithe/scout_compass_bearing_game

scout_compass_bearing_game

Calculate bearings and generate: post labels, bearing following instructions and game cheat sheet instructions.

Scout compass bearing challenge game

Posts are set out in a circle a good distance apart. One post starting at magnetic North, other posts at each compass point N NNE NE ENE E ESE . . . e.t.c. Each post is labeled with name and has a scrambled alphabet in a grid.
Scouts receive an instruction sheet with start post and series of bearings to follow. At each post visited a letter of a word is obtained.
A simple grid reference for each post describes how to obtain a letter. The grid reference at N post comes from the Irish grid reference system. The letters in the grid are scrambled at each other post. https://en.wikipedia.org/wiki/Irish_grid_reference_system#/media/File:Irish_Grid.svg
A full scrambled alphabet is on each post. This allows a large combination of word instructions to be used. It allows interesting quotes or song lyrics to be used as a challenge for a group of scouts.
e.g. of post label with post name and scrambled alphabet in grid:
########################################
#
# POST: 337.5 => NNW
#
#        1   2   3   4   5 - Easting
#
#    5   Y   H   T   M   G   
#    4   W   B   C   I   U   Q   
#    3   K   P   Z   R   L   
#    2   S   X   O   N   J   
#    1   F   V   E   D   A   
#     \
#      Northing
#
########################################
e.g. of instruction sheet for a two letter word:
########################################
#
# Word 0
# START at POST: 67.5 => ENE
#
# 0. Follow bearing 123.75 to next Post,
#    Record letter @ Easting 1, Northing 1  _______
# 0. Follow bearing 146.25 to next Post,
#    Record letter @ Easting 6, Northing 4  _______
#
########################################
e.g. of portion of cheat sheet
########################################
# Cheat Sheet
#
# Word 0 is We, post path is [67.5, 45.0, 22.5]
#    DEBUG post:45.0 c:W
#    DEBUG post:22.5 c:e
#
.
.
.
A python script is used . . . 16 posts are currently used. 8 posts or other number can wasily be used with script adjustment. The word list or quote used can be changed in script. TODO: map and allow arbitrary positioning of posts e.g. in rectangle or other shape would be suitable for a permanently marked compass bearing challenge.
The script is quite messy currently . . WIP . . beware of roadworks and dragons.

FILES:

The script, run:
  • python scout_bearing_to_compasspoint.py 
Numpy is used a little bit, matplotlib is called but not needed to generate game instructions, there is some not used curses at end of script.
Output of script text post labels and word instructions:
  • scout_bearing_to_compasspointDEBUG.txt
Put the script in an open-office doc, insert a section around the post labels and in format->section make it two columns. Do the same around word instructions. Adjust labels/instructions so they do not wrap around a column or page. print. Cut up. Attach labels to posts. Have fun!
See files:
  • scout_compass_bearing_posts.odt
  • scout_compass_bearing_posts.pdf 




Monday, 10 April 2017

simple bash 'logrotate'

'logrotate' = not a logrotate but more of a multiple result handle
e.g. test results, core files, log files

'infinate' (max bash integer) 'logrotate' pattern for bash:


    # multiple runs of same test, . . logrotate test result
    [[ -e dir/testresult_${testname}_${host}.xml ]] && {
        K=$(find dir/testresult_${testname}_*_${host}.xml 2>/dev/null |wc -l)
        ((K++))
        mv dir/testresult_${testname}_{,${K}_}${host}.xml
    }

Coupled with test harvest e.g. . . 
rsync -avzh --remove-source-files ${user}@${host}:XML/*${host}.xml ./ || true

optional || true so that lack of xml files doesn't mark job/script as fail


Sunday, 12 March 2017

Scout County Survivor - Air drop Token hunt challenge

3 rock Scout County
Survivor Token Map Challenge


An aircraft has been heard flying overhead. Your team catch
a brief glimpse of the aircraft through storm clouds. It is being
severely buffeted by strong winds. You see multiple things
are dropped. Some items fall quickly, other items blow in the
wind. Shortly afterwards some leaflets are seen floating down
from the sky.

The leaflets say:

Dear Survivors,

Please be assured help is on the way. We hope that rescue
teams will reach you in approx. 24 hours.
Due to rough terrain and poor visibility we have had difficulty
pinpointing your location from the air. Supplies have been
dropped at several locations that we think you may be able to
reach. Please see approximate locations of drops on the
map.

DO NOT RISK INJURY TO YOURSELVES as you will have
to survive independantly until rescue!

(IN REAL LIFE: Look for triangular survivor tokens. You should retrieve the token, bring it to Scout Leaders Area and redeem it for items recovered from supply drop cache.)


PDF and Inkscape SVGZ TOKENS: Food, Shelter, Fire, First Aid

https://drive.google.com/drive/folders/0B03nt669Z-O0Mms0UGhfRHU3NXM?usp=sharing

Tuesday, 17 January 2017

weekend B(ullet?)Log, fix guitar, bike maintenance, photo sync, visit Limerick

Thur
 x repair Maeve's guitar using wood glue, leave for 48hrs

Sat
 - Drove down & back from Limerick. Met Eimear&Stephen&Aoife.
 x rsync'd photos james laptop -> USB drive
 x look for Maeve school photos -  found a few cute ones but not for sending to journal
 x Strung/tuned guitar. But as strings tightened glue stretched :-(

Sun
  x fix guitar with superglue
  x fix Kate bike one set brake pads replaced
  x fix Maeve bike brake squeal (brake cables oiled, tightened // front brake pads fully off and back on - nuts were in ok order // BALANCED each side of brakes front and back (spring adjusted screws both sides)
  x fix James bike disc brake pads (from Halfords) back brake was worn just down to metal, front brake less worn but replaced
  x fixed 3 bike tubes
  x Strung/tuned guitar. But as strings tightened glue stretched :-(

Mon
  x Strung/tuned guitar. But the superglue is not holding.
  x Repair guitar using glue + bracket. (cut the bracket)
  x Strung/tuned guitar. repair is holding.
  . guitar bracket flush, round bottom corner, hammer a curve in it
  - need a mini-anvil :)

Tue
  x morn: tuned guitar - it's starting to hold in tune ok, Maeve tested it

Books
  x gave rationality.pdf Harry Potter to Kate/...
  . reading graphic novel last man Y

for Wed/future . . .
  . Glenmalure hike plan
  . scouts plan hike for Jan/Feb ?
  . scouts PLC . . long term plan . . adventures, skills, special interest, Survivor, County Cup
  . scouts Annual Camp plans
  . scouts County meetings/activities
  . scouts James leader training
  . Cycling submission: DART crossing/Booterstown
  . DLR fernhill submission


Looked @ Bullet Journal mechanics:

http://bulletjournal.com/get-started/

https://www.buzzfeed.com/rachelwmiller/how-to-start-a-bullet-journal

https://youtu.be/fm15cmYU0IM



This blog acts as an occasional diary or article log for me.
I have a book for Scouts and work which is diary/planner journal.
I have often scrappy bits of paper with task lists or planning ideas.
Also task manager app, google calendar, gmail, .. .



 

Sunday, 13 November 2016

Balally scout orienteering map and challenge

1. Made map and controls description with oomap

http://oomap.co.uk/ie/#/5828dfec5a29c/oterrain_ioa/15/-6.2267/53.2781/

Map ID: 5828dfec5a29c


2. Print .pdf of MAP + CONTROL sheet + some info scouting ireland added (using libre office draw to edit the pdf.)

BalallyScoutOrienteering.pdf in google drive


3. Made white and orange control point markers from plastic corriboard - with a control number and symbol of chemical element. Attached coloured pencil and little Darkness-into-Light tea light to control.

4. Scouters met the day before and put out most controls hidden on course.
5. Scouters met before meeting and put out controls which are more exposed.

6. Ran the challenge!

Challange Directions: STAY SAFE! Stay together. Be careful of traffic. Be kind and polite to members of the public. Do course safely but as fast as possible. Visit all marks. Record code of mark with coloured marker on your control sheet.


Num Score Description Code

1 10 maple tree near path

2 50 NE corner. behind bushes, up a tree, at fence

3 30 NE of lampost. alder tree

4 30 cypress tree near scout den

5 20 line up gaa olafs nets

6 10 beech near car park

7 20 path opposite lamp post

8 30 NW of forked tree

9 50 opposite lamp post in hedge

10 10 lamp post by garden

11 10 willow grove and bank

12 20 Southside of junction box

13 30 lamp post


BalallyScoutOrienteering.pdf - map and event description with controls


Wednesday, 9 November 2016

Use the --foreground option with timeout command and docker exec - prevents hang

TLDR; 1. the timeout command is a very useful command in scripts to make sure they don't get stuck on a hanging command

TLDR; 2. Using the --foreground option in timeout command which calls docker exec or other commands might prevent the command hanging.

e.g. timeout --foreground 5 docker exec -i su - -c ' '


https://github.com/moby/moby/issues/28207



docker exec hang when run using timeout command (and docker v1.12.2) #28207

 Open
Gaoithe opened this issue on Nov 9, 2016 · 11 comments

Comments

@Gaoithe
 
 

Gaoithe commented on Nov 9, 2016 • 

There are a few issues open around docker exec hanging but this one seems quite specific to running docker exec under the timeout command and to latest docker version 1.12.2 . . .
Have scripts which run docker exec like this:
timeout 1m docker exec -i $id sh -c "$command"
They had been working ok. After upgrade to docker 1.12.2 the scripts hang on those docker exec commands.
Interestingly, if I run the command on command-line (bash shell from ssh) then no hangs are seen.
If the command is run from inside a #!/bin/bash script then the hang happens all the time.

BUG REPORT INFORMATION

Description
docker exec command hangs when run in a bash script using timeout command and
same command using timeout doesn't hang from command-line
Steps to reproduce the issue:
  1. make a script like this called ugh.sh and run it:
#!/bin/bash
timeout 1m docker exec -it $contid sh -c "ls"
  1. chmod 755 ugh.sh; ./ugh.sh
NOTE that the very same command run in shell doesn't hang.



LATER:


 

pixelb commented on Nov 14, 2016

Have you tried the --foreground option to timeout? If docker is behaving as a monitor itself then this should timeout all children and be the least invasive way to run docker
@Gaoithe
 
 
Author

Gaoithe commented on Nov 14, 2016

Thank you @pixelb. That works. Interesting! Using timeout --foreground 1m docker exec . . . etc the commands now do not hang (when running in bash script from bash shell which is when we saw hang before.). The hang was not and is not seen when the timeout and docker exec was called interactively from shell. I realise now (slightly more) the significance of that.
That looks like a good workaround for our scripts.


https://stackpointer.io/unix/unix-linux-run-command-with-timeout/500/

USAGE:

$ timeout 1s sleep 10
$ echo $?
124

$ timeout 10s sleep 1
$ echo $?
0

$ timeout --help
Usage: timeout [OPTION] DURATION COMMAND [ARG]...
  or:  timeout [OPTION]
Start COMMAND, and kill it if still running after DURATION.

Mandatory arguments to long options are mandatory for short options too.
      --preserve-status
                 exit with the same status as COMMAND, even when the
                   command times out
      --foreground
                 when not running timeout directly from a shell prompt,
                   allow COMMAND to read from the TTY and get TTY signals;
                   in this mode, children of COMMAND will not be timed out
  -k, --kill-after=DURATION
                 also send a KILL signal if COMMAND is still running
                   this long after the initial signal was sent
  -s, --signal=SIGNAL
                 specify the signal to be sent on timeout;
                   SIGNAL may be a name like 'HUP' or a number;
                   see 'kill -l' for a list of signals
      --help     display this help and exit
      --version  output version information and exit

DURATION is a floating point number with an optional suffix:
's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days.

If the command times out, and --preserve-status is not set, then exit with
status 124.  Otherwise, exit with the status of COMMAND.  If no signal
is specified, send the TERM signal upon timeout.  The TERM signal kills
any process that does not block or catch that signal.  It may be necessary
to use the KILL (9) signal, since this signal cannot be caught, in which
case the exit status is 128+9 rather than 124.

GNU coreutils online help:
For complete documentation, run: info coreutils 'timeout invocation'