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