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