Skip to content

Instantly share code, notes, and snippets.

View gcotelli's full-sized avatar
🏠
Working from home

Gabriel Omar Cotelli gcotelli

🏠
Working from home
View GitHub Profile
OSWindowMorphicEventHandler >> visitWindowExposeEvent: anEvent [
"Completely redraw world when visible part of window changes to prevent some graphical glitches"
morphicWorld worldState doFullRepaint.
@gcotelli
gcotelli / CodeFormatting.st
Last active January 1, 2024 19:41
Pharo 9 Code Formatting
EFFormatter
maxLineLength: 100;
useBasicCommentFormat: true;
formatCommentCloseToStatements: false;
indentStyle: #tabulation;
"Signature"
methodSignatureOnMultipleLines: true;
selectorAndArgumentCombinedMaxSize: 40;
"Blocks"
keepBlockInMessage: true;
| newNames methods missingSelectors changes |
newNames :=
(Willow classification >> #bootstrap4) names difference:
(Willow classification >> #bootstrap3) names.
methods := ComponentClassificationCommandBuilder allSelectorsInProtocol: '*Willow-Bootstrap-4'.
missingSelectors := (newNames difference: methods) sorted.
changes := missingSelectors collect: [ :selector |
| source change |
source := '<1s>
@gcotelli
gcotelli / Rewrite.st
Last active September 19, 2019 13:59
Rewrite changes
| env rewriter result methods changes |
env := RBBrowserEnvironment default forPackages: (RPackageOrganizer default packages select: [:p | p name beginsWith: 'Z' ]).
rewriter := RBParseTreeRewriter new.
rewriter
replace:'`@class == `@aClass or:[`@class inheritsFrom: `@aClass]' with: '`@class includesBehavior: `@aClass'.
changes := Array with: (RBSmalllintChecker runRule: (RBTransformationRule new
rewriteRule: rewriter;
yourself)
@gcotelli
gcotelli / CodeSearching.st
Last active March 13, 2021 13:04
Code Searching in Pharo
| env rule result methods |
env := RBBrowserEnvironment default .
rule := CodeSearchingRule new.
rule matcher
matches:'`@col do: [:`el | `@html render: `el ]' do:[:n :a | true] .
result := (RBSmalllintChecker
runRule: rule
@gcotelli
gcotelli / CodeFormatting.st
Created November 20, 2018 23:03
Pharo Code Formatting Configuration
BIConfigurableFormatter
maxLineLength: 100;
useBasicCommentFormat: true;
formatCommentWithStatements: true;
indentString: Character tab asString;
"Signature"
methodSignatureOnMultipleLines: true;
selectorAndArgumentCombinedMaxSize: 40;
"Blocks"
keepBlockInMessage: true;
@gcotelli
gcotelli / Label-Creation.st
Last active May 20, 2019 19:20
GitHub Label Creation using the API, run on Pharo 7
| repo owner api labels newLabels |
repo := 'REPO'.
owner := 'OWNER'.
api := IceGitHubAPI new
credentials: (IcePlaintextCredentials new username: 'USER';password: 'PASSWORD';yourself).
labels := api get: ('repos/<1s>/<2s>/labels' expandMacrosWith: owner with: repo).
labels collect: [ :label | api delete: ('/repos/<1s>/<2s>/labels/<3s>' expandMacrosWith: owner with: repo with: (label at: #name) urlEncoded) ].
newLabels :=
#(
('Type: Defect' 'A problem which impairs or prevents the functions of the product.' 'f44336' )
String streamContents: [:s |
| constantsClass |
constantsClass := CssFontConstants.
(constantsClass class methods groupedBy: [ :method | method category ])
keysAndValuesDo: [ :category :methods |
s nextPutAll: 'initialize'.
category substrings do:[:string | s nextPutAll: string ].
s nextPutAll: 'Constants'.
s cr.
| table |
table := self componentSupplier tableBuilder
addColumn: [ :column | column
rendering: [ :number | number ];
summarizedWith: [ [:html | html strong: 'All even?'] ] ];
addColumn: [ :column | column
rendering: [ :number | number even ];
titled: 'Is even?' applying: [:cell | cell addClass willow ];
summarizedWith: [:numbers | numbers allSatisfy: [ :number | number even ]] ];