Skip to content

Instantly share code, notes, and snippets.

OpalCompiler>>compile
| cm |
[ [ ast := self parse.
self doSemanticAnalysis.
self callPlugins ]
on: OCSourceCodeChanged
do: [ :notification |
self source: notification newSourceCode.
notification retry ].
cm := ast generate: self compilationContext compiledMethodTrailer ]
@peteruhnak
peteruhnak / slot-vs-accessor.md
Last active September 20, 2017 17:28
Slot vs accessor methods for subscribing/unsubscribing

Subscription Slot vs Accessor

Base (subscription to the model in some manner)

BaseController>>subscribeTo: aModel
  aModel announcer when: ModelRenamed do: [ :ann | self logCr: self class name, ': ' , aModel name ]

BaseController>>unsubscribeFrom: aModel
  aModel announcer unsubscribe: self
@peteruhnak
peteruhnak / StHubToGitHub.st
Last active August 18, 2017 12:31
Copy a project from SmalltalkHub to GitHub
"Based on Uko's script https://gist.github.com/Uko/6898022"
"Get reference to the source repository"
source := MCSmalltalkhubRepository allInstances detect: [ :each |
each location includesSubstring: 'StName/project-name'
].
"Get reference to the target repository"
destination := MCFileTreeGitRepository allInstances detect: [ :each |
each location includesSubstring: 'project-name/repository'
BaselineOfXMLMAGenerator project latestVersion projects collect: [ :each | each name -> each versionString ] as: Array. "{'XMLParser'->#stable. 'XPath'->#stable. 'Magritte'->#stable. 'MagritteXMLBindings'->'baseline'. 'ChangesBuilder'->'baseline'}"
version := BaselineOfXMLMAGenerator project latestVersion.
nodes := version projects, version packages, version groups.
b := RTMondrian new.
b shape text text: #name.
b nodes: nodes.
xmi := OPUMLBootstrapGeneratorTest umlSpecs.
reader := OPUMLXMIReader new.
reader classPrefix: 'OPUML'.
model := (reader readXmi: xmi) first.
"select all classes in the entire metamodel"
cls := (model packagedElements flatCollect: #packagedElements) select: [ :each | each isKindOf: OPUMLClass ].
rootName := 'Behavior'.
@peteruhnak
peteruhnak / RPackage-pseudo-docs.md
Last active June 25, 2017 15:50
Pharo RPackage pseudo-docs

Packages RPackage

Retrieving existing package by name

  • 'MyPackage' asPackage
  • RPackage organizer packageNamed: 'MyPackage'

Create package

  • (RPackage named: 'MyPackage') register
1 to: 100 do: [ :o |
'log.txt' asFileReference
writeStreamDo: [ :stream |
stream
setToEnd;
nextPutAll: 'o(';
nextPutAll: o asString;
nextPutAll: ')';
crlf ].

lockSurfaces.st#L68

sourceHandle := interpreterProxy fetchInteger: FormBitsIndex ofObject: sourceForm.

The above returns 0 just before the crash; the surface was NOT GCed however.

sourceForm was retrieved from here loadBitBltFrom.warping..st

sourceForm := interpreterProxy fetchPointer: BBSourceFormIndex ofObject: bitBltOop.

"For more than 1 depth stencilling (form with alpha for example). use rule 37"
| stencil blitter output color |
color := Color orange.
stencil := Form extent: 32@32 depth: 32.
(FormCanvas on: stencil)
fillOval: (1@1 corner: 31@31)
color: (Color white alpha: 0.5)