Recently I removed an old task from a PierToDo. I noticed it raised a walked-back from PRAdminRemoveCommand>>#doValidate
. The problem was the message self pierAdminAnnouncer
returned nil. I was able to reproduce the problem in a clean Pier image using a simple component:
- Create a component and choose the
counter
option - Increment the counter (it needs some sort of data)
- Click remove and confirm. Error is the same PRAdmin remove problem
Removing the page that contains the component does not raise the error.
Another problem is that http://localhost:8080/piersetup does not open due to missing the TWBSTabWidget
class.
A straight-forward way to resolve this is to remove Pier-Admin from the Pier baselines. It is part of the add-Ons baseline, and the extentions are in part of the core baseline.
I recently started playing a game against my wife called anagrams. Since she is rather good at it, my first attempt was to use command line and the MacOS dictionary:
0 Johns-MBP$ grep '^[pcilas][pcilas][pcilas][pcilas][pcilas][pcilas][pcilas]$' /usr/share/dict/words | grep -v ll
aplasia
asialia
classic
...
This wasn't very fast since it took too long to type the pattern, and also to guess what double-letter options should be avoided.
Next, created some Smalltalk code for possible matches:
| pattern matches stream |
pattern := 'ufmets' asBag.
matches := OrderedCollection new.
stream := '/usr/share/dict/words' asFileReference readStream.
[ stream atEnd ] whileFalse: [ | word boolean |
word := stream nextLine.
( word size <= pattern size and: [ (word allSatisfy: [ :c | pattern includes: c ]) and: [ boolean := true.
word asBag doWithOccurrences: [ :letter :number | (pattern occurrencesOf: letter) < number ifTrue: [ boolean := false ] ].
boolean ] ] ) ifTrue: [ matches add: word ] ].
stream close.
matches sorted: [ :a :b | a size > b size ]
This takes care of the double-letter problem, and won my first game. Unfortunately it requires a change in the pattern (the text ufmets
above).
To make this faster, the next step is to allow the pattern as a command-line argument, this booklet explains the idea. Creating the class:
CommandLineHandler subclass: #WordCommandLineHandler
instanceVariableNames: ''
classVariableNames: ''
package: 'Custom-CommandLine'
On the class side, created:
commandName
^ 'word'
Instance side has:
activate
self activateHelp
ifTrue: [ ^ self ].
self arguments size = 1
ifFalse: [ self printHelp.
^ self exitFailure: 'Missing Arguments' ].
self
printAnagrams;
quit
and:
printAnagrams
| pattern matches stream |
pattern := self arguments first asBag.
matches := OrderedCollection new.
stream := '/usr/share/dict/words' asFileReference readStream.
[ stream atEnd ]
whileFalse: [ | word boolean |
word := stream nextLine.
(word size <= pattern size
and: [ (word allSatisfy: [ :c | pattern includes: c ])
and: [ boolean := true.
word asBag
doWithOccurrences: [ :letter :number |
(pattern occurrencesOf: letter) < number
ifTrue: [ boolean := false ] ].
boolean ] ])
ifTrue: [ matches add: word ] ].
stream close.
(matches sorted: [ :a :b | a size > b size ])
do: [ :str |
str size > 2
ifTrue: [ self stdout
print: str;
lf ] ]
After staving the image, this can be ran as:
0 Johns-MBP$ ./pharo ./anagram.image word pcilas
'spical'
'spica'
'scalp'
'salic'
...
As I was writing this, 3Blue1Brown released a wordle video that is related.
While working on the Pier editor, I've ran into several issues understanding the code (see Displaying Variables in Pier). To get a little more momentum, I started working on one of the Pier Components, the JQuery Cycler.
After working for a while, this may not be the most effective work - a slideshow like this can be done in CSS and HTML (see this example):
This is from when I removed the tile in my kitchen and added drywall.
After upgrading this wiki to the latest code, the changes report displays the user as:
While this only affects logged-in users who view the changes, it is annoying.
When researching this, I found:
- The message
PRContext(Object)>>#magritteDescriptionBuilders
is missing QCDescriptionBuilderContainer
(from the Magritte-Model package). This is also missing in an older image - This area also involves some internal code:
Pragma allNamed: #magritteBuilder from: PRContext to: Object
- For working and non-working, this returns an empty array. - When I was looking into
PRHistoryView>>buildReport
in the debugger, inspecting self buildDescription
raised an error for kernel sent to nil
One option that resolves the issue:
PUUser>>#printOn: aStream
"Needed so the changes view displays without 'PUUser[1234..] name: admin'."
aStream nextPutAll: self name
This seems like a better solution since there are many problems. One is Pier does not yet work on Pharo 9 (first issue is in Pillar). I also noticed problems running Exercism in the new version too (seems to work best on Pharo 8).
More information on the Pier changes feature can be found on Complete Task in List of Changes.
This uses the Buenos Aires Smalltalk group's docker work and here-docs (just create the files with the text between the greater-thans and the closing bang if your shell does not support it):
0 Johns-MacBook-Pro$ mkdir pharo-pier; cd pharo-pier
0 Johns-MacBook-Pro$ cat > start.st <<-!
Transcript show: 'Pier should be running in the background'.
"Suspend UI process, not needed on headless"
(Process allSubInstances reject: #isTerminated)
detect: [ :process | process name includesSubstring: 'UI Process' ]
ifFound: [ :process | process suspend ].
Processor activeProcess suspend.
!
0 Johns-MacBook-Pro$ cat > load-project.st <<-!
Metacello new
baseline:'PierCore';
repository: 'github://Pier-CMS/Pier3:main/repository';
onConflictUseLoaded;
load.
!
0 Johns-MacBook-Pro$ cat > Dockerfile <<-!
# Use the images generated from this repository as base
FROM basmalltalk/pharo:8.0-image
# Put the load-project.st script in the docker image and then load the project
COPY load-project.st ./
RUN pharo Pharo.image load-project.st --save --quit
# Put start.st in the docker image and configure the docker image to start it
COPY start.st ./
CMD [ "pharo", "Pharo.image", "start.st" ]
!
0 Johns-MacBook-Pro$ docker build . -t pharo-pier
0 Johns-MacBook-Pro$ docker run --interactive --tty --rm --publish 8080:8080 pharo-pier
The last command should display the transcript message of pier running. If one connects to http://localhost:8080/pier the basic pier in a web browser. By changing load-project.st
with another pier project or branch then a larger project can be tested.