Friday, 20 November 2015

The quick way to using Rails

lynda.com Ruby on Rails essential training by Kevin Skoglund

Ruby on rails tutorial Learn Rails by Example Michael Hartl

Web Applications by Johm Ousterhout at Stanford Uni
(1 week)

Pick up specific things at
Railscasts by Ryan Bates

Don't bother learning CSS or HTML or Ruby

Saturday, 14 November 2015

TightVNC server for just one app window



    • Now it is possible to show a single application rather than the whole remote desktop. For that, run a server with a -shareapp CLI option and pass a running process ID as its argument.

    Tuesday, 10 November 2015

    Dev Things I did today, Tues 2015/11/11

    Tried for help with Mongoose, so I can get the Http HOST header field to display in the Mongoose Access Log

    Got confirmation of state of Play of SqueakCheck.

    It's now 20:52, so it's time I got moving further ahead.

    It's now 1:56am. No further ahead.


    Monday, 9 November 2015

    Dev Things I Did Today, Mon 2015-11-10

    Between midnight and 6am.

    Bought domain names.
    loveswordplay.com / ,co.uk
    clubknight.co.uk / .uk
    scorekeep.co.uk/ .uk
    grantlove.co.uk

    Set them up at 1&1 to point to the FreeDNS DNS servers
    ns1.afraid.org
    ns2.
    ns3.
    ns4.

    Set FreeDNS up to point to my server at 80.192.200.150/
    Port forwarding is to Stack for 80 and 443

    Tests:
    Chrome. DevTools mode, no caching

    80.192.200.150/
    clubknight.uk / .co.uk
    loveswordplay.com / .co.uk

    all return the Clubknight index page

    grantlove.co.uk returns the 'teal' Love Swordplay index page

    scorekeep.uk / .co.uk returned 404

    Created a folder for scorekeep
    M:\webroot\scorekeep
    D:\Mongoose\webroot\scorekeep

    Created index file for Scorekeep on M, and copied it to D:

    Next test:

    www.scorekeep.uk returns a Clubknight index page, not the scorekeep index page

    www.clubknight.uk/trial does not work
    clubknight.uk.to/trial does not work

    Okay - redirected clubknight.co.uk and .uk.to to
    ./
    This means they pick up the index file correctly.  But they do not pick up the /trial subdirectory properly

    Tried removing all clubknight entries, so all three use the root.

    All of them should point to exactly the same server, so there should be no need to rewrite those three names, all of them should behave the same way

    The mongoose.conf file has been wiped.  By using the Advanced Settings facility

    http://192.168.0.113/__mg_mc refers to the Mongoose Configuration file

    K, working.
    the php file was wrong, as was the access log

    And root was at D:\Mongoose instead of D:\Mongoose\web_root

    It all works now :-)  Tuesday 5:41am

    Set up a PharoCloud account





    Saturday, 7 November 2015

    To start Smalltalk on Pi

    Squeak:
    In a terminal window,
    cd /home/Squeak
    bash squeak.sh

    Pharo:
    In a terminal window,
    cd /PiPharo
    ./PharoS Pharo.image &

    Thursday, 5 November 2015

    Pharo's FileSystem





    myCurrDirectory := FileSystem disk workingDirectory .

    FileSystem 
         disk ( a class method)
     "Answer a filesystem that represents the 'on-disk' filesystem used by the host operating system."

    root ( a class method)
    ^ self disk root

    root
    "Returns the root of the receiver filesystem, i.e. / on unix"
    ^ self referenceTo: Path root

    So.
    FileSystem disk
        creates a new FileSystem object

    FileSystem disk workingDirectory
        creates a new FileSystem object and returns the current directory
    FileSystem disk root
       creates a new FileSystem object, and  magically returns the root path [I currently do not understand this code]

    I now understand this code!  Only 24 hours has past.
    I'm betting:
    FileSystem disk
        creates the new FileSystem instance, and returns
            aFileSystem, with a current disk
                Asking for its root location returns the fully qualified filepath to the root

    changeDirectory: aPath
    self workingDirectoryPath: (self resolve: aPath)  
       
    resolve: aResolvable
    ^ aResolvable asResolvedBy: self

    My brain hurts!


    Wednesday, 4 November 2015

    Getting Google to index web sites.

    Add it to your Google dashboard.

    This is the dashboard  (login to your Google account to access it
    https://www.google.com/webmasters/tools/home?hl=en

    Google sends you a verification file, one that is static for a given Google account.

    i.e. REMEMBER whether the site is for euanmee, or fencingisfun or gordon.r.love

    euanmee : google330990923fcba193.html
    fencingisfunscotland (? - probably, anyway): google7cfe21b3a8296589.html 

    Place the google verification file in the top level folder for the domain

    Then tell Google the file is there






    Specifically for Blogger.com sites, you need to provide a detailed Site Map to Google

    Generate one here:
    (It's important that you tell this generator about your .com site, and not the .local.tld alias that google tells users about, not the .co.uk one, in my case)
    http://ctrlq.org/blogger/

    Structure of Introductory How-to posts, on using facilities

    This sort of 

    This is what it is for:  

    This is how it works: 

    This is how you get it:

    This is how you use it: 

    Background and history (if available / applicable) 

    format is really important to me.

    Tuesday, 3 November 2015

    Unique IDs

    We only need 128-bit UUID (Universally Unique IDs) generated randomly where there are multiple authorities generating IDs, into a space where the items identified are pooled.


    e.g. All National Governing Bodies running their own fencer tracking software.

    Randomly generated UUIDs are very slow to use in databases as primary keys, compared to incremented values.

    Therefore, you want hybrid keys, with a prefix which increments with each new member of the db table, suffixed by a UUID.

    e.g.  000,000,001 0bd6cf13-87c0-a844-b98a-af77d5138f12

    To count the Fencers, requires a Class Instance variable, and for Fencers and School fencers to share a class, and not be sub-classed.

    Or, to use a class variable, and for all people - fencers, parents, referees, judges, etc to share a common increment.

    How many fencers and officials are there, world-wide, over the decades, including historic fencers.

    10,000 historic fencers
    20,000 FIE-rules fencers in the UK, each with an average lifespan as a fencer of 10 years.  (=> 2,000 new per annum)

    Italy and France quintuple the popularity

    China:

    America, similar popularity

    60,000,000 in UK
    20,000 fencers

    =>3000 people per fencer

    1,000,000,000 people in China
    If it's as popular as it is in the UK, then
    350,000 fencers

    If it's 10 times as popular in China, then 3.5 Million

    If it's 100 times as popular in China, then 35 million

    99,999,999 for the size of the single-authority index - one person in thirty in the world's most populous nation

    so personIdNum + personUuid - 2 fields for two items.

    NGB IdNum and FIE id num
    SubNGB IdNum - e.g if Scottish Fencing ran their own
    5 different IDs.  Say they have multiple NGBs?

    Governing Body ID would be a Dictionary of Governing Body and ID num

    Combined when receiving internationals

    So - up to 8 chars of integer for the ID for Person
    About 100 times less than that for competition - there are fewer competitions than fencers.
    But we'll run at 8bytes/1 64-bit word for the Ids, with another 2 64-bit words for the UUIDs
    So Event and Round and Pool and Bout will always be matched up to a competition
    8bytes Competition 150 Events per competition (age groups, and gender and weapon), so say 9999 Events
    Rounds Up to 9999 rounds (say there is a multi round competition that just keeps going around the world?)
    Bouts Up to 9999 bouts in a Round (again some sort of long-lived global competition)

    To make them unique when put together,
    Competition ID + UUID + Competition + Event + Round + Pool + Bout
    8 + 36 + 4 + 4 + 4 = 56 bytes of ID number

    SmallInts are stored in 32bit in 32 bit systems, and 64 bit in 64 bit systems
    so
    4,294,967,276 up to 4.3 billion in a smallint on a 32 bit system
    18,446,744,000,000,000,000 - up to 18.5 quintillion on a 64-bit system

    So storing as an integer would be space efficient in memory.  Prob still efficient on disc

    => integer Id Nums all round, plus a UUID.

    Using Fuel or SandstoneDB

    I can save a whole object, and retrieve a whole object with Fuel. 

    All I need is persistence of new things:
       New fencers (or overwriting fencer data)
       Persisting empty pools
       Persisting bout scores, as they occur
       Persisting completed bouts
       Persisting collections of completed bouts.
       Persisting collections of completed, part-completed and unstarted bouts.

    All reference to the data in use will be from within the image.
    Being able to retrieve a whole competition, if a server has failed.

    SandstoneDB does not pass it's Test suite in either Pharo 4 or Pharo 5

    So Fuel it is.  I can store any object to disc with fuel.  

    Therefore, I can store fencers, the dictionary of all the fencers.

    For the future: investigate if Magma (an in-image persist-to-disc object DB would speed things up)

    Fuel-SIP
    aka Simple Image-based Persistence with Fuel

    the instance methods are just what I do with my manual Fuel code, with an extra level of indirection
    materializeFrom:

    serializeTo:

    The class methods seem



    Reading and writing pool information - design thoughts.

    Things I want to do from Directoire

    Append a BoutScore

    Append a -status entry to -status.js
       bout score
       result
       change of bout

    In the future, when there is a timer on Referee
       fencing restarted
       fencing stopped

    So, I want to

    read all of a status

    write a score

    write a result

    write a change of bout

    Perhaps I should do two things:

    Write to -status and then copy it to a fuel status

    When I read, read from Fuel status

    ==>
    1st task - install SandstoneDb

    Attempting to loading SandstoneDb cause Pharo to throw up

    2nd Task - Install SandstoneDbFuel

    This will let me use Fuel to save and load the SandstoneDb records

    3rd task - Create SandstoneDbCouch - where the Sandstone records are Couched

    Created Smallltalk post as precis of Configuration issues in general

    Monday, 2 November 2015

    Dev Things I did Today

    Read up on UUIDs
    Generated UUIDs
    Added personUuid and accesors on GWPerson
    chatted in ProjectPharo
    Used Fencer objects for real
    Used Fuel to save objects to files, and retrieved them
    Found where Fuel saves by default

    Thought of ways of getting initials

    Currently, setInitials uses firstMiddleInitial which assumes that there is a middle name

    Amended it to cope with empty middle names

    Watched a video on how Smalltalk died

    Discovered that UUIDs are much much much much much slower to work with as keys than incremented integers / set objecttype id string + incremented integer.

    toto now reboots with vnc running, as per:
    https://learn.adafruit.com/adafruit-raspberry-pi-lesson-7-remote-control-with-vnc/running-vncserver-at-startup




    How do get rid of invalid characters from ClubKnight data input

    String>>findIn:startingAt:matchTable:

    Finds any string matching a character in the table

    Will be great to do whitelists for chars in pool and competition and Round names.

    To reboot a Pi from ssh

    sudo reboot


    To close down the Pi
    sudo shutdown 
       or
    sudo halt


    SSH from Chromebook

    Use the Secure Shell app from the Chrome app store

    The native shell (Ctrl-Alt-t) is called crosh. It used to have a ssh app, but no longer does.

    If there is a problem with the setup stored for the Chrome's ssh for a given remote host, you can:

    From the connection dialog, select an identity from the dropdown and press
      the DELETE key.  This will remove both the private and public key files from
      the HTML5 filesystem

    Or you can use the Javascript console from the Secure Shell tab, and then type in:

    > How do I remove a key?
    From the connection dialog, select an identity from the dropdown and press
    the DELETE key. This will remove both the private and public key files from
    the HTML5 filesystem.
    > How do I remove ALL keys?
    Open the JavaScript console and type...
    term_.command.removeDirectory('/.ssh/')
    This will remove any non-key files you may have uploaded as well. It will
    *not* affect your preferences.

    Progress! Using Gawain Directoire to do stuff.

    Today, I've got Gawain to do some real work

    I've created a Fencer

    Stored the Fencer to disc

    Loaded the fencer in from disc

    :-)

    In a Workspace.

    The Fencer had a DoB, given name, family name, and his full name was generated by a method.

    Still needed - a method to generate a short name, and a method to generate initials.

    a UUID
     


    Sunday, 1 November 2015

    Mount a MyBook drive partition on toto

    tot now works to mount the folder.

    First I had to

    sudo mkdir /mnt/shares
    then
    sudo mkdir /mnt/shares/mongoose
    then
    sudo mount -t cifs //192.168.0.251/mongoose /mnt/shares/mongoose -o username=NasLogin,password=NasLoginPsswd

    then sudo nano /etc/fstab
    and add the line
    //192.168.0.251/mongoose <tab> /mnt/shares/mongoose <tab> cifs username=NasLogin,password=NasLoginPsswd<tab>0<tab>0

    It's better to have the login name and password stores in a separate credentials file. 

    (Re)Setting up toto - ssh and vnc

    k - the user login is pi, and now is std +1 on raspberry.  root has the same password.

    Tried to update the installed Raspbian to the latest version.

    Raspbian is now 3660MB , and the memory card only has a 3519MB capacity

    Re-installed the 2014 Raspbian onto the card

    using SDFormatter,  the image files stored in Downloads/Raspberry Pi and Win32DiskImager

    (There was a problem getting the SD card or either of the two card readers to work, but eventually they did, and I uncompressed the image to D:\GrlTemp, then wrote it to the card.

    I used the Pi-config boot tool to set the Pi name to toto, the pi user password, and to enable SSH.

     I installed tightvncserver
    std psswd for VNC
    the desktop is toto:1
    tightvncserver set up a default startup script in /home/pi/.vnc/xstartup
    with a log to /home/pi/.vnc/toto:1.log



    success with logging in on VNC to toto

    Each number for the window e.g. the 3 in "New 'X' desktop is toto:3" should be added to the 5900 base port, to get the port number for the session.   port 5900 only works if there is a :0 window.

    To make the Maplin wireless mouse responsive on teh Pi, I had to:

    add
    usbhid.mousepoll=0

    to /boot/cmdline.txt

    And I had to be superuser to save the amended file - so I had to 
    sudo nano /boot/cmdline.txt  

    Putty is now set up on the PC to SSH in to toto.   At which point I can type vncserver in at the command prompt, and it will run, at which point I can VNC in to the Pi

    VNC still does not work on bootup, but at least I do not ever need to connect toto up to the monitor, even after a reboot


    Saturday, 31 October 2015

    How to add a new millestone to a FogBugz project

    Open the Agile link (top-right of page)
    select the project
    Use the Add a milestone button at top-right, row-three

    .js.map files - Source maps

    These map the original developer .js file's line numbers onto locations in the .min.js file, to return proper locations in case of a bug.


    Dev things I did today, Fri 30/10/15

    experimented with grlDictionary, watching how the internal array of associations filled up, and automagically got bigger when full

    added poolId and accessors to Bout

    added roundId and accessors to Round and to Pool

    Round now knows what Round it is.  Pool now knows what Round it belongs to.

    So how to use the pools object in Round.  It should be a dictionary of Pool objects, keyed on poolId.


    ==========
    What is the lowest level that is useful?

    A list of fencer names.

    Input a list of fencers names, and store them as fencers.

    idea:
    A shortcut for setting up single event competition, that automatically fills up the event data from the competition data entry

    A pool.

    A dictionary of bouts, each with a dictionary of boutScores

    Something that will write the
    pool html index file

    And write the pool's Referee files

    ========

    added competitionId and eventId to Round
    added competitionId and events to Competition
    added eventId and rounds to Event
    added accessors for name startDate to Competition
    amended  boutNumber to boutNum in BoutScores
    added competitionId and eventId to Pool
    added FencerRound class
    added wins, draws, defeats, hitsScored, hitsReceived, indicators, rank, fencerId, roundId, poolId to FencerRound

    Installed latest Seaside on Pharo 4.  Installed Gawain-Directoire on Seaside.  Installed

    Set up my first component/webpage on Seaside.

    Create a Root component from WAComponent.  Set (class attribute) canBeRoot to ^true
    Created a renderContentOn: method that writes the HTML.













    Friday, 30 October 2015

    The list of Unique Short Names

    i.e. Set should be used to determine uniqueness of shortNames

    aSet
       listOfShortNames includes: aNewShortName
          ifTrue:
            [
                find out who also has the shortName
                make that shortname longer
                amend that original shortName everywhere it appears
                get a longer shortname for the new candidate]

    Things I Did Today, Fri 30/10/15

    Up just before noon
    fresh t and pants and socks
    Last night, washed for bed
    breakfast porridge and oj

    Took pill

    Tidied pens up from around the house

    Took Alexa to Amy's

    Bought new pills

    Bought treats and snacks

    Put dinner in oven and on hob

    Separated Thing I did Today into Dev and non-dev

    Watched 3 Grimms




    Thursday, 29 October 2015

    Things I Did Today, Wed/Thursday 28/29/10/15

    Wed. Got up, and made lunch out of noodles, beans, sweetcorn and chili sauce.  It was very *very* hot.

    I had to defrost the sweet chili sauce - it had fallen off the back of the shelf in the Fridge.

    Angus was pleasant when he came home tonight.

    Designed the Classes and variables for Person, Fencer, SchoolFencer, Competition, Event, Round, Pool, Bout

    Wrote the accessors for Classes Person, Parent, Fencer, SchoolFencer

    Wrote initial addChild: and addEmail: methods to Parent

    Couldn't find how to set a Date object to a certain date.  Asked the question on Stack Exchange.
    Lifted my rep from 6 to 21.  It didn't answer my question,

    Set up a Monticello repository for Gawain-Directoire :-)

    Discovered that my Pharo 1.4 image is not saving when I Save and Quit

    I played Warframe from 3:3opm, paused to watch a Grimm with Angus and CJ, and played Warframe all through the night, going to bed at 7am once CJ was up.

    I then removed Warframe from the PC, to try and ensure I actually get on with creative things, rather than simply consuming things.

    Thursday
    Watched an episode of Japanese drama
    Got up, fresh pants and T. Made a twin soup medley.

    Put away the inner PC box

    Went to bed at ~2:20am

    Began doing Smalltalk coding.

    Designed the classes BoutScores

    Wrote the accessors for Classes Bout, BoutScore, Pool,

    Redesigned those Classes as I went

    Watched a TV movie - girl ordered to work on horse ranch by courts. "Spirit Riders"
    while web-browsing

    Read the answers to my question on Stack Overflow.
    Asked the question I really intended to ask on Stack Overflow.  Lifted my rep to 35.  Found the answer to the question I really wanted the answer to. :-)

    And also received the answer I really wanted on StackExchange

    Did the foodbin x3 and the bin and cleared the surfaces with Alexandra. :-)

    Read up on Matrix, Date, String, DateAndTime

    Began to read OU Collections book

    Discovered about Lockdown for Squeak - allows you to set up Squeak to just-run the app, rather than letting the end-users the full run of the Smalltalk image

    http://stackoverflow.com/questions/19350167/can-you-deploy-applications-written-in-smalltalk-squeak-pharo-like-a-java-app
    http://bike-nomad.com/squeak/





    , then asked the question i really wanted

    Tuesday, 27 October 2015

    Things I did today, Tuesday 27/10/15

    Up at 11:30am

    Breakfast alpen + oj
    Empty + fill the dishwasher
    Take Angus to dentist
    Get Angus to bring down his dirty clothes and clear up some of his floor
    Warframe
    Carve pumpkin w alexa
    Watch Flash with Alexa



    Next steps: Oct 2015

    Software improvements

    Often the client device ends up displaying an empty pool grid or Test Area
       Add a change to the text to say "if you see this, press refresh" 

    Is this a server issue or a software issue?

    Hardware improvements

    Currently, Mongoose running data from D:
        Why is favicon.ico served so slowly?  Should it be served as an explicit http request in the page?
        Should the fonts be served locally?  The actual font file (T...etc.woff2) is the second slowest

     Would moving to LightTPD sort these issues?

    Would it happen if it was served from Toto?
    How to mount
    mount //192.168.1.222/win_share -t smbfs /mnt/folder_on_linux -o "username=winuser,password=winsharepassword"


    Audience  
    A version of the Referee files that does not allow access to the Boutlist or bout 
    Therefore - initialise.js has to have a toggle for Referee or Audience.
    If Referee, the buttons for BoutList and Bout are written
    If not referee, they are not written.



    Data written to a DB server.  
       CloudDB
       PostgreSQL 
       (Or both)
       a Smalltalk image
       a Smalltalk image with persistence.
            
    Working with Fencing Time

    FT creates an pool file, empty of scores.

    1) Grab the competition info.  Or have it re-entered.
    2) Read the empty pool.  Create a referee page for this pool.

    Referee does its thing.

    3) Read the pool scores.
    4) Write the scores into the FT pool file.


    1) 
    a) Where does FT write the files to?
    b) Format of the files?
    c) How to get that info from FT to Directoire
    d) What will this part of Direcoire run in or on?

    2) 
    a) Read the .XML file in.
    a) ii) Ideally, read all the XML files for the entire round in.
    b) 
    i) Write each pool file to Referee.  (This is the bit I need to get my head around - where do I write it to?) 
    ii) Needs to be written to where it can be opened by a device's browser.
    iii) So...   using Clubknight or an equivalent, create a folder for the competition's Referee files.
    Put the files in the folder.
    Create a competition/event/round list of Referee pools.
    Or - create a single html file with the single link.  Email a bit.ly version of the link to the Referee. Or make it available to the specific device?

    When the bout has been accepted by Directoire, (remove the link) 



    Create a competition in ClubKnight or in Directoire.



    Read an empty Fencing Time file.  Create a fresh Write 
    Get the connection to Fencing Time sorted.

    Monday, 26 October 2015

    Things I did today, Monday 26/10/15

    Washed Angus's pants
    Hung up Angus's pants
    Went through crushing the cardboard and plastic from the sink with Alexandra
    Got rid of Dominos boxes
    Cleared plastic bottles and cardboard juice boxes from kitchen
    Got Angus to do the dishwasher before computer - HUGE fight
    Put oven on for dinner
    a little tidying of litchen
    a little tidying of bathroom
    clothes mountain in bedroom
    put away my clothes from drying racks

    Sudoku iller x 1.5


    Out of bed at 11:30am

    alpen + oj for breakfast
    Pot noodle at 3:30pm

    No warframe until 5pm!  WF from 5-5pm, 6:30pm-8pm

    Attempted to track down the cause of so many badly displaying Pools from clubknight/trial
    Often showing test area instead of the Pool

    Sunday, 25 October 2015

    The out-of-order bout scores problem

    Due to timing issues, sometimes early hits from the bout arrive later than the later hits.

    If these are simply appended to the list of scores, then the last score to be written to -status.js would be applied to a recovered bout.  And we want the last bout recorded, not the last bout received by PHP.

    So - will freezing out the user input until the hit is recorded fix this? Yes.

    Would freezing out user input for a second fix this?  Yes.

    Would putting the scores into an array of scores, indexed by a score-input counter fix this?  Definitely.

    So currently the scores are sent as the current score for [fencer1][fencer2] and [fencer2][fencer1]

    Continue doing that, as at present.

    When you send an updated score, send an increment number.

    When you store the updated score (append it to -status.js) store them into an array of current bout's scores.

    When restarting a recovered incomplete bout, find the current score that has the largest increment number, and use it.

    If the current bout is unstarted, then no change from current code.

    If the current bout is complete, no change  from current code.

    So - send to getScores.php
    getScores.php

    change in -status.js format to include increment number




    Saturday, 24 October 2015

    Things I did today, Sat 24/10/15

    Warframe

    Bringing gawainDev, gawain and trial into synch

    Getting BitBucket versions of gawainDev and gawain into synch

    All brought into synch with Referee 4.0.5/CK 3.9.3 from gawainDev

    Getting rid of the now-irrelevant clubknight-trial directory

    Moving trial to D:\

    Setting up separate D: Mongoose (port 80) and M: Mongoose (port 8080)

    Setting up port forward for port 8080

    Performance comparison tests on the D: + SSD and M: + NAS Clubknights

    Load LightTPD

    Begin configuration of LightTPD on Windows.

    Things I did today

    Tuesday
    Warframe and Smalltalk PBE

    Wednesday
    Warframe and Smalltalk PBE

    Thursday
    Warframe and Smalltalk PBE

    Friday
    Warframe and Smalltalk PBE

    ClubKnight Dev->Production, Mk1

    There are three configurations for ClubKnight

    1) Development

    2) Test

    3) Production

    Production holds the production code in

    /web_root/trial/
              /templates/  holds the .phtml files
              orgs.php
              /<orgs>/<competitions>
           



    Clubknight Perforrmance on Mongoose

    Clubknight is sometimes slow to response

    Currently, the response comes in from the 'net,
    Mongoose serves up the .php page for the pool
    it requests the ancillary files from the server disk

    so... net to pc, mongoose uses PHP to assemble the page, which then calls the ancillaries - .css, .js - from the NAS drives

    Sometimes this can take up to 6-7 seconds total.

    Firefox breaks the timings down to:
    650ms to 6secs to assemble the PHP page
    ~300ms start to end for all the ancillaries, which all happen in parallel

    Moving the files to the local SSD was meant to speed things up enormously, by doing away with the disk spin-up period in the assembly of the initial PHP web page

    But....  it didn't

    It is very slightly *slower* to pull from the local SSD than from the NAS drive across the intranet

    So....  time to find a faster server than Mongoose?

    Perhaps that will help with the PHP log append issue.

    If the server becomes more responsive, then that should make any intrusion from a waiting graphic less intrusive.

    A trial of LightTPD served a static file in 22ms



    Clubknight server configuration, Mk2

    The server is now:

    M:\<etc>\gawainDev   - Dev

    M:\<etc>\gawain    - Test

    M: Mongoose is now on port 8080

    The clubknight splash page sends the user to the D: Mongoose,
    so you have to manually add the :8080 into the url again


    D:\<etc>\trial  is on port 80   - Production


    Doodles on what next

    How to architect what's coming.

    clubknight/trial

    clubknight/referee

    clubknight/audience

    clubknight/bigscreen

    except that means it's be different datasets


    So.....






    Friday, 23 October 2015

    Things I did today, Mon 19/10/15

    Went to bed with CJ
    Did not sleep at all.
    Got up at 8:30am
    Play SkyForge til 10:30am
    Went to bed and slept til 12:15pm

    Got up, moved Lenny closer, ready for taking stuff to the dump and collecting the new microwave.


    Tuesday, 20 October 2015

    Referee architecture

    getBout.php - which bout are we on
    getScores.php - the latest current score in the current bout
    getResults.php - all the latest info at the End of the Bout


    gawainDev is the dev area
    gawain is the testing area
    clubknight-trial is pre-production
    trial is (currently) production

    Each of them uses their own Organisation lists


    Things I did today, 20/10/15

    Took children to dentist

    Got haircut

    Made Alexa and I baked potatoes in the new microwave

    Helped Alexa do the baked beans

    Fell asleep, watching Brooklyn 99 with Alexa

    2 Warframe missions

    Watched 1 Grimm

    Updated getScores, getResults, getBout to use
    file_put_contents("orgs/$orgId/$competitionId/$filename", $toWrite, FILE_APPEND | LOCK_EX);


    Monday, 19 October 2015

    Things I did today, Sat/Sun 17-18/10/15

    Tidied and vacuumed the living room
    Tidied and vacuumed the hall
    Cleared the kitchen surfaces, filled the dishwasher
    Made the bed

    Played 2 missions of Warframe

    Went through more chapters of Pharo By Example, including overcoming 3 issues

    Watched 2 eps of Grimm with Angus

    Put petrol in Lenny, parked him, and Fuelly-ed

    Watched 2 Grimms with Angus & CJ

    ======

    Set up a char x2 and played 4 missions of SkyForge

    watched 2 Grimms with Angus and CJ




    Friday, 16 October 2015

    Things I did today Thu 15/10/15

    Krispies
    4 egg omelette
    Pot noodle
    biscuits

    Shopping at Margiotta
    Pizza
    flat sausage
    ice cream
    biscuits
    scones
    baking powder
    olive oil spray
    magazines - car, new scientist
    sweetcorn
    kidney beans

    more tidying in study
    Created a skid plate for the PC
       - this lets it slide in and out of its slot very easily

    Created a slot for the PC, by the radiator

    Reorganised and labelled the PC cables - power;  monitor power + monitor signal x2 ; monitor audio ; keyboard
    Connected up the PC. All working :-)

    Played Warframe
    Sudoku

    Downloaded Pharo by example and the corresponding version of Pharo





    Wednesday, 14 October 2015

    The 5 stages of grieving

    Denial

    Anger

    Bargaining

    Depression

    Acceptance

    Things I did today Wed 14/10/15

    Went to bed early - tried to fall asleep to videos
    Slept in late

    Krispies for lunch
    mid-afternoon Knorr chicknoodle soup, w 2 eggs as straciatella
    Cheese & pickle toasties mid-evening

    Pebble charge arrived
    Unpack PC
    Begin tidying study (3 batches of 1/2 hour)

    Put porridge oats into plastic tub

    Several goes at Guardian Sudoku and Killer
    One killer on phone
    Found cordless handset, charged the batteries



    Tuesday, 13 October 2015

    Next ClubKnight step

    Fix the out-of-order hit recording
    =======================
    a) Place a pause at the client end between each hit recorded

    b) Store the hits into a PHP array as they arrive.
    Do not log hits if they arrive after later hits which have already been logged
    http://www.w3schools.com/php/php_sessions.asp on how to persist data between invocations of a script

    or store the sequence number into SQLite rather than a session store, or into CouchDB

    c) Store the hits as an array in Javascript in the client, and store the index/sequence number in status, so they are restored to the recorded-order, and not the logged order

    Eliminate part-recorded data
    ===================
    1) Hardware
    a) Stop using the NAS, start using local hard disc
    b) Start using local SSD to speed things up

    2) Upgrade to PHP 5.5.30
    Does this fix it?
    NO.

    3) Change from
    fopen()
    fwrite()
    fclose()

      to

    file_put_contents($file, $data, FILE_APPEND | LOCK_EX);

    This also incorporates flock()

    Provide Gawain Audience.
    ==================
    List pools on a separate competition page
    These pools go to pages which do not have Boutlist or Bout divs accessible (or perhaps not even included)

    Next enhancement: search by fencer name, and get a list of links to only relevant pools.

    Gawain BigScreen
    =============
    A list of which pool each fencer has been assigned to, and their referee
     to display in alphabetical order






    How to block the screen until the data is sent

    Custom-made 'loading/working' graphics
    http://ajaxload.info/

    xmlHttpRequest.onreadystatechange method fires spontaneously every time the XHR state changes - i.e. everytime there is fresh information about the XHR's progress that returns from the server

    http://www.w3schools.com/ajax/ajax_xmlhttprequest_onreadystatechange.asp
    readyStateHolds the status of the XMLHttpRequest. Changes from 0 to 4:
    0: request not initialized
    1: server connection established
    2: request received
    3: processing request
    4: request finished and response is ready
    status200: "OK"
    404: Page not found

    https://en.wikipedia.org/wiki/XMLHttpRequest#The_onreadystatechange_event_listener

    http://www.antradar.com/blog-in-order-ajax-handling


    position: fixed;
    top: 0px;
    left: 0px;
    height: 100%;
    width: 100%;
    background-color: white;
    opacity: 0.3;
    display:none;
    z-index: 100; /* should be large enough to be on top of everything */



    http://stackoverflow.com/questions/2941189/how-to-overlay-one-div-over-another-div?rq=1

    Using a div with style z-index:1; and position: absolute; you can overlay your div on any other div.
    z-index determines the order in which divs 'stack'. A div with a higher z-index will appear in front of a div with a lower z-index
    ========================

    http://stackoverflow.com/questions/2212578/overlaying-a-image-over-a-whole-web-page


    HTML<div class="overlay"></div>


    CSS

    .overlay{ position:absolute; top:0;left:0; width:100%;height:100%; background:url("image.png") repeat; }

    You probably want to put the div at the very end of the html to ensure it's above everything else on the page, alternatively you could use z-indexing, eg.

    .overlay{ position: fixed; top: 0px; left: 0px; height: 100%; width: 100%;
    background-color: white; opacity: 0.3; display:none; z-index: 100; /* should be large enough to be on top of everything */ }


    an example:
    http://forums.asp.net/t/2043990.aspx?display+loading+image+on+button+click
    http://jsbin.com/fazaxivofu/1/edit?html,output

    another
    https://blog.oio.de/2010/11/08/how-to-create-a-loading-animation-spinner-using-jquery/

    Things I did today 12/10/15

    Fell asleep on couch, ~midnight
    Woke up, went to bed, ~4am
    Woke up, 12:40pm
    Got up 1pm
    Ran bath

    Made porridge w cheese
    smoothie
    orange juice

    Put away recycling
    set off dishwasher

    Sudoku 70 mins

    Read Sat guardian mags

    Blogged Ruby variable naming


    Looked up sports high scores, decided on 10,000 point limit.

    Identified JavaScript's largest safely integer value : 4294967295

    (2^32-1) = 4,294,967,295 or almost 4.3Billion

    There is a new standard out, with a max safe integer value of 2^53-1, but it's poorly supported.

    Ruby variable names convention

    The first characters of a name indicate how the name is used. 

    lowercase letter : Local variables, method parameters, and method names 

    uppercase letter: class names, module names, and constants

    Prefixes:

    global variables : $

    instance variables : @

    class variables : @@

    As no variable may begin with a digit, no digit can follow immediately after a $ @ or @@ prefix

    Things I did today 10 & 11 Oct 2015

    Today
    ====
    Calculated the pumped storage potential of the Tummell/Rannoch/Pitlochrie hydro series
    Read Strathclyde Uni's pumped storage document - turns out folk have thought about it
    Set up two test pools, ran one with Chrome on Chromebook, ran one with Chrome on Galaxy S3. on PHP 5.5.10

    Read up on PHP's manual for fwrite
    Bug reported PHP fwrite issue
    Discovered how to install a new version of PHP for Mongoose
    Installed PHP 5.5.30
    Re-configured Mongoose to use it

    Installed Ruby 2.2
    Looked into how to use Ruby to check all the -status.js files in /trial/orgs/ to id the ones where the write was buggy
     - if the line starts // or bo or cu then it's fine

    Blogged the ClubKnight architecture
    Noted the issue with restoring incomplete bouts when the hots have been recorded out-of-order
    To do: record it on Fogbugz

    Read up on the 60-year climate cycle

    Found the curtain pole measurements, and copied them

    Took out the food bag and the bin bag
    Emptied the dishwasher, and filled it

    Krispies
    Cooked Kraft macaroni cheese
    Toasted the final two pancakes
    Cup-a-soup, 2 slices bread

    All while 4 eps of White Collar
    Started The 4400 - 3.5 eps

    Yesterday
    =======
    Looked into Solar Slate Photovoltaic tiles
    RES group have some
    Solar Century c21e have some (less good looking)
    Have Edinburgh council approved them for use in conservation areas?
    Must install tiles by 31stDec to receive the additional £8k pounds in government funding
    Must have a home energy-efficiency certificate
    Must be installed by a registered MCS installer

    Set up laptop as web server
    Reserved the laptop's IP
    Port forwarded http/port 80 to the laptop
    Confirmed the configuration of the laptop's VNC server

    Chopped a spare onion

    porridge with cheese
    sausage risotto with 2.5 peppers, an onion, mixed veg

    JavaScript's largest safely integer value : 4.29 billion

    JavaScript's largest safely integer value : 4294967295

    (2^32-1) = 4,294,967,295 or almost 4.3Billion

    There is a new standard out, with a max safe integer value of 2^53-1, but it's poorly supported.

    Highest recorded scores for sports

    A ceiling of 10,000 points should cover all of these:


    [Association] Football - 149-0 in Madagascar

    Rugby 356-3 - 53 tries

    Basketball 186-184

    [Field] Hockey

    Ice hockey  International: 82-0, NHL 16-3

    American Football NFL: 72-41, College: 171-0, 158-6

    10-pin bowling - perfect score 3,000

    Snooker - perfect score 147.  Up to 155 if the opponent gives away a foul.


    Monday, 12 October 2015

    Approaches to ensuring incomplete bouts restore to the last-recorded score

    Currently, many loggings go missing or get logged out of order - if the score up/down buttons are pressed in rapid succession.

    If they arrive out of order, then they would restore the wrong score - if the bout is still incomplete at the time of the restoration.

    It will be wrong because the restoration takes the latest-logged result to be the latest, i.e. current result.

    It is not a problem for any completed bout - the "End the Bout" button tends not to be pressed rapidly after the last hit is recorded, and the record, including scores, is re-written.

    One option - record a sequence number each time a hit is recorded, and verify that the hit being restored has the highest sequence number.  This means that the format of the hit-recording array needs to be altered.

    Currently it is stored as
    // Bout 1
    currBout=1; boutStartTimes[1] = '2015-10-12T07:47:58.401Z';
    currFencer1 = 1;  currFencer2 = 2;boutStarted[1][2] = true ; boutStarted[2][1] = true ;
    boutScores[1][2] = 3;  boutScores[2][1] = 0;

    Make the boutScores[][] into boutScores[currFencer1][currFencer2][hitSequence] ?

    And increment the hitSequence each time a hit is recorded - OR a hit is corrected - by the referee.

    How would it work out on the restoration?  To be continued...

    Clubknight - data loss testing

    Cluknight occassionally loses the data from the beginning of a log string to the pool status file.

    Rough guesstimate - 0.3% of logging attempts

    Here is an attempt to re-create the data loss under controlled conditions

    1st try:
    From Chromebook
    On local intranet
    HP laptop as server, using wired ethernet, Virgin Superhub2 as router

    Test / 151012 data loss / 0820
    5 fencers, to 10
    Alternating patterns of  10-0, 0-10, 5-10/10-5
    No errors
    85 hits
    ~105 records
    679 lines of data
    30KB

    2nd
    from Chrome on GRL's Samsung Galaxy 3
    Test / 151012 data loss / 0845 Samsung Chrome
    5 fencers, to 10
    Alternating patterns of  10-0, 0-10, 5-10/10-5
    15 bouts
    ~125 hits
    ~155 records
    1098 lines
    48KB

    Bout 1
      Hit 1 missing
      Hits 3 and 2 are written out of order
    Bout 2 Hit 2 missing entirely
    Bout 3
      Hit 2,4,6,8,13 missing
      11,12 out of order
    Bout 4
      3 2 1 4 7 6 9 10
      5, 8 missing
    Bout 5
      4 2 1 3 5 6 7 9 8
      10 missing
    Bout 6
      1 3 4 5 7 8 9 10 13 11 12 15 14
      2, 6 missing
    Bout 7

    3rd pool  151012-1710-Chromebook
    ======
    Upgraded PHP to 5.5.30
    (hardware - HP laptop, NAS, Mongoose 5.5 running from NAS, PHP 5.5.30 not-thread safe x86 )
    A one second pause between each send is perfectly adequate
    Clicking as fast as you can led to 60% data loss, and out of order for the other 40%

    Clicking ~2/sec still loses
    Bout 6
    Reloaded into LG G3
    On touchscreen, going from 10th increment to End the bout asap, lost some of the writing 





    Architecture of ClubKnight

    Currently:

    clubknight.uk.to is the default Mongoose host domain

    It links to :
    http://clubknight.uk.to/trial/newOrg.php

    newOrg.php creates a new 
          trial/orgs/<org> directory
       and in it
          index.html
          ((O-<org>Comps.php
          compsList.phtml
          ()-<org>NewComp.php

    ((O-<org>Comps.php displays 
          the list in compsList.phtml 
       and 
          a link to ()-<org>NewComp.php

    ()-<org>NewComp.php creates
          trial/<org>/<comp>
    and 
         adds <comp> to trial/<org>/compsList.phtml
    and 
         creates in trial/<org>/<comp> 
             index.html
            ((C-<comp>Pools.php
            <comp>PoolsList.phtml
            ()<comp>NewPool.php

    ()<comp>NewPool.php  creates
       adds <pool> to 
           trial/<org>/<comp>/<comp>PoolsList.phtml
       and 
          creates in trial/<org>/<comp>
             (P)-<comp>-Rd()-Grp0820.php
             <comp>-Rd()-Grp0820.js
             <comp>-Rd()-Grp0820-status.js
            





    VNC for Black2

    Port 6666, and  it's 0.110 on the Superhub atm.

    PHP bug, PHP upgrade, PHP configuration

    The tests are showing that the writes are happening out of order, or not happening at all.

    But none of them are happening partially.

    Reading up on the PHP site, PHP is indeed designed so that they should either happen in full, or not happen at all.

    So it's a PHP bug.

    I have upgraded from PHP 5.5.10, supplied with Mongoose, to PHP 5.5.30, the latest in the 5.5 series.

    I have upgraded to non-thread safe, x86

    There are reports that PHP is not threadsafe whichever of the two binaries you choose.

    To alter the version used, simply place the unzipped PHP folder in the Mongoose directory, and amend the mongoose config .txt file in the Mongoose directory to refer to the new PHP directory.

    Thursday, 8 October 2015

    Naive thoughts on how to structure the Referee data for CouchDB

    Option 1
    A Database per pool
    Document per match?
    Sub-doc per hit?

    Option 2
    A Database per match
    Document per hit?


    For the authorised users database:
    A database per user

    Wednesday, 7 October 2015

    Logging from Referee

    Currently, Referee attempts to send any changes in data incrementally, as and when they happen.

    There are three kinds:

    Change of the active bout
       - if the referee is skipping a bout or returning to an earlier incomplete bout
       - send the new bout number
    Example:
    // Bout 3
    currBout=3; currFencer1 = 1;  currFencer2 = 3;


    Change to the mid-bout score
       - if a fencer scores a hit, or the referee corrects a typo
       - send all the latest info for both of the fencers in the current bout
    Example:
    ///////////////////////////////////////////////////
    // Bout 1
    currBout=1; boutStartTimes[1] = '2015-01-26T19:48:00.548Z';
    currFencer1 = 1;  currFencer2 = 2;
    boutStarted[1][2] = true ; boutStarted[2][1] = true ;
    boutScores[1][2] = 3;  boutScores[2][1] = 0;

    Bout is complete
       - if the referee confirms the bout is over
       - send the final bout scores
    Example:
    ///////////////////////////////////////////////////
    ///////////////////////////////////////////////////
    // Bout 1 over 
    ///////////////////////////////////////////////////
    currBout=1; boutStartTimes[1] = '2015-01-26T19:48:00.548Z';
    currFencer1 = 1;  currFencer2 = 2;
    boutScores[1][2] = 4;  boutScores[2][1] = 0;
    boutVictors[1][2] = 'V';   boutVictors[2][1] = 'L';
    boutStarted[1][2] = true ; boutStarted[2][1] = true ;
    boutStartTimes[1] = '2015-01-26T19:48:00.548Z';
    boutFinishTimes[1] = '2015-01-26T19:48:05.427Z';
    ///////////       ///////////////       ///////////

    Typical lengths

    Question.  What if the current bout is changed to a partially complete bout?

    Then the previous logging of the latest score should still exist.
    What if it did not write successfully back then?

    Gawain (GW) should re-write the most recent score for the part-complete bout which has now returned to being the current bout.

    Asked a question on Stack Exchange today

    "Why is PHP file append only wholly successful in 99.7% attempts"

    Couchbase and CouchDB

    Couchbase is a merge of an earlier fork of CouchDB with MemBase.

    CouchApps are only for CouchDB.


    Tuesday, 6 October 2015

    Gawain Current architecture

    Mongoose running on Stack and on Black2

    Web content stored at myBookDuo/mongoose - accessed from any XXHTWN location

    Data directories are in:
       myBookDuo/mongoose/web_root

    The default domain hostname is ________ and is at that level

    The alternative hostnames are one level down from there, in
    myBookDuo/mongoose/web_root/
       elucidiumprime
       elucidium
       clubknight
       clubknight-trial
       paff
       grantlove
       fif
       myrddin

    Other folders at that level:
     

         

    RPi - toto

    Set up for VNC access

    Set up for ssh access

    Set up Mongoose on toto
    OR
    set up Apache on toto

    What is the IP address?

    What is the VNC port?

    JavaScript Grid widgets

    Jqxgrid

    For Excel-style grids, with nested grids available
    http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/

    BackGrid
    http://backgridjs.com/
    Another Excel-style grid

    Gridster
    http://gridster.net/
    Almost it - but can't do swaps except sometimes.  It does inserts instead of swaps sometimes.



    Although a post by the author at:

    https://github.com/ducksboard/gridster.js/issues/54
    says

    "The behavior is as follows:
    Widgets of smaller or equal size to the dragged widget (player) 
    will swap places with the original widget.
    This causes tiles to swap left and right as well as up and down.
    By default smaller players will shift larger widgets down.
    I have added an option to prevent this behavior:
    $.gridster({
        shift_larger_widgets_down: false
    });
    
    By setting shift_larger_widgets_down to false, smaller widgets will not displace larger ones."

    So it should work *if* the tiles are the same size.


    sBaseline
    Designed to have a tiled set of richly graphic tiles, and inserts instead of swaps sometimes.

    BUT - seems to do swaps most often - just doesn;t show you that that is what is happening.

    The Love Swordplay Gawain Suite

    Gawain - Gordon's Application Without An Interesting Name

    ClubKnight
    App for phones that allows device users to enter Fencer names and start Referee for one pool at a time.

    Referee
    The JS app for recording and displaying scores

    Later sophistication
    Differing colours for complete and incomplete bouts.

    Audience
    Referee minus access to Bout and Boutlist, and without storing anything back to the server.

    Later sophistication:
    Store the bout being viewed

    BigScreen
    Audience

    Later sophistication
    Tickertapes of latest events along the bottom of the screen.
    Auto slideshow from one pool to another
    Additional area for who is about to fence

    Directoire
    The central app for adding fencers, and altering who fights who, and recording results, and then determining the next round's pools and matches

    Later Sophistication
    Organising Season championships results
    Perhaps as a different Name
    Season

    AskGawain
    All results for all fencers from all fights, searchable

    Mercurial in the Cloud - Bitbucket.org

    eme std+1 ?

    Fogbugz

    The way to get into the Fogbugz listing is now to go to
    https://loveswordplay.fogbugz.com/
    grl std+1

    Pharocloud.com and Ephemerics

    Pharocloud.com allows you to run zipped Pharo images on the cloud.

    rig std+1

    They are run in "Ephemeric" instances.  i.e. they store the image offline, until it's called for, at which point they restore it from disk and start the image running again.  It gets stored back to disk after 30 seconds of inactivity.

    To set up the System, click on "Ephemerics", take note of the "API User ID" (User Id) and the "API Auth Token" (Password) and then press the "Open Cloud Client" button.

    In the "Ephemerics Cloud Manager", enter the User Id and Password, and press "Sign In".

    At this point, you can drag'n'drop a zipped Pharo image onto the Ephemerics browser window.






    SmileUpps, CouchApps, Stripe, JSON.stringify, JSON.parse

    What are SmileUpps?

    They are specialised versions of CouchApps, run on the cloud at
    https://www.smileupps.com/

    They are easy to integrate with stripe.com

    No acc

    What is Stripe.com
    It's a payment system.  It takes online payments made by standard credit/debit cards in a web-browser.
    grl now has an account, fab std+1

    What are CouchApps

    They seem to be a way of storing the Javascript and graphics for web apps in CouchDB documents, and getting CouchDB to serve the assets as a web app.

    There is probably some additional scripting to learn to use them, to configure the app.

    JSON.parse and JSON.stringify
    How turn a JS object into JSON.  And how to turn JSON back into the constituent parts.

    New questions
    How to assign multiple constituent parts of JSON into the correct JS variables.