Re: [Pharo-users] how to convert this with a stream

2019-03-26 Thread Carlo
Hi Roelof

The block [] should be (). What's happening is that the block is being added to 
outcome which will then print itself out.

Cheers
Carlo

On 26 Mar 2019, at 20:45, Roelof Wobben  wrote:

Hello

Could be , im confused now

I tried this :

outcome
add: 'Team   | MP |  W |  D |  L |  P'.
outcome
add: [ String
streamContents: [ :s |
TeamStatusSorted
do: [ :each |
s << each name.
s << String cr ] ] ].
^ outcome

but  get now a output of the header and then the code.

Roelof



Op 26-3-2019 om 19:38 schreef Carlo:
> Hi Roelof
> 
> I think you meant
>   String streamContents:
> and not
>   Array streamContents:
> 
> 
> 
> On 26 Mar 2019, at 20:12, Roelof Wobben  wrote:
> 
> Hello,
> 
> I have a SortedCollection of teams.
> 
> Now I need to convert this to a line like this :
> 
> 'Allegoric Alaskans |  1 |  1 |  0 |  0 |  3'
> 
> I tried it with this :
> 
> outcome := Array
> streamContents: [ :s |
> TeamStatusSorted
> do: [ :each |
> s << each name.
> s << String cr ] ].
> ^ outcome
> 
> 
> or String streamContents but it will not give me the right answer,
> So please some hints how I can make this work.
> 
> Roelof
> 
> 
> 
> 
> 






Re: [Pharo-users] how to convert this with a stream

2019-03-26 Thread Carlo
Hi Roelof

I think you meant 
  String streamContents: 
and not 
  Array streamContents:



On 26 Mar 2019, at 20:12, Roelof Wobben  wrote:

Hello,

I have a SortedCollection of teams.

Now I need to convert this to a line like this :

'Allegoric Alaskans |  1 |  1 |  0 |  0 |  3'

I tried it with this :

outcome := Array
streamContents: [ :s |
TeamStatusSorted
do: [ :each |
s << each name.
s << String cr ] ].
^ outcome


or String streamContents but it will not give me the right answer,
So please some hints how I can make this work.

Roelof






Re: [Pharo-users] splitting a string using regex

2019-01-15 Thread Carlo
Hi Steve

If you use \n then that is trying to match a non-printable character i.e. 
linefeed. The \\n will match the text '\n'.

Example matching linefeed:

> myString := 'one{1}{1}two{1}{1}' format: {String lf}.
> re := '\n' asRegex.
> myString splitOn: re. 

Answers a collection of 5 elements.

Regards
Carlo

On 15 Jan 2019, at 06:25, Steve Quezadas  wrote:

I am answering my own question because I found the solution for it.

This is the code that didn't work:
> myString := 'one\n\ntwo\n\n'.
> re := '\n\n' asRegex.
> myString splitOn: re.

The reason it didn't work was because you apparently have to escape the 
newlines pattern in the regex line. So the correct (working) example is here:
> myString := 'one\n\ntwo\n\n'.
> re := '\\n\\n' asRegex.
> myString splitOn: re.

I am putting this on here just in case someone else runs into the same problem.

- Steve



On 01/14/2019 09:06 AM, Steve Quezadas wrote:
> I am trying to split a string in pharo using a regular expression.
> A simple example that works:
> myString := 'one\n\ntwo\n\n'.
> myString splitOn: '\n\n'.
> A simple example that does not work:
> myString := 'one\n\ntwo\n\n'.
> re := '\n\n' asRegex.
> myString splitOn: re.
> The result of the above is I get the regular old string back 
> ('one\n\ntwo\n\n'). I went through the source code and it should be able to 
> handle a regex object:
> > "splitter - can be a subsequence, a Block or a Regex (String receiver
> > only). Any other object used as a splitter is treated as an Array
> > containing that object."
> I am baffled as to why it's not working. is there something simple I am 
> missing?
> - Steve





Re: [Pharo-users] XML Writer not pretty printing

2018-08-14 Thread Carlo
Hi Peter

It seems that #preservesIgnorableWhitespace: is only adhered to "...When 
validation is enabled and a DTD with element declarations is present..." (See 
comment in SAX2ContentHandler>>ignorableWhitespace:) The actual parsing code is 
in SAXParserDriver>>handleWhitespace:

What you could do is use #removeAllFormattingNodes but your-mileage-may-vary...

parser := XMLDOMParser
on:'

  

'.

(parser parseDocument)
removeAllFormattingNodes;
prettyPrinted.

Regards
Carlo

On 14 Aug 2018, at 13:08, Peter Uhnak  wrote:

Hi,

I am trying to output a pretty printed document, but it seems that the 
configuration is being ignored

doc := '

  

' parseXML.

String << [ :stream |
doc 
printOn: stream
beforeWritingDo: [ :writer | 
writer
enablePrettyPrinting;
enablePlatformSpecificLineBreak.
writer formatter indentString: '  '. ] ]


produces

 "'

  

'"

I thought that maybe #preservesIgnorableWhitespace: has something to do with 
it, but whether it is true or false, the output is not pretty printed (not to 
mention, that pretty printing should ignore any preserved whitespaces anyway).

Is this a bug? Should I print it in a different way?

Thanks,
Peter




Re: [Pharo-users] transactions on pharo objects

2018-08-06 Thread Carlo
Hi

This research from VPRI may be useful: Worlds: Controlling the Scope of Side 
Effects <http://www.vpri.org/pdf/tr2011001_final_worlds.pdf> and Experiments 
with Worlds <http://www.vpri.org/pdf/m2013002_experiments.pdf> (Alessandro 
Warth, Yoshiki Ohshima, Ted Kaehler, and Alan Kay)
They had a JS and Squeak version running which can be found at 
http://www.tinlizzie.org/~awarth/worlds/ 
<http://www.tinlizzie.org/~awarth/worlds/>

Regards
Carlo

On 30 Jul 2018, at 15:16, Peter Uhnák mailto:i.uh...@gmail.com>> wrote:

Hi,

is there some library or approach how to do transactions in pharo?
And I don't mean database transactions, but directly in memory on Pharo 
objects... e.g.

