Re: [Pharo-users] Beginner's question on morphs

2016-03-15 Thread Markus Stumptner

Thanks! Extremely useful answers.

Cheers
Markus



Re: [Pharo-users] Ideas of web services that I could script in a couple of lines?

2016-03-15 Thread Sven Van Caekenberghe

> On 14 Mar 2016, at 07:25, stepharo  wrote:
> 
> 
>>> On 13 Mar 2016, at 22:42, Henrik Nergaard  wrote:
>>> 
>>> Correct, I used that for the example since it is by default in the Image .
>> And that is a pity, IMHO, it sneaked in, while others have asked for NeoJSON 
>> to be included in the past ;-)
> 
> Sven is STON able to replace MCFileTreeJsonParser
> if so can you open a bug entry and we kill it. You know my point of view of 
> such parsers

https://pharo.fogbugz.com/f/cases/17822/Use-STON-for-JSON-parsing-in-MC-FileTree

> Stef
>> 
>> Anyway, STON, which is also part of the base image can parse JSON just as 
>> well.
>> 
>>   STON fromString: '[42, {"JSON":true}, -1.5]'.
>> 
>> You can also generate JSON.
>> 
>>   STON toJsonStringPretty: { 42. { 'JSON'->true } asDictionary. -1.5 }.
>> 
>>   STON toJsonString: { 42. { 'JSON'->true } asDictionary. -1.5 }.
>> 
>>> Best regards,
>>> Henrik  
>>> 
>>> -Original Message-
>>> From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of 
>>> stepharo
>>> Sent: Sunday, March 13, 2016 10:34 PM
>>> To: Any question about pharo is welcome 
>>> Subject: Re: [Pharo-users] Ideas of web services that I could script in a 
>>> couple of lines?
>>> 
>>> Henrik
>>> 
>>> do you use MCFileTreeJsonParser
>>> just because this was just the JSON parser you got at hand?
>>> 
>>> Stef
>>> 
>>> Le 13/3/16 22:24, Henrik Nergaard a écrit :
 Accessing the Nominatim service: 
 http://wiki.openstreetmap.org/wiki/Nominatim .
 
 http://ws.stfx.eu/ATBXE2DN83CW
 
 Best regards,
 Henrik
 
 -Original Message-
 From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf 
 Of stepharo
 Sent: Sunday, March 13, 2016 9:52 PM
 To: Any question about pharo is welcome 
 Subject: [Pharo-users] Ideas of web services that I could script in a 
 couple of lines?
 
 Hi hernan and others
 
 I'm looking for ideas of simple services capital, dictionaries
 forecast that I could access using Zinc in a couple of lines.
 
 This is for challenges that I'm writing for the mooc.
 Stef
 
 
 
>>> 
>> 
>> 
> 
> 




Re: [Pharo-users] Ideas of web services that I could script in a couple of lines?

2016-03-15 Thread Sven Van Caekenberghe

> On 14 Mar 2016, at 09:33, p...@highoctane.be wrote:
> 
> JSON is so pervasive that a base Pharo image should have things named after 
> it.
> STON is supercool but there is no JSON name in it, that's an issue for me.

I added a class facade STONJSON to make this more explicit (with tests):

===
Name: STON-Core-SvenVanCaekenberghe.70
Author: SvenVanCaekenberghe
Time: 15 March 2016, 5:07:59.236863 pm
UUID: c990d2ab-a407-4935-b489-c55139fdd665
Ancestors: STON-Core-SvenVanCaekenberghe.69

Improve class comments

Add STONJSON facade class to make it more explicit that you can use STON for 
simple JSON parsing and generation

Add STONJSONTests to test JSON compatibility
===
Name: STON-Tests-SvenVanCaekenberghe.62
Author: SvenVanCaekenberghe
Time: 15 March 2016, 5:08:19.634401 pm
UUID: 097090ae-a1ca-4401-86b0-07d7d446a9dc
Ancestors: STON-Tests-SvenVanCaekenberghe.61

Improve class comments

Add STONJSON facade class to make it more explicit that you can use STON for 
simple JSON parsing and generation

Add STONJSONTests to test JSON compatibility
===


This is the STON class comment


===
STON implements serialization and materialization using the Smalltalk Object 
Notation format.

I am a class side facade offering a high level API to write and read objects 
using STON.

U s a g e

Basic operations

  #toString:
  #fromString:

  STON toString: DisplayScreen boundingBox.
  STON fromString:  'Rectangle{#origin:Point[0,0],#corner:Point[1920,1030]}'.

  STON toString: { DateAndTime now. Float pi. 1 to: 10 by: 2. 3 days }.
  STON fromString:  
'[DateAndTime[''2016-03-15T13:57:59.462422+01:00''],3.141592653589793,Interval{#start:1,#stop:10,#step:2},Duration{#nanos:0,#seconds:259200}]'

You can also read from or write to streams

  #fromStream:
  #put:onStream:

There is also the option to do pretty printing (indenting, multi line output) 

  #toStringPretty:
  #put:onStreamPretty:

STON is more or less a superset of JSON and is backwards compatible with JSON 
while parsing, and can be compatible with it while writing. The important 
differences (and the whole reason why STON exists in the first place) are 

  - class information (except for lists (Array) and maps (Dictionary))
  - proper handling of shared and circular references
  - more Smalltalk like syntax (Symbols with #, single qouted Strings, nil 
instead of null)
  - more defined special types (Date, Time, DataAndTime, ByteArray, Point)

Parsing JSON is done using #fromString: or #fromStream: with the results being 
composed of Arrays and Dictionaries.

Writing objects as JSON is done using: 

  #toJsonString[Pretty]:
  #put:asJsonOnStream[Pretty]:

Note that you can only write Arrays and Dictionaries !

For a much more sophisticated JSON parser/writer implementation, have a look at 
NeoJSON.

Like JSON, STON does not allow for comments. However, a preprocessor option can 
skip C style comments before parsing.

I also define some contants used in the implementation: the class used as list, 
map and association, as well as the optional class name key (used when reading 
objects using an unknown class).


I m p l e m e n t a t i o n

The 2 key methods are

  #stonOn:
  #fromSton:

which work together with STONWriter and STONReader; read their class comments 
for all configuration options (you can use the #reader and #writer methods to 
avoid referring to these classes directly).

Several methods are used to support and/or control the implementation

  #stonName - defines the external name for a class
  #stonAllInstVarNames - defines which instance variable to write
  #stonContainSubObjects - shortcut looking into objects for subobjects
  #stonShouldWriteNilInstVars - option to skip writing nil valued instance 
variables


S y n t a x

value
  primitive-value
  object-value
  reference
  nil
primitive-value
  number
  true
  false
  symbol
  string
object-value
  object
  map
  list
object
  classname map
  classname list
reference
  @ int-index-previous-object-value
map
  {}
  { members }
members
  pair
  pair , members
pair
  string : value
  symbol : value
  number : value
list
  []
  [ elements ]
elements
  value 
  value , elements
string
  ''
  ' chars '
chars
  char
  char chars
char
  any-printable-ASCII-character-
except-'-"-or-\
  \'
  \"
  \\
  \/
  \b
  \f
  \n
  \r
  \t
  \u four-hex-digits
symbol
  # chars-limited
  # ' chars '
chars-limited
  char-limited
  char-limited chars-limited
char-limited
  a-z A-Z 0-9 - _ . /
classname
  

Re: [Pharo-users] Ideas of web services that I could script in a couple of lines?

2016-03-15 Thread p...@highoctane.be
Wonderful. You are my hero :-)

Phil

On Tue, Mar 15, 2016 at 5:14 PM, Sven Van Caekenberghe  wrote:

>
> > On 14 Mar 2016, at 09:33, p...@highoctane.be wrote:
> >
> > JSON is so pervasive that a base Pharo image should have things named
> after it.
> > STON is supercool but there is no JSON name in it, that's an issue for
> me.
>
> I added a class facade STONJSON to make this more explicit (with tests):
>
> ===
> Name: STON-Core-SvenVanCaekenberghe.70
> Author: SvenVanCaekenberghe
> Time: 15 March 2016, 5:07:59.236863 pm
> UUID: c990d2ab-a407-4935-b489-c55139fdd665
> Ancestors: STON-Core-SvenVanCaekenberghe.69
>
> Improve class comments
>
> Add STONJSON facade class to make it more explicit that you can use STON
> for simple JSON parsing and generation
>
> Add STONJSONTests to test JSON compatibility
> ===
> Name: STON-Tests-SvenVanCaekenberghe.62
> Author: SvenVanCaekenberghe
> Time: 15 March 2016, 5:08:19.634401 pm
> UUID: 097090ae-a1ca-4401-86b0-07d7d446a9dc
> Ancestors: STON-Tests-SvenVanCaekenberghe.61
>
> Improve class comments
>
> Add STONJSON facade class to make it more explicit that you can use STON
> for simple JSON parsing and generation
>
> Add STONJSONTests to test JSON compatibility
> ===
>
>
> This is the STON class comment
>
>
> ===
> STON implements serialization and materialization using the Smalltalk
> Object Notation format.
>
> I am a class side facade offering a high level API to write and read
> objects using STON.
>
> U s a g e
>
> Basic operations
>
>   #toString:
>   #fromString:
>
>   STON toString: DisplayScreen boundingBox.
>   STON fromString:
> 'Rectangle{#origin:Point[0,0],#corner:Point[1920,1030]}'.
>
>   STON toString: { DateAndTime now. Float pi. 1 to: 10 by: 2. 3 days }.
>   STON fromString:
> '[DateAndTime[''2016-03-15T13:57:59.462422+01:00''],3.141592653589793,Interval{#start:1,#stop:10,#step:2},Duration{#nanos:0,#seconds:259200}]'
>
> You can also read from or write to streams
>
>   #fromStream:
>   #put:onStream:
>
> There is also the option to do pretty printing (indenting, multi line
> output)
>
>   #toStringPretty:
>   #put:onStreamPretty:
>
> STON is more or less a superset of JSON and is backwards compatible with
> JSON while parsing, and can be compatible with it while writing. The
> important differences (and the whole reason why STON exists in the first
> place) are
>
>   - class information (except for lists (Array) and maps (Dictionary))
>   - proper handling of shared and circular references
>   - more Smalltalk like syntax (Symbols with #, single qouted Strings, nil
> instead of null)
>   - more defined special types (Date, Time, DataAndTime, ByteArray, Point)
>
> Parsing JSON is done using #fromString: or #fromStream: with the results
> being composed of Arrays and Dictionaries.
>
> Writing objects as JSON is done using:
>
>   #toJsonString[Pretty]:
>   #put:asJsonOnStream[Pretty]:
>
> Note that you can only write Arrays and Dictionaries !
>
> For a much more sophisticated JSON parser/writer implementation, have a
> look at NeoJSON.
>
> Like JSON, STON does not allow for comments. However, a preprocessor
> option can skip C style comments before parsing.
>
> I also define some contants used in the implementation: the class used as
> list, map and association, as well as the optional class name key (used
> when reading objects using an unknown class).
>
>
> I m p l e m e n t a t i o n
>
> The 2 key methods are
>
>   #stonOn:
>   #fromSton:
>
> which work together with STONWriter and STONReader; read their class
> comments for all configuration options (you can use the #reader and #writer
> methods to avoid referring to these classes directly).
>
> Several methods are used to support and/or control the implementation
>
>   #stonName - defines the external name for a class
>   #stonAllInstVarNames - defines which instance variable to write
>   #stonContainSubObjects - shortcut looking into objects for subobjects
>   #stonShouldWriteNilInstVars - option to skip writing nil valued instance
> variables
>
>
> S y n t a x
>
> value
>   primitive-value
>   object-value
>   reference
>   nil
> primitive-value
>   number
>   true
>   false
>   symbol
>   string
> object-value
>   object
>   map
>   list
> object
>   classname map
>   classname list
> reference
>   @ int-index-previous-object-value
> map
>   {}
>   { members }
> members
>   pair
>   pair , members
> pair
>   string : value
>   symbol : value
>   number : value
> list
>   []
>   [ elements ]
> elements
>   value
>   value , elements
> string
>   ''
>   ' chars '
> chars
>   char
>   char chars
> char
>   any-printable-ASCII-character-
> exce

Re: [Pharo-users] Ideas of web services that I could script in a couple of lines?

2016-03-15 Thread stepharo



Le 14/3/16 09:33, p...@highoctane.be a écrit :
JSON is so pervasive that a base Pharo image should have things named 
after it.

STON is supercool but there is no JSON name in it, that's an issue for me.


Since STON can read and emit JSON I do not get the problem?



What would be a good way to do that? I wonder.

In the same vein, in Angular, consuming webservices that have a 
"proper" REST API (if there is such a thing, but still, this is nice) 
is easy with Restangular (https://github.com/mgonto/restangular). Not 
having such a thing has costed me much time during hackathons, during 
which competition using it was wrapping webservices at the speed of 
light while I was plodding along.


Is there such a thing in Pharo?

Seaside REST
Teapot



Phil

On Mon, Mar 14, 2016 at 8:44 AM, stepharo > wrote:


((STON fromString: (
ZnEasy
get: 'http://api.geonames.org/countryInfoJSON'
username: 'demo'
password: '') contents) at: #geonames) collect: [ : d | d
at: #capital ]

With STON :)







Re: [Pharo-users] Ideas of web services that I could script in a couple of lines?

2016-03-15 Thread p...@highoctane.be
On Tue, Mar 15, 2016 at 6:08 PM, stepharo  wrote:

>
>
> Le 14/3/16 09:33, p...@highoctane.be a écrit :
>
> JSON is so pervasive that a base Pharo image should have things named
> after it.
> STON is supercool but there is no JSON name in it, that's an issue for me.
>
>
> Since STON can read and emit JSON I do not get the problem?
>

Discoverability. See Sven other mail.

>
>
> What would be a good way to do that? I wonder.
>
> In the same vein, in Angular, consuming webservices that have a "proper"
> REST API (if there is such a thing, but still, this is nice) is easy with
> Restangular ( 
> https://github.com/mgonto/restangular). Not having such a thing has
> costed me much time during hackathons, during which competition using it
> was wrapping webservices at the speed of light while I was plodding along.
>
> Is there such a thing in Pharo?
>
> Seaside REST
>

No: this is for exposing endpoints, not consuming them. See Restangular.



> Teapot
>

No: same.

I use SeasideREST and Teapot BTW.

>
>
> Phil
>
> On Mon, Mar 14, 2016 at 8:44 AM, stepharo  wrote:
>
>> ((STON fromString: (
>> ZnEasy
>> get: 'http://api.geonames.org/countryInfoJSON'
>> username: 'demo'
>> password: '') contents) at: #geonames) collect: [ : d | d at:
>> #capital ]
>>
>> With STON :)
>>
>>
>>
>
>


Re: [Pharo-users] [Mongo] Creating MongoTimeStamp

2016-03-15 Thread Martin Dias
Hi,

Voyage's build is green:
https://travis-ci.org/tinchodias/voyage/jobs/116040942
(for the build I temporarily updated BaselineOfVoyage to load #development
version of Mongo).

I will release 1.9.2 as stable if nobody disagrees.

Martin


Re: [Pharo-users] [Mongo] Creating MongoTimeStamp

2016-03-15 Thread Esteban Lorenzano
+1

> On 15 Mar 2016, at 20:53, Martin Dias  wrote:
> 
> Hi,
> 
> Voyage's build is green: 
> https://travis-ci.org/tinchodias/voyage/jobs/116040942 
> 
> (for the build I temporarily updated BaselineOfVoyage to load #development 
> version of Mongo).
> 
> I will release 1.9.2 as stable if nobody disagrees.
> 
> Martin
> 
> 



Re: [Pharo-users] Ideas of web services that I could script in a couple of lines?

2016-03-15 Thread Offray Vladimir Luna Cárdenas

Pretty nice!

I'm taking note of such small gems in an interactive 
[grafoscopio](http://smalltalkhub.com/#!/~Offray/Grafoscopio/) notebook. 
When they take the form of such notebooks I don't know how they should 
be credited... any suggestions?


Cheers,

Offray

On 13/03/16 16:24, Henrik Nergaard wrote:

Accessing the Nominatim service: http://wiki.openstreetmap.org/wiki/Nominatim .

http://ws.stfx.eu/ATBXE2DN83CW

Best regards,
Henrik

-Original Message-
From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of 
stepharo
Sent: Sunday, March 13, 2016 9:52 PM
To: Any question about pharo is welcome 
Subject: [Pharo-users] Ideas of web services that I could script in a couple of 
lines?

Hi hernan and others

I'm looking for ideas of simple services capital, dictionaries
forecast that I could access using Zinc in a couple of lines.

This is for challenges that I'm writing for the mooc.
Stef








Re: [Pharo-users] [Mongo] Creating MongoTimeStamp

2016-03-15 Thread Martin Dias
Done: released 1.9.2.

However, I discovered a problem to run Voyage tests in the Test Runner (and
in Nautilus). The problem comes from 1.9.1. This is weird because Travis
builds are green... but in ui tools tests have this weird problem.

I reported it in https://github.com/estebanlm/voyage/issues/14

Martin

On Tue, Mar 15, 2016 at 5:07 PM, Esteban Lorenzano 
wrote:

> +1
>
> On 15 Mar 2016, at 20:53, Martin Dias  wrote:
>
> Hi,
>
> Voyage's build is green:
> https://travis-ci.org/tinchodias/voyage/jobs/116040942
> (for the build I temporarily updated BaselineOfVoyage to load #development
> version of Mongo).
>
> I will release 1.9.2 as stable if nobody disagrees.
>
> Martin
>
>
>
>