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'



Thursday 3 November 2016

rsync from android MTP . . freezy/hangy problems. s/rsync/crude script/

Samsung Galaxy Nexus.
3.8G of photos in internal storage.
Options are MTP "mounting" or PTP.
Ubuntu 14.xx

1.

First attempt copying using file manager . . . started out okay. Reported 3.8G will be copied over in 7 mins . . 15 mins . . later 1 hour and x mins. And it was getting stuck / hanging up (looked like at the same point).

Unplug/replug USB did not bring back MTP connection after hang. Needed to go to phone USB computer connection Settings and un-check and then re-check MTP to recover it.

2.

rsync
cd /run/user/1000/gvfs/
cd mtp* # e.g. mtp::host=%5Busb%3A001%2C017%5D/
cd "Internal storage/DCIM"
rsync -avzhP ./ ~/Pictures/201611FionnOldMobilePhone/DCIM/
see errors like this:

          1.59M 100%    1.67MB/s    0:00:00 (xfr#1834, to-chk=957/2800)
Camera/IMG_20130808_123846.jpg
          1.98M 100%    1.25MB/s    0:00:01 (xfr#1835, to-chk=956/2800)
rsync: read errors mapping "/run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C017%5D/Internal storage/DCIM/Camera/IMG_20130808_123846.jpg": No data available (61)
Camera/IMG_20130808_123902.jpg
          1.43M 100%    1.57MB/s    0:00:00 (xfr#1836, to-chk=955/2800)
rsync: read errors mapping "/run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C017%5D/Internal storage/DCIM/Camera/IMG_20130808_123902.jpg": No data available (61)
Camera/IMG_20130808_124320.jpg
          1.58M 100%    1.21MB/s    0:00:01 (xfr#1837, to-chk=954/2800)
rsync: read errors mapping "/run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C017%5D/Internal storage/DCIM/Camera/IMG_20130808_124320.jpg": No data available (61)
Camera/IMG_20130808_124435.jpg
          1.54M 100%    2.00MB/s    0:00:00 (xfr#1838, to-chk=953/2800)
rsync: read errors mapping "/run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C017%5D/Internal storage/DCIM/Camera/IMG_20130808_124435.jpg": No data available (61)
Camera/IMG_20130808_124530.jpg
          1.90M 100%    1.54MB/s    0:00:01 (xfr#1839, to-chk=952/2800)
rsync: read errors mapping "/run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C017%5D/Internal storage/DCIM/Camera/IMG_20130808_124530.jpg": No data available (61)
Camera/IMG_20130808_124625.jpg
         32.77K   1%  126.98kB/s    0:00:17 
. . restarted . .
. . stuck again . . 

. . seemed to be getting stuck on the same files . . 
 
These errors seem to be encountered if rsyncing from files which get changed while sync happens.  I think android should not be changing them. I don't think MTP would expose corrupt disk problem ? Something like antivirus locking the files should not be problem. Anyway, MTP connection a bit flaky . . maybe something on the android side is locking files or MTP drivers are a bit funny.
 
3.
 
Tried rsync with --remove-source-files on whole and on file selections (e.g. Camera/IMG_201606*) still got stuck. Each time after hang needed to go into droid unselect MTP and select again to connect again. At least files to be checked/transferred are being reduced now by removing them after they are synced.



    rsync -avzhP --remove-source-files ./ ~/Pictures/201611FionnOldMobilePhone/DCIM/

4.
 
rsync was getting stuck on the same file all the time. cp seemed to have less of a hanging problem. more tolerant of read errors? So made a script to do copy and remove if copy successful.

    # Script using cp -p (and remove files as we go)
    DEST=/home/jamesc/Pictures/201611FionnOldMobilePhone/DCIM/Camera/
    cd /run/user/1000/gvfs/mtp*/Intern*/DCIM
    FILES=$(ls Camera/)
    for f in $FILES; do echo -n $f; cp -p Camera/$f $DEST/ && rm Camera/$f && echo success; done

This was run in a while true loop periodically recovering MTP connection when it hung.
 
      while true; do ~/bin/sync_flaky_mtp.sh; sleep 1; done

The script saw some funny errors e.g. :
 
    IMG_20130814_113108.jpgsuccess
    IMG_20130815_145354.jpgsuccess
    IMG_20130815_145455.jpgcp: error reading ‘Camera/IMG_20130815_145455.jpg’: Input/output error
    cp: failed to extend ‘/home/jamesc/Pictures/201611FionnOldMobilePhone/DCIM/Camera/IMG_20130815_145455.jpg’: Input/output error
    IMG_20130815_145500.jpgsuccess
    IMG_20130815_151552.jpgsuccess
    . . .
    IMG_20130824_095526.jpgsuccess
    IMG_20130824_095537.jpg

And it would hang . . . periodically recovered MTP connection as already described.
 
5.
 
The script evolved . . . 

    Binary files Camera/IMG_20160104_095626.jpg and /home/jamesc/Pictures/201611FionnOldMobilePhone/DCIM/Camera//IMG_20160104_095626.jpg differ
    IMG_20160104_100128.jpgalready
    RM
    IMG_20160104_100157.jpgalready

       #!/bin/bash
DEST=/home/jamesc/Pictures/201611FionnOldMobilePhone/DCIM/Camera/
cd /run/user/1000/gvfs/mtp*/Intern*/DCIM
FILES=$(ls Camera/)
#echo FILES=$FILES
ls Camera/ |wc -l
for f in $FILES; do
   echo -n $f;
   if [[ ! -e $DEST/$f ]]; then
      # the timeout doesn't work on frozen mtp file
             # we run this full script in a while true; do ~/bin/sync_flaky_mtp.sh; sleep 1; done loop
             # and periodically visit, if stuck unlock phone, deselect MTP and select it again
             # (to interrupt and restart MTP connection)
             # simply unplug & replug doesn't bring MTP connection back ok
      timeout 20s cp -p Camera/$f $DEST/ && rm Camera/$f && echo success;
   else
      echo already done by earlier script which did not tidy up;
      diff -u Camera/$f $DEST/$f
      if [[ $? == 0 ]]; then
         rm Camera/$f && echo RM
      else
         # doing this copy on the weird files causes nasty freezy freezes.
         #cp -p Camera/$f $DEST/$f && rm Camera/$f && echo success;
                # ALOT of files found to be a few bytes different.
                # another copy caused hanging . . . so if dest file kindof looks ok we just remove source
         identify $DEST/$f && rm Camera/$f && echo RM
      fi
   fi;
done

beep

    # a few bytes in size different
    ls -al Camera/IMG_20150117_171621.jpg $DEST/Camera/IMG_20150117_171621.jpg
      -rw------- 1 jamesc jamesc 1277901 Jan 17  2015 Camera/IMG_20150117_171621.jpg
      -rwxr----- 1 jamesc jamesc 1275306 Nov  3 01:09 $DEST/Camera/IMG_20150117_171621.jpg
 
    # copy again ? results in same size difference, date/time fixed up though
    cp -p Camera/IMG_20150117_171621.jpg $DEST/Camera/IMG_20150117_171621.jpg
    ls -al Camera/IMG_20150117_171621.jpg $DEST/Camera/IMG_20150117_171621.jpg
      -rw------- 1 jamesc jamesc 1277901 Jan 17  2015 Camera/IMG_20150117_171621.jpg
      -rw------- 1 jamesc jamesc 1275306 Jan 17  2015 $DEST/Camera/IMG_20150117_171621.jpg
    diff -u Camera/IMG_20150117_171621.jpg $DEST/Camera/IMG_20150117_171621.jpg
      Binary files Camera/IMG_20150117_171621.jpg and $DEST/Camera/IMG_20150117_171621.jpg differ

So EVENTUALLY by removing files we had already copied we had less and less to do and got through all files. Phew. And yay.

    du -h $DEST/.. --max-depth=0
      3.6G    /home/jamesc/Pictures/201611FionnOldMobilePhone/DCIM/Camera//..


Various other reading . . . 



Tuesday 18 October 2016

char c; int i; c[&i]; // index a simple var using pointer in c compiles (and runs often without segfault)


    char c;
    int i;
    printf("%02x",c[&i]);
    //printf("%02x",c[i]); // doesn't compile, error, cannot access c as array
    // "error: subscripted value is neither array nor pointer nor vector"


c[&i] there is SOOOO BAD and WROOONG. Semantically wrong. But apparently not syntactically wrong in c.

Why does it compile?
Because 1. array[i] == *(array+i) == *(i+array) == i[array]
And 2. c casts char to int happily

In case of c[&i] c is the index added to pointer &i.
Now &i + value of c indexes an undefined area of memory so it is not good to use this!!


    char c;
    int i[10];
    // normal access into array (bad to use a char as array index though)
    for(c=0;c<10;c++) printf("%02x",i[c]); // normal-ish
    for(c=0;c<10;c++) printf("%02x",*(i+c)); // equivalent pointer arithmetic
    for(c=0;c<10;c++) printf("%02x",*(c+i)); // equivalent
    for(c=0;c<10;c++) printf("%02x",c[i]);    // allowed BUT NOT NORMAL



    char c;
    int i;
    int buffer[20]; // buffer helps prog not seg fault!
    // abnormal access into memory at offset of (int)c from &i
    //for(c=0;c<10;c++) printf("%02x",&i[c]); // COMPILE ERROR
    for(c=0;c<10;c++) printf("%02x",*(&i+c)); // a bit weird
    for(c=0;c<10;c++) printf("%02x",*(c+&i)); // not normal
    for(c=0;c<10;c++) printf("%02x",c[&i]);    // but it compiles and runs(mostly)

    for(c=0;c<10;c++) printf("%02x,",i[&c]); // this is all
    printf(" ");
    for(c=0;c<10;c++) printf("%02x,",*(i+&c)); // a bit weird
    printf(" ");
    for(c=0;c<10;c++) printf("%02x,",*(&c+i)); // not normal
    //for(c=0;c<10;c++) printf("%02x,",&c[i]);    // COMPILE ERROR
    printf("\n");



While answering this question:
http://stackoverflow.com/questions/40116073/c-duplicate-character-character-by-character/40117178#40117178

Asked this question:
http://stackoverflow.com/questions/40118549/in-c-ci-compiles-where-c-and-i-are-variables-not-arrays-pointers-but-i

Monday 26 September 2016

Reset Windows 7 Administrator account (or any user account) password

Had some fun on Sunday trying to get access to Admin account on Windows 7 laptop. 
I attempted some other methods but what eventually worked for me was a bit of a hack/trick. Replace sethc.exe (sticky keys) with cmd.exe and trigger sticky keys (sticky keys is run as Administrator). This was done through using Notepad.exe which is run to view logfiles after system recovery. Other techniques to get in on command-line as admin with drive mounted didn't work. This trick is at least quite amusing :-) also simple and portable :-D. 
Background: The Administrator password with laptop was not known. There was a user account with admin privs so users didn't find the need of it. UNTIL the windows login page stopped showing their user! We are guessing the User profile became corrupt or had something bad in it.
I attempted a series of procedures before getting the Notepad+sticky keys replace hack to work. For the record here they are (and the problem I encountered with them):
  1. When trying to log in as Administrator after an incorrect password you are prompted to insert rescue disk (in order to reset password). We had a Windows 7 rescue disk on cd. But the prompt asked for floppy or USB. I had no handy USB stick and was too lazy to go shopping and messing with creating USB boot disk.
  2. Using system repair disk to get in on command-line did not allow the replacing of sethc.exe with cmd.exe trick/hack. Or allow resetting admin password 'net use Administrator *'. The command-line was running as admin but not as the real admin on machine more as the system repair admin and the disk did not seem to be mounted with full access . . . ~ not sure ~
  3. Using linux system rescue cd (https://www.system-rescue-cd.org (version 4.8.2)) I could not mount the drive. I would kindof see it was a GPT partitioned drive - tools ntfs-3g gparted sfdisk should work with GPT but didn't. This computer has a prompt for username + domain + password before windows starts so not sure but maybe there is some extra security (which is needed to mount drive?)
  4. We looked at recovering the User Profile - editing registry - but . . . 
What eventually DID work was follow system recover sequence (no external/additional cd needed) at end view logfile (opens in Notepad). Then do file open - browse to cmd.exe - copy - paste - overwrite sethc.exe. Then reboot - trigger sticky keys - set password using command-line 'net user Administrator *'.
Procedure:
  1. Shutdown and reboot. When Windows starting is seen hold down the power button and power off.
  2. Power on. Windows boot should report that last Windows start up failed so it will give the option of "Launch startup repair". Choose this option.
  3. Cancel the Startup Repair. Cancel the System Restore.
  4. A report dialog will show reporting repair could not be done. In there expand "View problem details". Under problem details a link to x:/windows/... log file is shown. Click on this.
  5. Notepad.exe opens showing the logfile. This Notepad is running as Administrator and the mounted filesystem x: is your hard disk.
    5.1 Notepad: File - Open - browse to X:/Windows/system32 - scroll to sethc.exe
    5.2 Right-click on sethc.exe and rename to sethc-BACKUP.exe
    5.3 Scroll to cmd.exe. Right-click on cmd.exe. Copy. Right click. Paste.
    5.4. When I pasted cmd.exe the command-line ran (as Administrator) so I did 'cd x:/Windows/system32' and then 'copy cmd.exe sethc.exe' on command-line.
    5.4-1 If you prefer not command-line then just use Notepad File Open browser and make a copy of cmd.exe and rename it to sethc.exe
  6. Reboot without any funny stuff.
  7. At login page hit shift key 5 times or more triggering sticky keys. Instead of sticky keys prompt a command-line dialog appears. Running as Administrator. 'net user Administrator *' to set the password.
Good description with screenshots of the procedure here: http://null-byte.wonderhowto.com/how-to/hack-windows-7-become-admin-0160151/

The rsync of old user to new user after successful recover. And a game of blockus :-)


In conclusion, this solution doesn't require you to have any extra boot or repair CD. It is very portable :-) It is pretty simple. So it is probably worth trying as one of the first password recovery methods.
We finished up Sunday with making a new user, failing to copy files from old user -> new user using windows, installing cygwin with rsync, rsyncing from old user -> new user (-avzhP and excluding ntdata files and a few other). Then backing up stuff generally. Took ages (3/4hours?) but successful recover at the end, phew.

Saturday 24 September 2016

Recipe: Mackerel with spinach and apple

Recipe: Mackerel with spinach and apple

As usual winging it in the kitchen. Successful and tasty soup and fish for tea today.
The selection of ingredients depends often on what is there, what needs to be used.

Apple baked with the mackerel was a nice combination. James & Fionnuala and the girls liked it alot.

Ingredients:
    2 plums
    2-3 tomatoes
    4 mushrooms (optional but good especially if you have a wife who loves them!)
    half a red onion
    mackerel - 3 fillets (Aldi's best)
    apple - tart(as in a bit sour) (my Mum and Dad brought some up from Cobh this Monday)
    spinach - we got a bag with the organic fruit & veg box
    oil, salt, pepper
    squeeze of lemon

Method:
   Turn on oven ~190 degrees.
   De-stone and slice plums, slice tomatoes, slice & dice onion, remove stalk from mushrooms.
   Put those in pyrex baking dish (some oil in first) and mix and put in oven.
   Shred/Chop some spinach - add spinach to dish in oven and mix in.
      (this was done a while after the rest baked a bit as I was making soup @ the same time).
   Add a small amount of lemon juice to dish in oven.
   Stir the dish in oven once or twice.
   Keep 3 large spinach leaves aside for the fish.

   Slice apple into wedges (quarter the apple, remove core/pips, slice).
   Take fish out of packet, rinse.
   Lay fish on a dish(I had it in a jug), season, put on oil, put apple on top.
   Squeeze on a small amount of lemon juice.
 
   13 mins to serving time put on the fish:
       Lay each fillet on a spinach leaf and lay wedges of apple on top.
       Lay side by side on top of the dish in oven.

   The apple stuck to top of mackerel and spinach stuck under.
   The spinach+fish+apple were easy to lift off and put on plate.
   Serve the mix underneath beside the fish.

https://en.wikipedia.org/wiki/Mackerel

--------------------------------------
We had soup with fish (and for he who didn't fancy fish):

Soup with 3 potatoes diced, half a butternut squash (deseeded but with skin) diced, 1 leek, 2 small carrots diced, some turmeric (the real root - small slices), grated ginger, chopped spinach, a black chilli pepper, a jug of vegetable broth(or stock), water, seasoning (salt, pepper, curry powder)
In that order (more or less) add ingredients and fry with oil first. Stirring frequently. If taking too long dicing and there is danger of burning then add some broth. You want to fry/broil the hard veg for a bit. I had broth from cooking potatoes + carrot + onion earlier in day. Add enough water at end to give a nice soup consistency not too thick. Spinach was added at end after heat was turned off.
After all cooked then buzz to smooth.

Serve with toast & butter.

--------------------------------------
Earlier on we had mash potato with black pudding, brocolli and eggs. (and some beans)

Mashed potato.
Potatoes roughly chopped. Carrot diced. Onion diced.
Boil potatoes with a small amount of salt in water. (some brine from an olive jar does nicely)
Add carrot and onion.
When potatoes  cooked (not soft/disentegrating) drain.
Keep the broth for making soup later.
Add some butter and a splash on milk.
Mash.

Serve with black pudding, egg, brocolli stalk and head fried with turmeric.
--------------------------------------

Friday 5 August 2016

Major and minor chord notes and positions on guitar fretboard.

Useful for when you figure out nots in a tune and wish to fit chords to play along.


Major and Minor chord notes

A  Major chord  A   C#  E   A
A  Minor chord  A   C   E   A
A# Major chord  A#  D   F   A#
A# Minor chord  A#  C#  F   A#
B  Major chord  B   D#  F#  B
B  Minor chord  B   D   F#  B
C  Major chord  C   E   G   C
C  Minor chord  C   D#  G   C
C# Major chord  C#  F   G#  C#
C# Minor chord  C#  E   G#  C#
D  Major chord  D   F#  A   D
D  Minor chord  D   F   A   D
D# Major chord  D#  G   A#  D#
D# Minor chord  D#  F#  A#  D#
E  Major chord  E   G#  B   E
E  Minor chord  E   G   B   E
F  Major chord  F   A   C   F
F  Minor chord  F   G#  C   F
F# Major chord  F#  A#  C#  F#
F# Minor chord  F#  A   C#  F#
G  Major chord  G   B   D   G
G  Minor chord  G   A#  D   G
G# Major chord  G#  C   D#  G#
G# Minor chord  G#  B   D#  G#

Major chords on the fretboard:

 
A Major:
||| E |   |   |   |   | A |   |   |   | C#|   |   | E |   |   |   |   | A |   |   |
|||   |   | C#|   |   | E |   |   |   |   | A |   |   |   | C#|   |   | E |   |   |
|||   |   | A |   |   |   | C#|   |   | E |   |   |   |   | A |   |   |   | C#|   |
|||   |   | E |   |   |   |   | A |   |   |   | C#|   |   | E |   |   |   |   | A |
||| A |   |   |   | C#|   |   | E |   |   |   |   | A |   |   |   | C#|   |   | E |
||| E |   |   |   |   | A |   |   |   | C#|   |   | E |   |   |   |   | A |   |   |
A# Major:
|||   | F |   |   |   |   | A#|   |   |   | D |   |   | F |   |   |   |   | A#|   |
|||   |   |   | D |   |   | F |   |   |   |   | A#|   |   |   | D |   |   | F |   |
|||   |   |   | A#|   |   |   | D |   |   | F |   |   |   |   | A#|   |   |   | D |
||| D |   |   | F |   |   |   |   | A#|   |   |   | D |   |   | F |   |   |   |   |
|||   | A#|   |   |   | D |   |   | F |   |   |   |   | A#|   |   |   | D |   |   |
|||   | F |   |   |   |   | A#|   |   |   | D |   |   | F |   |   |   |   | A#|   |
B Major:
|||   |   | F#|   |   |   |   | B |   |   |   | D#|   |   | F#|   |   |   |   | B |
||| B |   |   |   | D#|   |   | F#|   |   |   |   | B |   |   |   | D#|   |   | F#|
|||   |   |   |   | B |   |   |   | D#|   |   | F#|   |   |   |   | B |   |   |   |
|||   | D#|   |   | F#|   |   |   |   | B |   |   |   | D#|   |   | F#|   |   |   |
|||   |   | B |   |   |   | D#|   |   | F#|   |   |   |   | B |   |   |   | D#|   |
|||   |   | F#|   |   |   |   | B |   |   |   | D#|   |   | F#|   |   |   |   | B |
C Major:
||| E |   |   | G |   |   |   |   | C |   |   |   | E |   |   | G |   |   |   |   |
|||   | C |   |   |   | E |   |   | G |   |   |   |   | C |   |   |   | E |   |   |
||| G |   |   |   |   | C |   |   |   | E |   |   | G |   |   |   |   | C |   |   |
|||   |   | E |   |   | G |   |   |   |   | C |   |   |   | E |   |   | G |   |   |
|||   |   |   | C |   |   |   | E |   |   | G |   |   |   |   | C |   |   |   | E |
||| E |   |   | G |   |   |   |   | C |   |   |   | E |   |   | G |   |   |   |   |
C# Major:
|||   | F |   |   | G#|   |   |   |   | C#|   |   |   | F |   |   | G#|   |   |   |
|||   |   | C#|   |   |   | F |   |   | G#|   |   |   |   | C#|   |   |   | F |   |
|||   | G#|   |   |   |   | C#|   |   |   | F |   |   | G#|   |   |   |   | C#|   |
|||   |   |   | F |   |   | G#|   |   |   |   | C#|   |   |   | F |   |   | G#|   |
|||   |   |   |   | C#|   |   |   | F |   |   | G#|   |   |   |   | C#|   |   |   |
|||   | F |   |   | G#|   |   |   |   | C#|   |   |   | F |   |   | G#|   |   |   |
D Major:
|||   |   | F#|   |   | A |   |   |   |   | D |   |   |   | F#|   |   | A |   |   |
|||   |   |   | D |   |   |   | F#|   |   | A |   |   |   |   | D |   |   |   | F#|
|||   |   | A |   |   |   |   | D |   |   |   | F#|   |   | A |   |   |   |   | D |
||| D |   |   |   | F#|   |   | A |   |   |   |   | D |   |   |   | F#|   |   | A |
||| A |   |   |   |   | D |   |   |   | F#|   |   | A |   |   |   |   | D |   |   |
|||   |   | F#|   |   | A |   |   |   |   | D |   |   |   | F#|   |   | A |   |   |
D# Major:
|||   |   |   | G |   |   | A#|   |   |   |   | D#|   |   |   | G |   |   | A#|   |
|||   |   |   |   | D#|   |   |   | G |   |   | A#|   |   |   |   | D#|   |   |   |
||| G |   |   | A#|   |   |   |   | D#|   |   |   | G |   |   | A#|   |   |   |   |
|||   | D#|   |   |   | G |   |   | A#|   |   |   |   | D#|   |   |   | G |   |   |
|||   | A#|   |   |   |   | D#|   |   |   | G |   |   | A#|   |   |   |   | D#|   |
|||   |   |   | G |   |   | A#|   |   |   |   | D#|   |   |   | G |   |   | A#|   |
E Major:
||| E |   |   |   | G#|   |   | B |   |   |   |   | E |   |   |   | G#|   |   | B |
||| B |   |   |   |   | E |   |   |   | G#|   |   | B |   |   |   |   | E |   |   |
|||   | G#|   |   | B |   |   |   |   | E |   |   |   | G#|   |   | B |   |   |   |
|||   |   | E |   |   |   | G#|   |   | B |   |   |   |   | E |   |   |   | G#|   |
|||   |   | B |   |   |   |   | E |   |   |   | G#|   |   | B |   |   |   |   | E |
||| E |   |   |   | G#|   |   | B |   |   |   |   | E |   |   |   | G#|   |   | B |
F Major:
|||   | F |   |   |   | A |   |   | C |   |   |   |   | F |   |   |   | A |   |   |
|||   | C |   |   |   |   | F |   |   |   | A |   |   | C |   |   |   |   | F |   |
|||   |   | A |   |   | C |   |   |   |   | F |   |   |   | A |   |   | C |   |   |
|||   |   |   | F |   |   |   | A |   |   | C |   |   |   |   | F |   |   |   | A |
||| A |   |   | C |   |   |   |   | F |   |   |   | A |   |   | C |   |   |   |   |
|||   | F |   |   |   | A |   |   | C |   |   |   |   | F |   |   |   | A |   |   |
F# Major:
|||   |   | F#|   |   |   | A#|   |   | C#|   |   |   |   | F#|   |   |   | A#|   |
|||   |   | C#|   |   |   |   | F#|   |   |   | A#|   |   | C#|   |   |   |   | F#|
|||   |   |   | A#|   |   | C#|   |   |   |   | F#|   |   |   | A#|   |   | C#|   |
|||   |   |   |   | F#|   |   |   | A#|   |   | C#|   |   |   |   | F#|   |   |   |
|||   | A#|   |   | C#|   |   |   |   | F#|   |   |   | A#|   |   | C#|   |   |   |
|||   |   | F#|   |   |   | A#|   |   | C#|   |   |   |   | F#|   |   |   | A#|   |
G Major:
|||   |   |   | G |   |   |   | B |   |   | D |   |   |   |   | G |   |   |   | B |
||| B |   |   | D |   |   |   |   | G |   |   |   | B |   |   | D |   |   |   |   |
||| G |   |   |   | B |   |   | D |   |   |   |   | G |   |   |   | B |   |   | D |
||| D |   |   |   |   | G |   |   |   | B |   |   | D |   |   |   |   | G |   |   |
|||   |   | B |   |   | D |   |   |   |   | G |   |   |   | B |   |   | D |   |   |
|||   |   |   | G |   |   |   | B |   |   | D |   |   |   |   | G |   |   |   | B |
G# Major:
|||   |   |   |   | G#|   |   |   | C |   |   | D#|   |   |   |   | G#|   |   |   |
|||   | C |   |   | D#|   |   |   |   | G#|   |   |   | C |   |   | D#|   |   |   |
|||   | G#|   |   |   | C |   |   | D#|   |   |   |   | G#|   |   |   | C |   |   |
|||   | D#|   |   |   |   | G#|   |   |   | C |   |   | D#|   |   |   |   | G#|   |
|||   |   |   | C |   |   | D#|   |   |   |   | G#|   |   |   | C |   |   | D#|   |
|||   |   |   |   | G#|   |   |   | C |   |   | D#|   |   |   |   | G#|   |   |   |

Minor chords on the fretboard

A Major:
||| E |   |   |   |   | A |   |   | C |   |   |   | E |   |   |   |   | A |   |   |
|||   | C |   |   |   | E |   |   |   |   | A |   |   | C |   |   |   | E |   |   |
|||   |   | A |   |   | C |   |   |   | E |   |   |   |   | A |   |   | C |   |   |
|||   |   | E |   |   |   |   | A |   |   | C |   |   |   | E |   |   |   |   | A |
||| A |   |   | C |   |   |   | E |   |   |   |   | A |   |   | C |   |   |   | E |
||| E |   |   |   |   | A |   |   | C |   |   |   | E |   |   |   |   | A |   |   |
A# Major:
|||   | F |   |   |   |   | A#|   |   | C#|   |   |   | F |   |   |   |   | A#|   |
|||   |   | C#|   |   |   | F |   |   |   |   | A#|   |   | C#|   |   |   | F |   |
|||   |   |   | A#|   |   | C#|   |   |   | F |   |   |   |   | A#|   |   | C#|   |
|||   |   |   | F |   |   |   |   | A#|   |   | C#|   |   |   | F |   |   |   |   |
|||   | A#|   |   | C#|   |   |   | F |   |   |   |   | A#|   |   | C#|   |   |   |
|||   | F |   |   |   |   | A#|   |   | C#|   |   |   | F |   |   |   |   | A#|   |
B Major:
|||   |   | F#|   |   |   |   | B |   |   | D |   |   |   | F#|   |   |   |   | B |
||| B |   |   | D |   |   |   | F#|   |   |   |   | B |   |   | D |   |   |   | F#|
|||   |   |   |   | B |   |   | D |   |   |   | F#|   |   |   |   | B |   |   | D |
||| D |   |   |   | F#|   |   |   |   | B |   |   | D |   |   |   | F#|   |   |   |
|||   |   | B |   |   | D |   |   |   | F#|   |   |   |   | B |   |   | D |   |   |
|||   |   | F#|   |   |   |   | B |   |   | D |   |   |   | F#|   |   |   |   | B |
C Major:
|||   |   |   | G |   |   |   |   | C |   |   | D#|   |   |   | G |   |   |   |   |
|||   | C |   |   | D#|   |   |   | G |   |   |   |   | C |   |   | D#|   |   |   |
||| G |   |   |   |   | C |   |   | D#|   |   |   | G |   |   |   |   | C |   |   |
|||   | D#|   |   |   | G |   |   |   |   | C |   |   | D#|   |   |   | G |   |   |
|||   |   |   | C |   |   | D#|   |   |   | G |   |   |   |   | C |   |   | D#|   |
|||   |   |   | G |   |   |   |   | C |   |   | D#|   |   |   | G |   |   |   |   |
C# Major:
||| E |   |   |   | G#|   |   |   |   | C#|   |   | E |   |   |   | G#|   |   |   |
|||   |   | C#|   |   | E |   |   |   | G#|   |   |   |   | C#|   |   | E |   |   |
|||   | G#|   |   |   |   | C#|   |   | E |   |   |   | G#|   |   |   |   | C#|   |
|||   |   | E |   |   |   | G#|   |   |   |   | C#|   |   | E |   |   |   | G#|   |
|||   |   |   |   | C#|   |   | E |   |   |   | G#|   |   |   |   | C#|   |   | E |
||| E |   |   |   | G#|   |   |   |   | C#|   |   | E |   |   |   | G#|   |   |   |
D Major:
|||   | F |   |   |   | A |   |   |   |   | D |   |   | F |   |   |   | A |   |   |
|||   |   |   | D |   |   | F |   |   |   | A |   |   |   |   | D |   |   | F |   |
|||   |   | A |   |   |   |   | D |   |   | F |   |   |   | A |   |   |   |   | D |
||| D |   |   | F |   |   |   | A |   |   |   |   | D |   |   | F |   |   |   | A |
||| A |   |   |   |   | D |   |   | F |   |   |   | A |   |   |   |   | D |   |   |
|||   | F |   |   |   | A |   |   |   |   | D |   |   | F |   |   |   | A |   |   |
D# Major:
|||   |   | F#|   |   |   | A#|   |   |   |   | D#|   |   | F#|   |   |   | A#|   |
|||   |   |   |   | D#|   |   | F#|   |   |   | A#|   |   |   |   | D#|   |   | F#|
|||   |   |   | A#|   |   |   |   | D#|   |   | F#|   |   |   | A#|   |   |   |   |
|||   | D#|   |   | F#|   |   |   | A#|   |   |   |   | D#|   |   | F#|   |   |   |
|||   | A#|   |   |   |   | D#|   |   | F#|   |   |   | A#|   |   |   |   | D#|   |
|||   |   | F#|   |   |   | A#|   |   |   |   | D#|   |   | F#|   |   |   | A#|   |
E Major:
||| E |   |   | G |   |   |   | B |   |   |   |   | E |   |   | G |   |   |   | B |
||| B |   |   |   |   | E |   |   | G |   |   |   | B |   |   |   |   | E |   |   |
||| G |   |   |   | B |   |   |   |   | E |   |   | G |   |   |   | B |   |   |   |
|||   |   | E |   |   | G |   |   |   | B |   |   |   |   | E |   |   | G |   |   |
|||   |   | B |   |   |   |   | E |   |   | G |   |   |   | B |   |   |   |   | E |
||| E |   |   | G |   |   |   | B |   |   |   |   | E |   |   | G |   |   |   | B |
F Major:
|||   | F |   |   | G#|   |   |   | C |   |   |   |   | F |   |   | G#|   |   |   |
|||   | C |   |   |   |   | F |   |   | G#|   |   |   | C |   |   |   |   | F |   |
|||   | G#|   |   |   | C |   |   |   |   | F |   |   | G#|   |   |   | C |   |   |
|||   |   |   | F |   |   | G#|   |   |   | C |   |   |   |   | F |   |   | G#|   |
|||   |   |   | C |   |   |   |   | F |   |   | G#|   |   |   | C |   |   |   |   |
|||   | F |   |   | G#|   |   |   | C |   |   |   |   | F |   |   | G#|   |   |   |
F# Major:
|||   |   | F#|   |   | A |   |   |   | C#|   |   |   |   | F#|   |   | A |   |   |
|||   |   | C#|   |   |   |   | F#|   |   | A |   |   |   | C#|   |   |   |   | F#|
|||   |   | A |   |   |   | C#|   |   |   |   | F#|   |   | A |   |   |   | C#|   |
|||   |   |   |   | F#|   |   | A |   |   |   | C#|   |   |   |   | F#|   |   | A |
||| A |   |   |   | C#|   |   |   |   | F#|   |   | A |   |   |   | C#|   |   |   |
|||   |   | F#|   |   | A |   |   |   | C#|   |   |   |   | F#|   |   | A |   |   |
G Major:
|||   |   |   | G |   |   | A#|   |   |   | D |   |   |   |   | G |   |   | A#|   |
|||   |   |   | D |   |   |   |   | G |   |   | A#|   |   |   | D |   |   |   |   |
||| G |   |   | A#|   |   |   | D |   |   |   |   | G |   |   | A#|   |   |   | D |
||| D |   |   |   |   | G |   |   | A#|   |   |   | D |   |   |   |   | G |   |   |
|||   | A#|   |   |   | D |   |   |   |   | G |   |   | A#|   |   |   | D |   |   |
|||   |   |   | G |   |   | A#|   |   |   | D |   |   |   |   | G |   |   | A#|   |
G# Major:
|||   |   |   |   | G#|   |   | B |   |   |   | D#|   |   |   |   | G#|   |   | B |
||| B |   |   |   | D#|   |   |   |   | G#|   |   | B |   |   |   | D#|   |   |   |
|||   | G#|   |   | B |   |   |   | D#|   |   |   |   | G#|   |   | B |   |   |   |
|||   | D#|   |   |   |   | G#|   |   | B |   |   |   | D#|   |   |   |   | G#|   |
|||   |   | B |   |   |   | D#|   |   |   |   | G#|   |   | B |   |   |   | D#|   |
|||   |   |   |   | G#|   |   | B |   |   |   | D#|   |   |   |   | G#|   |   | B |


G Major: G A B C D E F#

    0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16
||| E |   | F#| G |   | A |   | B | C |   | D |   | E |   | F#| G |   | A |   | B |
||| B | C |   | D |   | E |   | F#| G |   | A |   | B | C |   | D |   | E |   | F#|
||| G |   | A |   | B | C |   | D |   | E |   | F#| G |   | A |   | B | C |   | D |
||| D |   | E |   | F#| G |   | A |   | B | C |   | D |   | E |   | F#| G |   | A |
||| A |   | B | C |   | D |   | E |   | F#| G |   | A |   | B | C |   | D |   | E |
||| E |   | F#| G |   | A |   | B | C |   | D |   | E |   | F#| G |   | A |   | B |
           xxxxxxxxxxxxxxx
            Ionian key G => G(3)
                   xxxxxxxxxxxxxxxxxxx
                    Dorian key G => A(5)
                               xxxxxxxxxxxxxxx
                                Phyrgian key G => B(7)
                               xxxxxxxxxxxxxxx
                                Lydian key G => C(8)
                                       xxxxxxxxxxxxxxxxxxx
                                        Mixolydian key G => D(10)
                                               xxxxxxxxxxxxxxxxxxx
                                                Aeolian key G => E(12)
           xxxxxxxxxxxxxxx                                 xxxxxxxxxxxxxxx
                                                            Locrian key G => F#(14)



Mode name       Notes (all natural)
ionian mode     C, D, E, F, G, A, B, C
dorian mode     D, E, F, G, A, B, C, D
phrygian mode   E, F, G, A, B, C, D, E
lydian mode     F, G, A, B, C, D, E, F
mixolydian mode G, A, B, C, D, E, F, G
aeolian mode    A, B, C, D, E, F, G, A
locrian mode    B, C, D, E, F, G, A, B

e.g. G ionian mode(normal G major): G, A, B, C, D, E, F#, G.   g-ionian-mode g-major-scale
e.g. G phrygian mode: G, Ab, Bb, C, D, Eb, F, G.   g-phrygian-mode

e.g. A7 is A mixolydian: A, B, C#, D, E, F#, G, A    Root,3rd,5th,7th: A C# E G    on guitar: 002020 = EAEGC#E  (Rx1 3x1 5x3 7x1)  7th note is played (duhrr A7)

A  Major:  A   B   C#  D   E   F#  G#  A             Root,3rd,5th,7th: A C# E G#   on guitar: 002220 = EAEAC#E  (Rx2 3x1 5x3)
 major = ionian mode

A  Minor:  A   B   C   D   E   F   G   A             Root,3rd,5th,7th: A C E G     on guitar: 002200 = EAEACE   (Rx2 3x1 5x3)
 natural minor = aeolian mode