p := Person new.

transaction do: [
p name: 'Nobody'.
p age: 70.
] on: Error do: [
transaction rollback.
].

self assert: p name equals: 'Nobody'.
self assert: p age equals: 70.

transaction do: [
p name: 'Somebody'.
p age: 1 / 0.
] on: Error do: [
transaction rollback.
].

self assert: p name equals: 'Nobody'.
self assert: p age equals: 70.

Any pointers appreciated.

Thanks,
Peter




Re: [Pharo-users] SQLite bridge crashed Pharo 5.

2016-04-13 Thread Carlo
Hi

I've recently been playing with medical provider data sets which are quite 
large, also around 270K records. I'm using a Moose image Pharo5.0 Latest 
update: #50643 on a Mac OS X.

The initial issue I had was with memory settings for the VM. This has been 
increased and the image ranges from 800MB to 1.3GB and has been fine. There 
have been occasional crashes/hangs but this is to do with memory limits and GC. 
Typically this occurs when making class format changes to existing instances of 
data e.g. new variables introduced to a working image with a large data set. To 
counter this I have a base image which I update the code and then import the 
data (CSV for now) using NeoCSV. This process takes about 30 seconds so it's 
not too painful.

The other issue I've come across is a slow down in querying the data sets using 
the Playground. I profiled the code and found that the culprit to be 
GLMTreeMorphModel>>explicitlySelectMultipleItems: which is terribly slow as it 
iterates over the entire data set. I've made a modification to prevent the 
expensive iteration when there are more than 5 records to be displayed e.g. 
 
self roots size > 5
ifTrue: [ ^ self ].

I'm also using 
Teapot to be able to perform easy querying of the 2 data sets and to build an 
HTML comparison view of the records. This uses the in-memory OO model to 
populate the html.
Teapot to be able to pull a STON representation into a different image, then 
building instances for performing querying or simple reporting.
The Playground workspace to query and analyse the data cheaply e.g. self 
collect: [ :each | each disciplineCode ] as: Bag. Then using the customised 
view to quickly see a distribution of values.

Anyway the reason for this long-winded email is to hopefully provide some 
useful feedback but more to thank everyone involved in building a powerful 
environment. I'd hate to name people, because I'm sure to miss most, but the 
efforts of people like Sven (Neo*, STON), Doru (Moose*), Avi (ROE, BTREE) are 
appreciated. I know there are a lot of hands behind the scenes to make Pharo, 
from the fast VM to the UI, so thanks to all.

Regards
Carlo


On 13 Apr 2016, at 2:49 AM, Offray Vladimir Luna Cárdenas 
<offray.l...@mutabit.com> wrote:

Hi,

On 12/04/16 16:51, Stephan Eggermont wrote:
> On 12/04/16 22:44, Offray Vladimir Luna Cárdenas wrote:
>> I'm working with visualizations a external dataset which contains 270k
>> records. So the best strategy seems to bridge pharo with SQLite to keep
>> requirements low while using Roassal to visualize aggregated information
>> that is obtained from querying the database.
> 
> It won't fit in image?
> 

I tried with RTTabTable and NeoCVS but they can not load the data. I made a 
test drawing 150k points and the image starts to lag and trying to query the 
data becomes inefficient compared to query the data on SQLite. For the moment 
I'll export the query results to CVS, but I'll hope to have the SQLite bridge 
working soon.

Offray




Re: [Pharo-users] Transcrip Show: in a loop

2015-11-13 Thread Carlo
Hi

You could fork a thread which will free up the UI thread.
e.g.

[ 10 timesRepeat: [ 
aLongComputation.
Transcript show: 'some message' ] ] fork

Regards
Carlo


On 13 Nov 2015, at 12:06 PM, abdelghani ALIDRA <alidran...@yahoo.fr> wrote:

Thanks Vincent,

 flush does not seem to work but I think I am going to use bench.

Abdelghani

De : Blondeau Vincent <vincent.blond...@worldline.com>
À : abdelghani ALIDRA <alidran...@yahoo.fr>; Any question about pharo is 
welcome <pharo-users@lists.pharo.org> 
Envoyé le : Vendredi 13 novembre 2015 10h37
Objet : RE: [Pharo-users] Transcrip Show: in a loop

Hi,
 
For benchmarking, you should do :
[ aLongComputation] bench
 
It is simpler that to write on Transcript the execution time.
 
About the writing of the messages on Transcript, that is a normal behavior.
Maybe you should try “Transcript flush” to force the message writing?
 
Vincent
 
De : Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] De la part de 
abdelghani ALIDRA
Envoyé : vendredi 13 novembre 2015 10:21
À : pharo-users@lists.pharo.org
Objet : [Pharo-users] Transcrip Show: in a loop
 


Hi all,
 
In order to monitor my program performance, I am using Transcrip>>show as 
follows ;
 
10 timesRepeat:[
aLongComputation.
Transcript show: 'some message'.
]
 
The thing is that the messages are not shown one after another but all together 
after the loop is finished, unless I put a ... self halt
Is this behavior normal? is there any way to make the messages come one by one?
 
Thanks
 
Abdelghani


Ce message et les pièces jointes sont confidentiels et réservés à l'usage 
exclusif de ses destinataires. Il peut également être protégé par le secret 
professionnel. Si vous recevez ce message par erreur, merci d'en avertir 
immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant 
être assurée sur Internet, la responsabilité de Worldline ne pourra être 
recherchée quant au contenu de ce message. Bien que les meilleurs efforts 
soient faits pour maintenir cette transmission exempte de tout virus, 
l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne 
saurait être recherchée pour tout dommage résultant d'un virus transmis.

This e-mail and the documents attached are confidential and intended solely for 
the addressee; it may also be privileged. If you receive this e-mail in error, 
please notify the sender immediately and destroy it. As its integrity cannot be 
secured on the Internet, the Worldline liability cannot be triggered for the 
message content. Although the sender endeavours to maintain a computer 
virus-free network, the sender does not warrant that this transmission is 
virus-free and will not be liable for any damages resulting from any virus 
transmitted.



Re: [Pharo-users] Is it always needed to redefine #hash message when you redefine #= message?

2015-05-26 Thread Carlo
Hi 

Any two objects that are = must answer the same #hash value.
The hash is used in any of the HashedCollection's for storage and then to find 
the exact element the #= is used.
If 2 objects are #= but their hash values are different the HashedCollection 
will not find the correct storage slot and you will have undefined behaviour 
when looking up objects.

Out of interest, Andres Valloud wrote a whole book on 'Hashing in Smalltalk' 
(http://www.lulu.com/content/1455536)

Also the Javadoc comments are pretty good in explaining the usage:
 The general contract of hashCode is:
 Whenever it is invoked on the same object more than once during an execution 
 of a Java application, the hashCode method must consistently return the same 
 integer, provided no information used in equals comparisons on the object is 
 modified. This integer need not remain consistent from one execution of an 
 application to another execution of the same application.
 If two objects are equal according to the equals(Object) method, then calling 
 the hashCode method on each of the two objects must produce the same integer 
 result.
 It is not required that if two objects are unequal according to the 
 equals(Object) method, then calling the hashCode method on each of the two 
 objects must produce distinct integer results. However, the programmer should 
 be aware that producing distinct integer results for unequal objects may 
 improve the performance of hash tables.
 As much as is reasonably practical, the hashCode method defined by class 
 Object does return distinct integers for distinct objects.

Cheers
Carlo

On 26 May 2015, at 8:45 PM, Julien Delplanque jul...@tamere.eu wrote:

The subject of this mail is exactly my question.

I came to this question by looking at Object#= message implementation.


= anObject
   Answer whether the receiver and the argument represent the same
   object. If = is redefined in any subclass, consider also redefining the
   message hash.

   ^self == anObject


When do we need to redefine #hash message?

Is it the right way to implement equality between two objects or is there 
another message that I should override?

Regards,
Julien





Re: [Pharo-users] Alt-tab between windows

2015-05-16 Thread Carlo
Hi

I see my earlier email was bounced again...


Ok, hacked and debugged my pharo 4 image and I've got ctrl- left or right 
working on my mac.

Two changes needed 

TaskListMorphkeyStroke: event  needs to change as per below to add the ctrl 
left or right.

TaskListMorphkeyStroke: event 
Process keys to switch task.
event keyCharacter = Character escape ifTrue: [^self delete].
event anyModifierKeyPressed ifFalse: [^self done].

event keyString =  'Ctrl-left' ifTrue: [^self selectPreviousTask].
event keyString =  'Ctrl-right'   ifTrue: [^self selectNextTask].

event keyString =  'Opt-Shift-tab' ifTrue: [^self selectPreviousTask].
event keyString =  'Opt-tab'  ifTrue: [^self selectNextTask]

Then TaskListMorphisNavigationEvent: aKeyboardEvent needs to change as per 
below:

isNavigationEvent: aKeyboardEvent
| validCombos |
validCombos := Array with: Character tab alt with: Character tab alt 
shift with: Character arrowLeft ctrl with: Character arrowRight ctrl .
^ validCombos contains: [:each | each = aKeyboardEvent 
asKeyCombination].

Ctrl-left or Ctrl-right works, and again you need to press any key to select 
the window on preview.

Cheers
Carlo

On 16 May 2015, at 1:05 AM, Avdi Grimm a...@avdi.org wrote:

Messing around, I've gotten the impression that Morphic doesn't really have the 
concept of a window manager. I've even played with the Tiling Window Manager, 
but it isn't really a *manager* in the usual sense, it's more of a collection 
of shortcuts for manually resizing windows.

Without having dove into the implementation yet, it feels like Morphic is more 
a system where each window paints itself where it wants to be, and there isn't 
a centralized controller or manager of windows. Is that accurate?

On Fri, May 15, 2015 at 6:58 PM Nicolai Hess nicolaih...@web.de 
mailto:nicolaih...@web.de wrote:


2015-05-16 0:52 GMT+02:00 Avdi Grimm a...@avdi.org mailto:a...@avdi.org:
Hey folks! I've dabbled with smalltalk here and there over the years, but 
recently I've settled in to learn Pharo in earnest. A few of you might have 
seen the videos I've been putting up; they seem to be making the rounds on 
Twitter. I just want to say I've felt really welcomed by all the people who 
have commented with helpful tips, or offered to help with my exploration :-)

I've run into my first big blocker as a newcomer. Like many programmers I'm a 
fan of keeping my hands on the keyboard. Now, I'm more flexible on this than 
some. I recognize that Pharo is a visual environment, and it makes sense to 
explore it with a mouse. And some interactions just make more sense with a 
mouse.

That said, no matter what windowing environment I'm in, I find the ability to 
quickly cycle between windows without leaving the keyboard pretty crucial. One 
Windows or Ubuntu I would normally do this with Alt-Tab or Super-Tab. On MacOS 
it's Cmd-Tab.

I've been trying to figure out how to do this in Pharo. I've looked for answers 
with Google, SO, and on IRC, and I've come up blank. I'm starting to think it 
can't be done.

So, I've come here for your help. Is there a way to cycle between windows? Or 
is anyone working on it? Or, perhaps, am I missing an element of the Pharo 
programming workflow which renders it unneeded?

Many thanks,

--
Avdi

I miss this too.

This worked in Pharo 1.4 (alt + left arrow / alt+right arrow).

I don't know why this was removed. 

I often wanted to look at this and try to bring it back, but didn't find the 
time.


nicolai




Re: [Pharo-users] Alt-tab between windows

2015-05-16 Thread Carlo
Hi

See my earlier email was bounced.
...

Ok, hacked and debugged my pharo 4 image and I've got ctrl- left or right 
working on my mac.

Two changes needed 

TaskListMorphkeyStroke: event  needs to change as per below to add the ctrl 
left or right.

TaskListMorphkeyStroke: event 
Process keys to switch task.
event keyCharacter = Character escape ifTrue: [^self delete].
event anyModifierKeyPressed ifFalse: [^self done].

event keyString =  'Ctrl-left' ifTrue: [^self selectPreviousTask].
event keyString =  'Ctrl-right'   ifTrue: [^self selectNextTask].

event keyString =  'Opt-Shift-tab' ifTrue: [^self selectPreviousTask].
event keyString =  'Opt-tab'  ifTrue: [^self selectNextTask]

Then TaskListMorphisNavigationEvent: aKeyboardEvent needs to change as per 
below:

isNavigationEvent: aKeyboardEvent
| validCombos |
validCombos := Array with: Character tab alt with: Character tab alt 
shift with: Character arrowLeft ctrl with: Character arrowRight ctrl .
^ validCombos contains: [:each | each = aKeyboardEvent 
asKeyCombination].

Ctrl-left or Ctrl-right works, and again you need to press any key to select 
the window on preview.

Cheers
Carlo



On 16 May 2015, at 1:32 AM, Avdi Grimm a...@avdi.org wrote:

I'd be totally cool with Alt-Left/Right. I just want *something* so I don't 
have to lift my hand just to switch from e.g. Browser to Playground and back.

On Fri, May 15, 2015 at 7:23 PM Nicolai Hess nicolaih...@web.de 
mailto:nicolaih...@web.de wrote:
2015-05-16 1:11 GMT+02:00 Carlo snoob...@gmail.com 
mailto:snoob...@gmail.com:
On my 

Pharo4.0
Latest update: #40609

Pressing Alt-Tab brings up a debugger. Debugging the method shows:

But this does not work for Pharo on Windows . On windows alt+tab always 
switches between active applications.
There was some code on older versions of pharo, that uses alt+left arrow/right 
arrow instead of alt+tab for
the windows vm

 

newPreviewMorph
Answer a new preview holder.
self halt.
^ Morph new
color: Color transparent;
extent: self defaultPreviewExtent;
yourself.


On 16 May 2015, at 1:09 AM, Avdi GScreenshot 2015:05:16, 1:11 AM.pngrimm 
a...@avdi.org mailto:a...@avdi.org wrote:



On Fri, May 15, 2015 at 7:06 PM Carlo snoob...@gmail.com 
mailto:snoob...@gmail.com wrote:
Removing the 'self halt' still works though.

Can you give me a little more detail about where to find this? Thanks! 




Re: [Pharo-users] Alt-tab between windows

2015-05-15 Thread Carlo
On my 

Pharo4.0
Latest update: #40609

Pressing Alt-Tab brings up a debugger. Debugging the method shows:

newPreviewMorph
Answer a new preview holder.
self halt.
^ Morph new
color: Color transparent;
extent: self defaultPreviewExtent;
yourself.


On 16 May 2015, at 1:09 AM, Avdi Grimm a...@avdi.org wrote:



On Fri, May 15, 2015 at 7:06 PM Carlo snoob...@gmail.com 
mailto:snoob...@gmail.com wrote:
Removing the 'self halt' still works though.

Can you give me a little more detail about where to find this? Thanks! 



Re: [Pharo-users] Alt-tab between windows

2015-05-15 Thread Carlo
As far as I know you are correct in assumption of morphic windows; especially 
considering experiences playing with Self where it originated from.
TWM is a way of managing the multiple open windows.

Morphic objects are cool though especially in Squeak or Lively Kernel (Pharo 
less so) e.g. rotate a workspace or editor and you can edit it while rotated, 
or resizing it. In Squeak you could start an mpeg video in a morph and then 
rotate the window or duplicate it while continuing playback. Gimmicky but still 
cool to see what a few concepts interacting can do.

On 16 May 2015, at 1:05 AM, Avdi Grimm a...@avdi.org wrote:

Messing around, I've gotten the impression that Morphic doesn't really have the 
concept of a window manager. I've even played with the Tiling Window Manager, 
but it isn't really a *manager* in the usual sense, it's more of a collection 
of shortcuts for manually resizing windows.

Without having dove into the implementation yet, it feels like Morphic is more 
a system where each window paints itself where it wants to be, and there isn't 
a centralized controller or manager of windows. Is that accurate?

On Fri, May 15, 2015 at 6:58 PM Nicolai Hess nicolaih...@web.de 
mailto:nicolaih...@web.de wrote:


2015-05-16 0:52 GMT+02:00 Avdi Grimm a...@avdi.org mailto:a...@avdi.org:
Hey folks! I've dabbled with smalltalk here and there over the years, but 
recently I've settled in to learn Pharo in earnest. A few of you might have 
seen the videos I've been putting up; they seem to be making the rounds on 
Twitter. I just want to say I've felt really welcomed by all the people who 
have commented with helpful tips, or offered to help with my exploration :-)

I've run into my first big blocker as a newcomer. Like many programmers I'm a 
fan of keeping my hands on the keyboard. Now, I'm more flexible on this than 
some. I recognize that Pharo is a visual environment, and it makes sense to 
explore it with a mouse. And some interactions just make more sense with a 
mouse.

That said, no matter what windowing environment I'm in, I find the ability to 
quickly cycle between windows without leaving the keyboard pretty crucial. One 
Windows or Ubuntu I would normally do this with Alt-Tab or Super-Tab. On MacOS 
it's Cmd-Tab.

I've been trying to figure out how to do this in Pharo. I've looked for answers 
with Google, SO, and on IRC, and I've come up blank. I'm starting to think it 
can't be done.

So, I've come here for your help. Is there a way to cycle between windows? Or 
is anyone working on it? Or, perhaps, am I missing an element of the Pharo 
programming workflow which renders it unneeded?

Many thanks,

--
Avdi

I miss this too.

This worked in Pharo 1.4 (alt + left arrow / alt+right arrow).

I don't know why this was removed. 

I often wanted to look at this and try to bring it back, but didn't find the 
time.


nicolai




Re: [Pharo-users] Alt-tab between windows

2015-05-15 Thread Carlo
Was taking a look in my image and followed references to Character alt or ctrl 
and found the hooks, but changing them wasn't working.

Remembered now that there is a Keymap Browser under World/System/Keymap Browser
You could try looking at that or wait until someone that knows responds...

Cheers
Carlo




On 16 May 2015, at 1:32 AM, Avdi Grimm a...@avdi.org 

wrote:

I'd be totally cool with Alt-Left/Right. I just want *something* so I don't 
have to lift my hand just to switch from e.g. Browser to Playground and back.

On Fri, May 15, 2015 at 7:23 PM Nicolai Hess nicolaih...@web.de 
mailto:nicolaih...@web.de wrote:
2015-05-16 1:11 GMT+02:00 Carlo snoob...@gmail.com 
mailto:snoob...@gmail.com:
On my 

Pharo4.0
Latest update: #40609

Pressing Alt-Tab brings up a debugger. Debugging the method shows:

But this does not work for Pharo on Windows . On windows alt+tab always 
switches between active applications.
There was some code on older versions of pharo, that uses alt+left arrow/right 
arrow instead of alt+tab for
the windows vm

 

newPreviewMorph
Answer a new preview holder.
self halt.
^ Morph new
color: Color transparent;
extent: self defaultPreviewExtent;
yourself.


On 16 May 2015, at 1:09 AM, Avdi GScreenshot 2015:05:16, 1:11 AM.pngrimm 
a...@avdi.org mailto:a...@avdi.org wrote:



On Fri, May 15, 2015 at 7:06 PM Carlo snoob...@gmail.com 
mailto:snoob...@gmail.com wrote:
Removing the 'self halt' still works though.

Can you give me a little more detail about where to find this? Thanks! 




Re: [Pharo-users] Error: RemoteString past end of file on Pharo 4.0

2015-05-03 Thread Carlo
Hi

My first thought was also to do with the .change file, as I have received this 
error before when creating manual backups of images.

Cheers
Carlo

On 04 May 2015, at 12:22 AM, Cyril Ferlicot cyril.ferli...@gmail.com wrote:

It happend to me when I renamed some .image without renaming the .change file.
Maybe that's the problem.

On 3 May 2015 at 23:35, Offray Vladimir Luna Cárdenas off...@riseup.net wrote:
 Hi,
 
 I was about to update some changes on my project as a result of this weekend
 hackathon, but I got this error:
 
 Error: RemoteString past end of file
 
 I'm using:
 
  - Pharo4.0 Latest update: #40611
  - OS: 3.12.39-1-MANJARO #1 SMP PREEMPT Sat Mar 21 07:54:52 UTC 2015 x86_64
 GNU/Linux
 
 I found [1] and [2] for this error, but I can't make sense on any fix I can
 apply (I don't know about slices)
 
 [1]
 http://forum.world.st/Error-Remote-String-past-end-of-file-td4707766.html
 [2] https://pharo.fogbugz.com/f/cases/10411/#78632
 
 Any help is appreciated.
 
 Cheers,
 
 Offray
 



-- 
Cheers
Cyril Ferlicot





Re: [Pharo-users] initializeWith* and constructors

2015-05-03 Thread Carlo
Hi

Kent Beck came up with some useful idioms in his book Smalltalk Best Practice 
Patterns. 
One of them was the 'Creation Parameter Method' which is basically the set 
based initialisation method (which Ben mentioned below). This idiom used in 
conjunction with the Complete Creation Method I believe helps communicate 
how can I create a valid instance? to users of your objects.

Cheers
Carlo


On 02 May 2015, at 4:52 PM, Ben Coman b...@openinworld.com wrote:

There are other conventions like: 

* set...
   * Delay class  forMilliseconds: aNumber
^ self new setDelay: aNumber forSemaphore: Semaphore new

* initializeFor...
   * DynamicMessageImplementor class#for:in:
^ self new initializeFor: aMessage in: aClass

* from:to:...
* Bezier2Segment class#from:to:via:
^self new from: startPoint to: endPoint via: viaPoint

I dug a bit to produce this script so you can view more yourself...

protocols := (Protocol allInstances select: [ :p | p name = 'instance 
creation' ]) flatCollect: [ :p | p methods ].
methods := protocols select: [ :m | (m occurrencesOf: $:)  1 ].
implementors := methods flatCollect: [ :m | m implementors ].
constructorExamples := implementors select: [ :i | (i sourceCode 
includesAll: 'new') or: [ i sourceCode includesAll: 'basicNew' ] ]. 

cheers -ben


On Sat, May 2, 2015 at 9:02 PM, Peter Uhnák i.uh...@gmail.com 
mailto:i.uh...@gmail.com wrote:
It seems to me that Smalltalkers are not very fond of constructors and I can't 
comprehend why.

If for example I want to create object X that _needs_ object Y, then I would 
have to make a Y accessor.

Xy: anY
y := anY

but this makes no sense as I can still change the `y` object at later date 
breaking everything.

An alternative is having:

XinitializeWithY: anY
y := anY.
self initialize.

Xy: anY
^ self basicNew initalizeWithY: anY.

However I see only 59 initializeWith* methods (in about 6 packages) compared to 
2302 initialize methods. Thus I am deducing that doing this is not very common.

Am I missing something or am I trying to unnecessarily constraint the user and 
I should just trust™ him that he knows what he should use?

As a user of an interface I would prefer not to have useless things available 
that would just break things.

Thanks,
Peter




Re: [Pharo-users] Start up actions

2014-11-05 Thread Carlo
Hi Peter

From my perspective option b. offers the most flexibility and is most explicit 
although the StartupLoader class (see class comments and examples) seems 
versatile and simple. 

 a.  Include a file named startup.st in the same folder as the image, and 
 put a script to start the process in this file.
Benefit of using an external file as start-up action is that it allows changes 
to be made to the script independent of the image. Have found this to be 
useful. Looks like newer images make use of StartupLoader class which uses 
defined process and lookup procedure to find startup scripts.

 b.  Add a startup: method to the class controlling the background 
 process, and do Smalltalk addToStartUpList: MyClass.
Benefit is that you can make the startup process explicit and add some 
operational control methods here .e.g start process, report on process, end 
process.

 c.  Do Smalltalk addDeferredStartUpAction: [block which starts the 
 process].
This is very low level entry and you could run this and save image but 
typically you would want to have some operational type control over the 
process, checks etc. So I would rather stick to a. or b.

Cheers
Carlo


On 05 Nov 2014, at 1:50 PM, Sven Van Caekenberghe s...@stfx.eu wrote:

The absolute simplest thing is to just create the process and save the image 
with it, it will keep on running.

 On 05 Nov 2014, at 12:05, PBKResearch pe...@pbkresearch.co.uk wrote:
 
 Hello
 
 I have a puzzle as to how to implement a start-up action. I would like to 
 have a monitoring process running in the background while I am working on my 
 project, and it would be easier if this process started up automatically when 
 the image is loaded. I have hunted through my current image, and I have found 
 three possibilities:
 a.  Include a file named startup.st in the same folder as the image, and 
 put a script to start the process in this file.
 b.  Add a startup: method to the class controlling the background 
 process, and do Smalltalk addToStartUpList: MyClass.
 c.  Do Smalltalk addDeferredStartUpAction: [block which starts the 
 process].
 The first looks easiest, but it seems untidy to rely on having a separate 
 file sored with the image. All these methods should work;  is there any 
 reason to prefer any one of them, or any other better method?
 
 Thanks in advance for any advice.
 
 Peter Kenny






Re: [Pharo-users] Fileouts line ending (^M and noeol in Vim)

2014-09-12 Thread Carlo
You mean apart from changing the source in 
FileStreamwriteSourceCodeFrom:baseName:isSt: 
and adding 
 fileStream wantsLineEndConversion: true;

Don't think there is another simple way to get to this functionality.
Cheers
Carlo

On 12 Sep 2014, at 5:26 PM, Esteban A. Maringolo emaring...@gmail.com wrote:

Is there a way to change the default line ending of fileouts from mac to unix?

Or alternatively... how to deal with current line endings in Vim?
I'm using :e ++ff=mac, then :set ff=unix and then saving it again.
But there may be a better way.

Thank you!

Esteban A. Maringolo
eol.png




Re: [Pharo-users] XMLOrderedList Concantenation

2014-05-06 Thread Carlo
Hi

Sorry about that, I think it’s meant to be:

copyReplaceFrom: start to: stop with: replacementCollection
Delegate to my internal collection class as it may restrict copying 
and replacing.
See comment for OrderedCollectioncopyReplaceFrom:to:with: and 
OrderedCollectionat:put:

^ self newWithCollection: (self collection copyReplaceFrom: start to: 
stop with: replacementCollection)

Cheers
Carlo

On 06 May 2014, at 9:43 AM, Nicolai Hess nicolaih...@web.de wrote:




2014-05-06 1:17 GMT+02:00 Carlo snoob...@gmail.com:
Hi

The problem seems to be due to the use of an internal collection class of 
OrderedCollection which has restrictions on use of #at:put:. This means that 
certain methods will have to delegate to the internal collection class to be 
’safe’; in this scenario it is the XMLOrderedList copyReplaceFrom:to:with:

I don’t have write access to the 
http://www.smalltalkhub.com/#!/~PharoExtras/XMLParser/ project but here is a 
unit test and code change that seems to work.

Cheers
Carlo

XMLOrderedListTesttestConcatenation
| anXmlOrderedList expectedConcatenationResult |
expectedConcatenationResult := XMLOrderedList new add: '1'; yourself.
self
shouldnt: [ anXmlOrderedList := expectedConcatenationResult , 
XMLOrderedList new ]
raise: SubscriptOutOfBounds
description:
'Expect that concatenation does not fail even though 
internal collection class of XMLOrderedList is an OrderedCollection. See 
comment for XMLOrderedListcopyReplaceFrom:to:with:'.
self assert: anXmlOrderedList equals: expectedConcatenationResult.


XMLOrderedList copyReplaceFrom: start to: stop with: replacementCollection
Delegate to my internal collection class as it may restrict copying 
and replacing.
See comment for OrderedCollectioncopyReplaceFrom:to:with: and 
OrderedCollectionat:put:

^ self collection copyReplaceFrom: start to: stop with: 
replacementCollection





But the test fails :)

XMLOrderedList copyReplaceFrom: start to: stop with: replacementCollection
should return self, not the collection.

XMLOrderedList copyReplaceFrom: start to: stop with: replacementCollection
Delegate to my internal collection class as it may restrict copying 
and replacing.
See comment for OrderedCollectioncopyReplaceFrom:to:with: and 
OrderedCollectionat:put:

self collection copyReplaceFrom: start to: stop with: 
replacementCollection.






 

On 05 May 2014, at 7:13 PM, Ben Coman b...@openinworld.com wrote:


Thanks. That info made it much easier to try.  Sorry I didn't end up with an 
answer for you, but I confirm there is some issue here, or something new I can 
learn when other chip in. 

Here is what I tried.

* Installed XMLParser (monty.58) from Configuration Browser in Pharo 3.

* Ran your code. Got the same error.

* From the call stack I observed that 
XMLOrderedCollection(SequenceableCollection)copyReplaceFrom:to:with:
has the line newSequenceableCollection := self species new: newSize. such 
that it seems your error might be reduced to the question of why the following 
two snippets fail:
d := OrderedCollection new: 1.
d at: 1 put: 1.

e := OrderedCollection new: 3.
e at: 2 put: 1.

However I'm sorry that is beyond my knowledge, and I'm hoping someone else can 
chip in so I can learn something.

Pushing on, I noticed that XMLOrderedList has an instance variable /collection/ 
which holds the OrderedCollection.

Now I wonder (without great experience and hoping to learn something) if it 
smells funny that XMLOrderedList inherits all of SequencableCollection methods 
that can not operate on /collection/. 

I noticed that XMLOrderedList was using an inherited 
SequenceableCollectioncopyReplaceFrom:to:with 
while OrderedCollection overrode that method with its own. So taking 
inspiration XMLOrderedListcopyFrom:to: to override 
SequencableCollectioncopyReplaceFrom:to:with: to work with /collection/
seems to solve your problem:
XMLOrderedListcopyReplaceFrom: start to: stop with: replacementCollection 
^ self newWithCollection:
(collection copyReplaceFrom: start to: stop with: 
replacementCollection )


Along the way I noticed a few (possible) bugs that seems not related to your 
problem:

* When stepping through XMLOrderedListsetCollection:
there is a red-box-of-death for the instance variables, which can be solved by 
defining the following.
XMLOrderedListsize
^ collection ifNil: [ 0 ] ifNotNil: [ collection size]

* In the debugger the /collection/ instance variable is not shown! (e.g. line 
XMLOrderedListat:put:). 
Can someone confirm this should show?

HTH
cheers -ben

Thushar G R wrote:
 
 XMLOrderedList belongs to package XML-Parser-Nodes.
 
 a := XMLOrderedList new.
 a add:'1'.
 a , XMLOrderedList new.
 
 Here select all and Do it. On line 3 (a , XMLOrderedList new.)  i am expected 
 to get a copy

Re: [Pharo-users] XMLOrderedList Concantenation

2014-05-05 Thread Carlo
Hi

The problem seems to be due to the use of an internal collection class of 
OrderedCollection which has restrictions on use of #at:put:. This means that 
certain methods will have to delegate to the internal collection class to be 
’safe’; in this scenario it is the XMLOrderedList copyReplaceFrom:to:with:

I don’t have write access to the 
http://www.smalltalkhub.com/#!/~PharoExtras/XMLParser/ project but here is a 
unit test and code change that seems to work.

Cheers
Carlo

XMLOrderedListTesttestConcatenation
| anXmlOrderedList expectedConcatenationResult |
expectedConcatenationResult := XMLOrderedList new add: '1'; yourself.
self
shouldnt: [ anXmlOrderedList := expectedConcatenationResult , 
XMLOrderedList new ]
raise: SubscriptOutOfBounds
description:
'Expect that concatenation does not fail even though 
internal collection class of XMLOrderedList is an OrderedCollection. See 
comment for XMLOrderedListcopyReplaceFrom:to:with:'.
self assert: anXmlOrderedList equals: expectedConcatenationResult.


XMLOrderedList copyReplaceFrom: start to: stop with: replacementCollection
Delegate to my internal collection class as it may restrict copying 
and replacing.
See comment for OrderedCollectioncopyReplaceFrom:to:with: and 
OrderedCollectionat:put:

^ self collection copyReplaceFrom: start to: stop with: 
replacementCollection


On 05 May 2014, at 7:13 PM, Ben Coman b...@openinworld.com wrote:


Thanks. That info made it much easier to try.  Sorry I didn't end up with an 
answer for you, but I confirm there is some issue here, or something new I can 
learn when other chip in. 

Here is what I tried.

* Installed XMLParser (monty.58) from Configuration Browser in Pharo 3.

* Ran your code. Got the same error.

* From the call stack I observed that 
XMLOrderedCollection(SequenceableCollection)copyReplaceFrom:to:with:
has the line newSequenceableCollection := self species new: newSize. such 
that it seems your error might be reduced to the question of why the following 
two snippets fail:
d := OrderedCollection new: 1.
d at: 1 put: 1.

e := OrderedCollection new: 3.
e at: 2 put: 1.

However I'm sorry that is beyond my knowledge, and I'm hoping someone else can 
chip in so I can learn something.

Pushing on, I noticed that XMLOrderedList has an instance variable /collection/ 
which holds the OrderedCollection.

Now I wonder (without great experience and hoping to learn something) if it 
smells funny that XMLOrderedList inherits all of SequencableCollection methods 
that can not operate on /collection/. 

I noticed that XMLOrderedList was using an inherited 
SequenceableCollectioncopyReplaceFrom:to:with 
while OrderedCollection overrode that method with its own. So taking 
inspiration XMLOrderedListcopyFrom:to: to override 
SequencableCollectioncopyReplaceFrom:to:with: to work with /collection/
seems to solve your problem:
XMLOrderedListcopyReplaceFrom: start to: stop with: replacementCollection 
^ self newWithCollection:
(collection copyReplaceFrom: start to: stop with: 
replacementCollection )


Along the way I noticed a few (possible) bugs that seems not related to your 
problem:

* When stepping through XMLOrderedListsetCollection:
there is a red-box-of-death for the instance variables, which can be solved by 
defining the following.
XMLOrderedListsize
^ collection ifNil: [ 0 ] ifNotNil: [ collection size]

* In the debugger the /collection/ instance variable is not shown! (e.g. line 
XMLOrderedListat:put:). 
Can someone confirm this should show?

HTH
cheers -ben

Thushar G R wrote:
 
 XMLOrderedList belongs to package XML-Parser-Nodes.
 
 a := XMLOrderedList new.
 a add:'1'.
 a , XMLOrderedList new.
 
 Here select all and Do it. On line 3 (a , XMLOrderedList new.)  i am expected 
 to get a copy of 'a' , but instead it throws an error SubscriptOutOfBounds. 
 
 
 
 
 OrderedCollection(Object)errorSubscriptBounds:
 OrderedCollectionensureBoundsFrom:to:
 OrderedCollectionat:put:
 OrderedCollection(SequenceableCollection)replaceFrom:to:with:startingAt:
 XMLOrderedListreplaceFrom:to:with:startingAt:
 XMLOrderedList(SequenceableCollection)copyReplaceFrom:to:with:
 XMLOrderedList(SequenceableCollection),
 UndefinedObjectDoIt
 OpalCompilerevaluate
 SmalltalkEditorevaluateSelectionAndDo:
 PluggableTextMorphinspectIt in Block: [ textMorph editor 
 evaluateSelectionAndDo: [ :resu...etc...
 PluggableTextMorphhandleEdit: in Block: [ result := editBlock value ]
 TextMorphForEditView(TextMorph)handleEdit:
 PluggableTextMorphhandleEdit:
 PluggableTextMorphinspectIt
 SmalltalkEditor classbuildSmalltalkEditorKeymappingsOn: in Block: [ :morph 
 | morph inspectIt ]
 BlockClosurecull:
 BlockClosurecull:cull:
 BlockClosurecull:cull:cull:
 KMCategoryBindingcompleteMatch:buffer:
 KMKeymapnotifyCompleteMatchTo:buffer: in Block: [ :l | l completeMatch

Re: [Pharo-users] Base64 or HMAC problem

2014-04-28 Thread Carlo
Hi

I think you may have the incorrect expected value.

When using http://www.freeformatter.com/hmac-generator.html and entering 
“testpharmprescriptionsgetexecuted1403122014500” as message and 
“veQC+IBLq5qMO8oGcQupjg==“ as key, I get 
“01c4d717e9436b69116159b49398d8ea91864cc5c3ecdb104bab4b057469dd7b” hex output.
When I then enter this hex output into 
http://tomeko.net/online_tools/hex_to_base64.php?lang=en the generated base64 
is: 
AcTXF+lDa2kRYVm0k5jY6pGGTMXD7NsQS6tLBXRp3Xs=
which is identical to the Pharo generated output:
AcTXF+lDa2kRYVm0k5jY6pGGTMXD7NsQS6tLBXRp3Xs=

The ‘+’ and ‘=“ are the only 2 characters that would be encoded for HTTP which 
would mean the Pharo generated output is correct: 
AcTXF%2BlDa2kRYVm0k5jY6pGGTMXD7NsQS6tLBXRp3Xs%3D

Are you sure that your expected output is correct: 
%2B%2FYhVkcaEIHBeUESOsJYD1nKyJXVGyFX%2FlxR616aUK4%3D

Cheers
Carlo


On 28 Apr 2014, at 11:42 PM, Spiliosv spili...@gmail.com wrote:

Dear Sven,

I tried but still no luck. In any case the padding you are referring to is
for the key for the SHA256 encryption.
I have tested in the
'https://www.freeformatter.com/hmac-generator.html#ad-output' that the hex
values produced from my SHA256 operation are the same. Maybe the conversion
byteArray is wrong?
The correct result for the 'encodedSignature base64Encoded encodeForHTTP. '
should be '%2B%2FYhVkcaEIHBeUESOsJYD1nKyJXVGyFX%2FlxR616aUK4%3D''. This
result is added to a url request as the signature.

Any other suggestions?

Spilios





--
View this message in context: 
http://forum.world.st/Base64-or-HMAC-problem-tp4756788p4756864.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.





Re: [Pharo-users] iStoa, some new

2014-02-05 Thread Carlo
Thanks, that seems to work.

On 05 Feb 2014, at 12:38 PM, Hilaire Fernandes hilaire.fernan...@gmail.com 
wrote:

What about:

StoaApp current openInWorld.


Along Cliparts/, you may need to create a Users/ folder

Hilaire

Le 02/02/2014 22:13, Carlo a écrit :
 Stoa beUnix.
 StoaApp current show.


-- 
Dr. Geo http://drgeo.eu






Re: [Pharo-users] iStoa, some new

2014-02-02 Thread Carlo
Hi Hillaire

I pulled the code from smalltalhub and the resources, into pharo3. The LEDMorph 
dependency was resolved by pulling it from PharoExtras. 
I couldn’t find a starting point for demo so I tried the following in a 
workspace:

Stoa beUnix.
StoaApp current show.

But not having much luck. Do you have any workspace scripts you use to test 
your app?
Thanks
Carlo

On 01 Feb 2014, at 9:16 PM, Hilaire Fernandes hilaire.fernan...@gmail.com 
wrote:

Hello,

Some newer screenshots about iStoa.
To try, some instructions there [2]

Hilaire


[1] https://launchpad.net/istoa
[2]
http://bazaar.launchpad.net/~hilaire-fernandes/istoa/trunk/view/head:/README

-- 
Dr. Geo http://drgeo.eu
sshot1.jpegsshot2.jpegsshot3.jpegsshot4.jpegsshot5.jpegscore.jpeg




Re: [Pharo-users] ZdcSecureSMTPClient

2013-10-22 Thread Carlo
Hi

This code works for me in Pharo 1.3. You may have some success creating a 
similar MailMessage object but using ZdcSecureSMTPClient as the client. 

emailHtml: text to: recipients from: sender subject: subject
| message |
message := MailMessage empty.
message setField: 'from' toString: 'nore...@no.com'.
message setField: 'subject' toString: subject.
message
addAlternativePart: text contentType: 'text/html'.

SMTPClient
deliverMailFrom: message from
to: (self salesReportReceipients)
text: message text
usingServer: self smtpServer

Regards
Carlo

On 22 Oct 2013, at 11:29 AM, Sven Van Caekenberghe s...@stfx.eu wrote:

Hi,

On 22 Oct 2013, at 10:46, timothyageo...@gmail.com wrote:

 Hello,
 
 I tried your example for sending code thru Gmail. It works fine with 
 ZdcSecureSMTPClient Pharo 2.0. But when I set the content to an html string. 
 The text shows up as html (htmlbodyDear/body/html), encoding and all 
 but not html formatted. Ca you tell me what I'm doing wrong. Here is the code:
 mailMessage :=MailMessage empty.
 mailMessage setField: 'subject' toString: 'Some subject'.
   mailMessage body: (MIMEDocument  contentType: 'text/html' content:  
 'htmlbodyDear/body/html' ).

I just wrote the ZdcSecureSMTPClient subclass, I am not familiar with the finer 
points of MailMessage. I am guessing that for HTML content you have to work 
with MIME parts. I am CC-ing the pharo-users list, maybe there are people who 
already did this who can help you further.

Regards,

Sven




Re: [Pharo-users] no SortedDictionary available?

2013-07-17 Thread Carlo
Hi

Have you tried: http://www.squeaksource.com/BTree
Used it long ago and worked well.

Regards
Carlo

On 18 Jul 2013, at 2:10 AM, Hernán Morales Durand hernan.mora...@gmail.com 
wrote:

Have a look at:

http://www.smalltalkhub.com/#!/~hernan/SortedDictionary

use at your own risk, given I have no time for writing tests now.
Cheers,

Hernán

El 17/07/2013 5:31, Sabine Knöfel escribió:
 Hi,
 
 I am looking for a Dictionary which sorts its entries by the keys.
 Some Kind of SortedDictionary.
 I assume, there is none - right?
 
 I only found the OrderPreservingDictionary (which is not the same).
 
 Background: storing exchangerates by date.
 
 Sabine
 
 
 
 
 
 --
 View this message in context: 
 http://forum.world.st/no-SortedDictionary-available-tp4699050.html
 Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
 
 .