Re: [Factor-talk] Why is an empty paragraph not writable by gadget. ?

2015-09-21 Thread Georg Simon
Thank you. It works.


Am Sun, 20 Sep 2015 09:47:28 -0700
schrieb John Benediktsson :

> Okay, fixed both those issues:
> 
> https://github.com/slavapestov/factor/commit/e0bcd7423b7968cee3ee975e969f3e0e7b60ea27
> 
> https://github.com/slavapestov/factor/commit/d5c5a1389d60e9a5981d669c26d958f315039a8e
> 
> Now it works, but working means it doesn't take up any visual space
> with no children.
> 
> 
> 
> 
> 
> On Sun, Sep 20, 2015 at 9:42 AM, John Benediktsson 
> wrote:
> 
> > Looks like wrap-words doesn't work with an empty sequence.
> >
> > And if you "fix" that, paragraphs don't work because they can't
> > calculate their dimensions from an empty list of children.
> >
> > So, perhaps two bugs to fix.
> >
> >
> > On Sun, Sep 20, 2015 at 4:08 AM, Georg Simon 
> > wrote:
> >
> >> IN: scratchpad 500   add-gadget gadget.
> >>
> >> works ( shows an invisible gadget ). But
> >>
> >> IN: scratchpad 500  gadget.
> >>
> >> gives the error "Sequence index out of bounds".
> >>
> >> Is that a bug or a feature ?
> >>
> >>
> >> --
> >> ___
> >> Factor-talk mailing list
> >> Factor-talk@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/factor-talk
> >>
> >
> >


--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] how to run-pipeline

2015-09-21 Thread HP Wei
I want to run binary codes (C++) under linux using run-pipeline

In linux shell, the task is 

cmd1 -a arg1 -b arg2 | cmd2 -c arg3

I know in general, in factor, I need to construct

{ str1  str2 } run-pipeline
where str1 = “cmd1 -a arg1 -b arg2”
   str2 = “cmd2 -c arg3”
Ultimately, I may also insert some factor quot in betweeen
str1 and str2 to do some processing before handing the 
result to cmd2.


Here is what I envision:

TUPLE: cmd1 a b ;

:  ( — cmd1 )
cmd1 new
“default a” >>a
“default b” >>b ;

: get-cmd1 ( cmd1 — str1 )
   [ a>> ] [ b>> ] bi 
   “cmd1 -a %s -b %s” sprintf  ;

so now, I can write

 
   my_b >>b
get-cmd1

— similarly for cmd2.

But I bump into a mental block when trying to 
put things together for run-pipeline

If there were just one cmd1 (without cmd2),
I thought I could do

${  my_b >>b get-cmd1 } run-pipeline

Adding cmd2, I could write

${  my_b >>b get-cmd1   my_c >>c get-cmd2 } run-pipeline

But this looks ugly.  
Is there a simpler way ?

Thanks
HP Wei



--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] SHA-256

2015-09-21 Thread Alexander Ilin
Hello, John!

21.09.2015, 22:23, "John Benediktsson" :
> I don't know what version of Factor you are using, but I made a couple 
> improvements improvements to sha checksums over the last year or two.

  Right! I keep forgetting that I'm on 0.96, which is wildly out of date, 
apparently.

> I can hash a 17 mb file in 4.5 seconds on my laptop:

  That sounds quite a bit more reasonable.

> There is still a lot of optimization potential because it doesn't inline 
> fixnum arithmetic completely on 64-bit.  I was working on it awhile ago and 
> didn't quite finish.

  I'm on 32 bit for now, so it shouldn't affect me.

> If you really need performance now, here's another way that calls out to 
> ``shasum`` and is fast.
>
>     : shasum ( path -- checksum )
>         absolute-path { "shasum" "-a" "256" } swap suffix
>         utf8 [ readln ] with-process-reader " " split1 drop ;
>
>     IN: scratchpad [ "~/testfile" shasum ] time
>     Running time: 0.206797194 seconds
>
> Hope that helps.

  Actually, that helps immensely! Thank you very much!

---=---
Александр

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] SHA-256

2015-09-21 Thread John Benediktsson
I don't know what version of Factor you are using, but I made a couple
improvements improvements to sha checksums over the last year or two.

I can hash a 17 mb file in 4.5 seconds on my laptop:

IN: scratchpad "~/testfile" file-info size>> .
17825792

IN: scratchpad gc [ "~/testfile" sha-256 checksum-file ] time
Running time: 4.533698574 seconds

