Re: [Pharo-users] VPS difficulties

2018-12-03 Thread horrido
I agree totally. We shouldn't do anything to scare away people new to Pharo.
It's a hard enough sell as it is. This kind of thing only undermines my
advocacy.



Ben Coman wrote
> On Tue, 4 Dec 2018 at 02:07, Sven Van Caekenberghe <

> sven@

> > wrote:
> 
>> Yes, I can confirm that it looks like /etc/security/limits.d settings are
>> not honoured inside an LXC/LXD container on Linux. I am not sure that
>> there
>> is a way around this, as it seems that such limits are part of the
>> technology used to implement containers (and hence it might conflict with
>> them by design as you could then step outside your container's limits).
>> Maybe there is a way around this.
>>
>> Note that the VM keeps on running fine, despite the warning. It feels as
>> if that warning is a bit aggressive and that there should be an option to
>> silence it.
>>
> 
> Perhaps even this warning should be disabled.  We've been operating a long
> time with the threaded-timer as default with no adverse reports.
> The warning undermines the confidence of new users and gets in the way of
> their smooth first experience.
> 
> Regarding any concern about clock jitter, perhaps the place to put this
> rtprio advice is in the DelayScheduler class comment,
> which I guess is where anyone having a problem with jitter would go
> looking.
> Here is a pertinent thread...
> http://forum.world.st/Unix-heartbeat-thread-vs-itimer-td4928943i20.html
> 
> cheers -ben
> 
> 
>> On 3 Dec 2018, at 17:47, Norbert Hartl <

> norbert@

> > wrote:
>> >
>> > I didn’t read much of this thread but the VPS might give a hint. If you
>> are in a virtualized server and you want to modify kernel parameters the
>> underlying host needs to allow that.
>> >
>> > Norbert
>> >
>> >
>> >> Am 03.12.2018 um 16:55 schrieb horrido <

> horrido.hobbies@

> >:
>> >>
>> >> Yes, I did. I even rebooted Ubuntu.
>> >>
>> >> Given that this problem occurs for both Debian and Ubuntu, there must
>> be
>> >> some commonality that hasn't been documented.
>> >>
>> >>
>> >>
>> >> Ben Coman wrote
>> >>> At https://linux.die.net/man/5/limits.conf
>> >>> I read "note that all limit settings are set per login."
>> >>> You haven't mentioned whether you logged out and back in again?
>> >>>
>> >>> cheers -ben
>> >>>
>> >>> On Mon, 3 Dec 2018 at 23:17, horrido <
>> >>
>> >>> horrido.hobbies@
>> >>
>> >>> > wrote:
>> >>>
>>  I've switched over to Ubuntu Server 18.04 LTS. I've repeated all the
>>  steps
>>  to
>>  arrive at Pharo installation. I'm still having the same problem:
>>  pthread_setschedparam failed.
>> 
>>  Here's my /etc/security/limits.d/pharo.conf:
>> 
>>  * hard rtprio 2
>>  * soft rtprio 2
>> 
>> 
>> 
>>  Sven Van Caekenberghe-2 wrote
>> >> On 2 Dec 2018, at 18:40, horrido <
>> 
>> > horrido.hobbies@
>> 
>> > > wrote:
>> >>
>> >> Bizarre. I've created a new VirtualBox image of Debian and now
>> this
>> >> solution
>> >> no longer works! I'm still getting the thread priority warning. So
>>  this
>> >> solution appears to be unreliable.
>> >
>> > Why use Debian (not that it is bad, it is just a bit more
>> technical)
>> ?
>> >
>> > I think you would have less problems using Ubuntu (it is just as
>> open,
>>  it
>> > is what everybody else is using and it is much more user friendly).
>> >
>> >>
>> >
>> >>> 
> 
>> >>
>> >>
>> >> On Fri, 23 Nov 2018 at 04:02, horrido 
>> wrote:
>> >>
>> >>> Okay, I've resolved everything. First, the reason why I'm getting
>> the
>> >>> 'pthread_setschedparam failed' error when I run Pharo under
>> Debian
>> is
>> >>> because it must be run as 'root'! Don't ask me why, but that's
>> the
>> >>> reason
>> >>> why Pharo can't set thread priorities. (This wasn't an issue
>> under
>> >>> Ubuntu
>> >>> Server – go figure.)
>> >>>
>> >>> Second, I am now using Pharo's own SHA256 class. It's probably
>> not
>> as
>> >>> secure
>> >>> (because it doesn't use a salt value) and not as quick to execute
>>  (not
>> >>> being
>> >>> C code), but for my purpose, it doesn't really matter.
>> >>>
>> >>> So I can use DigitalOcean or OVH to run my web server in a VPS.
>> >>>
>> >>
>> >> Good to hear.  But you shouldn't need to run Pharo as root,
>> >> just be root to create this config file
>> >> cat <
>> >
>> >>> 
> >
>  
>> >
>> > *  hardrtprio  2
>> >> *  softrtprio  2
>> >> END
>> >>
>> >> cheers -ben
>>
>>





--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] VPS difficulties

2018-12-03 Thread Ben Coman
On Tue, 4 Dec 2018 at 02:07, Sven Van Caekenberghe  wrote:

> Yes, I can confirm that it looks like /etc/security/limits.d settings are
> not honoured inside an LXC/LXD container on Linux. I am not sure that there
> is a way around this, as it seems that such limits are part of the
> technology used to implement containers (and hence it might conflict with
> them by design as you could then step outside your container's limits).
> Maybe there is a way around this.
>
> Note that the VM keeps on running fine, despite the warning. It feels as
> if that warning is a bit aggressive and that there should be an option to
> silence it.
>

Perhaps even this warning should be disabled.  We've been operating a long
time with the threaded-timer as default with no adverse reports.
The warning undermines the confidence of new users and gets in the way of
their smooth first experience.

Regarding any concern about clock jitter, perhaps the place to put this
rtprio advice is in the DelayScheduler class comment,
which I guess is where anyone having a problem with jitter would go looking.
Here is a pertinent thread...
http://forum.world.st/Unix-heartbeat-thread-vs-itimer-td4928943i20.html

cheers -ben


> On 3 Dec 2018, at 17:47, Norbert Hartl  wrote:
> >
> > I didn’t read much of this thread but the VPS might give a hint. If you
> are in a virtualized server and you want to modify kernel parameters the
> underlying host needs to allow that.
> >
> > Norbert
> >
> >
> >> Am 03.12.2018 um 16:55 schrieb horrido :
> >>
> >> Yes, I did. I even rebooted Ubuntu.
> >>
> >> Given that this problem occurs for both Debian and Ubuntu, there must be
> >> some commonality that hasn't been documented.
> >>
> >>
> >>
> >> Ben Coman wrote
> >>> At https://linux.die.net/man/5/limits.conf
> >>> I read "note that all limit settings are set per login."
> >>> You haven't mentioned whether you logged out and back in again?
> >>>
> >>> cheers -ben
> >>>
> >>> On Mon, 3 Dec 2018 at 23:17, horrido <
> >>
> >>> horrido.hobbies@
> >>
> >>> > wrote:
> >>>
>  I've switched over to Ubuntu Server 18.04 LTS. I've repeated all the
>  steps
>  to
>  arrive at Pharo installation. I'm still having the same problem:
>  pthread_setschedparam failed.
> 
>  Here's my /etc/security/limits.d/pharo.conf:
> 
>  * hard rtprio 2
>  * soft rtprio 2
> 
> 
> 
>  Sven Van Caekenberghe-2 wrote
> >> On 2 Dec 2018, at 18:40, horrido <
> 
> > horrido.hobbies@
> 
> > > wrote:
> >>
> >> Bizarre. I've created a new VirtualBox image of Debian and now this
> >> solution
> >> no longer works! I'm still getting the thread priority warning. So
>  this
> >> solution appears to be unreliable.
> >
> > Why use Debian (not that it is bad, it is just a bit more technical)
> ?
> >
> > I think you would have less problems using Ubuntu (it is just as
> open,
>  it
> > is what everybody else is using and it is much more user friendly).
> >
> >>
> >
> >>> 
> >>
> >>
> >> On Fri, 23 Nov 2018 at 04:02, horrido 
> wrote:
> >>
> >>> Okay, I've resolved everything. First, the reason why I'm getting
> the
> >>> 'pthread_setschedparam failed' error when I run Pharo under Debian
> is
> >>> because it must be run as 'root'! Don't ask me why, but that's the
> >>> reason
> >>> why Pharo can't set thread priorities. (This wasn't an issue under
> >>> Ubuntu
> >>> Server – go figure.)
> >>>
> >>> Second, I am now using Pharo's own SHA256 class. It's probably not
> as
> >>> secure
> >>> (because it doesn't use a salt value) and not as quick to execute
>  (not
> >>> being
> >>> C code), but for my purpose, it doesn't really matter.
> >>>
> >>> So I can use DigitalOcean or OVH to run my web server in a VPS.
> >>>
> >>
> >> Good to hear.  But you shouldn't need to run Pharo as root,
> >> just be root to create this config file
> >> cat <
> >
> >>>  
> >
> > *  hardrtprio  2
> >> *  softrtprio  2
> >> END
> >>
> >> cheers -ben
>
>


Re: [Pharo-users] Latest Pharo and Aida/Web

2018-12-03 Thread Benoit St-Jean via Pharo-users
--- Begin Message ---
If I'm not mistaken (according to the fact that both class comments are exactly 
the same), SecureHashAlgorithm (in Squeak) is the exact same thing as class 
SHA1 (in Pharo)... 

Just updating the code with the "new" class name will probably do the job!

- 
Benoît St-Jean 
Yahoo! Messenger: bstjean 
Twitter: @BenLeChialeux 
Pinterest: benoitstjean 
Instagram: Chef_Benito
IRC: lamneth 
Blogue: endormitoire.wordpress.com 
"A standpoint is an intellectual horizon of radius zero".  (A. Einstein) 

On Monday, December 3, 2018, 4:18:55 p.m. EST, eftomi 
 wrote:  
 
 Hi, I'm trying to run Aida/Web on Pharo 5.0, 6.1 and 7.0 with no luck. After
package inclusion with Catalog Browser, the initialisation with 

SwazooAida demoStart

wasn't working, since Timestamp was not present. After I "faked" it with
DateAndTime, the web server is running, but if I visit the initial web
address http://localhost:/, I get his error:

WebSecurityManager class>>hashPassword: (SecureHashAlgorithm is Undeclared).

Before I continue with exploration & debugging, I'd like to know how far
from a working and stable team is Aida & latest Pharo (if somebody knows, of
course). I'm a beginner with Smalltalk and Aida seems to be very nice
framework, however there are other options as well, without any challenges
for a newbie :-)

Thanks, Tomaz 




--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

  --- End Message ---


[Pharo-users] Latest Pharo and Aida/Web

2018-12-03 Thread eftomi
Hi, I'm trying to run Aida/Web on Pharo 5.0, 6.1 and 7.0 with no luck. After
package inclusion with Catalog Browser, the initialisation with 

SwazooAida demoStart

wasn't working, since Timestamp was not present. After I "faked" it with
DateAndTime, the web server is running, but if I visit the initial web
address http://localhost:/, I get his error:

WebSecurityManager class>>hashPassword: (SecureHashAlgorithm is Undeclared).

Before I continue with exploration & debugging, I'd like to know how far
from a working and stable team is Aida & latest Pharo (if somebody knows, of
course). I'm a beginner with Smalltalk and Aida seems to be very nice
framework, however there are other options as well, without any challenges
for a newbie :-)

Thanks, Tomaz 




--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] can I improve this

2018-12-03 Thread Benoit St-Jean via Pharo-users
--- Begin Message ---
Wouldn't be that hard to implement.  We just need a modulo (like I did) when 
sending #next to wrap around...
Or even better: a "cyclic" iterator, something like #withWrapDo: ?

- 
Benoît St-Jean 
Yahoo! Messenger: bstjean 
Twitter: @BenLeChialeux 
Pinterest: benoitstjean 
Instagram: Chef_Benito
IRC: lamneth 
Blogue: endormitoire.wordpress.com 
"A standpoint is an intellectual horizon of radius zero".  (A. Einstein) 

On Monday, December 3, 2018, 1:28:09 p.m. EST, phil--- via Pharo-users 
 wrote:  
 
 CyclicReadStream. Not in base Pharo.
I wish.
We have atWrap: but not the best.
Phil

On Mon, Dec 3, 2018 at 1:17 PM Richard O'Keefe  wrote:

"if I use do:   this ends at the end of the array."True.  But all that means is 
that you have to keen on using #do:.
Processing an array repeatedly is as simple as  [true] whileTrue: [    anArray 
do: [:each |      ...]]
I had intended to twist this into
  [changes anySatisfy: [:change | ...]] whileFalse.
However, in this case your second alternative has much to recommend it.The 
control flow is simple.  There's no magic about it.  It's anunusual setup, so 
no need to get fancy.
  seen := Set new.  frequency := 0.  found := false.  i := changes size.  
[found] whileFalse: [    i := i = changes size ifTrue: [1] ifFalse: [i+1].    
frequency := frequency + (changes at: i).    found := seen includes: frequency. 
   seen add: frequency].

I like this better than what I had.
If we _were_ to get fancy, then introducing a CyclicReadStreamclass and doing   
 seen := Set new.    frequency := 0.    found := false.    stream := 
CyclicReadStream on: self changes.    [found] whileFalse: [      frequency := 
frequency + stream next.      found := seen includes: frequency.      seen add: 
frequency].wouldn't shrink the code much.  Oddly enough, I've 
encounteredproblems in previous Advent of Code exercises where 
CyclicReadStreamwould have been handy.  But just for this case?  No.

On Tue, 4 Dec 2018 at 00:25, Roelof Wobben  wrote:

  hello Richard, 
 
 Thanks, I figured that out already.
 What I do not get is how to read the array multiple times. 
 
 if I use do:   this ends at the end of the array.
 
 Or I must use something as this : 
 
 index := 0 
 if index > array length 
     index =:  1 
 else 
 index := index + 1 
 
 
 and then read the number with array at: index 
 
 Roelof
 
 
 Op 3-12-2018 om 10:08 schreef Richard O'Keefe:
  
  Roelof Wobben wrote "I have to reread the file till the adding causes the 
same outcome  as we had already" You have to process the *sequence of changes* 
repeatedly; you DON't have to *reread the file*.  Somebody already made this 
point. Having read the changes into an array, you can iterate repeatedly over 
that array. 
  to find the first repeated frequency given a sequence of changes     make an 
empty Set to hold the sums that have been seen so far.
      set the frequency to 0.     loop forever         for each change in the 
changes             increment the frequency by the change.             if the 
frequency is in the set                 return the frequency            
otherwise add the frequency to the set.
  
   partTwo: aFileName     Transcript print: (self firstRepeatedFrequency: (self 
changesFrom: aFileName)); cr; flush.  
  On Mon, 3 Dec 2018 at 19:31, Roelof Wobben  wrote:
  
  Thanks, 
 
 For the second I have to take a good look.
 
 I have to reread the file till the adding causes the same outcome  as we had 
already 
 
 so for example if we have the sequence : 
 
 +3, +3, +4, -2, -4
 
 it has as outcome : 
 
 3 6 10 8 4 
 
 so no outcome is there a second time so we repeat the sequence
 
 
 7 10 
 
 the 10 shows up a second time so there we have our answer. 
 
 
 Roelof
 
 
 
 Op 3-12-2018 om 03:45 schreef Richard O'Keefe:
  
  The key question is "what do you mean by improve"? I'd start by asking "what 
are you doing that you will still have to do in part 2, and what won't you do?" 
 So looking at part 2, you will want to convert the lines to integers, and   
input := Array streamContents: [:lines |     'input.txt' asFileReference 
readStreamDo: [:in |       [in atEnd] whileFalse: [lines nextPut: in nextLine 
asInteger]]]. gives you a chunk of code you can use in both parts.  So you 
might want to have 
  Day1   changesFrom: aFileName     ^Array streamContents: [:changes |       
aFileName asFileReference readStreamDo: [:in |         [in atEnd] whileFalse: 
[changes nextPut: in nextLine asInteger]]]   partOne: aFileName     ^(self 
changesFrom: aFileName) sum   partTwo: aFileName     ... The file name should 
not be wired in because you want some test files. 
  
   
  
  
   
 
  
  
 
 

  --- End Message ---


Re: [Pharo-users] can I improve this

2018-12-03 Thread phil--- via Pharo-users
--- Begin Message ---
 CyclicReadStream. Not in base Pharo.

I wish.

We have atWrap: but not the best.

Phil

On Mon, Dec 3, 2018 at 1:17 PM Richard O'Keefe  wrote:

> "if I use do:   this ends at the end of the array."
> True.  But all that means is that you have to keen on using #do:.
>
> Processing an array repeatedly is as simple as
>   [true] whileTrue: [
> anArray do: [:each |
>   ...]]
>
> I had intended to twist this into
>
>   [changes anySatisfy: [:change | ...]] whileFalse.
>
> However, in this case your second alternative has much to recommend it.
> The control flow is simple.  There's no magic about it.  It's an
> unusual setup, so no need to get fancy.
>
>   seen := Set new.
>   frequency := 0.
>   found := false.
>   i := changes size.
>   [found] whileFalse: [
> i := i = changes size ifTrue: [1] ifFalse: [i+1].
> frequency := frequency + (changes at: i).
> found := seen includes: frequency.
> seen add: frequency].
>
> I like this better than what I had.
>
> If we _were_ to get fancy, then introducing a CyclicReadStream
> class and doing
> seen := Set new.
> frequency := 0.
> found := false.
> stream := CyclicReadStream on: self changes.
> [found] whileFalse: [
>   frequency := frequency + stream next.
>   found := seen includes: frequency.
>   seen add: frequency].
> wouldn't shrink the code much.  Oddly enough, I've encountered
> problems in previous Advent of Code exercises where CyclicReadStream
> would have been handy.  But just for this case?  No.
>
>
> On Tue, 4 Dec 2018 at 00:25, Roelof Wobben  wrote:
>
>> hello Richard,
>>
>> Thanks, I figured that out already.
>> What I do not get is how to read the array multiple times.
>>
>> if I use do:   this ends at the end of the array.
>>
>> Or I must use something as this :
>>
>> index := 0
>> if index > array length
>> index =:  1
>> else
>> index := index + 1
>>
>>
>> and then read the number with array at: index
>>
>> Roelof
>>
>>
>> Op 3-12-2018 om 10:08 schreef Richard O'Keefe:
>>
>> Roelof Wobben wrote
>> "I have to reread the file till the adding causes the same outcome  as
>> we had already"
>> You have to process the *sequence of changes* repeatedly;
>> you DON't have to *reread the file*.  Somebody already made this point.
>> Having read the changes into an array, you can iterate repeatedly over
>> that array.
>>
>> to find the first repeated frequency given a sequence of changes
>> make an empty Set to hold the sums that have been seen so far.
>> set the frequency to 0.
>> loop forever
>> for each change in the changes
>> increment the frequency by the change.
>> if the frequency is in the set
>> return the frequency
>>otherwise add the frequency to the set.
>>
>>  partTwo: aFileName
>> Transcript print: (self firstRepeatedFrequency: (self changesFrom:
>> aFileName)); cr; flush.
>>
>> On Mon, 3 Dec 2018 at 19:31, Roelof Wobben  wrote:
>>
>>> Thanks,
>>>
>>> For the second I have to take a good look.
>>>
>>> I have to reread the file till the adding causes the same outcome  as we
>>> had already
>>>
>>> so for example if we have the sequence :
>>>
>>> +3, +3, +4, -2, -4
>>>
>>> it has as outcome :
>>>
>>> 3 6 10 8 4
>>>
>>> so no outcome is there a second time so we repeat the sequence
>>>
>>>
>>> 7 10
>>>
>>> the 10 shows up a second time so there we have our answer.
>>>
>>>
>>> Roelof
>>>
>>>
>>>
>>> Op 3-12-2018 om 03:45 schreef Richard O'Keefe:
>>>
>>> The key question is "what do you mean by improve"?
>>> I'd start by asking "what are you doing that you will still have to do in
>>> part 2, and what won't you do?"  So looking at part 2, you will want to
>>> convert the lines to integers, and
>>>   input := Array streamContents: [:lines |
>>> 'input.txt' asFileReference readStreamDo: [:in |
>>>   [in atEnd] whileFalse: [lines nextPut: in nextLine asInteger]]].
>>> gives you a chunk of code you can use in both parts.  So you might
>>> want to have
>>>
>>> Day1
>>>   changesFrom: aFileName
>>> ^Array streamContents: [:changes |
>>>   aFileName asFileReference readStreamDo: [:in |
>>> [in atEnd] whileFalse: [changes nextPut: in nextLine asInteger]]]
>>>   partOne: aFileName
>>> ^(self changesFrom: aFileName) sum
>>>   partTwo: aFileName
>>> ...
>>> The file name should not be wired in because you want some test files.
>>>
>>>
>>>
>>>
>>
--- End Message ---


Re: [Pharo-users] VPS difficulties

2018-12-03 Thread Sven Van Caekenberghe
Yes, I can confirm that it looks like /etc/security/limits.d settings are not 
honoured inside an LXC/LXD container on Linux. I am not sure that there is a 
way around this, as it seems that such limits are part of the technology used 
to implement containers (and hence it might conflict with them by design as you 
could then step outside your container's limits). Maybe there is a way around 
this.

Note that the VM keeps on running fine, despite the warning. It feels as if 
that warning is a bit aggressive and that there should be an option to silence 
it.

> On 3 Dec 2018, at 17:47, Norbert Hartl  wrote:
> 
> I didn’t read much of this thread but the VPS might give a hint. If you are 
> in a virtualized server and you want to modify kernel parameters the 
> underlying host needs to allow that. 
> 
> Norbert
> 
> 
>> Am 03.12.2018 um 16:55 schrieb horrido :
>> 
>> Yes, I did. I even rebooted Ubuntu.
>> 
>> Given that this problem occurs for both Debian and Ubuntu, there must be
>> some commonality that hasn't been documented.
>> 
>> 
>> 
>> Ben Coman wrote
>>> At https://linux.die.net/man/5/limits.conf
>>> I read "note that all limit settings are set per login."
>>> You haven't mentioned whether you logged out and back in again?
>>> 
>>> cheers -ben
>>> 
>>> On Mon, 3 Dec 2018 at 23:17, horrido <
>> 
>>> horrido.hobbies@
>> 
>>> > wrote:
>>> 
 I've switched over to Ubuntu Server 18.04 LTS. I've repeated all the
 steps
 to
 arrive at Pharo installation. I'm still having the same problem:
 pthread_setschedparam failed.
 
 Here's my /etc/security/limits.d/pharo.conf:
 
 * hard rtprio 2
 * soft rtprio 2
 
 
 
 Sven Van Caekenberghe-2 wrote
>> On 2 Dec 2018, at 18:40, horrido <
 
> horrido.hobbies@
 
> > wrote:
>> 
>> Bizarre. I've created a new VirtualBox image of Debian and now this
>> solution
>> no longer works! I'm still getting the thread priority warning. So
 this
>> solution appears to be unreliable.
> 
> Why use Debian (not that it is bad, it is just a bit more technical) ?
> 
> I think you would have less problems using Ubuntu (it is just as open,
 it
> is what everybody else is using and it is much more user friendly).
> 
>> 
> 
>>> 
>> 
>> 
>> On Fri, 23 Nov 2018 at 04:02, horrido  wrote:
>> 
>>> Okay, I've resolved everything. First, the reason why I'm getting the
>>> 'pthread_setschedparam failed' error when I run Pharo under Debian is
>>> because it must be run as 'root'! Don't ask me why, but that's the
>>> reason
>>> why Pharo can't set thread priorities. (This wasn't an issue under
>>> Ubuntu
>>> Server – go figure.)
>>> 
>>> Second, I am now using Pharo's own SHA256 class. It's probably not as
>>> secure
>>> (because it doesn't use a salt value) and not as quick to execute
 (not
>>> being
>>> C code), but for my purpose, it doesn't really matter.
>>> 
>>> So I can use DigitalOcean or OVH to run my web server in a VPS.
>>> 
>> 
>> Good to hear.  But you shouldn't need to run Pharo as root,
>> just be root to create this config file
>> cat <
> 
>>> >>> 
> 
> *  hardrtprio  2
>> *  softrtprio  2
>> END
>> 
>> cheers -ben
 
>> 
>> 
>> 
>> 
>> 
>> --
>> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
> 




Re: [Pharo-users] can I improve this

2018-12-03 Thread Benoit St-Jean via Pharo-users
--- Begin Message ---
It's just a matter of taste and/or habit.  Quite frankly, I never think about 
using #streamContents nor #readStream or other variations since I've always had 
to write that kinda code "the long way" since 1992 ! 

- 
Benoît St-Jean 
Yahoo! Messenger: bstjean 
Twitter: @BenLeChialeux 
Pinterest: benoitstjean 
Instagram: Chef_Benito
IRC: lamneth 
Blogue: endormitoire.wordpress.com 
"A standpoint is an intellectual horizon of radius zero".  (A. Einstein) 

On Monday, December 3, 2018, 11:09:31 a.m. EST, Roelof Wobben 
 wrote:  
 
 Op 3-12-2018 om 17:01 schreef Benoit St-Jean via Pharo-users:

Many many many thanks

For me too

and that is the answer I expect

Two question,

Why is trough StandardFileStream a line

and can this also be rewritten with a StreamContents



Roelof


  --- End Message ---


Re: [Pharo-users] VPS difficulties

2018-12-03 Thread Norbert Hartl
I didn’t read much of this thread but the VPS might give a hint. If you are in 
a virtualized server and you want to modify kernel parameters the underlying 
host needs to allow that. 

Norbert


> Am 03.12.2018 um 16:55 schrieb horrido :
> 
> Yes, I did. I even rebooted Ubuntu.
> 
> Given that this problem occurs for both Debian and Ubuntu, there must be
> some commonality that hasn't been documented.
> 
> 
> 
> Ben Coman wrote
>> At https://linux.die.net/man/5/limits.conf 
>> 
>> I read "note that all limit settings are set per login."
>> You haven't mentioned whether you logged out and back in again?
>> 
>> cheers -ben
>> 
>> On Mon, 3 Dec 2018 at 23:17, horrido <
> 
>> horrido.hobbies@
> 
>> > wrote:
>> 
>>> I've switched over to Ubuntu Server 18.04 LTS. I've repeated all the
>>> steps
>>> to
>>> arrive at Pharo installation. I'm still having the same problem:
>>> pthread_setschedparam failed.
>>> 
>>> Here's my /etc/security/limits.d/pharo.conf:
>>> 
>>> * hard rtprio 2
>>> * soft rtprio 2
>>> 
>>> 
>>> 
>>> Sven Van Caekenberghe-2 wrote
> On 2 Dec 2018, at 18:40, horrido <
>>> 
 horrido.hobbies@
>>> 
 > wrote:
> 
> Bizarre. I've created a new VirtualBox image of Debian and now this
> solution
> no longer works! I'm still getting the thread priority warning. So
>>> this
> solution appears to be unreliable.
 
 Why use Debian (not that it is bad, it is just a bit more technical) ?
 
 I think you would have less problems using Ubuntu (it is just as open,
>>> it
 is what everybody else is using and it is much more user friendly).
 
> 
 
>> 
> 
> 
> On Fri, 23 Nov 2018 at 04:02, horrido  wrote:
> 
>> Okay, I've resolved everything. First, the reason why I'm getting the
>> 'pthread_setschedparam failed' error when I run Pharo under Debian is
>> because it must be run as 'root'! Don't ask me why, but that's the
>> reason
>> why Pharo can't set thread priorities. (This wasn't an issue under
>> Ubuntu
>> Server – go figure.)
>> 
>> Second, I am now using Pharo's own SHA256 class. It's probably not as
>> secure
>> (because it doesn't use a salt value) and not as quick to execute
>>> (not
>> being
>> C code), but for my purpose, it doesn't really matter.
>> 
>> So I can use DigitalOcean or OVH to run my web server in a VPS.
>> 
> 
> Good to hear.  But you shouldn't need to run Pharo as root,
> just be root to create this config file
> cat <
 
>> >> 
 
 *  hardrtprio  2
> *  softrtprio  2
> END
> 
> cheers -ben
>>> 
> 
> 
> 
> 
> 
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html 
> 


Re: [Pharo-users] VPS difficulties

2018-12-03 Thread horrido
Yes, I have a normal account. And, yes, the ownership is root:root.


Sven Van Caekenberghe-2 wrote
> sven@ubuntu:~/Documents/pharo7$ uname -a
> Linux ubuntu 4.15.0-39-generic #42-Ubuntu SMP Tue Oct 23 15:48:01 UTC 2018
> x86_64 x86_64 x86_64 GNU/Linux
> 
> sven@ubuntu:~/Documents/pharo7$ cat /etc/issue
> Ubuntu 18.04.1 LTS
> 
> sven@ubuntu:~/Documents/pharo7$ id
> uid=1000(sven) gid=1000(sven)
> groups=1000(sven),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare)
> 
> sven@ubuntu:~/Documents/pharo7$ cat /etc/security/limits.d/pharo.conf 
> *  hardrtprio  2
> *  softrtprio  2
> 
> sven@ubuntu:~/Documents/pharo7$ ls -lah /etc/security/limits.d/pharo.conf 
> -rw-r--r-- 1 root root 50 Apr 30  2018 /etc/security/limits.d/pharo.conf
> 
> sven@ubuntu:~/Documents/pharo7$ pwd
> /home/sven/Documents/pharo7
> 
> sven@ubuntu:~/Documents/pharo7$ curl get.pharo.org/64/70+vm | bash
>   % Total% Received % Xferd  Average Speed   TimeTime Time 
> Current
>  Dload  Upload   Total   SpentLeft 
> Speed
> 100  3054  100  30540 0   1961  0  0:00:01  0:00:01 --:--:-- 
> 1960
> Downloading the latest 70 Image:
> http://files.pharo.org/get-files/70/pharo64.zip
> Pharo.image
> Downloading the latest pharoVM:
>   http://files.pharo.org/get-files/70/pharo64-linux-stable.zip
> pharo-vm/pharo
> Creating starter scripts pharo and pharo-ui
> 
> sven@ubuntu:~/Documents/pharo7$ ./pharo Pharo.image printVersion
> [version] 'Pharo7.0.0'
> 'Pharo-7.0.0+rc1.build.1434.sha.ee53b61de346d1dd58999e239e1c3dc5da069b6d
> (64 Bit)'
> 
> sven@ubuntu:~/Documents/pharo7$ file
> pharo-vm/lib/pharo/5.0-201806281256/pharo 
> pharo-vm/lib/pharo/5.0-201806281256/pharo: ELF 64-bit LSB executable,
> x86-64, version 1 (SYSV), dynamically linked, interpreter
> /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.24,
> BuildID[sha1]=2778173a7eac63dca9a970146659c2de8fef4160, with debug_info,
> not stripped
> 
> sven@ubuntu:~/Documents/pharo7$ ldd
> pharo-vm/lib/pharo/5.0-201806281256/pharo 
>   linux-vdso.so.1 (0x7ffed93c1000)
>   libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x7f21defbc000)
>   libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x7f21dec1e000)
>   libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
> (0x7f21de9ff000)
>   libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x7f21de60e000)
>   /lib64/ld-linux-x86-64.so.2 (0x7f21df1c)
> 
> sven@ubuntu:~/Documents/pharo7$ ./pharo-ui Pharo.image 
> 
> [normal UI]
> 
> Do you have a normal user account ?
> Are the permissions on /etc/security/limits.d/pharo.conf root:root ?
> 
>> On 3 Dec 2018, at 16:16, horrido <

> horrido.hobbies@

> > wrote:
>> 
>> I've switched over to Ubuntu Server 18.04 LTS. I've repeated all the
>> steps to
>> arrive at Pharo installation. I'm still having the same problem:
>> pthread_setschedparam failed.
>> 
>> Here's my /etc/security/limits.d/pharo.conf:
>> 
>> * hard rtprio 2
>> * soft rtprio 2
>> 
>> 
>> 
>> Sven Van Caekenberghe-2 wrote
 On 2 Dec 2018, at 18:40, horrido <
>> 
>>> horrido.hobbies@
>> 
>>> > wrote:
 
 Bizarre. I've created a new VirtualBox image of Debian and now this
 solution
 no longer works! I'm still getting the thread priority warning. So this
 solution appears to be unreliable.
>>> 
>>> Why use Debian (not that it is bad, it is just a bit more technical) ?
>>> 
>>> I think you would have less problems using Ubuntu (it is just as open,
>>> it
>>> is what everybody else is using and it is much more user friendly).
>>> 
 
>>> 
> 
 
 
 On Fri, 23 Nov 2018 at 04:02, horrido  wrote:
 
> Okay, I've resolved everything. First, the reason why I'm getting the
> 'pthread_setschedparam failed' error when I run Pharo under Debian is
> because it must be run as 'root'! Don't ask me why, but that's the
> reason
> why Pharo can't set thread priorities. (This wasn't an issue under
> Ubuntu
> Server – go figure.)
> 
> Second, I am now using Pharo's own SHA256 class. It's probably not as
> secure
> (because it doesn't use a salt value) and not as quick to execute (not
> being
> C code), but for my purpose, it doesn't really matter.
> 
> So I can use DigitalOcean or OVH to run my web server in a VPS.
> 
 
 Good to hear.  But you shouldn't need to run Pharo as root,
 just be root to create this config file
 cat <
>>> 
> >
>>> 
>>> *  hardrtprio  2
 *  softrtprio  2
 END
 
 cheers -ben
 
 
 
 
 
 --
 Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>> 
>> 
>> 
>> 
>> 
>> --
>> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html





--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] can I improve this

2018-12-03 Thread Roelof Wobben

Op 3-12-2018 om 17:01 schreef Benoit St-Jean via Pharo-users:

Many many many thanks

For me too

and that is the answer I expect

Two question,

Why is trough StandardFileStream a line

and can this also be rewritten with a StreamContents



Roelof




Re: [Pharo-users] VPS difficulties

2018-12-03 Thread Sven Van Caekenberghe
sven@ubuntu:~/Documents/pharo7$ uname -a
Linux ubuntu 4.15.0-39-generic #42-Ubuntu SMP Tue Oct 23 15:48:01 UTC 2018 
x86_64 x86_64 x86_64 GNU/Linux

sven@ubuntu:~/Documents/pharo7$ cat /etc/issue
Ubuntu 18.04.1 LTS

sven@ubuntu:~/Documents/pharo7$ id
uid=1000(sven) gid=1000(sven) 
groups=1000(sven),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare)

sven@ubuntu:~/Documents/pharo7$ cat /etc/security/limits.d/pharo.conf 
*  hardrtprio  2
*  softrtprio  2

sven@ubuntu:~/Documents/pharo7$ ls -lah /etc/security/limits.d/pharo.conf 
-rw-r--r-- 1 root root 50 Apr 30  2018 /etc/security/limits.d/pharo.conf

sven@ubuntu:~/Documents/pharo7$ pwd
/home/sven/Documents/pharo7

sven@ubuntu:~/Documents/pharo7$ curl get.pharo.org/64/70+vm | bash
  % Total% Received % Xferd  Average Speed   TimeTime Time  Current
 Dload  Upload   Total   SpentLeft  Speed
100  3054  100  30540 0   1961  0  0:00:01  0:00:01 --:--:--  1960
Downloading the latest 70 Image:
http://files.pharo.org/get-files/70/pharo64.zip
Pharo.image
Downloading the latest pharoVM:
http://files.pharo.org/get-files/70/pharo64-linux-stable.zip
pharo-vm/pharo
Creating starter scripts pharo and pharo-ui

sven@ubuntu:~/Documents/pharo7$ ./pharo Pharo.image printVersion
[version] 'Pharo7.0.0' 
'Pharo-7.0.0+rc1.build.1434.sha.ee53b61de346d1dd58999e239e1c3dc5da069b6d (64 
Bit)'

sven@ubuntu:~/Documents/pharo7$ file pharo-vm/lib/pharo/5.0-201806281256/pharo 
pharo-vm/lib/pharo/5.0-201806281256/pharo: ELF 64-bit LSB executable, x86-64, 
version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, 
for GNU/Linux 2.6.24, BuildID[sha1]=2778173a7eac63dca9a970146659c2de8fef4160, 
with debug_info, not stripped

sven@ubuntu:~/Documents/pharo7$ ldd pharo-vm/lib/pharo/5.0-201806281256/pharo 
linux-vdso.so.1 (0x7ffed93c1000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x7f21defbc000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x7f21dec1e000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 
(0x7f21de9ff000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x7f21de60e000)
/lib64/ld-linux-x86-64.so.2 (0x7f21df1c)

sven@ubuntu:~/Documents/pharo7$ ./pharo-ui Pharo.image 

[normal UI]

Do you have a normal user account ?
Are the permissions on /etc/security/limits.d/pharo.conf root:root ?

> On 3 Dec 2018, at 16:16, horrido  wrote:
> 
> I've switched over to Ubuntu Server 18.04 LTS. I've repeated all the steps to
> arrive at Pharo installation. I'm still having the same problem:
> pthread_setschedparam failed.
> 
> Here's my /etc/security/limits.d/pharo.conf:
> 
> * hard rtprio 2
> * soft rtprio 2
> 
> 
> 
> Sven Van Caekenberghe-2 wrote
>>> On 2 Dec 2018, at 18:40, horrido <
> 
>> horrido.hobbies@
> 
>> > wrote:
>>> 
>>> Bizarre. I've created a new VirtualBox image of Debian and now this
>>> solution
>>> no longer works! I'm still getting the thread priority warning. So this
>>> solution appears to be unreliable.
>> 
>> Why use Debian (not that it is bad, it is just a bit more technical) ?
>> 
>> I think you would have less problems using Ubuntu (it is just as open, it
>> is what everybody else is using and it is much more user friendly).
>> 
>>> 
>> 
>>> 
>>> 
>>> On Fri, 23 Nov 2018 at 04:02, horrido  wrote:
>>> 
 Okay, I've resolved everything. First, the reason why I'm getting the
 'pthread_setschedparam failed' error when I run Pharo under Debian is
 because it must be run as 'root'! Don't ask me why, but that's the
 reason
 why Pharo can't set thread priorities. (This wasn't an issue under
 Ubuntu
 Server – go figure.)
 
 Second, I am now using Pharo's own SHA256 class. It's probably not as
 secure
 (because it doesn't use a salt value) and not as quick to execute (not
 being
 C code), but for my purpose, it doesn't really matter.
 
 So I can use DigitalOcean or OVH to run my web server in a VPS.
 
>>> 
>>> Good to hear.  But you shouldn't need to run Pharo as root,
>>> just be root to create this config file
>>> cat <
>> >> 
>> *  hardrtprio  2
>>> *  softrtprio  2
>>> END
>>> 
>>> cheers -ben
>>> 
>>> 
>>> 
>>> 
>>> 
>>> --
>>> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
> 
> 
> 
> 
> 
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html




Re: [Pharo-users] can I improve this

2018-12-03 Thread Benoit St-Jean via Pharo-users
--- Begin Message ---
Works fine with my Squeak and Pharo code.
Result is 558 in both cases!

- 
Benoît St-Jean 
Yahoo! Messenger: bstjean 
Twitter: @BenLeChialeux 
Pinterest: benoitstjean 
Instagram: Chef_Benito
IRC: lamneth 
Blogue: endormitoire.wordpress.com 
"A standpoint is an intellectual horizon of radius zero".  (A. Einstein) 

On Monday, December 3, 2018, 10:37:57 a.m. EST, Roelof Wobben 
 wrote:  
 
 Op 3-12-2018 om 16:13 schreef Benoit St-Jean via Pharo-users:
> file := StandardFileStream readOnlyFileNamed: 'C:\Recv\day.1.input'.
> [file atEnd] whileFalse: [numbers add: (file nextLine asInteger)].
> file close.
very wierd, on my Pharo 7 box I do not work.
I also see a message that temp variables are not written or read


Can you try your code on my input : 
https://gist.github.com/RoelofWobben/001a0d7f9a8d5b5a0ebbc3f133dbd032
and tell me the outcome.

I have solved it already so you do not spoil anything


Roelof


  --- End Message ---


Re: [Pharo-users] VPS difficulties

2018-12-03 Thread horrido
Yes, I did. I even rebooted Ubuntu.

Given that this problem occurs for both Debian and Ubuntu, there must be
some commonality that hasn't been documented.



Ben Coman wrote
> At https://linux.die.net/man/5/limits.conf
> I read "note that all limit settings are set per login."
> You haven't mentioned whether you logged out and back in again?
> 
> cheers -ben
> 
> On Mon, 3 Dec 2018 at 23:17, horrido <

> horrido.hobbies@

> > wrote:
> 
>> I've switched over to Ubuntu Server 18.04 LTS. I've repeated all the
>> steps
>> to
>> arrive at Pharo installation. I'm still having the same problem:
>> pthread_setschedparam failed.
>>
>> Here's my /etc/security/limits.d/pharo.conf:
>>
>> * hard rtprio 2
>> * soft rtprio 2
>>
>>
>>
>> Sven Van Caekenberghe-2 wrote
>> >> On 2 Dec 2018, at 18:40, horrido <
>>
>> > horrido.hobbies@
>>
>> > > wrote:
>> >>
>> >> Bizarre. I've created a new VirtualBox image of Debian and now this
>> >> solution
>> >> no longer works! I'm still getting the thread priority warning. So
>> this
>> >> solution appears to be unreliable.
>> >
>> > Why use Debian (not that it is bad, it is just a bit more technical) ?
>> >
>> > I think you would have less problems using Ubuntu (it is just as open,
>> it
>> > is what everybody else is using and it is much more user friendly).
>> >
>> >>
>> > 
> 
>> >>
>> >>
>> >> On Fri, 23 Nov 2018 at 04:02, horrido  wrote:
>> >>
>> >>> Okay, I've resolved everything. First, the reason why I'm getting the
>> >>> 'pthread_setschedparam failed' error when I run Pharo under Debian is
>> >>> because it must be run as 'root'! Don't ask me why, but that's the
>> >>> reason
>> >>> why Pharo can't set thread priorities. (This wasn't an issue under
>> >>> Ubuntu
>> >>> Server – go figure.)
>> >>>
>> >>> Second, I am now using Pharo's own SHA256 class. It's probably not as
>> >>> secure
>> >>> (because it doesn't use a salt value) and not as quick to execute
>> (not
>> >>> being
>> >>> C code), but for my purpose, it doesn't really matter.
>> >>>
>> >>> So I can use DigitalOcean or OVH to run my web server in a VPS.
>> >>>
>> >>
>> >> Good to hear.  But you shouldn't need to run Pharo as root,
>> >> just be root to create this config file
>> >> cat <
>> > 
> >
>  >>
>> >  *  hardrtprio  2
>> >> *  softrtprio  2
>> >> END
>> >>
>> >> cheers -ben
>>





--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] can I improve this

2018-12-03 Thread Roelof Wobben

found it.

I use the old reading code from part1.
but on part2 you did add the input to the numbers collection

so numbers was keeping empty

sorry for the noise

Roelof



Op 3-12-2018 om 16:13 schreef Benoit St-Jean via Pharo-users:

| file total numbers index frequencies duplicate |

duplicate := false.
frequencies := Set new: 15.
frequencies add: 0.
numbers := OrderedCollection new: 1000.
total := 0.

file := StandardFileStream readOnlyFileNamed: 'C:\Recv\day.1.input'.
[file atEnd] whileFalse: [numbers add: (file nextLine asInteger)].
file close.

index := 0.
[duplicate] whileFalse: [index := index \\ (numbers size) + 1.
                        total := total + numbers at: index.
                        (frequencies includes: total)
                            ifTrue: [duplicate := true]
                            ifFalse: [frequencies add: total]].

total





Re: [Pharo-users] VPS difficulties

2018-12-03 Thread Ben Coman
At https://linux.die.net/man/5/limits.conf
I read "note that all limit settings are set per login."
You haven't mentioned whether you logged out and back in again?

cheers -ben

On Mon, 3 Dec 2018 at 23:17, horrido  wrote:

> I've switched over to Ubuntu Server 18.04 LTS. I've repeated all the steps
> to
> arrive at Pharo installation. I'm still having the same problem:
> pthread_setschedparam failed.
>
> Here's my /etc/security/limits.d/pharo.conf:
>
> * hard rtprio 2
> * soft rtprio 2
>
>
>
> Sven Van Caekenberghe-2 wrote
> >> On 2 Dec 2018, at 18:40, horrido <
>
> > horrido.hobbies@
>
> > > wrote:
> >>
> >> Bizarre. I've created a new VirtualBox image of Debian and now this
> >> solution
> >> no longer works! I'm still getting the thread priority warning. So this
> >> solution appears to be unreliable.
> >
> > Why use Debian (not that it is bad, it is just a bit more technical) ?
> >
> > I think you would have less problems using Ubuntu (it is just as open, it
> > is what everybody else is using and it is much more user friendly).
> >
> >>
> > 
> >>
> >>
> >> On Fri, 23 Nov 2018 at 04:02, horrido  wrote:
> >>
> >>> Okay, I've resolved everything. First, the reason why I'm getting the
> >>> 'pthread_setschedparam failed' error when I run Pharo under Debian is
> >>> because it must be run as 'root'! Don't ask me why, but that's the
> >>> reason
> >>> why Pharo can't set thread priorities. (This wasn't an issue under
> >>> Ubuntu
> >>> Server – go figure.)
> >>>
> >>> Second, I am now using Pharo's own SHA256 class. It's probably not as
> >>> secure
> >>> (because it doesn't use a salt value) and not as quick to execute (not
> >>> being
> >>> C code), but for my purpose, it doesn't really matter.
> >>>
> >>> So I can use DigitalOcean or OVH to run my web server in a VPS.
> >>>
> >>
> >> Good to hear.  But you shouldn't need to run Pharo as root,
> >> just be root to create this config file
> >> cat <
> >  >>
> >  *  hardrtprio  2
> >> *  softrtprio  2
> >> END
> >>
> >> cheers -ben
>


Re: [Pharo-users] can I improve this

2018-12-03 Thread Roelof Wobben

Op 3-12-2018 om 16:13 schreef Benoit St-Jean via Pharo-users:

file := StandardFileStream readOnlyFileNamed: 'C:\Recv\day.1.input'.
[file atEnd] whileFalse: [numbers add: (file nextLine asInteger)].
file close.

very wierd, on my Pharo 7 box I do not work.
I also see a message that temp variables are not written or read


Can you try your code on my input : 
https://gist.github.com/RoelofWobben/001a0d7f9a8d5b5a0ebbc3f133dbd032

and tell me the outcome.

I have solved it already so you do not spoil anything


Roelof




Re: [Pharo-users] VPS difficulties

2018-12-03 Thread horrido
I've switched over to Ubuntu Server 18.04 LTS. I've repeated all the steps to
arrive at Pharo installation. I'm still having the same problem:
pthread_setschedparam failed.

Here's my /etc/security/limits.d/pharo.conf:

* hard rtprio 2
* soft rtprio 2



Sven Van Caekenberghe-2 wrote
>> On 2 Dec 2018, at 18:40, horrido <

> horrido.hobbies@

> > wrote:
>> 
>> Bizarre. I've created a new VirtualBox image of Debian and now this
>> solution
>> no longer works! I'm still getting the thread priority warning. So this
>> solution appears to be unreliable.
> 
> Why use Debian (not that it is bad, it is just a bit more technical) ?
> 
> I think you would have less problems using Ubuntu (it is just as open, it
> is what everybody else is using and it is much more user friendly).
> 
>> 
> 
>> 
>> 
>> On Fri, 23 Nov 2018 at 04:02, horrido  wrote:
>> 
>>> Okay, I've resolved everything. First, the reason why I'm getting the
>>> 'pthread_setschedparam failed' error when I run Pharo under Debian is
>>> because it must be run as 'root'! Don't ask me why, but that's the
>>> reason
>>> why Pharo can't set thread priorities. (This wasn't an issue under
>>> Ubuntu
>>> Server – go figure.)
>>> 
>>> Second, I am now using Pharo's own SHA256 class. It's probably not as
>>> secure
>>> (because it doesn't use a salt value) and not as quick to execute (not
>>> being
>>> C code), but for my purpose, it doesn't really matter.
>>> 
>>> So I can use DigitalOcean or OVH to run my web server in a VPS.
>>> 
>> 
>> Good to hear.  But you shouldn't need to run Pharo as root,
>> just be root to create this config file
>> cat <
> >
>  *  hardrtprio  2
>> *  softrtprio  2
>> END
>> 
>> cheers -ben
>> 
>> 
>> 
>> 
>> 
>> --
>> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html





--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] can I improve this

2018-12-03 Thread Benoit St-Jean via Pharo-users
--- Begin Message ---
I'm on Squeak btw.  Tried it in Pharo 6.1 and it looks like number parsing is 
different.
Here's a version that works fine on Pharo 6.1
| file total numbers index frequencies duplicate |

duplicate := false.
frequencies := Set new: 15.
frequencies add: 0.
numbers := OrderedCollection new: 1000.
total := 0.

file := StandardFileStream readOnlyFileNamed: 'C:\Recv\day.1.input'.
[file atEnd] whileFalse: [numbers add: (file nextLine asInteger)].
file close.

index := 0.
[duplicate] whileFalse: [index := index \\ (numbers size) + 1.
                        total := total + numbers at: index.
                        (frequencies includes: total) 
                            ifTrue: [duplicate := true]
                            ifFalse: [frequencies add: total]].

total

- 
Benoît St-Jean 
Yahoo! Messenger: bstjean 
Twitter: @BenLeChialeux 
Pinterest: benoitstjean 
Instagram: Chef_Benito
IRC: lamneth 
Blogue: endormitoire.wordpress.com 
"A standpoint is an intellectual horizon of radius zero".  (A. Einstein) 

On Monday, December 3, 2018, 10:12:36 a.m. EST, Roelof Wobben 
 wrote:  
 
 Op 3-12-2018 om 16:08 schreef Benoit St-Jean via Pharo-users:

yep

I did change it by the argument

partTwo: aFileName
     | total numbers index frequencies duplicate file |

duplicate := false.
frequencies := Set new: 15.
frequencies add: 0.
numbers := OrderedCollection new: 1000.
total := 0.

file := self changesFrom: aFileName.

index := 0.
[duplicate] whileFalse: [index := index \\ (numbers size) + 1.
     total := total + numbers at: index.
     (frequencies includes: total)
     ifTrue: [duplicate := true]
     ifFalse: [frequencies add: total]].

^total

and changesFrom looks like this :

changesFrom: aFileName
     ^Array streamContents: [:changes |
   aFileName asFileReference readStreamDo: [:in |
     [in atEnd] whileFalse: [changes nextPut: in nextLine asInteger]]]


  --- End Message ---


Re: [Pharo-users] can I improve this

2018-12-03 Thread Roelof Wobben

Op 3-12-2018 om 16:08 schreef Benoit St-Jean via Pharo-users:

yep

I did change it by the argument

partTwo: aFileName
    | total numbers index frequencies duplicate file |

duplicate := false.
frequencies := Set new: 15.
frequencies add: 0.
numbers := OrderedCollection new: 1000.
total := 0.

file := self changesFrom: aFileName.

index := 0.
[duplicate] whileFalse: [index := index \\ (numbers size) + 1.
    total := total + numbers at: index.
    (frequencies includes: total)
    ifTrue: [duplicate := true]
    ifFalse: [frequencies add: total]].

^total

and changesFrom looks like this :

changesFrom: aFileName
    ^Array streamContents: [:changes |
  aFileName asFileReference readStreamDo: [:in |
    [in atEnd] whileFalse: [changes nextPut: in nextLine asInteger]]]




Re: [Pharo-users] can I improve this

2018-12-03 Thread Benoit St-Jean via Pharo-users
--- Begin Message ---
Did you change the file name?

- 
Benoît St-Jean 
Yahoo! Messenger: bstjean 
Twitter: @BenLeChialeux 
Pinterest: benoitstjean 
Instagram: Chef_Benito
IRC: lamneth 
Blogue: endormitoire.wordpress.com 
"A standpoint is an intellectual horizon of radius zero".  (A. Einstein) 

On Monday, December 3, 2018, 9:52:08 a.m. EST, Roelof Wobben 
 wrote:  
 
 yep, on  Pharo this is a empty collection.

numbers := OrderedCollection new: 1000.

so   index \\ (numbers size)   is  something divide by zero

Roelof



Op 3-12-2018 om 15:44 schreef Roelof Wobben:
> Op 3-12-2018 om 15:30 schreef Benoit St-Jean via Pharo-users:
>
> Thanks,
>
> But at first glance you do not use the contents of file anywhere or am 
> I mistaken.
> When I try your code on the real input I see a divide by zero error 
> message.
>
> Roelof
>
>
>
>


  --- End Message ---


Re: [Pharo-users] can I improve this

2018-12-03 Thread Roelof Wobben

yep, on  Pharo this is a empty collection.

numbers := OrderedCollection new: 1000.

so   index \\ (numbers size)   is  something divide by zero

Roelof



Op 3-12-2018 om 15:44 schreef Roelof Wobben:

Op 3-12-2018 om 15:30 schreef Benoit St-Jean via Pharo-users:

Thanks,

But at first glance you do not use the contents of file anywhere or am 
I mistaken.
When I try your code on the real input I see a divide by zero error 
message.


Roelof









Re: [Pharo-users] can I improve this

2018-12-03 Thread Roelof Wobben

Op 3-12-2018 om 15:30 schreef Benoit St-Jean via Pharo-users:

Thanks,

But at first glance you do not use the contents of file anywhere or am I 
mistaken.

When I try your code on the real input I see a divide by zero error message.

Roelof





Re: [Pharo-users] can I improve this

2018-12-03 Thread Benoit St-Jean via Pharo-users
--- Begin Message ---
Concerning Day1, part2 of Advent Of Code 2018, here's my quick take (Coded in a 
workspace with Squeak)...

| file total numbers index frequencies duplicate |

duplicate := false.
frequencies := Set new: 15.
frequencies add: 0.
numbers := OrderedCollection new: 1000.
total := 0.

file := StandardFileStream readOnlyFileNamed: 'day.1.input'.
[file atEnd] whileFalse: [numbers add: (Integer readFrom: file nextLine)].
file close.

index := 0.
[duplicate] whileFalse: [index := index \\ (numbers size) + 1.
                        total := total + numbers at: index.
                        (frequencies includes: total) 
                            ifTrue: [duplicate := true]
                            ifFalse: [frequencies add: total]].

^total

- 
Benoît St-Jean 
Yahoo! Messenger: bstjean 
Twitter: @BenLeChialeux 
Pinterest: benoitstjean 
Instagram: Chef_Benito
IRC: lamneth 
Blogue: endormitoire.wordpress.com 
"A standpoint is an intellectual horizon of radius zero".  (A. Einstein) 

On Monday, December 3, 2018, 2:01:08 a.m. EST, p...@highoctane.be 
 wrote:  
 
 Also, given the time that some people solve the puzzle, doing it too nice is 
actually not the best use of time in AoC.
Now, I'll try to solve quick and this will for sure lead to interesting things 
in Pharo.
>From Reddit, people solve it quick then make it nice.
Phil
On Mon, Dec 3, 2018, 03:45 Richard O'Keefe --- End Message ---


Re: [Pharo-users] can I improve this

2018-12-03 Thread Roelof Wobben

  
  
Thanks, 
  
  I found the function #atWrap  who maybe can be handy 
  
  
  
  
  Op 3-12-2018 om 13:17 schreef Richard O'Keefe:


  
  
"if I use
do:   this ends at the end of the array."
True.  But
all that means is that you have to keen on using #do:.


Processing an array
  repeatedly is as simple as
  [true] whileTrue: [
    anArray do: [:each
  |
      ...]]


I had intended to
  twist this into


  [changes anySatisfy:
  [:change | ...]] whileFalse.


However, in this case
  your second alternative has much to recommend it.
The control flow is
  simple.  There's no magic about it.  It's an
unusual setup, so no
  need to get fancy.


  seen := Set new.
  frequency := 0.
  found := false.
  i := changes size.
  [found] whileFalse:
  [
    i := i = changes
  size ifTrue: [1] ifFalse: [i+1].
    frequency :=
  frequency + (changes at: i).
    found := seen
  includes: frequency.
    seen add:
  frequency].



I like this better
  than what I had.


If we _were_ to get
  fancy, then introducing a CyclicReadStream
class and doing
    seen := Set new.
    frequency := 0.
    found := false.
    stream :=
  CyclicReadStream on: self changes.
    [found]
  whileFalse: [
      frequency :=
  frequency + stream next.
      found := seen
  includes: frequency.
      seen add:
  frequency].
wouldn't shrink the
  code much.  Oddly enough, I've encountered
problems in previous
  Advent of Code exercises where CyclicReadStream
would have been
  handy.  But just for this case?  No.


  
  
  
On Tue, 4 Dec 2018 at 00:25, Roelof Wobben 
  wrote:


  
hello
  Richard, 
  
  Thanks, I figured that out already.
  What I do not get is how to read the array multiple times.
  
  
  if I use do:   this ends at the end of the array.
  
  Or I must use something as this : 
  
  index := 0 
  if index > array length 
      index =:  1 
  else 
  index := index + 1 
  
  
  and then read the number with array at: index 
  
  Roelof
  
  
  Op 3-12-2018 om 10:08 schreef Richard O'Keefe:


  
Roelof Wobben
  wrote
"I
have to reread the file till the adding causes the
same outcome  as we had already"
You have to process the
  *sequence of changes* repeatedly;
you DON't have to *reread the
  file*.  Somebody already made this point.
Having read the changes into
  an array, you can iterate repeatedly over that array.


to find the first repeated
  frequency given a sequence of changes
    make an empty Set to hold
  the sums that have been seen so far.

    set the frequency to 0.
    loop forever
        for each change in
  the changes
            increment the
  frequency by the change.
            if the frequency
  is in the set
                return the
  frequency
           otherwise add the
  frequency to the set.



 partTwo: aFileName
    Transcript print: (self
  firstRepeatedFrequency: (self changesFrom:
  aFileName)); cr; flush.
  
  
  
On Mon, 3 Dec 2018 at 19:31, Roelof
  Wobben 
  wrote:


  
Thanks,
  
  
  For the second I have to take a good look.
  
  I have to reread the file till the adding causes
 

Re: [Pharo-users] can I improve this

2018-12-03 Thread Richard O'Keefe
"if I use do:   this ends at the end of the array."
True.  But all that means is that you have to keen on using #do:.

Processing an array repeatedly is as simple as
  [true] whileTrue: [
anArray do: [:each |
  ...]]

I had intended to twist this into

  [changes anySatisfy: [:change | ...]] whileFalse.

However, in this case your second alternative has much to recommend it.
The control flow is simple.  There's no magic about it.  It's an
unusual setup, so no need to get fancy.

  seen := Set new.
  frequency := 0.
  found := false.
  i := changes size.
  [found] whileFalse: [
i := i = changes size ifTrue: [1] ifFalse: [i+1].
frequency := frequency + (changes at: i).
found := seen includes: frequency.
seen add: frequency].

I like this better than what I had.

If we _were_ to get fancy, then introducing a CyclicReadStream
class and doing
seen := Set new.
frequency := 0.
found := false.
stream := CyclicReadStream on: self changes.
[found] whileFalse: [
  frequency := frequency + stream next.
  found := seen includes: frequency.
  seen add: frequency].
wouldn't shrink the code much.  Oddly enough, I've encountered
problems in previous Advent of Code exercises where CyclicReadStream
would have been handy.  But just for this case?  No.


On Tue, 4 Dec 2018 at 00:25, Roelof Wobben  wrote:

> hello Richard,
>
> Thanks, I figured that out already.
> What I do not get is how to read the array multiple times.
>
> if I use do:   this ends at the end of the array.
>
> Or I must use something as this :
>
> index := 0
> if index > array length
> index =:  1
> else
> index := index + 1
>
>
> and then read the number with array at: index
>
> Roelof
>
>
> Op 3-12-2018 om 10:08 schreef Richard O'Keefe:
>
> Roelof Wobben wrote
> "I have to reread the file till the adding causes the same outcome  as we
> had already"
> You have to process the *sequence of changes* repeatedly;
> you DON't have to *reread the file*.  Somebody already made this point.
> Having read the changes into an array, you can iterate repeatedly over
> that array.
>
> to find the first repeated frequency given a sequence of changes
> make an empty Set to hold the sums that have been seen so far.
> set the frequency to 0.
> loop forever
> for each change in the changes
> increment the frequency by the change.
> if the frequency is in the set
> return the frequency
>otherwise add the frequency to the set.
>
>  partTwo: aFileName
> Transcript print: (self firstRepeatedFrequency: (self changesFrom:
> aFileName)); cr; flush.
>
> On Mon, 3 Dec 2018 at 19:31, Roelof Wobben  wrote:
>
>> Thanks,
>>
>> For the second I have to take a good look.
>>
>> I have to reread the file till the adding causes the same outcome  as we
>> had already
>>
>> so for example if we have the sequence :
>>
>> +3, +3, +4, -2, -4
>>
>> it has as outcome :
>>
>> 3 6 10 8 4
>>
>> so no outcome is there a second time so we repeat the sequence
>>
>>
>> 7 10
>>
>> the 10 shows up a second time so there we have our answer.
>>
>>
>> Roelof
>>
>>
>>
>> Op 3-12-2018 om 03:45 schreef Richard O'Keefe:
>>
>> The key question is "what do you mean by improve"?
>> I'd start by asking "what are you doing that you will still have to do in
>> part 2, and what won't you do?"  So looking at part 2, you will want to
>> convert the lines to integers, and
>>   input := Array streamContents: [:lines |
>> 'input.txt' asFileReference readStreamDo: [:in |
>>   [in atEnd] whileFalse: [lines nextPut: in nextLine asInteger]]].
>> gives you a chunk of code you can use in both parts.  So you might
>> want to have
>>
>> Day1
>>   changesFrom: aFileName
>> ^Array streamContents: [:changes |
>>   aFileName asFileReference readStreamDo: [:in |
>> [in atEnd] whileFalse: [changes nextPut: in nextLine asInteger]]]
>>   partOne: aFileName
>> ^(self changesFrom: aFileName) sum
>>   partTwo: aFileName
>> ...
>> The file name should not be wired in because you want some test files.
>>
>>
>>
>>
>


Re: [Pharo-users] VPS difficulties

2018-12-03 Thread Ben Coman
That is strange. Can you post your "/etc/security/limits.d/pharo.conf" file?

cheers -ben

On Mon, 3 Dec 2018 at 01:42, horrido  wrote:

> Bizarre. I've created a new VirtualBox image of Debian and now this
> solution
> no longer works! I'm still getting the thread priority warning. So this
> solution appears to be unreliable.
>
> 
>
>
> On Fri, 23 Nov 2018 at 04:02, horrido  wrote:
>
> > Okay, I've resolved everything. First, the reason why I'm getting the
> > 'pthread_setschedparam failed' error when I run Pharo under Debian is
> > because it must be run as 'root'! Don't ask me why, but that's the reason
> > why Pharo can't set thread priorities. (This wasn't an issue under Ubuntu
> > Server – go figure.)
> >
> > Second, I am now using Pharo's own SHA256 class. It's probably not as
> > secure
> > (because it doesn't use a salt value) and not as quick to execute (not
> > being
> > C code), but for my purpose, it doesn't really matter.
> >
> > So I can use DigitalOcean or OVH to run my web server in a VPS.
> >
>
> Good to hear.  But you shouldn't need to run Pharo as root,
> just be root to create this config file
> cat < *  hardrtprio  2
> *  softrtprio  2
> END
>
> cheers -ben
> 
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] Pharo 7 Monticello browser and github repositories

2018-12-03 Thread Ben Coman
On Mon, 3 Dec 2018 at 01:48, Sanjay Minni via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> How to add new github repositories in Monticello (Browser) in Pharo 7
> (e.g to include the repository for Voyage)
>
> Monticello browser does show github repositories - how to edit / add new
> ones ?
>

Please try Iceberg.  Your feedback as a fresh Iceberg user would be useful.
Sorry I don't have any links handy, but it would be interesting to see what
you can work out intuitively.

One thing though, if you are using Windows you'll need to "Use custom SSH
keys..."
(if you are using ssh based protocol)

cheers -ben


Re: [Pharo-users] can I improve this

2018-12-03 Thread Roelof Wobben

  
  
hello Richard, 
  
  Thanks, I figured that out already.
  What I do not get is how to read the array multiple times. 
  
  if I use do:   this ends at the end of the array.
  
  Or I must use something as this : 
  
  index := 0 
  if index > array length 
      index =:  1 
  else 
  index := index + 1 
  
  
  and then read the number with array at: index 
  
  Roelof
  
  
  Op 3-12-2018 om 10:08 schreef Richard O'Keefe:


  
  
Roelof Wobben wrote
"I have to
reread the file till the adding causes the same outcome  as
we had already"
You have to process the
  *sequence of changes* repeatedly;
you DON't have to *reread
  the file*.  Somebody already made this point.
Having read the changes into
  an array, you can iterate repeatedly over that array.


to find the first repeated
  frequency given a sequence of changes
    make an empty Set to
  hold the sums that have been seen so far.

    set the frequency to 0.
    loop forever
        for each change in
  the changes
            increment the
  frequency by the change.
            if the frequency
  is in the set
                return the
  frequency
           otherwise add the
  frequency to the set.



 partTwo: aFileName
    Transcript print: (self
  firstRepeatedFrequency: (self changesFrom: aFileName)); cr;
  flush.
  
  
  
On Mon, 3 Dec 2018 at 19:31, Roelof Wobben 
  wrote:


  
Thanks, 
  
  For the second I have to take a good look.
  
  I have to reread the file till the adding causes the same
  outcome  as we had already 
  
  so for example if we have the sequence : 
  
  +3, +3, +4, -2, -4

it has as outcome : 

3 6 10 8 4 

so no outcome is there a second time so we repeat the
sequence


7 10 

the 10 shows up a second time so there we have our
answer. 


  Roelof
  
  
  
  Op 3-12-2018 om 03:45 schreef Richard O'Keefe:


  
The key
  question is "what do you mean by improve"?
I'd start by
  asking "what are you doing that you will still have to
  do in
part 2, and
  what won't you do?"  So looking at part 2, you will
  want to
convert the
  lines to integers, and
  input :=
  Array streamContents: [:lines |
   
  'input.txt' asFileReference readStreamDo: [:in |
      [in
  atEnd] whileFalse: [lines nextPut: in nextLine
  asInteger]]].
gives you a
  chunk of code you can use in both parts.  So you might
want to have


Day1
  changesFrom:
  aFileName
    ^Array
  streamContents: [:changes |
     
  aFileName asFileReference readStreamDo: [:in |
        [in
  atEnd] whileFalse: [changes nextPut: in nextLine
  asInteger]]]
  partOne:
  aFileName
    ^(self
  changesFrom: aFileName) sum
  partTwo:
  aFileName
    ...
The file name
  should not be wired in because you want some test
  files.





  

  


  

  


  

  


  




Re: [Pharo-users] UFFI and opaque(ish) types

2018-12-03 Thread p...@highoctane.be
Alistair,

I also would like to see how this works.

https://github.com/estebanlm/TalkFFI

There is also https://github.com/Pharophile/swig

https://github.com/Pharophile/swig/tree/master/Lib/pharo

(actually this is a fork from Ronie's work) that does some Pharo magic for
bindings.


And https://github.com/pavel-krivanek/CCodeGenerator may help to generate
some quick external things to reload (it is Slang externalized).

We need a solid push on all of this front since it takes wayyy too much
time to produce a binding. It is error prone, boring, and frankly UFFI
deserves better given its power.

Best,
Phil


On Mon, Dec 3, 2018 at 10:27 AM Alistair Grant 
wrote:

> Hi Ben and Phil,
>
> Thanks for your replies.
>
> On Sun, Dec 02, 2018 at 10:53:11PM +0800, Ben Coman wrote:
> > One option could be to create a small shared library that you compile
> for each
> > platform that just exported the member offsets...
> > https://www.embedded.com/design/prototyping-and-development/4024941/
> > Learn-a-new-trick-with-the-offsetof--macro
> >
> > You first FFI to that read struct member offsets and dynamically create
> the
> > definitions for your target library.
> > I haven't tried it in practice.
> >
> > cheers -ben
> >
> > P.S. Occasionally I dream about compilers being able to embed a
> pre-compiled
> > header declaration block in the library for FFI users to iterate...
> > https://clang.llvm.org/docs/PCHInternals.html#declarations-block
>
>
>
> On Sun, Dec 02, 2018 at 04:41:38PM +0100, p...@highoctane.be wrote:
> > No, but what about FFIExternalPackedStructureTest  and FFITestStructure ?
> >
> > Never tried with a typedef in the fieldsDesc but may work.
> >
> > Phil
>
>
> OK, it sounds like this still hasn't been adressed.
>
> The other idea that we've discussed in the past is to supply human
> readable text files that describe the structures for each platform, e.g.
> a STON file.  The file would be generated by automatically creating a
> program that dumps the required information to the STON text file.  This
> would allow the definitions to be used on platforms that don't have a
> compiler or the dev versions of the libraries installed.  I think we
> could even use the current #fieldDesc methods to generate these programs
> (maybe with some additional information stored in the class).
>
> A couple of links:
>
> -
> http://forum.world.st/PATCH-added-FilePlugin-error-code-lookup-function-tp5071376p5071620.html
> -
> http://forum.world.st/PATCH-added-FilePlugin-error-code-lookup-function-tp5071376p5075016.html
>
>
> Thanks again,
> Alistair
>
>
>
>


Re: [Pharo-users] UFFI and opaque(ish) types

2018-12-03 Thread Alistair Grant
Hi Ben and Phil,

Thanks for your replies.

On Sun, Dec 02, 2018 at 10:53:11PM +0800, Ben Coman wrote:
> One option could be to create a small shared library that you compile for each
> platform that just exported the member offsets... 
> https://www.embedded.com/design/prototyping-and-development/4024941/
> Learn-a-new-trick-with-the-offsetof--macro
> 
> You first FFI to that read struct member offsets and dynamically create the
> definitions for your target library.
> I haven't tried it in practice.
> 
> cheers -ben
> 
> P.S. Occasionally I dream about compilers being able to embed a pre-compiled
> header declaration block in the library for FFI users to iterate... 
> https://clang.llvm.org/docs/PCHInternals.html#declarations-block



On Sun, Dec 02, 2018 at 04:41:38PM +0100, p...@highoctane.be wrote:
> No, but what about FFIExternalPackedStructureTest  and FFITestStructure ?
> 
> Never tried with a typedef in the fieldsDesc but may work.
> 
> Phil


OK, it sounds like this still hasn't been adressed.

The other idea that we've discussed in the past is to supply human 
readable text files that describe the structures for each platform, e.g. 
a STON file.  The file would be generated by automatically creating a 
program that dumps the required information to the STON text file.  This 
would allow the definitions to be used on platforms that don't have a 
compiler or the dev versions of the libraries installed.  I think we 
could even use the current #fieldDesc methods to generate these programs 
(maybe with some additional information stored in the class).

A couple of links:

- 
http://forum.world.st/PATCH-added-FilePlugin-error-code-lookup-function-tp5071376p5071620.html
- 
http://forum.world.st/PATCH-added-FilePlugin-error-code-lookup-function-tp5071376p5075016.html


Thanks again,
Alistair




Re: [Pharo-users] can I improve this

2018-12-03 Thread Richard O'Keefe
Roelof Wobben wrote
"I have to reread the file till the adding causes the same outcome  as we
had already"
You have to process the *sequence of changes* repeatedly;
you DON't have to *reread the file*.  Somebody already made this point.
Having read the changes into an array, you can iterate repeatedly over that
array.

to find the first repeated frequency given a sequence of changes
make an empty Set to hold the sums that have been seen so far.
set the frequency to 0.
loop forever
for each change in the changes
increment the frequency by the change.
if the frequency is in the set
return the frequency
   otherwise add the frequency to the set.

 partTwo: aFileName
Transcript print: (self firstRepeatedFrequency: (self changesFrom:
aFileName)); cr; flush.

On Mon, 3 Dec 2018 at 19:31, Roelof Wobben  wrote:

> Thanks,
>
> For the second I have to take a good look.
>
> I have to reread the file till the adding causes the same outcome  as we
> had already
>
> so for example if we have the sequence :
>
> +3, +3, +4, -2, -4
>
> it has as outcome :
>
> 3 6 10 8 4
>
> so no outcome is there a second time so we repeat the sequence
>
>
> 7 10
>
> the 10 shows up a second time so there we have our answer.
>
>
> Roelof
>
>
>
> Op 3-12-2018 om 03:45 schreef Richard O'Keefe:
>
> The key question is "what do you mean by improve"?
> I'd start by asking "what are you doing that you will still have to do in
> part 2, and what won't you do?"  So looking at part 2, you will want to
> convert the lines to integers, and
>   input := Array streamContents: [:lines |
> 'input.txt' asFileReference readStreamDo: [:in |
>   [in atEnd] whileFalse: [lines nextPut: in nextLine asInteger]]].
> gives you a chunk of code you can use in both parts.  So you might
> want to have
>
> Day1
>   changesFrom: aFileName
> ^Array streamContents: [:changes |
>   aFileName asFileReference readStreamDo: [:in |
> [in atEnd] whileFalse: [changes nextPut: in nextLine asInteger]]]
>   partOne: aFileName
> ^(self changesFrom: aFileName) sum
>   partTwo: aFileName
> ...
> The file name should not be wired in because you want some test files.
>
>
>
>


Re: [Pharo-users] [Pharo-dev] [Ann] Fog 1.0.0-beta

2018-12-03 Thread Santiago Bragagnolo
It was late yesterday hahaha, I made many mistakes, thanks Marcus.
Anyway, the address is this one:

https://github.com/smartanvil/Fog 




El lun., 3 de dic. de 2018 09:12, Marcus Denker 
escribió:

> Link to GitHub:
>
> https://github.com/smartanvil/Fog 
>
> On 3 Dec 2018, at 01:20, Santiago Bragagnolo 
> wrote:
>
> Hi All!
>
> I have being working on releasing versions (i should do it more often).
>  I am happy to announce Fog v1.0.0-beta. I think I found a API that i like
> enough. So, i took the courage to pass to 1.
>
>  Thew new version changes many things:  Redefines the roll of the session,
> it minimize the roll of the connection, it cleans up the code, it defines a
> more verbose but less magic API. It generates proxies for the contracts.
>
> It supports now all the types including: maps and arrays.
>
> Goodnight :)
>
>
> Santiago
>
>
> Fog
>
> Pharo Ethereum Driver
>
> Fog is a library that allows the user to connect to an ethereum based
> blockchain data base.
>
> Is based on the Javascript canonical implementation done by Ethereum
> community Ethereum Javascript API
> .
> 
> Download code Iceberg
> / Baseline
>
> Metacello
>   new
>   baseline: 'Fog';
>   repository: 'github://sbragagnolo/Fog/src';
>   load.
>
>
>


Re: [Pharo-users] [Pharo-dev] [Ann] Fog 1.0.0-beta

2018-12-03 Thread Marcus Denker
Link to GitHub:

https://github.com/sbragagnolo/Fog 

> On 3 Dec 2018, at 01:20, Santiago Bragagnolo  
> wrote:
> 
> Hi All! 
> 
> I have being working on releasing versions (i should do it more often).
>  I am happy to announce Fog v1.0.0-beta. I think I found a API that i like 
> enough. So, i took the courage to pass to 1. 
> 
>  Thew new version changes many things:  Redefines the roll of the session, it 
> minimize the roll of the connection, it cleans up the code, it defines a more 
> verbose but less magic API. It generates proxies for the contracts.
> 
> It supports now all the types including: maps and arrays.
> 
> Goodnight :) 
> 
> 
> Santiago
> 
> 
> Fog
> 
> Pharo Ethereum Driver
> 
> Fog is a library that allows the user to connect to an ethereum based 
> blockchain data base.
> 
> Is based on the Javascript canonical implementation done by Ethereum 
> community Ethereum Javascript API 
> .
> 
>  
> Download code
> 
>  Iceberg / Baseline
> 
> Metacello
>   new
>   baseline: 'Fog';
>   repository: 'github://sbragagnolo/Fog/src';
>   load.