[Pharo-users] Re: BlockClosure folding

2022-03-14 Thread Julián Maestri
Not satisfying the equality, but you can use polymorphism.

Block >> , aBlock
^ BlockCompositor andAll: OrderedCollection with: self with: aBlock

BlockCompositor >> #, aBlock
conditions add: aBlock.

BlockCompositor >> value: anObject
^ conditions allSatisfy: [:e | e value: anObject ]

I don't really like the name BlockCompositor, but can't think of a better
name at the moment.

You could also implement logic for #or: using #+ and: #anySatisfy: for
example, but need to safeguard against mixing both conditions.

On Mon, 14 Mar 2022 at 22:29, Hernán Morales Durand <
hernan.mora...@gmail.com> wrote:

> I think I saw a coding pattern a while ago that allows you to do the
> following:
>
> cond1 , cond2 , cond3 , cond4
>
> And providing a kind of folding selector condition #and: you would get:
>
> [ cond1 and: [ cond2 and: [ cond3 and: [ cond4 ] ] ] ].
>
> for example:
>
> conditions := [ : each | each firstName = 'Boca' ] ,
> [ : each | each lastName = 'Baret' ] ,
> [ : each | each fullName = 'Virgasia' ].
>
> such that the following assert is met:
>
> self assert: conditions equals: [ : each | each firstName = 'Boca' and: [
> each lastName = 'Baret' and: [ each fullName = 'Virgasia' ] ] ].
>
> Any ideas or pointers?
>
> Cheers,
>
> Hernán
>
>


[Pharo-users] Re: Pharo-SQLite3: closing connections immediately and deleting the database file

2021-08-12 Thread Julián Maestri
As far as I know you need to tell it to open a file called :memory: and in
Pharo-SQLite3 you should be able to use: SQLite3Connection memory

I've never done this before in Pharo, but it's worth trying, it should be
faster and easier to set up.

https://www.sqlite.org/inmemorydb.html
https://github.com/pharo-rdbms/Pharo-SQLite3/blob/7614fe8d0ac03fc94ed6be7e61e28d9111a5d482/doc/getting_started.md#creating-a-connection

On Fri, 13 Aug 2021 at 00:26, Esteban Maringolo 
wrote:

> After I set up the tests I knew that was possible, but never knew how
> to actually do it.
>
> Regards!
>
> Esteban A. Maringolo
>
> On Thu, Aug 12, 2021 at 8:55 PM Julián Maestri  wrote:
> >
> > Not exactly what you are asking for, but did you consider using sqlite
> in memory?
> >
> > On Sat, 7 Aug 2021 at 23:23, Esteban Maringolo 
> wrote:
> >>
> >> I've been doing exactly that. It is, creating a new DB file for each
> >> test, and I was having the same problem as you.
> >>
> >> I suggested a change to the driver to cover that situation:
> >> https://github.com/pharo-rdbms/Pharo-SQLite3/pull/22/files
> >>
> >> Try applying that change and see if that works.
> >>
> >> I still prefer to recreate the database, it will give you a full fresh
> >> start, and if you want you can halt before the deletion of the db, to
> >> analyze its internal state.
> >>
> >> Best regards!
> >>
> >>
> >> Esteban A. Maringolo
> >>
> >> On Sat, Aug 7, 2021 at 11:13 PM  wrote:
> >> >
> >> > Hi
> >> >
> >> > Actually I will just do a bunch of
> >> >
> >> > DROP TABLE IF EXISTS
> >> >
> >> > instead of dropping the db altogether.
> >> >
> >> > Thanks, Vince
>


[Pharo-users] Re: Pharo-SQLite3: closing connections immediately and deleting the database file

2021-08-12 Thread Julián Maestri
Not exactly what you are asking for, but did you consider using sqlite in
memory?

On Sat, 7 Aug 2021 at 23:23, Esteban Maringolo  wrote:

> I've been doing exactly that. It is, creating a new DB file for each
> test, and I was having the same problem as you.
>
> I suggested a change to the driver to cover that situation:
> https://github.com/pharo-rdbms/Pharo-SQLite3/pull/22/files
>
> Try applying that change and see if that works.
>
> I still prefer to recreate the database, it will give you a full fresh
> start, and if you want you can halt before the deletion of the db, to
> analyze its internal state.
>
> Best regards!
>
>
> Esteban A. Maringolo
>
> On Sat, Aug 7, 2021 at 11:13 PM  wrote:
> >
> > Hi
> >
> > Actually I will just do a bunch of
> >
> > DROP TABLE IF EXISTS
> >
> > instead of dropping the db altogether.
> >
> > Thanks, Vince
>


[Pharo-users] Re: Problem installing Seaside on Windows

2021-03-23 Thread Julián Maestri
Before you give up, try this:
Install (or reinstall) git from https://git-scm.com/ and make sure to set
up the option to use Windows Secure Channel library.

[image: image.png]

It has solved a lot of issues for me with pharo + git on windows, and not
being able to clone via https.


On Tue, 23 Mar 2021 at 11:08, David Pennington 
wrote:

> This is way to complicated for 70 year old developer. Running the code on
> the github page loaded Seaside,inifile and Ston without fuss so why is it
> so difficult on Windows?
> I have given up and decided to set my Mac up to be on with the lid down
> and use that as a server as this is a low traffic Web site.
> Thanks for all your help.
> David
>
> On 23 Mar 2021 07:32, Sven Van Caekenberghe  wrote:
>
>
>
> > On 22 Mar 2021, at 19:05, Stéphane Ducasse 
> wrote:
> >
> > david
> >
> > did you succeed to clone or checkout a github repo from this machine and
> without pharo at all?
>
> This is indeed step one: make sure that you can check out code from
> git(hub) on the command line in Windows. Only if that works you can do the
> next steps.
>
> BTW, once you have a repository checked out, you can just point Iceberg to
> it and load code.
>
> PS: yes, you will also have to learn the basic of git(hub).
>
> > Because Pharo is just using libgit.
> >
> > S.
> >
> >> On 22 Mar 2021, at 18:58, David Pennington 
> wrote:
> >>
> >> Tried that. I got the following
> >>
> >> Failed to get server certificate: the handle is in the wrong state for
> the requested operation.
> >>
> >> I assume that someone thinks that this is helpful:-)
> >>
> >> On 22 Mar 2021 16:06, Sanjay Minni  wrote:
> >> Hi David,
> >>
> >> I have repeatedly installed Seaside on Pharo 8 / 9 64 bit - Windows 10
> >> without any issues and I have done it both ssh and https
> >>
> >> I do it quickly / simply by
> >>
> >> tools->iceberg->[+ add](on top panel right)
> >> on popup select: 'clone from github.com'
> >> fill in owner: SeasideSt(case does not
> matter)
> >>project: seaside
> >>local directory:   (leave the default
> for
> >> now)
> >>protocol  try https first
> (not
> >> sure if github requires a password)
> >>  or ssh which
> may be
> >> slightly complicated
> >> once seaside libraries are pulled in and seaside appears in the iceberg
> >> panel then
> >> right click on seaside
> >>  on popup scroll down to metacello->install baseline (default)
> >>
> >> hope that works
> >>
> >>
> >>
> >>
> >> Long Haired David wrote
> >> > Hi everyone.
> >> >
> >> > I have been developing a new web site using Seaside on my M1
> MacBookAir
> >> > and I have had no issues.
> >> >
> >> > To deploy it, I have to install Pharo on either a Windows 10 or a
> Windows
> >> > Server 2012 server. Pharo has installed on both without any issues.
> >> > However, I am having problems installing Seaside.
> >> >
> >> > I have Pharo 8.0 installed on both (64 bit version).
> >> >
> >> > If I try and install from the Catalog, I get the following error in
> the
> >> > Transcript.
> >> >
> >> > IceGenericError: Failed to stat file
> >> > 'C:/Users/david/Documents/Pharo/images/Pharo 8.0 - 64bit
> >> > (stable)/pharo-local.
> >> >
> >> > If I try using Monticello, I get the following:
> >> >
> >> > Metacello new
> >> > baseline:'Seaside3';
> >> > repository: 'github://SeasideSt/Seaside:master/repository';
> >> > load
> >> > I got an error while cloning: There was an authentication error while
> >> > trying to execute the operation: .
> >> > This happens usually because you didn't provide a valid set of
> >> > credentials.
> >> > You may fix this problem in different ways:
> >> >
> >> > 1. adding your keys to ssh-agent, executing ssh-add ~/.ssh/id_rsa in
> your
> >> > command line.
> >> > 2. adding your keys in settings (open settings browser search for
> "Use
> >> > custom SSH keys" and
> >> > add your public and private keys).
> >> > 3. using HTTPS instead SSH (Just use an url in the form
> HTTPS://etc.git).
> >> > I will try to clone the HTTPS variant.
> >> >
> >> > Can you help please?
> >> >
> >> > David
> >> > Totally Objects
> >>
> >>
> >>
> >>
> >>
> >> -
> >> cheers,
> >> Sanjay
> >> --
> >> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
> >>
> >>
> >
> > 
> > Stéphane Ducasse
> > http://stephane.ducasse.free.fr / http://www.pharo.org
> > 03 59 35 87 52
> > Assistant: Aurore Dalle
> > FAX 03 59 57 78 50
> > TEL 03 59 35 86 16
> > S. Ducasse - Inria
> > 40, avenue Halley,
> > Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
> > Villeneuve d'Ascq 59650
> > France
> >
>
>
>


[Pharo-users] Re: is there a better way

2021-01-08 Thread Julián Maestri
You can also try https://github.com/ba-st/Superluminal which has caching
support among other things.

On Wed, 6 Jan 2021, 16:42 Esteban Maringolo,  wrote:

> To avoid doing something like that, and for a web scrapping tool I
> wrote, I implemented a basic subclass of ZnClient (called
> ZnCachingClient) that used a disk cache where each key/file was the
> hash of the requested URL.
>
> I haven't used in a while but it should continue to work, in any case,
> I published it in a Github repository:
> https://github.com/eMaringolo/zinc-caching-client
>
> Best regards,
>
> Esteban A. Maringolo
>
> On Wed, Jan 6, 2021 at 3:37 PM Richard Sargent
>  wrote:
> >
> >
> >
> > On Wed, Jan 6, 2021 at 10:34 AM Roelof Wobben via Pharo-users <
> pharo-users@lists.pharo.org> wrote:
> >>
> >>
> >> Thanks,
> >>
> >> Right now im downloading/fetching the images every time again.
> >>
> >> As I see it, the biggest bottleneck is that I have 10 images.
> >> And for all 10 I fetching the image and the data I could display when a
> >> user wants it.
> >> So that will be 20 calls to the api.
> >>
> >> So maybe some cache could be handy.
> >> Any hints how to make a cache in smalltalk.
> >
> >
> > Dictionary coupled with #at:ifAbsentPut:
> >
> >>
> >> Roelof
> >>
> >>
> >>
> >> Op 6-1-2021 om 19:19 schreef Sven Van Caekenberghe:
> >> > Roelof,
> >> >
> >> > Working with multiple high resolution images, as I believe you are
> >> > doing, is always going to be a real challenge, performance wise. It
> >> > just takes time to transfer lots of data.
> >> >
> >> > First you have to make sure that you are not doing too much work
> >> > (double downloads, using too high resolutions for previews or
> >> > browsing). Also, make sure your ultimate client (the browser) can
> >> > cache as well if applicable (set modification dates on the response).
> >> >
> >> > Next you could cache images locally (on your app server) so that next
> >> > time you need the same image, you do not need to download it again. Of
> >> > course, this only helps if your hit rate is higher than zero (if you
> >> > actually ask for the same image multiple times).
> >> >
> >> > It is also possible to do multiple download requests concurrently: if
> >> > the other end is fast enough, that can certainly help.
> >> >
> >> > HTH,
> >> >
> >> > Sven
> >> >
> >> >> On 6 Jan 2021, at 18:11, Roelof Wobben via Pharo-users
> >> >>  wrote:
> >> >>
> >> >>
> >> >> I did it on the root document and see this :
> >> >>
> >> >> 
> >> >>
> >> >> So as far as I see it , The most time it taken by getting all the
> >> >> data from all the 10 images.
> >> >>
> >> >> I hope someone can look at me if im on the right track and will help
> >> >> me to figure out faster ways to achieve the same
> >> >>
> >> >> Roelof
> >> >>
> >> >>
> >> >>
> >> >> Op 5-1-2021 om 05:16 schreef Richard O'Keefe:
> >> >>> Before you take another step, explore the root document.
> >> >>>
> >> >>> Profiling is easy.
> >> >>> Open a Playground.
> >> >>> Type an expression such as
> >> >>> 3 tinyBenchmarks
> >> >>> Right click and select 'Profile it'.
> >> >>>
> >> >>> More generally, in a browser, look at the "Tool - Profilers"
> >> >>> class category. The classic approach was
> >> >>> MessageTally spyOn: [3 tinyBenchmarks]
> >> >>> If I understand correctly, 'Profile it' uses TimeProfiler,
> >> >>> which has a nicer interface. (This is in Pharo 8.)
> >> >>>
> >> >>>
> >> >>> On Sun, 3 Jan 2021 at 23:03, Roelof Wobben 
> wrote:
> >> >>> I want that the code fetches a url and some data from the
> >> >>> Rijksmuseaum api.
> >> >>> And as far as I see it the second it not pointless because it
> >> >>> getting more detailed info about the painting as in the first get.
> >> >>>
> >> >>> I did not profiled it because I never learned how to do that in
> Pharo.
> >> >>>
> >> >>> Roelof
> >> >>>
> >> >>>
> >> >>>
> >> >>> Op 3-1-2021 om 01:09 schreef Richard O'Keefe:
> >>  What do you want the code to do?
> >>  Have you profiled the code to see where the time is going?
> >> 
> >>  A quick look at the code shows
> >>  - Paintings does one web get
> >>  - each Painting does two more web gets
> >>  ! and the first of those seems to be pretty pointless,
> >>  as it refetches an object that Paintings already fetched
> >>  and just looked at.
> >> 
> >> 
> >> 
> >>  On Sun, 3 Jan 2021 at 01:16, Roelof Wobben via Pharo-users
> >>   wrote:
> >>  Hello,
> >> 
> >>  I have now this code : https://github.com/RoelofWobben/Rijksmuseam
> >> 
> >>  but it seems to be slow.
> >> 
> >>  Can anyone help me with a way I can use a sort of cache so the page
> >>  looks first at the cache if a image is there .
> >>  If so, take the image from there , if not , ask the api for the
> url of
> >>  the image.
> >> 
> >>  Roelof
>


[Pharo-users] Re: PrintString in PBE8

2020-12-29 Thread Julián Maestri
As far as I know:

aStream
nextPutAll: ' with value: ‘;
print: count.

Works with most streams, does not create intermediary streams, and is
readable.

On Sun, 27 Dec 2020 at 05:59, Stéphane Ducasse 
wrote:

>
>
> On 26 Dec 2020, at 20:41, Sean P. DeNigris  wrote:
>
> Sven Van Caekenberghe-2 wrote
>
> Maybe his question is (also) why the automatic refactoring did it wrong,
> the rules warned about the wrong use of #printString, suggested a fix, but
> the solution is still using #printString, hence the same problem.
>
>
> I might be reading it wrong, but I thought everything worked as advertised,
> and the limitation was that there was no option to automatically fix the
> other warning about the printString. The "Use cascaded nextPutAll:’s
> instead
> of #, in #nextPutAll:" transformation did change:
>
> aStream nextPutAll: ' with value: ', count printString.
>
> to:
>
> aStream
>  nextPutAll: ' with value: ';
>  nextPutAll: count printString
>
>
>
>
> Yes but with such approach you still create an extra intermediary
> stream.
>
> The solution should be
>
>
> aStream
>nextPutAll: ' with value: ‘.
>count printOn: aStream
>
> Now this is a bit more tricky to do.
>
>
>
>
>
> -
> Cheers,
> Sean
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>
> 
> Stéphane Ducasse
> http://stephane.ducasse.free.fr / http://www.pharo.org
> 03 59 35 87 52
> Assistant: Aurore Dalle
> FAX 03 59 57 78 50
> TEL 03 59 35 86 16
> S. Ducasse - Inria
> 40, avenue Halley,
> Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
> Villeneuve d'Ascq 59650
> France
>
>


Re: [Pharo-users] transactional saving of images

2019-11-18 Thread Julián Maestri
Agree, sounds like a good idea.

As far as I know newer versions do not do this.

On Mon, Nov 18, 2019, 07:17 Marcus Denker  wrote:

>
>
> > On 15 Nov 2019, at 11:15, Siemen Baader  wrote:
> >
> > Hi,
> >
> > I have had a few occasions where I broke an image because I either ran
> out of disk space or had an endless loop that grew my image endlessly (I
> think).
> >
> > But why does Pharo not save the image & .changes file in hidden files
> named eg  ~Pharo.image while it saves? Then it can rename them when saving
> was successful. Many unix programs do this.
> >
> > (I'm using pharo 6.1 so don't know if newer versions do this)
> >
> Hi,
>
> I think this sounds like a good idea.
>
> Marcus
>
>
>
>
>


Re: [Pharo-users] Smallest docker image for pharo >=7 ?

2019-10-16 Thread Julián Maestri
Example:
# Stage 1: Load the project on an empty image, in this case this is a
development image (should change to use a minimal image)

FROM basmalltalk/pharo:7.0-image AS loader
COPY load-project.st ./
RUN pharo Pharo.image load-project.st --save --quit

# Stage 2: Copy the resulting Pharo.image with our project loaded
# into a new docker image with just the vm
# start in a new stage to keep docker image minimal
FROM basmalltalk/pharo:7.0

USER root

WORKDIR /opt/app
COPY start.sh .
COPY --from=loader /opt/pharo/Pharo.image ./
COPY --from=loader /opt/pharo/Pharo.changes ./
COPY --from=loader /opt/pharo/Pharo*.sources ./

RUN mkdir logs \
  && chmod a+x start.sh \
  && chown --recursive pharo:pharo /opt/app

USER pharo
EXPOSE 8080

CMD ["./start.sh"]


The resulting image size is ~80mb including image, changes & sources
Reference: https://docs.docker.com/develop/develop-images/multistage-build/

As a side note, the final image size is not what really matters, if you
have 20 different images all starting from the same base image (eg
ubuntu:18.04) the base layer is shared among all images so the network /
disk usage is less than the total size of the image.

It's important to keep the docker image thin, but also to keep layers at a
minimum and not adding / removing stuff during the build, because those are
stored in the middle layers (multi stage helps to remove that).

Cheers.

On Tue, 15 Oct 2019 at 20:00, Hernán Morales Durand <
hernan.mora...@gmail.com> wrote:

>
>
> El lun., 14 oct. 2019 a las 5:23, Pierce Ng ()
> escribió:
>
>> On Mon, Oct 14, 2019 at 04:07:49AM -0300, Hernán Morales Durand wrote:
>> > Because I am lazy and want to avoid searching through all DockerHub
>> > repository pages... Do you know a Dockerfile to generate the smallest
>> > possible docker image for Pharo?
>> > Anyone could make it work Pharo on Alpine since it uses different libc?
>>
>> Hi Hernán,
>>
>> Please see following links:
>>
>> - https://github.com/pharo-contributions/Docker-Alpine
>> - https://hub.docker.com/r/pierceng/pharovm-alpine
>> - https://hub.docker.com/r/pierceng/pharo7-alpine
>> - https://www.samadhiweb.com/blog/2019.07.20.alpine.pharo.minimal.html
>> - https://www.samadhiweb.com/blog/2019.08.11.minimizing.pharo.html
>>
>>
> Nice! It works with latest minimal 7.0.4 too.
>
> BTW you used .sources whith seem to be for Pharo 7
> (Pharo7.0-32bit-0903ade.sources), but when I tried with latest stable
> minimal and for some reason requires the V60 sources:
>
> $ docker run --rm --ulimit rtprio=2 pharo7_docker_alpine printVersion
> Pharo cannot locate the sources file named /pkg/image/PharoV60.sources.
>
> I found also another approach using rtprio=2:2 suggested from
> https://github.com/ba-st/docker-pharo/blob/master/docs/rtprio.md
> (soft:hard ulimits).
>
> The Alpine-based VM can be made smaller by removing unused/irrelevant
>> modules.
>>
>> Image-wise, currently I am using Pharo 7 minimal, which is just under
>> 30MB, and that forms the lower bound of the Pharo image size.
>>
>>
> The built image here is aprox. 99 Mbytes
>
> REPOSITORY   TAG IMAGE IDCREATED
>   SIZE
> pharo7_docker_alpine latest  595b9ece26253 hours
> ago 99.4MB
>
> but I think you didn't sumed the .sources.
>
>
>> However there is also the Pharo Candle effort that aims to make really
>> small images, which I hope to try out soon.
>>
>> > I am also interested in which stage you use to install packages into the
>> > image, and why? Do you copy the contained image into docker already
>> built?
>>
>> For Pharo, I start with the regular or minimal image, then load my
>> packages.
>>
>> For Docker, I first build a container image for the VM only. Using that
>> I build a new container image from the Pharo image and other required
>> files.
>>
>>
> Thank you for sharing Pierce.
>
> Hernán
>
>


Re: [Pharo-users] Can I control the location of the PharoDebug.log

2019-08-02 Thread Julián Maestri
I think Smalltalk logFileName: is what you want

On Wed, Jul 31, 2019, 20:58 Dale Henrichs 
wrote:

> It appears that the PharoDebug.log can be dropped into the directory
> from which a Pharo image is launched ... I would have expected it to be
> dropped into the local directory, but that does not appear to be the
> case ...
>
> I've looked in the Settings Browser and there does not appear to be a
> way to influence the location of the PharoDebug.log.
>
> I am currently using the `st` command line handler if that is important.
>
> I've googled for PharoDebug.log to no avail.
>
> Any help will be appreciated,
>
> Dale
>
>
>


Re: [Pharo-users] ODBCDriver

2019-06-03 Thread Julián Maestri
As far as I know, he just started porting it to Pharo 7.

On Sun, Jun 2, 2019, 13:51 Tomaž Turk  wrote:

> I just found this marvel: https://github.com/apiorno/ODBCDriver.
>
> But when I try to
>
> | con |
> con := ODBCConnection dsn:'myDSN' user:'usr' password:'pwd'.
>
> it responds with an error "Instance of ODBCLibrary class did not
> understand #sqlAllocEnv":
>
>
> running on Win 10 and Pharo 7.0.3.  I'd appreciate any help.
>
> Best wishes,
> Tomaz
>
>
>


Re: [Pharo-users] Zinc + HTTPS does not check for self signed certificates.

2018-07-10 Thread Julián Maestri
Forgot to mention, this was done in Pharo 6.1 (from zeroconf script). On
Windows 7 and Ubuntu 16.04 (32 bit vm)

On 10 July 2018 at 20:28, Julián Maestri  wrote:

> tl;dr
> Querying an HTTPS site with a self signed certificate does not fail /
> raise an exception (and it should).
>
> Long:
> I'm trying to use client and server HTTPS validation with Zinc on Pharo.
>
> I prepared: a self signed CA certificate, and server and client
> certificates signed by the same CA.
> I set up an Apache server with a site over HTTPS requiring client
> authentication. This worked (had to install the client certificate on my
> browser to access the site).
>
> After some failed attempts, i found this link
> <http://forum.world.st/How-to-use-HTTPS-SSL-with-Zinc-tp4952461p4952507.html>
> which was very helpful and successfully managed to authenticate a
> *ZnClient* with the Apache Server.
>
> This is the small snippet, only configuring the full path to the client
> certificate is enough (getting the right format for the pem file is another
> thing, it must have both certificate and key inside).
>
> | result |
> Transcript clear.
> result := ZnClient new
>   certificate: 'certs/client.pem' asFileReference asAbsolute pathString;
>   logToTranscript;
>   url: 'https://my-secure-site';
>   get.
> Transcript crShow: result.
>
> That worked on linux, windows still fails i don't know why.
>
> Trying to make it work on linux, i started checking without client
> authentication, and realized that Zinc was not complaining about the server
> certificate not known by a trusted CA.
> I changed the server certificate with a new one, self signed to make the
> case simpler, and Zing still did not complain.
>
> This is a problem, it should either fail, or let me configure it to fail
> when the server is not trustworthy.
> I'm not sure if it's Zinc, Zodiac or the SqueakSSL plugin.
>
> Am i doing anything wrong? Is there a configuration option which i can not
> find? If necessary, i can (temporarily) set up a public server with a
> self-signed certificate to help reproduce the case (the server i'm
> currently using is on a local network).
>
>
>
> PD: Sadly for this particular project (reverse proxy) this would be a no
> go, i can not use Pharo :(
>
>


[Pharo-users] Zinc + HTTPS does not check for self signed certificates.

2018-07-10 Thread Julián Maestri
tl;dr
Querying an HTTPS site with a self signed certificate does not fail / raise
an exception (and it should).

Long:
I'm trying to use client and server HTTPS validation with Zinc on Pharo.

I prepared: a self signed CA certificate, and server and client
certificates signed by the same CA.
I set up an Apache server with a site over HTTPS requiring client
authentication. This worked (had to install the client certificate on my
browser to access the site).

After some failed attempts, i found this link

which was very helpful and successfully managed to authenticate a *ZnClient*
with the Apache Server.

This is the small snippet, only configuring the full path to the client
certificate is enough (getting the right format for the pem file is another
thing, it must have both certificate and key inside).

| result |
Transcript clear.
result := ZnClient new
  certificate: 'certs/client.pem' asFileReference asAbsolute pathString;
  logToTranscript;
  url: 'https://my-secure-site';
  get.
Transcript crShow: result.

That worked on linux, windows still fails i don't know why.

Trying to make it work on linux, i started checking without client
authentication, and realized that Zinc was not complaining about the server
certificate not known by a trusted CA.
I changed the server certificate with a new one, self signed to make the
case simpler, and Zing still did not complain.

This is a problem, it should either fail, or let me configure it to fail
when the server is not trustworthy.
I'm not sure if it's Zinc, Zodiac or the SqueakSSL plugin.

Am i doing anything wrong? Is there a configuration option which i can not
find? If necessary, i can (temporarily) set up a public server with a
self-signed certificate to help reproduce the case (the server i'm
currently using is on a local network).



PD: Sadly for this particular project (reverse proxy) this would be a no
go, i can not use Pharo :(


Re: [Pharo-users] pharo bash script with startup

2018-06-27 Thread Julián Maestri
Try with ./pharo or try with an absolute image path.

On Wed, Jun 27, 2018, 04:03 Tim Mackinnon  wrote:

> I’ve not noticed that problem on ubuntu or AWS lambda so there must be
> something different going on.
>
> Sent from my iPhone
>
> On 27 Jun 2018, at 07:30, Otto Behrens  wrote:
>
> Hi,
>
> I just installed pharo 6.1 using the .zip file (
> http://files.pharo.org/platform/Pharo6.1-64-linux.zip) and battled to
> start up pharo with arguments.
>
> The issue is that the pharo bash script (in the extracted home dir) quotes
> all arguments:
>
> # execute
> exec "$LINUX/pharo" \
> --plugins "$LINUX" \
> --encoding utf8 \
> -vm-display-X11 \
> "$image"
>
> where
>
> image = $*
>
> The impact is that if I want to run a startup script, eg.
>
> pharo my.image startup.st
>
> pharo complains with "Could not open the Pharo image file: 'my.image
> startup.st'
>
> So I must run the executable directly?
>
> If so, some questions about the options that the bash script passes in:
> --plugins "$LINUX"is this necessary? will the default not be enough?
> --encoding utf8  the usage output says for example --textenc
> default is "UTF-8". Is utf8 the same thing?
> -vm-display-X11I tried starting without this, and it worked. Do I
> need to explicitly start with this?
>
> Thanks
> Otto
>
>


Re: [Pharo-users] Microservices using Pharo

2018-06-26 Thread Julián Maestri
At work we're using some microservices in pharo, implemented with Zink and
Teapot, can't tell you much about performance because they are not being
stress tested currently.

I'm using Traefik as a load balancer WITH sticky session on docker, mainly
because it scales acording to the docker configuration (traefik can detect
new docker instances and add them to the load balancer group)
https://docs.traefik.io/configuration/backends/docker/

To keep images running we use a docker swarm which is in charge of
restarting them if they fail. Why? ease of use, it's easier to deploy and
keep track of what is where.
https://docs.docker.com/engine/swarm/

For the Pharo docker image i'm running one based on debian slim, with the
VM for Pharo 6.1 (32 bit). Code in https://github.com/ba-st/docker-pharo,
available in the docker registry as basmalltalk/pharo:6.1

As i have no need for the sources file and removing it reduces the final
image size it's removed, but you can add it (or prevent it's removal if you
need)

If you need help with any of these, please ask (if it's urgent send me a
direct mail, i don't read the Pharo list very often).

On 27 June 2018 at 02:42, jtuc...@objektfabrik.de 
wrote:

> Norbert,
>
> Am 26.06.18 um 21:41 schrieb Norbert Hartl:
>
>
>
> Am 26.06.2018 um 20:44 schrieb Andrei Stebakov :
>
> What would be an example for load balancer for Pharo images? Can we run
> multiple images on the same server or for the sake of balancing
> configuration we can only run one image per server?
>
> There are a lot of possibilities. You can start multiple images on
> different ports and use nginx with an upstream rule to load balance. I
> would recommend using docker for spawning multiple images on a host. Again
> with nginx as frontend load balancer. The point is that you can have at
> least twice as muh inages running then you have CPU cores. And of course a
> lot more.
>
>
> the last time I checked nginx, the load balancing and sticky session stuff
> was not available in the free edition. So I guess you either pay for nginx
> (which I think is good) or you know some free 3d party addons...
>
> I wonder what exactly the benefit of Docker is in that game? On our
> servers we run 10 images on 4 cores with HT (8 virtual cores) and very
> rareley have real performance problems. We use Glorp, so there is a lot of
> SQL queriing going on for quite basic things already. So my guess would be
> that your "2 images per core"  are conservative and leave air for even a
> third one, depending on all the factors already discussed here.
>
> What's not to underestimate is all the stuff around monitoring and
> restarting images when things go wrong, but that's another story...
>
> Joachim
>
>
>
> --
> ---
> Objektfabrik Joachim Tuchel  mailto:jtuc...@objektfabrik.de 
> 
> Fliederweg 1 http://www.objektfabrik.de
> D-71640 Ludwigsburg  http://joachimtuchel.wordpress.com
> Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1
>
>
>


Re: [Pharo-users] How to LAN feature

2018-05-13 Thread Julián Maestri
>
> (impossible without the added networking prims, and still unreliable
> whether it will find the correct ones with...)
>

The problem seems to be here: he->h_addr_list[0] its a list of addresses
and only the first one is used.

Unix:
https://github.com/pharo-project/pharo-vm/blob/e0ce2d9d78c3c7b37bbc12cd8730c6a15f1f057c/opensmalltalk-vm/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c#L273
Windows:
https://github.com/pharo-project/pharo-vm/blob/e0ce2d9d78c3c7b37bbc12cd8730c6a15f1f057c/opensmalltalk-vm/platforms/win32/plugins/SocketPlugin/sqWin32NewNet.c#L1843
h_addr_list explanation:
http://www.gnu.org/software/libc/manual/html_node/Host-Names.html

But changing that might affect the whole networking package, so i don't
think it's going to be changed soon.


On 13 May 2018 at 15:20, Hilaire  wrote:

> I already tried the one you suggested, but it returns the loopback IP on
> P7.
>
> With the Henrik SSDP package, I can get the IP:
>
> SSDPParticipant new allLocalV4Addresses.
>
> However when I activate a second network interface, this last one returns
> an empty collection. When inactivating this second interface, it still
> returns an empty collection...
>
> Hilaire
>
>
> Le 13/05/2018 à 20:05, Julián Maestri a écrit :
>
>> NetNameResolver localHostAddress. "#[192 168 0 4]"
>>
>
> --
> Dr. Geo
> http://drgeo.eu
>
>
>
>


Re: [Pharo-users] How to LAN feature

2018-05-13 Thread Julián Maestri
I think he means you can not discover all interfaces from Pharo. I have 2
network interfaces with addresses 192.168.0.4 and 192.168.56.1
Pharo only returns the first one.

NetNameResolver localHostName  "'thepc'".
NetNameResolver localHostAddress. "#[192 168 0 4]"
NetNameResolver nameForAddress:  #[192 168 0 4] timeout: 60. "'thepc'"

NetNameResolver nameForAddress:  #[192 168 56 1] timeout: 60. "'thepc'"

If you need to broadcast something on the second one, you have no way to
automatically discover it. (eg if you wanted to prompt the user which one
to broadcast to, or to broadcast on them all)

On 13 May 2018 at 14:50, Hilaire  wrote:

> Hi Norbert,
>
> Just to be sure I understood correctly what you wrote regarding network
> interface: Do you mean it is impossible to discover the network interface
> IP address from the image? It is this IP the teacher Dr. Geo server needs
> to broadcast over UDP.
>
> Hilaire
>
>
> Le 08/05/2018 à 16:22, Henrik Sperre Johansen a écrit :
>
>> mDNS and SSDP are pretty much interchangeable, implementation wise;)
>>
>> The main problem; most computers these days come with multiple networking
>> interfaces, and are usually connected to separate subnets.
>> So when you connect a socket to the broadcast address, you have no idea
>> which interface it will actually send the request over, and whether you
>> can
>> communicate with other entities is sort if hit or miss.
>>
>> Pharos netresolver is blissfully unaware/unable to tell you which
>> interfaces
>> are available,
>> most of the work in the SSDP implementation went into trying to detect all
>> the different ones (impossible without the added networking prims, and
>> still
>> unreliable whether it will find the correct ones with...), and bind:'ing a
>> socket to each specifically.
>>
>> IIRC, the default server/client instantiation exemplified in class
>> comments
>> now simply binds to 0:0:0:0 and hopes the default interface is what you
>> wanted,  SSDPServer>>onAllInterfacesOfferServiceType:atLocation: runs
>> through the more extensive setup.
>>
>> Cheers,
>> Henry
>>
>> P.S. In second place; a listener loop capable of error handling a spotty
>> wifi connection/machine sleep cycles...
>>
>
> --
> Dr. Geo
> http://drgeo.eu
>
>
>
>


Re: [Pharo-users] How to LAN feature

2018-05-08 Thread Julián Maestri
You could also publish on a zeroconf service (Bonjour/Avahi)
https://en.wikipedia.org/wiki/Zero-configuration_networking

On 8 May 2018 at 11:22, Henrik Sperre Johansen  wrote:

> Ben Coman wrote
> > mDNS would be an interesting facility to include in the main Pharo
> release
> > image,
> > perhaps making it very easy for our "live" systems to locate each other
> on
> > a local network without external infrastructure.
> >
> >
> > cheers -ben
>
> mDNS and SSDP are pretty much interchangeable, implementation wise ;)
>
> The main problem; most computers these days come with multiple networking
> interfaces, and are usually connected to separate subnets.
> So when you connect a socket to the broadcast address, you have no idea
> which interface it will actually send the request over, and whether you can
> communicate with other entities is sort if hit or miss.
>
> Pharos netresolver is blissfully unaware/unable to tell you which
> interfaces
> are available,
> most of the work in the SSDP implementation went into trying to detect all
> the different ones (impossible without the added networking prims, and
> still
> unreliable whether it will find the correct ones with...), and bind:'ing a
> socket to each specifically.
>
> IIRC, the default server/client instantiation exemplified in class comments
> now simply binds to 0:0:0:0 and hopes the default interface is what you
> wanted,  SSDPServer>>onAllInterfacesOfferServiceType:atLocation: runs
> through the more extensive setup.
>
> Cheers,
> Henry
>
> P.S. In second place; a listener loop capable of error handling a spotty
> wifi connection/machine sleep cycles...
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] Problem fetching a baseline

2017-12-29 Thread Julián Maestri
You are trying to load Tonel but not telling Metacello where to load it
from:

Metacello new
repository: 'github://pharo-vcs/tonel';
baseline: 'Tonel';
load.

Tells Metacello to load the packages in BaselineOfTonel from
https://github.com/pharo-vcs/tonel

On 29 December 2017 at 09:53, Vitor Medina Cruz 
wrote:

> Hello,
>
> I am experimenting with Metacello but I am having problems to test my
> configuration. First I thought the problem was with my configuration, but
> after serveral atemps I tried to fetch an arbitrary Baseline from default
> image:
>
> Metacello new
> className: 'BaselineOfTonel';
> baseline: 'Tonel';
> fetch.
>
> And I got the following error:
>
> "Could not resolve: BaselineOfTonel [BaselineOfTonel] in
> C:\Users\Vitor\Documents\Pharo\images\Pharo 6.1
> (stable)\pharo-local\package-cache http://smalltalkhub.com/mc/
> Pharo/MetaRepoForPharo30/main/"
>
> Which is the same I got with my own project. I tried using 'repository:'
> also, but got the same error.
>
> Am I doing something wrong?
>
> cheers,
> Vitor.
>
>
> 
>  Livre
> de vírus. www.avg.com
> .
> <#m_1552980269475238850_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>


Re: [Pharo-users] Iceberg URL regex not matching how I would expect it to?

2017-12-25 Thread Julián Maestri
u...@server.com:/proj/proj.git

Isn't it: g...@server.com:user/project.git ?

On Dec 24, 2017 15:36, "Ian Ian"  wrote:

> Hi All,
>
> I am having trouble setting up iceberg to access my repository via ssh.
>
> On the command line I assess it via:  git clone u...@server.com:/proj/proj.git
> and all works as expected.
>
> When adding trying to add the same repository to iceberg I get a parseUrl
> error thrown from class IceScpRemote.  While debugging I see the following
> regex:
>
> matcher := 
> '(ssh\://)?([\w\-]+@)?([\w\-.]+)(\:[\d]+)?(\:|/)/?([\w\-]+)/([\w\-]+)(\.git)?'
> asRegex.
>
> which parses usern...@server.com:/directory/proj.git.
>
> However fails to parse:  usern...@server.com:/dir1/dir2/proj.git
>
> The corrected version is as follows:
>
> matcher := 
> '(ssh\://)?([\w\-]+@)?([\w\-.]+)(\:[\d]+)?(\:|/)/?(([\w\-]+)/)+([\w\-]+)(\.git)?'
> asRegex.
>
> Questions:
>
> Is this by design?
> of the top of your head:  If I use the corrected version am I going to run
> into other issues?
>
>
> NB:  I am using 64 bit Pharo 6.0 Update: #60520
>
> Thanks in advance,
>
>
>


Re: [Pharo-users] 6.1 Stable 64 - Crash when loading repository

2017-10-05 Thread Julián Maestri
Sorry for the delay.

$ uname -a
Linux PC51 4.4.0-96-generic #119-Ubuntu SMP Tue Sep 12 14:59:54 UTC 2017
x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial



On 4 October 2017 at 17:09, Stephane Ducasse 
wrote:

> Hello Julian
>
> Thanks for the report.
> on which OS are you?
>
> Stef
>
> On Wed, Oct 4, 2017 at 8:33 PM, Julián Maestri  wrote:
> > On a clean image from get.pharo.org/64/
> > Attempting to load the following repository
> >
> > Metacello new
> >   baseline: 'WillowBootstrap';
> >   repository: 'github://ba-st/Willow-Bootstrap:master/source';
> >   load.
> >
> > Consistently causes a VM crash (crash.dump in attatchment).
> >
> > This does not happen with the 32 bit image.
> >
> > Image + VM details
> >
> >> Image
> >> -
> >> /home/jmaestri/Pharo/workspace/Pharo.image
> >> Pharo6.0
> >> Latest update: #60510
> >> Unnamed
> >> Virtual Machine
> >> ---
> >> /home/jmaestri/Pharo/workspace/pharo-vm/lib/pharo/
> 5.0-201707201942/pharo
> >> CoInterpreter VMMaker.oscog-eem.2254 uuid:
> >> 4f2c2cce-f4a2-469a-93f1-97ed941df0ad Jul 20 2017
> >> StackToRegisterMappingCogit VMMaker.oscog-eem.2252 uuid:
> >> 2f3e9b0e-ecd3-4adf-b092-cce2e2587a5c Jul 20 2017
> >> VM: 201707201942 https://github.com/OpenSmalltalk/opensmalltalk-vm.git
> $
> >> Date: Thu Jul 20 12:42:21 2017 -0700 $ Plugins: 201707201942
> >> https://github.com/OpenSmalltalk/opensmalltalk-vm.git $
> >> Unix built on Jul 20 2017 20:40:36 Compiler: 4.6.3
> >> VMMaker versionString VM: 201707201942
> >> https://github.com/OpenSmalltalk/opensmalltalk-vm.git $ Date: Thu Jul
> 20
> >> 12:42:21 2017 -0700 $ Plugins: 201707201942
> >> https://github.com/OpenSmalltalk/opensmalltalk-vm.git $
> >> CoInterpreter VMMaker.oscog-eem.2254 uuid:
> >> 4f2c2cce-f4a2-469a-93f1-97ed941df0ad Jul 20 2017
> >> StackToRegisterMappingCogit VMMaker.oscog-eem.2252 uuid:
> >> 2f3e9b0e-ecd3-4adf-b092-cce2e2587a5c Jul 20 2017
> >
> >
> >
> >
>
>


Re: [Pharo-users] Is a non-break space whitespace?

2017-09-28 Thread Julián Maestri
The non breaking space, is a whitespace character or separator depending on
the context.
As far as i know it's not considered as a separator only when deciding text
layout, it means do not break the line here: eg: "A distance of 100 meters"
(nbsp between 100 and meters) should be rendered as either:
> A distance of 100 meters
or:
> A distance of
> 100 meters
But not:
> A distance of 100
> meters

There's an opposite character (don't remember the code) which means  which is NOT a whitespace.

On 25 September 2017 at 10:21, stephan  wrote:

> On 25-09-17 09:53, Richard Sargent wrote:
>
>> Rather than off-the-cuffing anything, please honour the Unicode Character
>> Properties. Refer to
>> https://en.wikipedia.org/wiki/Unicode_character_property#Whitespace,
>> among
>> others.
>>
>
> That is a good idea. And it won't help you if you scrape data from the
> web, as you'll find plenty of bad encoding. And unclarity over which
> version of which standard was used (see mongolian vowel separator)
>
> Stephan
>
>
>


[Pharo-users] Pharo 61 crashes on iceberg history

2017-07-29 Thread Julián Maestri
I'm almost sure this is not the right place to report it.

Im having a vm crash when looking at the history of a repository on iceberg.

urpharo: malloc.c:2394: sysmalloc: Assertion `(old_top == initial_top (av)
> && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse
> (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
> ./pharo-ui: line 11:  2011 Aborted (core dumped)
> "$DIR"/"pharo-vm/pharo" "$@"
>

Pharo downloaded from get.pharo.org/64/ on Ubuntu 16.04 (64bit)

Has somebody had this problem?
Where's the right place to report this?

Thanks, Julián


Re: [Pharo-users] How to calculate someone's age elegantly? Does Duration work?

2017-07-28 Thread Julián Maestri
It still works, probably because dayOfMonth is not what you expected at
first glance.

For a date, you have 3 accessors, and i think you were expecting #dayNumber

(January third, 1990) day. "Wednesday".
(January third, 1990) dayOfMonth. "January 3"
(January third, 1990) dayNumber. "3"



On 27 July 2017 at 16:43, PBKResearch  wrote:

> Julián
>
>
>
> I don’t know Chalten, but I wonder whether your definition of
> Person>>ageOn: will work correctly. Could I suggest you add two extra
> assertions to your test:
>
>
>
> assert: (john ageOn: February fifteenth , 2013) equals: (TimeUnits year
> with: 49);
> assert: (john ageOn: April first , 2013) equals: (TimeUnits year with: 50);
>
>
>
> Clearly these should be true, but I think they will not be – unless
> Date>>dayOfMonth works in a very counter-intuitive way.
>
>
>
> HTH
>
>
>
> Peter Kenny
>
>
>
>
>
> *From:* Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] *On
> Behalf Of *Julián Maestri
> *Sent:* 27 July 2017 18:58
> *To:* Any question about pharo is welcome 
> *Subject:* Re: [Pharo-users] How to calculate someone's age elegantly?
> Does Duration work?
>
>
>
> Using https://github.com/ba-st/Chalten the solution was something like
> this:
>
>
>
> Person>>ageOn: aDate
>   | difference |
>   difference := (aDate year distanceFrom: self dateOfBirth year).
>   ^(aDate dayOfMonth < self dateOfBirth dayOfMonth)
> ifTrue: [difference - TimeUnits year unitaryMeasurement]
> ifFalse: [difference]
>
> Test for that
>
> testAge
> | john |
> john := Person namedFirst: 'John' last: 'Doe' born: March fourteenth ,
> 1963.
> self
> assert: (john ageOn: March thirteenth , 2013) equals: (TimeUnits year
> with: 49);
> assert: (john ageOn: March fourteenth , 2013) equals: (TimeUnits year
> with: 50);
> assert: (john ageOn: March fifteenth , 2013) equals: (TimeUnits year with:
> 50)
>
>
>
> On 21 July 2017 at 14:25, Tim Mackinnon  wrote:
>
> Paul - this is very helpful, gosh you learn a lot from what seemed like
> simple question.
>
> Your suggestion along with Subbu’s gives an easy workable solution - I
> also wonder if the method should be in the image along with the comment
> explaining half open intervals like you have. Do you think there is another
> name for that end method - displayEnd sounds like it actively displays - I
> wonder if boundedEnd or completeEnd or finiteEnd might be correct
> alternatives (or is displayEnd a decent convention that everyone
> understands?)
>
> I really have to learn how to submit pull requests (although it seems
> rather complicated at the moment while the full git integration process is
> being sorted out).
>
> Thanks everyone
>
> Tim
>
>
> > On 21 Jul 2017, at 16:40, Paul DeBruicker  wrote:
> >
> > Tim Mackinnon wrote
> >> I am also wondering if the issue with Timespan is concerning - I was
> >> surprised that putting a start and end date left me something that
> didn’t
> >> answer my end date presumably down to rounding when it’s converted down
> to
> >> a duration (making me wonder if its better to keep a start and end date
> >> and calculate the duration on the fly).
> >>
> >> Tim
> >
> >
> > The Timespans are half open intervals.
> > (https://en.wikipedia.org/wiki/Interval_(mathematics))
> >
> > Friday July 21st ends at 11:59:59.999... etc etc etc ...PM
> and
> > the 22nd starts at 12:00AM
> >
> >
> > If Timespans were closed intervals like you expect then we'd be out of
> whack
> > with our corner of the universe.  That extra clock tick adds complexity.
> >
> > But I add a method to my image called #displayEnd because I also want
> them
> > to print 3PM-4PM and not 3PM-3:59:59.9PM and use that in my print
> > statements and rendering for Seaside.
> >
> > displayEnd
> >   ^ start + duration
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > View this message in context: http://forum.world.st/How-to-
> calculate-someone-s-age-elegantly-Does-Duration-work-
> tp4955990p4956114.html
> > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
> >
>
>
>


Re: [Pharo-users] How to calculate someone's age elegantly? Does Duration work?

2017-07-27 Thread Julián Maestri
Using https://github.com/ba-st/Chalten the solution was something like this:

Person>>ageOn: aDate
>   | difference |
>   difference := (aDate year distanceFrom: self dateOfBirth year).
>   ^(aDate dayOfMonth < self dateOfBirth dayOfMonth)
> ifTrue: [difference - TimeUnits year unitaryMeasurement]
> ifFalse: [difference]

Test for that

> testAge
> | john |
> john := Person namedFirst: 'John' last: 'Doe' born: March fourteenth ,
> 1963.
> self
> assert: (john ageOn: March thirteenth , 2013) equals: (TimeUnits year
> with: 49);
> assert: (john ageOn: March fourteenth , 2013) equals: (TimeUnits year
> with: 50);
> assert: (john ageOn: March fifteenth , 2013) equals: (TimeUnits year with:
> 50)


On 21 July 2017 at 14:25, Tim Mackinnon  wrote:

> Paul - this is very helpful, gosh you learn a lot from what seemed like
> simple question.
>
> Your suggestion along with Subbu’s gives an easy workable solution - I
> also wonder if the method should be in the image along with the comment
> explaining half open intervals like you have. Do you think there is another
> name for that end method - displayEnd sounds like it actively displays - I
> wonder if boundedEnd or completeEnd or finiteEnd might be correct
> alternatives (or is displayEnd a decent convention that everyone
> understands?)
>
> I really have to learn how to submit pull requests (although it seems
> rather complicated at the moment while the full git integration process is
> being sorted out).
>
> Thanks everyone
>
> Tim
>
> > On 21 Jul 2017, at 16:40, Paul DeBruicker  wrote:
> >
> > Tim Mackinnon wrote
> >> I am also wondering if the issue with Timespan is concerning - I was
> >> surprised that putting a start and end date left me something that
> didn’t
> >> answer my end date presumably down to rounding when it’s converted down
> to
> >> a duration (making me wonder if its better to keep a start and end date
> >> and calculate the duration on the fly).
> >>
> >> Tim
> >
> >
> > The Timespans are half open intervals.
> > (https://en.wikipedia.org/wiki/Interval_(mathematics))
> >
> > Friday July 21st ends at 11:59:59.999... etc etc etc ...PM
> and
> > the 22nd starts at 12:00AM
> >
> >
> > If Timespans were closed intervals like you expect then we'd be out of
> whack
> > with our corner of the universe.  That extra clock tick adds complexity.
> >
> > But I add a method to my image called #displayEnd because I also want
> them
> > to print 3PM-4PM and not 3PM-3:59:59.9PM and use that in my print
> > statements and rendering for Seaside.
> >
> > displayEnd
> >   ^ start + duration
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > View this message in context: http://forum.world.st/How-to-c
> alculate-someone-s-age-elegantly-Does-Duration-work-tp4955990p4956114.html
> > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
> >
>
>
>


Re: [Pharo-users] Little challenge: Best way to read stream and count line returns

2017-07-17 Thread Julián Maestri
count := 0.
stream do: [ :character | (character = Character cr and: [stream peek =
Character lf]) ifTrue: [  count := count + 1 ]].
count.

Snippet with example:

| count crlftext stream |
stream := (String
streamContents: [ :s |
s
nextPutAll: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
crlf;
nextPutAll: 'Phasellus sollicitudin lorem ac nunc varius aliquam.';
crlf;
nextPutAll: 'Quisque posuere augue in quam suscipit eleifend.';
crlf;
nextPutAll: 'Donec non tempor ex.';
crlf;
nextPutAll: 'Phasellus placerat leo augue, eu placerat augue luctus quis. ';
crlf;
lf;
cr;
cr ]) readStream.
count := 0.
stream
do: [ :char |
(char = Character cr and: [ stream peek = Character lf ])
ifTrue: [ count := count + 1 ] ].
count

On 13 July 2017 at 09:31, Cyril Ferlicot  wrote:

> Hello everyone,
>
> I often needs to read some streams these days and to get some infos
> related to the lines returns for example.
> Because of the CRLF it is a little complicated sometimes.
>
> I have an example of code here:
>
> | lfShouldBeCounted char count remaining |
> lfShouldBeCounted := false.
> remaining := 0.
> count := 0.
> stream position: startPos.
> [ stream position = endPos ]
>   whileFalse: [
> "13 is a CR, 10 a LF"
> (char := stream next asInteger) = 13
>   ifTrue: [ count := count + 1. remaining := 0. lfShouldBeCounted :=
> false ]
>   ifFalse: [
> char = 10
>   ifTrue: [
> lfShouldBeCounted
>   ifTrue: [ count := count + 1. remaining := 0 ]
>   ifFalse: [ lfShouldBeCounted := true ] ]
>   ifFalse: [ remaining := remaining + 1 ] ] ]
>
> With this example I know how many lines where passed between the
> startPos and the endPos in a stream. I also know how many char there
> is between the last line return and the endPos.
>
>  I wanted to know if you had a better way to do that? The way need to
> be as performant than this snippet. I know some people here can
> produce a snippet more readable and easier to maintain :)
>
> --
> Cyril Ferlicot
> https://ferlicot.fr
>
> http://www.synectique.eu
> 2 rue Jacques Prévert 01,
> 59650 Villeneuve d'ascq France
>
>


Re: [Pharo-users] Week number from a date

2016-05-27 Thread Julián Maestri
Chalten might help, i remember it had representations for months of years
(January of 1990), it might have something similar for weeks.

On 13 May 2016 at 05:40, Cédrick Béler  wrote:

> Yes I agree. We may have a preference to set the week day start (fistDayOfWeek
> ?).
>
>
> After that we could agree on the fact the first week is the first complete
> week (otherwise it can be a preference).
>
> Then we need to find the first day index of the first fistDayOfWeek.
> (Date year: self year day: 1) weekdayIndex
> -> gives the index according to the preference (for now Sunday -> 1)
>
> Then it’s quite straightforward to get the week number.
>
> Just have to check if the current date is in the last week of the previous
> year (returns 52 or 53).
> I did something but not sure yet (but no preference).
>
> There are been some works on time representation (Chronos if I remember
> well ? but cannot load in Pharo 5, depends on OSProcess).
>
> An interesting read [1].
>
> Cheers,
>
> Cédrik
>
> ps:
> http://stephane.ducasse.free.fr/Teaching/CoursAnnecy/0506-M1-COO/A%20New%20Object-Oriented%20Model%20of%20the%20Gregorian%20Calendar.pdf
>
>
>
> Interesting to know. But I see this already seems hard coded...
>
> Date nameOfDay: 1 "--> #Sunday"
>
> Timespan subclass: #Date
> poolDictionaries: 'ChronologyConstants'
>
> ChronologyConstants class >> initialize
> DayNames := #(Sunday Monday Tuesday Wednesday Thursday Friday Saturday).
>
> Also seems to have changed at some point, with the historical
> nameOfDay recorded in the Terse Guide [1] circa 2010 shown to be
> different. Perhaps this is something we should make a regional
> preference. Was there any ongoing works on other regional
> preferences?
>
>


Re: [Pharo-users] [UpdatedPharoByExample] Collection chapter

2016-02-14 Thread Julián Maestri
I'm getting a PDF corruption error and can not open it, is it just me?

On 13 February 2016 at 12:21, stepharo  wrote:

> Hi guys
>
> here is a new chapter for UpdatedPharoByExample.
>
> Stef
>
>


[Pharo-users] Github + Metacello + Baselines

2015-12-26 Thread Julián Maestri
I'm trying to use a BaselineOf approach for development, and wanted to know
if I got something wrong.

1. Development must be done on the baseline?
2. Configurations must reference a specific point (commit,tag,branch) of
the baseline?
3. My dependencies to other projects must be Baselines or Configurations?
Why?

BaselineOf:
https://github.com/dalehenrich/metacello-work/blob/master/docs/GettingStartedWithGitHub.md

Thanks in advance, Julián