There is still a lot of optimization potential because it doesn't inline
fixnum arithmetic completely on 64-bit.  I was working on it awhile ago and
didn't quite finish.

If you really need performance now, here's another way that calls out to
``shasum`` and is fast.

: shasum ( path -- checksum )
absolute-path { "shasum" "-a" "256" } swap suffix
utf8 [ readln ] with-process-reader " " split1 drop ;

IN: scratchpad [ "~/testfile" shasum ] time
Running time: 0.206797194 seconds

Hope that helps.

Best,
John.




On Mon, Sep 21, 2015 at 12:09 PM, Alexander Ilin  wrote:

> Hello!
>
>   I just found out that calculation of SHA-256 checksum for a 17 Mb file
> takes about 200 seconds!
>   Does anyone have an idea how to improve that figure by at least two
> orders of magnitude?
>   sha256sum.exe does same in under 1 second.
>
> ---=---
>  Александр
>
>
> --
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] SHA-256

2015-09-21 Thread Alexander Ilin
Hello!

  I just found out that calculation of SHA-256 checksum for a 17 Mb file takes 
about 200 seconds!
  Does anyone have an idea how to improve that figure by at least two orders of 
magnitude?
  sha256sum.exe does same in under 1 second.

---=---
 Александр

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] stream-read

2015-09-21 Thread Alexander Ilin
Great, thank you!

21.09.2015, 19:23, "John Benediktsson" :
> You can just use read (or stream-read) which returns less bytes if the file 
> is smaller:
>
>     http://docs.factorcode.org/content/word-read,io.html
>
> So this does what you want:
>
>     "/path/to/file" utf8 [ 1024 read ] with-file-reader
>
> The stream-read-partial is used for some performance improvements in slurping 
> a whole file in chunks via each-stream-block.
>
> On Mon, Sep 21, 2015 at 8:35 AM, Alexander Ilin  wrote:
>> Hello!
>>
>>   I need to read a head of a file (name provided) up to 1024 bytes (return 
>> shorter string if the file size is less than 1024). I will then hash the 
>> read data.
>>
>>   I'd like to understand the difference between stream-read and 
>> stream-read-partial. Which one should I use for my task? Is the difference 
>> in the blocking behaviour?
>>
>> ---=---
>>  Александр
>>
>> --
>> ___
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
> ,
>
> --
> ,
>
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk


---=---
Александр

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] stream-read

2015-09-21 Thread John Benediktsson
You can just use read (or stream-read) which returns less bytes if the file
is smaller:

http://docs.factorcode.org/content/word-read,io.html

So this does what you want:

"/path/to/file" utf8 [ 1024 read ] with-file-reader

The stream-read-partial is used for some performance improvements in
slurping a whole file in chunks via each-stream-block.

On Mon, Sep 21, 2015 at 8:35 AM, Alexander Ilin  wrote:

> Hello!
>
>   I need to read a head of a file (name provided) up to 1024 bytes (return
> shorter string if the file size is less than 1024). I will then hash the
> read data.
>
>   I'd like to understand the difference between stream-read and
> stream-read-partial. Which one should I use for my task? Is the difference
> in the blocking behaviour?
>
> ---=---
>  Александр
>
>
> --
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] stream-read

2015-09-21 Thread Alexander Ilin
Hello!

  I need to read a head of a file (name provided) up to 1024 bytes (return 
shorter string if the file size is less than 1024). I will then hash the read 
data.

  I'd like to understand the difference between stream-read and 
stream-read-partial. Which one should I use for my task? Is the difference in 
the blocking behaviour?

---=---
 Александр

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Chris Double's Weblog

2015-09-21 Thread Alexander Ilin
Hello, Chris!

21.09.2015, 15:52, "Chris Double" :
> On Mon, Sep 21, 2015 at 6:50 PM, Alexander Ilin  wrote:
>>    I noticed your weblog is down. Are you going to bring it up, or is it 
>> dead permanently?
>
> It's up for me: http://bluishcoder.co.nz
>
> What error are you getting?
>
> All the factor articles are back online now too.

  It up now for me, too.
  For a few days I've seen only some boilerplate about nginx.

---=---
 Александр

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Chris Double's Weblog

2015-09-21 Thread Chris Double
On Mon, Sep 21, 2015 at 6:50 PM, Alexander Ilin  wrote:
>
>   I noticed your weblog is down. Are you going to bring it up, or is it dead 
> permanently?

It's up for me: http://bluishcoder.co.nz

What error are you getting?

All the factor articles are back online now too.

-- 
http://bluishcoder.co.nz

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk