Skip to content

Instantly share code, notes, and snippets.

View olekscode's full-sized avatar
🇺🇦
Stand with Ukraine

Oleksandr Zaitsev olekscode

🇺🇦
Stand with Ukraine
View GitHub Profile
@olekscode
olekscode / cormas-without-ui.st
Last active June 9, 2023 08:56
Example of running a Cormas simulation in Pharo 11 without UI
"Run this in Pharo 11"
"Load Cormas without UI"
Metacello new
onConflictUseLoaded;
onWarningLog;
repository: 'github://cormas/cormas:v0.5';
baseline: 'Cormas';
load: #Core.
prices := #(13 2 13 15 10 8 6.5 14 12 13 8). "prix en euro"
"----------------------"
sum := 0.
prices do: [ :each |
sum := sum + each ].
sum.
url := 'http://192.168.27.64:8080/shot.jpg'.
client := ZnClient new
url: url;
yourself.
imagePresenter := SpImagePresenter new.
imagePresenter autoScale: true.
imagePresenter open.
@olekscode
olekscode / pharo-diffs.st
Created June 20, 2021 00:34
Extract diffs from the commit history between two versions
repositoryName := 'DataFrame'.
oldVersionTag := 'v1.0'.
newVersionTag := 'v2.0'.
repository := (IceRepository registry detect: [ :repo |
repo isValid and: [ repo name = repositoryName ] ]).
oldCommit := (repository tags detect: [ :tag | tag name = oldVersionTag ]) commit.
newCommit := (repository tags detect: [ :tag | tag name = newVersionTag ]) commit.
numberOfPoints := 10000.
scale := 30.
pointExtent := 2@2.
color1 := Color fromString: '3288BD'.
color2 := Color fromString: 'D53E4F'.
mu1 := #(1 0) asPMVector.
mu2 := #(-1.5 -1) asPMVector.
"In Pharo 7"
methods := Smalltalk image allClasses flatCollect: [ :aClass |
aClass methods ].
signatures := methods collect: [ :method | method name ].
fileReference := '/Users/oleks/Documents/Data/Methods/signatures7.ston' asFileReference.
fileReference writeStreamDo: [ :stream |
Metacello new
baseline: 'DataFrame';
repository: 'github://PolyMathOrg/DataFrame/src';
load.
covidDataFile := '/Users/oleks/Documents/Data/COVID-19-geographic-disbtribution-worldwide-2020-03-17.csv' asFileReference.
"The date format is not understood by Pharo by default.
So we read CSV with all values as strings (without type inference)
and then manually convert dates and numbers"
# Rules for migrating from PetitParser to PetitParser2
# Source: https://kursjan.github.io/petitparser2/migration.html + Cyril Ferlicot (https://ferlicot.fr/)
PPParser => PP2Node
asParser => asPParser
PPCompositeParser => PP2CompositeNode
isPetitFailure => isPetit2Failure
PPCompositeParserTest => PP2CompositeNodeTest
i
me
my
myself
we
our
ours
ourselves
you
your
datasetBuilder := NGDatasetBuilder new.
trainMethods := datasetBuilder loadTrainMethodsTable.
validMethods := datasetBuilder loadValidMethodsTable.
testMethods := datasetBuilder loadTestMethodsTable.
model := NGModel new.
model trainOn: trainMethods.
model probabilityOfSequence: #(self initialize).