Planet Smalltalk

November 17, 2018

Hernán Morales Durand - Pharo Script of the Day: DesignInfo

Hi there.

Not so much of a script today. Continuing a little bit on the SLOC subject, yesterday I kind of resurrected on GitHub a package called DesignInfo. This package is based purely on Morphic (so it is possible even to run it without Roassal or Moose) and takes every package in a Pharo image, and count the lines of code (LOC, as provided by RPackage), along with other metrics like:

  • Lines of production code
  • Lines of test code
  • Percentage of production code
  • Percentage of test code

You can have a look with the following expressions:

DesignInfo linesOfCodeSortedMorph openInWorld.
DesignInfo linesOfCodeMorph openInWorld.

A histogram is displayed where red bars represents production code and blue bars represents test code. See two screenshots of what the package provides:

November 16, 2018

Yoshiki Ohshima - Adaptive MSDF

私がSqueak仲間に入れてもらったきっかけの一つは、ビットマップのテキストしかなかったSqueakを改良して、TrueTypeフォントを使ったテキストが使えるようにしたことではないかと思っているわけではあります。

最近は3Dグラフィックスのプログラミングをしているのですが、我々のシステムでも、読みやすいテキストが必要ということで、世の中の人が使っているMultichannel Signed Distance Fieldというやつに基づくテキストを実装して見ました。

ところで、この手法は文字サイズが小さくなると読みにくくなるという問題が知られています。他の人もアダプティブレンダリング方法を切り替えて、サイズが小さい時はあらかじめ作っておいたビットマップをテクスチャとして使う方法に切り替えているわけなのですが、具体的にその情報をどこにしまっておこうかなと思っていたところ、例によって賢い同僚が「MSDFはRGBしかつかっていないのだから、Aチャネルにしまっておいて、shaderで切り替えて使えば良い」と言ってくれました。なんとシンプルで賢いのか。

というわけで、早速その手法を実装すると、期待通りにズームインしてもズームアウトしても読みやすいテキスト部品が作れました。これで心置きなくスクリプティングシステムを作っていけます。めでたしめでたし。

Cincom Smalltalk - Camp Smalltalk Charlotte 2019

We would like to invite you to Camp Smalltalk Charlotte on  March 29–March 31, 2019 in  Charlotte, North Carolina.  Hope to see you there!  Event details and registration info are available here.  

The post Camp Smalltalk Charlotte 2019 appeared first on Cincom Smalltalk.

Cincom Smalltalk - The Idea behind a Smart Parking App Proof of Concept

How the Internet of Things (IoT) can offer solution-provider opportunities with significant future growth where Cincom Smalltalk would be a good fit

The post The Idea behind a Smart Parking App Proof of Concept appeared first on Cincom Smalltalk.

Joachim Tuchel - Seaside, File Libraries and UTF-8

In my seemingly endless hunt for potential problems with Umlauts travelling between our users’ web browsers and our Seaside images, I find new areas of “interest” almost daily. As a little background information, it might be useful to mention that at least the Smalltalk diealect we are using (VA Smalltalk) is not speaking UTF-8 natively, … Continue reading Seaside, File Libraries and UTF-8

November 15, 2018

ESUG news - [ANN] Camp Smalltalk 2019 in Charlotte, NC

Camp Smalltalk – Charlotte will be held in Charlotte, North Carolina on March 29 – March 31, 2019.

Camp Smalltalk is a wonderful opportunity to meet and engage with a passionate community of folks interested in Smalltalk programming. Participants will come together, with their favorite flavor of Smalltalk, to discuss a variety of interesting topics such as Smalltalk on IOT devices; web frameworks; virtual machine implementations; data processing applications; programming language design and tooling are expected. In past Camp Smalltalk events we have had participants who were completely new to Smalltalk, or just wanted to see what Smalltalk programming was all about. We are an open community that enjoys sharing our ideas and listening to new ones...so everyone is welcome!

Event details and registration

November 14, 2018

Torsten Bergmann - What FP can learn from Smalltalk

November 13, 2018

Pharo Weekly - Better management of encoding of environment variables

Hi all,

Thanks Ben for reading.

For those wanting a follow up, I’ve proposed this pull request:
https://github.com/pharo-project/pharo/pull/1980.
I’m still working on avoiding dependencies against UFFI, fixing one other
test.
This is however almost finished, and given that I had to adapt the
original *abstract
proposal* to fit the real system, here is an updated version:

API Proposal for OSEnvironment and friends
=========================

OSEnvironment is the common denominator for all platforms. They should
implement at least the following messages with the following semantics:

– *at: aVariableName [ifAbsent:/ifAbsentPut:/ifPresent:ifAbsent:]*

Gets the String value of an environment variable called `aVariableName`.
It is the system reponsibility to manage the encoding of *both arguments
and return values*.

– *at: aVariableName put: aValue*

Sets the environment variable called `aVariableName` to value `aValue`.
It is the system reponsibility to manage the encoding of *both arguments
and return values*.

– *removeKey: aVariableName*

Removes the environment variable called `aVariableName`.
It is the system reponsibility to manage the encoding of *both arguments
and return values*.

API Extensions for *Nix Systems (OSX & Linux)
=========================

Since *Nixes environment variables are binary data that could be encoded in
any encoding, the following methods provide more flexibility to access such
data in the encoding of the choice of the user, or even in binary form.

– *at: aVariableName encoding: anEncoding
[ifAbsent:/ifAbsentPut:/ifPresent:ifAbsent:/put:] / removeKey:**
aVariableName
encoding: anEncoding*

Variants of the common API from OSEnvironment.
The encoding used as argument will be used to encode/decode *both arguments
and return values*.

– *rawAt: anEncodedVariableName encoding: anEncoding
[ifAbsent:/ifAbsentPut:/ifPresent:ifAbsent:/put:] / removeRawKey:*
*anEncodedVariableName*

Variants of the common API from OSEnvironment.
These methods assume arguments and return values are encoded/decoded by the
user, so no marshalling or decoded is done by it.

Rationale
=========================

– Encoding/Decoding should be applied not only to values but to
variables names too. In most cases Ascii overlaps with utf* and Latin*
encodings, but this cannot be simply assumed.
– Windows requires calling the right *Wide version of the functions from
C, plus the correct encoding routine. This could be implemented as an FFI
call or by modifying the VM to do it properly instead of calling the Ascii
version.
– Unix FileSystems and environment variables could mix strings in
different encodings, thus the flexibility added by the low level *Nix
extensions.

Other Implementation Details
=========================

– VM primitives returning paths Strings should be carefuly managed to
decode them, since they are actually C strings (so byte arrays) disguised
as ByteStrings.
– Similar changes had to be applied to correctly obtain the current
working directory in case it is a wide string.

 

Guille

Cincom Smalltalk - Smalltalk Digest: November Edition

In this edition, we will discuss a Smart Parking App Proof of Concept and see a working demo of it. We will also feature a new Hidden Gems screencast as well as a reminder about next month’s talks by Cincomers.

The post Smalltalk Digest: November Edition appeared first on Cincom Smalltalk.

November 12, 2018

Smalltalk Jobs - Smalltalk Jobs -11/11/18

  • Richardson, TX / Ashburn, VA / Raleigh, NC / Temple Terrace, FL / Cedar Rapids, IATechnology Lead through Infosys
    • Required Skills:
      • “At least 4 years of experience in one of the following skills…” with a wide ranging list that includes SmallTalk and Gemstone
      • At least 4 years of experience in software development.
      • At least 4 years of experience in Project life cycle activities on development and maintenance projects.
      • At least 4 years of experience in Design and architecture review.
      • Ability to work in team in diverse/ multiple stakeholder environment.
      • Experience to Telecom domain
      • Experience and desire to work in a Global delivery environment
    • Additional listings: Infosys
  • Buenos Aires, ArgentinaSoftware Developer – Smalltalk (Job ID 180102888) at J.P. Morgan
    • Required Skills:
      • The candidate should have an understanding of an object oriented programming language (Smalltalk) and their underlying principles
      • Data modelling
      • Code version control
      • Understanding of coding optimizations
      • Enthusiasm for increasing knowledge of financial markets and products
      • Willingness to adopt and contribute to an agile development process
    • Wanted Skills:
      • Smalltalk
  • Centurion Gauteng, South AfricaSenior Smalltalk Developer New Project through E-Merge IT Recruitment
    • Required Skills:
      • Relevant tertiary qualification in Engineering or Computer Science
      • 5 – 8 years’ experience as a Small Talk developer
      • 5 – 8 years’ experience as a technical team lead
      • Extensive experience in Gemstone (3 years)
      • In-depth knowledge of unit and integration testing and test automation
      • In-depth knowledge of enterprise, SOA and development patterns and practices
      • Experience in build, release and test automation.
    • Wanted Skills:
      • Experience in IBM WebSphere, MQ and Process Server
    • Additional listings: E-Merge IT Recruitment
  • Quebec, CanadaAnalyste programmeur Smalltalk – VisualWork through Procom
    • Required Skills:
      • Doit être motivé à apprendre et à travailler en SmallTalk
      • Expérience pertinente en Smalltalk, VB.NET ou autre langage orienté-objet
      • Avoir travailler dans un environnement Windows avec Visual Studio
      • Anglais écrit intermédiaire
      • BAC ou DEC en informatique de gestion
      • Minimum 5 ans d’expérience en développement de systèmes
    • Wanted Skills:
      • Expérience dans le domaine de l’assurance de dommages
      • Expérience dans un environnement utilisant les services WEB
      • Expérience en SQL et banque de données relationnelles
      • Expérience dans des projets AGILE
      • Connaissance du COBOL .NET
      • Capacité de faire de l’analyse fonctionnelle simple
Good luck with your job hunting,
James T. Savidge

View James T. Savidge's profile on LinkedIn

This blog’s RSS Feed

November 11, 2018

Pharo Weekly - New random generator: WELL512 PRNG

Hi,

By accident I came across a pseudo random number generator that I never heard off before. It is supposed to be pretty good and had a very simple implementation. So I ported it to Pharo.

<class comment>

I am RandomWELL512, a random number generator.

I use the PRNG (Pseudo Randon Number Generator) WELL (Well equidistributed long-period linear) with a 512 bit state.

  https://en.wikipedia.org/wiki/Well_equidistributed_long-period_linear
  http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng.pdf

Implementation algorithm (See #nextUInt32)

  http://www.lomont.org/Math/Papers/2008/Lomont_PRNG_2008.pdf (Chris Lomont, www.lomont.org)

Usage

  RandomWELL512 new in: [ :r | (1 to: 10) collect: [ :i | r nextUInt32 ] ]. 

  RandomWELL512 new useUnixRandomGeneratorSeed; in: [ :r | (1 to: 10) collect: [ :i | r next ] ]. 

  RandomWELL512 new in: [ :r | (1 to: 10) collect: [ :i | r nextInt: 1000 ] ].

  RandomWELL512 new in: [ :random | | count all |
    random useUnixRandomGeneratorSeed.
    count := 1024 * 1024.
    all := Array new: count streamContents: [ :out |
      count timesRepeat: [ out nextPut: random next ] ].
    { all min. all max. all average. all stdev } ].

  [ RandomWELL512 new in: [ :random | 1 to: 1e6 do: [ :i | random next ] ] ] timeToRun.

Note that you should create one instance, seed it properly, and keep using it.

</class comment>

It is acceptably fast, generating 1M [0,1) Floats in about 0.1s. I compared the output with a fixed initial state to the C code that I started from and I got the same numbers. Maybe some people find this interesting.

I attached a file out.

Sven

Pharo Weekly - Zn nicer API

Hi,

I added a new convenience method to Zinc HTTP Components: ZnClient>>forJsonREST. This configures a ZnClient (HTTP client) to talk to standard JSON REST web services. Here are a couple of examples:

ZnClient new
  forJsonREST;
  get: 'https://jsonplaceholder.typicode.com/users'.

What #forJsonREST does is 3 things: set the 'Accept' header to 'application/json', install a #contentReader that parses incoming JSON as well as a #contentWriter that generates JSON.

ZnClient new
  systemPolicy;
  forJsonREST;
  url: 'https://jsonplaceholder.typicode.com/posts';
  contents: { #foo->1. #bar->2 } asDictionary;
  post.

As you can see, the full ZnClient API can be combined when needed.

ZnClient new
  forJsonREST;
  post: 'https://jsonplaceholder.typicode.com/posts' 
  contents: (NeoJSONObject new foo: 1; bar: 2; yourself).

#post:contents: combines separate #url: #contents: and #post message.

#forJsonREST uses NeoJSON[Object|Writer] if found, else STONJSON. If both are missing, this results in an error.
	
ZnClient new
  systemPolicy;
  forJsonREST;
  url: 'http://easy.t3-platform.net/rest/geo-ip';
  queryAt: #address put: '81.83.7.35';
  get.

Finally, here is a more sophisticated example, doing a DNS request over HTTPS:

ZnClient new
  systemPolicy;
  beOneShot;
  forJsonREST;
  accept: 'application/dns-json';
  url: 'https://cloudflare-dns.com/dns-query';
  queryAt: #name put: 'stfx.eu';
  queryAt: #type put: #AAAA;
  get.

Note that in most cases, you will configure one client to a specific endpoint and keep on reusing it. At one point in time it might be good to #close the client (although that happens on finalise as well). For single requests, you can use #beOneShot.

All this can be found in #bleedingEdge (HEAD). There are unit tests as well.

Sven

November 09, 2018

Clément Béra - 64 bits Immediate Floats

Hi all,

In this post I will try to discuss some inner details of OpenSmalltalk-VM immediate floats. Immediate floats are present only in 64 bits hence I won’t talk about 32 bits VM in the whole blog post. In addition, OpenSmalltalk-VM supports only double precision IEEE floating pointer, hence I won’t discuss single precision IEEE floating pointer.

Immediate objects

OpenSmalltalk-VM uses an immediate object scheme to represent object oriented pointers (oop) in memory. Basically, due to 64 bits alignment, the last 3 bits of all pointers to objects are 000. This is abused to encode in the oop itself specific objects, in our context, SmallIntegers, Characters and ImmediateFloats. This optimization allows to save memory and to improve performance by avoiding boxing allocation for common arithmetic operations. The last 3 bits of an oop are called a tag. The Immediate Float tag is 100 (4 in decimal). Objects encoded directly in the oop are in our terminology called immediate objects.

Immediate

Immediate floats

OpenSmalltalk-VM and its clients use the double precision IEEE format to represent floating pointers, supported by most modern hardware.

doubleIEEE.png

The key idea to the immediate float design is to use an immediate representation of double precision floats to avoid boxing and save memory, while still being 100% compatible with the IEEE double precision format (Customers requirement).

Therefore, in 64 bits, OpenSmalltalk-VM use two implementations for floats. The most common floats are represented with immediate floats, where 3 bits of the exponents are abused to encode the tags. The rest of the floats are represented as boxed floats.

ImmFloat

By design, immediate floats occupy just less than the middle 1/8th of the double range. They overlap the normal single-precision floats which also have 8 bit exponents, but exclude the single-precision denormals (exponent-127) and the single-precision NaNs (exponent +127). +/- zero is just a pair of values with both exponent and mantissa 0.

So the non-zero immediate doubles range from
+/- 0x3800,0000,0000,0001 / 5.8774717541114d-39
to +/- 0x47ff,ffff,ffff,ffff / 6.8056473384188d+38

Encoding and decoding

The encoded tagged form has the sign bit moved to the least significant bit, which allows for faster encode/decode because offsetting the exponent can’t overflow into the sign bit and because testing for +/- 0 is an unsigned compare for <= 0xf.

So given the tag is 4, the tagged non-zero bit patterns are
0x0000,0000,0000,001[c(8+4)]
to 0xffff,ffff,ffff,fff[c(8+4)]
and +/- 0d is 0x0000,0000,0000,000[c(8+4)]

Decoding of non-zero values in machine code is performed as follow:

Decoding.png

Encoding of non-zero values in machine code is performed as follow:

Encoding.png

Reading floats in general is fairly easy, the VM checks the class index, if the class index of immediate float is present, then the float is decoded from the oop, if the boxed float class index is present, the float is read from the boxed object.

Each primitive operation (arithmetic, comparison, etc.) has now to be implemented twice, once in both classes, where the first operand is expected to be an instance of the class where it is installed. In Smalltalk float primitive operations succeed if the second operand is one of the 2 float classes or a SmallInteger. It fails for large integers and arbitrary objects, in which case the VM takes a slow path to perform correctly the operation.

At the end of arithmetic operations, the resulting float has to be converted back from the unboxed format to either an immediate float or a boxed float. To do so, the VM checks the exponent of the float against the smallFloatExponentOffset, 896. 896 is 1023 – 127, where 1023 is the mid-point of the 11-bit double precision exponent range, and 127 is the mid-point of the 8-bit SmallDouble exponent range. If the exponent is in range, it can be converted to an immediate float. If not, one needs to check if the float is +/- 0, in which case it can still be converted to an immediate float, else it has to be converted to a boxed float. The code looks like that in Slang:

^exponent > self smallFloatExponentOffset
ifTrue: [exponent <= (255 + self smallFloatExponentOffset)]
ifFalse:
[(rawFloat bitAnd: (1 << self smallFloatMantissaBits - 1)) = 0
ifTrue: [exponent = 0]
ifFalse: [exponent = self smallFloatExponentOffset]]

x86_64 encoding/decoding

To conclude the post, here are the instructions generated in x86_64 to encode immediate floats. I put the instruction so that you can see how to encode efficiently using the theoretical design from the figures above and in addition quick checks for +/- 0.

000020da: rolq $1, %r9 : 49 D1 C1
000020dd: cmpq $0x1, %r9 : 49 83 F9 01
000020e1: jbe .+0xD (0x20f0=+@F0) : 76 0D
000020e3: movq $0x7000000000000000, %r8 : 4D B8 00 00 00 00 00 00 00 70
000020ed: subq %r8, %r9 : 4D 2B C8
000020f0: shlq $0x03, %r9 : 49 C1 E1 03
000020f4: addq $0x4, %r9 : 49 83 C1 04

Decoding is easier:

00002047: movq %rdx, %rax : 48 89 D0
0000204a: shrq $0x03, %rax : 48 C1 E8 03
0000204e: cmpq $0x1, %rax : 48 83 F8 01
00002052: jle .+0xD (0x2061=+@61) : 7E 0D
00002054: movq $0x7000000000000000, %r8 : 4D B8 00 00 00 00 00 00 00 70
0000205e: addq %r8, %rax : 49 03 C0
00002061: rorq $1, %rax : 48 D1 C8
00002064: movq %rax, %xmm0 : 66 48 0F 6E C0

Let me know if you have any question or you want me to expand this post with something else.

Note: Part of the blog post was extracted from the SpurMemoryManager class comment on immediate float, I thank Eliot Miranda and other OpenSmalltalk-VM contributors for writing it.

Joachim Tuchel - Glorp findings – using count:

Conntinuing on the Customer/Order example from my last post, we might want to only send some ads to customers who have ordered at least twice in the past. For this we’d first have to cunt all orders of our customers who haven’t ordered for at least 100 days. So the first step is to create … Continue reading Glorp findings – using count:

Joachim Tuchel - Glorp Subqueries – notExists:

I decided to get back to blogging after a very long break. Since I am quite busy with our Kontolino! project, I also decided that I need to get back to blogging with small articles that require little time – but might still be useful. So here is the idea: I am struggling with Glorp … Continue reading Glorp Subqueries – notExists:

November 07, 2018

Pharo Weekly - [Ann] v1.4.0 of Iceberg

Hello!

This week we are releasing the version v1.4.0 of Iceberg.
(https://github.com/pharo-vcs/iceberg/releases/tag/v1.4.0)

This version is available in the latest Pharo 7.

This release fixes a bug introduced in v1.3. It also add new features
in the repository view, add some cleaning and also re-introduce a
feature that was lost.

Thanks to all contributors.

Enjoy!

Full changelog:

Bugfixes

#1068 'There is no associated repository configured.' warning on right
clicking missing repository

Features

#1077 Repository view: Allow to collapse branches/remotes/tags trees
#847 Move tags under remotes in Repository view
#1070 set upstream if missing

Cleanups

#1066 Pharo 7: PackageManifest subclasses should be packaged with "Manifest"
#1015 Replace usages of Glamour in the Github Plugin
#1063 1061-Introduce-iconNamed-in-IceDefinition-and-IceTipModel-and-remove-all-the-terrible-Smalltalk-ui-icons

Pharo Weekly - [ann] Pharo 7.0.0-rc1

Greetings!

I’m announcing today we reach Pharo 7.0.0-rc1!

This is the first step to release a definitive version, and while we will continue integrating bug fixes, API change Pull Requests will be delayed until the open of Pharo 8.0.0 development.
Now, you would wonder what is the ChangeLog of this release… and answer is we still do not have one (btw, we should find a way to automate this).

Anyway… we are very close to release now 🙂

Please download, test, report issues.

November 06, 2018

Pharo Weekly - [Ann] release v1.3 of Iceberg

Hello!

This week we are releasing the version v1.3 of Iceberg.
(https://github.com/pharo-vcs/iceberg/releases/tag/v1.3.0
+https://github.com/pharo-vcs/iceberg/releases/tag/v1.3.1)

This version will be available after we merge this PR:

https://github.com/pharo-project/pharo/pull/1951

This release contains some new features such as the support of self
hosted gitlab, integration with github, etc.
It also contains multiple bug fixes, cleanups and enhancements.

On the CI part, Guille made the Appveyor build green! This will
increase the stability of the windows support.

Thanks to all contributors.

Enjoy!

Full changelog:

Features

#1021 Self hosted gitlab support
#1027 Improved new tag dialog to generate semantic versionning tags
#1044 Show a button “View on Github” when creating a PR
#1008 Add “create branch from GitHub issue” option
#1048 Add commands to open remotes on Github
#1010 Add menu entry in extras to force calculate diff

Bug corrections

#975 Metacello asks too many times what to install when there are
conflicting versions
#980 Iceberg should Identify better the packages and the normal files
#982 The Edit Project should have a Warning if it will affect the packages
#986 Iceberg does not realize changes in extended classes
#999 Pulling and pushing to a gitolite server asks password
#984 Conversion to Tonel generates corrupted .properties
#1041 Filter in repository view don’t work with capital letters
#1019 Metacello Integration leaves Monticello leftover repositories
#859 Creating a branch and pushing does not sets the upstream
#1043 Packages starting with lowercase not recognized
#991 Error on right click in the project editon wizard
#775 Reviewing a PR is broken
#1036 Debugger if we try to merge without selecting a branch
#1064 Fix failing tests regarding clean code in Pharo

Enhancements

#988 Iceberg should load the packages in a single MCLoader (This will
make the loads of packages atomic)
#1001 Use “instance creation” instead of “instance-creation” for
method protocol name
#1004 Use displayScaleFactor in UI
#977 Add ToolTip help to the Commands
#1030 Better support for binary files
#1034 SSH passphrase is now hidden

Cleanups

#1018 Iceberg UI relies on deprecated classes from Spec and Commander
#1051 Clean useless huge hierarchy in Github plugin UI

Infrastructure Enhancements

#1023 Fix CI for windows

November 03, 2018

Hernán Morales Durand - Pharo Script of the Day: One-liner identity matrix

Check how easy is to create an identity matrix in Pharo, in just one line: require matrix size from user and print the output:

(Array2D identity: (UIManager default request: 'Enter size of the matrix:') asInteger) asString

November 02, 2018

Pharo Weekly - [Pharo-dev] [ANN] The STON Specification

Hi,

Since there can never be enough documentation I finally took some time to write a more formal description of STON as a data format.

  https://github.com/svenvc/ston/blob/master/ston-spec.md

The idea is to let this stabilise a bit and to then update the two other documents describing STON, where necessary:

  https://github.com/svenvc/ston/blob/master/ston-paper.md
  https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfulBuild/artifact/book-result/STON/STON.html

Also, the latest changes in STON have to make their way to the Pharo image as well.

  https://github.com/svenvc/ston

All feedback is welcome.

Sven

Torsten Bergmann - Dynamic creation of compiler plugins in Pharo

A new class (merged this week into Pharo 7) called "OCCompilerDynamicASTPlugin" allows for the dynamic creation of compiler plugins


Object compiler
addPlugin:
(OCCompilerDynamicASTPlugin
newFromTransformBlock: [ :ast | (RBParseTreeRewriter replaceLiteral: 42 with: 'meaning of life') executeTree: ast. ast. ]
andPriority: 0
);
evaluate: '42'.
This would give 'meaning of life'

November 01, 2018

Joachim Tuchel - Seaside Learnings, pt. 123

Note to self: never, never ever try to use show:onAnswer: or answer: in an Ajax callback. In your delegating WATask or  WAComponent you will see the callback code run as if all was good, just the new components won’t show up in th browser. This will take a long time to debug and you won’t … Continue reading Seaside Learnings, pt. 123

October 30, 2018

Hernán Morales Durand - Pharo Script of the Day: Mass image format conversion from PNG to JPEG

You might find useful the following code to convert a whole directory of image in PNG format to JPEG:

(FileSystem disk workingDirectory filesMatching: '*.png') do: [ : pngFile |
pngFile asFileReference binaryReadStreamDo: [ : stream |
PluginBasedJPEGReadWriter
putForm: (PNGReadWriter formFromStream: stream)
onFileNamed: pngFile withoutExtension , 'jpg' ] ]
displayingProgress: 'Converting images to JPG...'.

October 26, 2018

David A. Smith - arcos


The arcos platform embedded in my blog.



Hernán Morales Durand - Pharo Script of the Day: Text analysis using tf-idf

Today's snippet takes a natural language text as input (a.k.a. the Corpus) where each line is considered a different document, and outputs a matrix of term documents with word mappings and frequencies for the given documents. This is also known as tf-idf, a distance metric widely used in information retrieval and provides the relevance or weight of terms in a document.

Why is not this just simple word counting?

If you increase relevance proportionally to word count, then all your query results will have words like "the" as the most relevant in the whole set of documents (or even in a single document), as it is a very common word. So you would need to decrease count for these common words, or increase count for "rare" words to get their relevance. This is where IDF (inverse document frequency) comes into play. With IDF you count documents, so you will assign low score to terms appeared in a lot of documents, then increasing the divider and decreasing relevance.

Finally, Stop words are removed and stemming is performed to reduce words with the same root.

First of all, you can install Moose-Algos (with some needed Hapax classes in a clean Pharo image by evaluating:


Metacello new
configuration: 'MooseAlgos';
smalltalkhubUser: 'Moose' project: 'MooseAlgos';
version: #development;
load.
Gofer it
smalltalkhubUser: 'GustavoSantos' project: 'Hapax';
package: 'Hapax';
package: 'Moose-Hapax-VectorSpace';
load.

Then you can execute the script:

| corpus tdm documents |
corpus := MalCorpus new.
documents := 'Julie loves me more than Linda loves me
Jane likes me more than Julie loves me'.
documents lines doWithIndex: [: doc : index |
corpus
addDocument: index asString
with: (MalTerms new
addString: doc
using: MalCamelcaseScanner;
yourself)].
corpus removeStopwords.
corpus stemAll.
tdm := HapTermDocumentMatrix on: corpus.
tdm.

October 25, 2018

Smalltalk Jobs - Smalltalk Jobs -10/25/18

Very cool job at Thales in Brest France working with 3D, VR and Pharo.  Do note that Thales has joined the Pharo Consortium so they seem into Smalltalk.

NB:  This is a 6 month internship (Stage in French) aimed at people finishing their BAC.  So this is probably only useful if you are a French student in France.

Hernán Morales Durand - Pharo Script of the Day: Count lines of code

Lines of code, LOC, SLOC, ELOC... one the simplest and metrics around, and we could find the method with the most LOC in the image with just one line of code (tested in Pharo 6.1):

SystemNavigation default allMethods 
collect: [ : m | m -> m linesOfCode ]
into: (SortedCollection sortBlock: [ : a : b | a value < b value ])

For more advanced software engineering queries have a look to the cool Moose ecosystem

October 24, 2018

Cincom Smalltalk - Cincomers to Speak at Upcoming JavaScript Meetup

Like chocolate and peanut butter, Cincom Smalltalk and JavaScript go hand and hand and you have an opportunity to see that for yourself at an upcoming JavaScript Meetup. On Wednesday, […]

The post Cincomers to Speak at Upcoming JavaScript Meetup appeared first on Cincom Smalltalk.

Cincom Smalltalk - Smalltalk Digest: October Edition

In this edition, we will discuss fiscally responsible ways to use year-end budget and how custom Services solutions may be a good fit for customers. We will also feature two new Hidden Gems screencasts as well as a preview for upcoming talks by Cincomers.

The post Smalltalk Digest: October Edition appeared first on Cincom Smalltalk.

Hernán Morales Durand - Pharo Script of the Day: SPARQL access to DBPedia


Let's face it, how many times you could have a mix of Natalie Portman with Smalltalk code? :) If you install a little SPARQL wrapper library in Pharo, you could for example access the Natalie's movie list querying DBPedia by writing something like the following code in the SPARQL query language:


DBPediaSearch new
setJsonFormat;
timeout: 5000;
query: 'PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?filmName WHERE {
?film foaf:name ?filmName .
?film dbpedia-owl:starring ?actress .
?actress foaf:name ?name.
FILTER(contains(?name, "Natalie"))
FILTER(contains(?name, "Portman"))
}';
execute

To actually get only the titles you can use NeoJSON to parse the results:

((((NeoJSONReader fromString: jsonResults) at: #results) at: #bindings) collect: [ : entry | entry at: #filmName ]) 
collect: [ : movie | movie at: #value ]

And this is how results looks like: