Re: [Pharo-users] some sort of mentor help ?

2019-12-03 Thread Todd Blanchard via Pharo-users
--- Begin Message ---
I looked at the site and I knocked out day 1.  These are little programming 
puzzles you can do in a playground.

Day 1's first puzzles is literally a 1 liner.

The story telling obfuscates the problem and can make the problem seem harder 
than it is.  You have to learn to cut through the noise and see the problem.

You are supposed to find the amount of fuel required to launch a given mass 
into space in a rocket.  This is the key paragraph.

"Fuel required to launch a given module is based on its mass. Specifically, to 
find the fuel required for a module, take its mass, divide by three, round 
down, and subtract 2."

The code for this is:

fuel := (mass / 3) floor - 2.

The floor function rounds downwards.  To round up you use ceiling.

You have a list of modules though.  If you click to get your module mass list, 
its a page with one number per line.  Getting this into a collection is really 
easy.

masses := #(  )

and execute that in your playground.  This is your input data.

To get the fuel for each mass, a collect: seems like a winner.

fuels := masses collect: [:mass | (mass / 3) floor - 2 ].

The final thing he wants is the total amount of fuel required.  You just add up 
the numbers.

total := fuels sum.

I leave the second puzzle of day 1 to you, it is almost the same except you 
have to iteratively calculate the fuel to lift the fuel you add.  
To do this you end up putting a loop into the collect; block and executing it 
over and over until the amount of additional fuel is <= zero.

I hope this gets you going.  You can email me directly at tblanch...@mac.com if 
you get stuck.  

> On Dec 3, 2019, at 2:54 PM, Roelof Wobben via Pharo-users 
>  wrote:
> 
> 
> From: Roelof Wobben 
> Subject: some sort of mentor help ?
> Date: December 3, 2019 at 2:54:19 PM PST
> To: pharo-users@lists.pharo.org
> 
> 
> Hello, 
> 
> do not know if this is the right channel but is there someone or some book 
> which can help me learn how to approach complex problems like the 
> AdventOfCode challenges , I try that but im stuck because most of the time I 
> have the feeling I choose a difficult solution where some easier one exist.
> or I have a very bad plan
> that is a wall I hit many times with my languages and I need a way to get out 
> of it and make a step further with Pharo
> 
> Regards, 
> 
> Roelof 
> 
> 
> 

--- End Message ---


[Pharo-users] some sort of mentor help ?

2019-12-03 Thread Roelof Wobben via Pharo-users
--- Begin Message ---

  
  
Hello, 

do not know if this is the right channel but is there someone or
some book which can help me learn how to approach complex problems
like the AdventOfCode challenges , I try that but im stuck because
most of the time I have the feeling I choose a difficult solution
where some easier one exist.

  

  or I have a very bad plan

  


  that is a wall I hit many times with my
languages and I need a way to get out of it and make a step
further with Pharo

Regards, 

Roelof 

  

  


--- End Message ---


Re: [Pharo-users] uFFI: Debugging "External module not found" Error

2019-12-03 Thread Ben Coman
>
> > On Dec 3, 2019, at 11:34 AM, Sean P. DeNigris 
> wrote:
> >
> > Alistair Grant wrote
> >> The same message is returned whether the module itself isn't found, or
> >> if one of its dependencies can't be found.
>

Secondary dependencies are awkward to track via command line.



> >
> > Good to know. I wonder if we can't provide more detailed error messages
> > here...
>

The following turned up in a search (I've no experience with it), but could
be useful...
https://linux.die.net/man/7/rtld-audit

Or perhaps the system can examine the DYNAMIC section of an ELF to pre-load
each dependency.
>From the image, something in part equivalent to...
https://github.com/finixbit/elf-parser/blob/master/elf_parser.cpp
GT inspector on an ELF file could an interesting demo ;)

btw, I wasn't aware of how "Runtime Search Path: Security" affected the
search path...
https://amir.rachum.com/blog/2016/09/17/shared-libraries/


> Alistair Grant wrote
> >> On linux you can check dependencies with `ldd file.so`, I don't know
> >> what the Mac equivalent is.
> >
> > Apparently, it's `otool -L whatever.dylib`, which returns:
> >   @rpath/libvlc.dylib (compatibility version 12.0.0, current version
> 12.0.0)
> >   @rpath/libvlccore.dylib (compatibility version 10.0.0, current
> version
> > 10.0.0)
> >   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
> version
> > 1252.50.4)
> >   /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current
> version
> > 7.0.0)
>

On Wed, 4 Dec 2019 at 03:58, Todd Blanchard via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> This is the most annoying thing about UFFI - the library search seems to
> opaque and I don't understand how it works.
>
> So far I am finding best practice is to find the library yourself and then
> provide the exact file path you want.
>
> That way, you can actually prompt the user to find it if you don't and
> they get a decent experience.
>


cheers -ben

P.S. an interesting side article...
https://medium.com/forensicitguy/whitelisting-ld-preload-for-fun-and-no-profit-98dfea740b9


Re: [Pharo-users] uFFI: Debugging "External module not found" Error

2019-12-03 Thread Todd Blanchard via Pharo-users
--- Begin Message ---
This is the most annoying thing about UFFI - the library search seems to opaque 
and I don't understand how it works.

So far I am finding best practice is to find the library yourself and then 
provide the exact file path you want.  

That way, you can actually prompt the user to find it if you don't and they get 
a decent experience.

> On Dec 3, 2019, at 11:34 AM, Sean P. DeNigris  wrote:
> 
> Alistair Grant wrote
>> The same message is returned whether the module itself isn't found, or
>> if one of its dependencies can't be found.
> 
> Good to know. I wonder if we can't provide more detailed error messages
> here...
> 
> 
> Alistair Grant wrote
>> On linux you can check dependencies with `ldd file.so`, I don't know
>> what the Mac equivalent is.
> 
> Apparently, it's `otool -L whatever.dylib`, which returns:
>   @rpath/libvlc.dylib (compatibility version 12.0.0, current version 
> 12.0.0)
>   @rpath/libvlccore.dylib (compatibility version 10.0.0, current version
> 10.0.0)
>   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
> 1252.50.4)
>   /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version
> 7.0.0)
> 
> 
> Still investigating...
> 
> 
> 
> -
> Cheers,
> Sean
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
> 


--- End Message ---


Re: [Pharo-users] uFFI: Debugging "External module not found" Error

2019-12-03 Thread Sean P. DeNigris
Alistair Grant wrote
> The same message is returned whether the module itself isn't found, or
> if one of its dependencies can't be found.

Good to know. I wonder if we can't provide more detailed error messages
here...


Alistair Grant wrote
> On linux you can check dependencies with `ldd file.so`, I don't know
> what the Mac equivalent is.

Apparently, it's `otool -L whatever.dylib`, which returns:
@rpath/libvlc.dylib (compatibility version 12.0.0, current version 
12.0.0)
@rpath/libvlccore.dylib (compatibility version 10.0.0, current version
10.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
1252.50.4)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version
7.0.0)


Still investigating...



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



Re: [Pharo-users] [vwnc] Parsing in Smalltalk

2019-12-03 Thread Sean P. DeNigris
Steffen Märcker wrote
> I can send you that code.

Awesome. I'll email you. Although, I wonder how relevant this is given your
answers down below. Are there many grammars available in Xtreams syntax to
make this useful? Also, what is the license? Can I add it somewhere on GH
under MIT (with attribution of course)?


Steffen Märcker wrote
> However, I moved away from Xtreams own PEG flavor to Bryan Ford's  
> original PEG syntax (close but more common)

Ah, interesting. I didn't realize that Xtreams used a custom PEG syntax. I
wonder why?!


Steffen Märcker wrote
>  From Bryan Ford's original PEG syntax:
> 1. Xtreams Grammer and Actor that build an Xtreams parser
> ...
> All three are available for VW in the Cincom's public repository:
> - Xtreasm-Parsing (8.2-3,stm): +PEG parser +some fixes to Xtreams parser

I'd certainly like to port that at some point, but I'm currently fairly
mystified about the best practice process. I just reached out to Pavel about
the Ring2 approach on which he spoke at ESUG. Do you have a documented
process or any pointers even?


Steffen Märcker wrote
> And 2, 3 for Pharo on GitHub, e.g.
> - https://github.com/kursjan/petitparser2/tree/master/PetitParser2-PEG

Great. I use PP2 a lot. So if IIUC, I can now feed a PEG-syntax grammar
string and have a PP2 parser generated for it?


Steffen Märcker wrote
> Speaking of, I just noticed that translator form Xtreams.PEG to PEG is  
> missing to complete the picture here. ;-)

Ah, yes that makes sense. Any idea how much effort would be involved?


Steffen Märcker wrote
> As far as I know, there is no BNF-like parser generator for Xtreams,  
> available.
> ...
> Is it an option for you to convert your BNF to PEG manually?

I'm not a parsing expert, so that may have been what I'm already doing and
I'm using the wrong terminology. I took the ABNF from rfc5322 [1] and
adapted it slightly [2] to be consumed by Xtreams [3]

[OT?]
As a final aside, I've been wondering if there's any way to generate
"hand-rolled" equivalent parsers from Xtreams, PP, etc. for use cases where
none of the libraries are available. I have in mind Pharo's MailMessage. It
doesn't seem like any full-featured parsing libraries will be integrated any
time soon, so the lowest levels use painful, duplication-riddled hand-rolled
parsers. It would be great to leverage all this great library tech to create
and reason about those...
[/OT]

Thanks for the discussion!

1. https://tools.ietf.org/html/rfc5322
2.
https://github.com/seandenigris/Xtreams-Pharo/blob/master/repository/Xtreams-Email.package/PEGParser.extension/class/grammarEmail.st
3.
https://github.com/seandenigris/Xtreams-Pharo/blob/master/repository/Xtreams-Email.package/PEGParserEmailTest.class/instance/setUp.st



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



Re: [Pharo-users] uFFI: Debugging "External module not found" Error

2019-12-03 Thread Alistair Grant
Hi Sean,

On Tue, 3 Dec 2019 at 17:26, Sean P. DeNigris  wrote:
>
> I was trying to get Pharo-LibVLC working on Mac. The following is copied from
> a GH issue[1]:
>
> > I have VLC installed via Homebrew cask, the formula for which simply
> > installs the dmg. I
> > first tried supplying a full path to the dylib that the VLC app uses
> > (/Applications/VLC.app/Contents/MacOS/lib/libvlc.5.dylib), which resulted
> > in "Error:
> > External module not found". I then remembered some trouble people have had
> > in the past
> > with FFI lookup locations and tried copying into the VM's plugin folder
> > both a link and the
> > actual dylib, with the same error. I read the uFFI booklet, but didn't
> > learn anything more.
> >
> > I also checked that the VLC lib was 64-bit via:
> >
> > lipo -info .../Pharo.app/Contents/MacOS/Plugins/libvlc.5.dylib
> > which returned:
> > Non-fat file: .../Plugins/libvlc.5.dylib is architecture: x86_64

The same message is returned whether the module itself isn't found, or
if one of its dependencies can't be found.

On linux you can check dependencies with `ldd file.so`, I don't know
what the Mac equivalent is.

HTH,
Alistair



Re: [Pharo-users] uFFI: Debugging "External module not found" Error

2019-12-03 Thread Sean P. DeNigris
Ben Coman wrote
> One catch that has confused me in the past, is when the system caches that
> it couldn't find the external module,
> so even when I copyied it to the VM folder or got the path correct, it
> continued to fail until I restarted the Image.

Great gotcha! We should add that to the docs. I'll have a go after I figure
this error out. In my case, restarting did not help  :/



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



Re: [Pharo-users] uFFI: Debugging "External module not found" Error

2019-12-03 Thread Ben Coman
On Wed, 4 Dec 2019 at 00:26, Sean P. DeNigris  wrote:

> I was trying to get Pharo-LibVLC working on Mac. The following is copied
> from
> a GH issue[1]:
>
> > I have VLC installed via Homebrew cask, the formula for which simply
> > installs the dmg. I
> > first tried supplying a full path to the dylib that the VLC app uses
> > (/Applications/VLC.app/Contents/MacOS/lib/libvlc.5.dylib), which resulted
> > in "Error:
> > External module not found". I then remembered some trouble people have
> had
> > in the past
> > with FFI lookup locations and tried copying into the VM's plugin folder
>

One catch that has confused me in the past, is when the system caches that
it couldn't find the external module,
so even when I copyied it to the VM folder or got the path correct, it
continued to fail until I restarted the Image.

cheers -ben


> > both a link and the
> > actual dylib, with the same error. I read the uFFI booklet, but didn't
> > learn anything more.
> >
> > I also checked that the VLC lib was 64-bit via:
> >
> > lipo -info .../Pharo.app/Contents/MacOS/Plugins/libvlc.5.dylib
> > which returned:
> > Non-fat file: .../Plugins/libvlc.5.dylib is architecture: x86_64
>
> [1] https://github.com/badetitou/Pharo-LibVLC/issues/1
>
>
>
> -
> Cheers,
> Sean
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


[Pharo-users] uFFI: Debugging "External module not found" Error

2019-12-03 Thread Sean P. DeNigris
I was trying to get Pharo-LibVLC working on Mac. The following is copied from
a GH issue[1]:

> I have VLC installed via Homebrew cask, the formula for which simply
> installs the dmg. I 
> first tried supplying a full path to the dylib that the VLC app uses 
> (/Applications/VLC.app/Contents/MacOS/lib/libvlc.5.dylib), which resulted
> in "Error: 
> External module not found". I then remembered some trouble people have had
> in the past 
> with FFI lookup locations and tried copying into the VM's plugin folder
> both a link and the 
> actual dylib, with the same error. I read the uFFI booklet, but didn't
> learn anything more.
> 
> I also checked that the VLC lib was 64-bit via:
> 
> lipo -info .../Pharo.app/Contents/MacOS/Plugins/libvlc.5.dylib 
> which returned:
> Non-fat file: .../Plugins/libvlc.5.dylib is architecture: x86_64

[1] https://github.com/badetitou/Pharo-LibVLC/issues/1



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