[racket-users] Re: Add fns or at least sample code for getting column names from table?

2016-12-29 Thread George Neuner
On Thu, 29 Dec 2016 17:23:48 -0500, "'John Clements' via Racket Users"
 wrote:

>
>> On Dec 28, 2016, at 12:51, David Storrs  wrote:
>> 
>> There's also this:
>> 
>> (query-rows db
>>"
>>SELECT column_name
>>   FROM information_schema.columns
>>   WHERE table_schema = 'your_schema'
>> AND table_name   = 'your_table'
>> “)
>
>I’m guessing that that one’s postgresql-only, especially given the 
>‘table_schema’ element.


The format of the "system catalog" is implementation defined.  There
is no common convention for naming system tables - every vendor does
things (at least a little) differently.  Correspondingly, there is no
portable way to query the catalog.

ODBC (and JDBC) provides functions to query the most commonly needed
catalog information, but if you need something it does not provide -
e.g., to look up table constraints - you have to figure out how to get
that information yourself.


The DB lib does return table header information in the rows-result
structure.  To get it you have to use the generic (query) rather than
one of the more specific query forms.

Perhaps DB should provide additional abstract catalog functions.  At
least equivalent to those that ODBC provides:
https://msdn.microsoft.com/en-us/library/ms711722(v=vs.85).aspx
 

George

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Narrow radix of string->number.

2016-12-29 Thread Gustavo Massaccesi
I'm not too worried about a x4 slowdown in number->string because I
don't expect it to be in a tight loop, but it would be nice that it
were faster.

I made some tests. (You must change the 100 to number-to-convert in
your sample program.)

I made a new function number->string**, replacing
(define-values (q r) (quotient/remainder N 10))
with
(define q (quotientr N 10))
(define r (remainder N 10))

The problem is that quotient/remainder is very slow for fixnums (IIRC
it can be JIT-inlined).


I increased the number of iterations x10, so the run time is a few seconds:
(define iterations 1000) ; x10 of original number
(define number-to-convert 123)
cpu time: 1734 real time: 1740 gc time: 0   ;number->string
cpu time: 7234 real time: 7258 gc time: 0   ;number->string*
cpu time: 3578 real time: 3580 gc time: 31  ;number->string**

So the new function is only x2 times slower. Perhaps tweaking it for
fixnums can get a 10% or 20% increase of speed.


But for bignum the story is totally different. Here I used the
original number of iterations because everything is much slower.
(define iterations 100) ; original number
(define number-to-convert 1234567890123456789012345678901234567890)
cpu time: 1125 real time: 1128 gc time: 16   ;number->string
cpu time: 14828 real time: 14818 gc time: 94   ;number->string*
cpu time: 20735 real time: 20736 gc time: 222  ;number->string**

The new function is even slower. But both functions are very slow
(x15) in comparison with the C version.

(Note: To compare the times remember to consider the x10 factor in the
iterations, for example the run time of the original C function is
proportional to 1734 vs 11250, as expected it's faster for the
fixnum.)

Gustavo



On Wed, Dec 28, 2016 at 5:41 PM, Robby Findler
 wrote:
> I started with Ryan's code from `~r` and tried to emulate some special
> cases I see the C code (and didn't worry about negative numbers) and
> ended up with something 4-5x slower than the C code version. :(  Code
> follows.
>
> Robby
>
> #lang racket
> (define (number->string* N)
>   (cond [(zero? N)
>  (string #\0)]
> [else
>  (let* ([short-size 10]
> [str (make-string short-size)])
>(let loop ([N N] [digits null] [i short-size])
>  (cond
>[(zero? N)
> (if (<= i 0)
> (if (null? digits)
> str
> (string-append (apply string digits) str))
> (substring str i short-size))]
>[else
> (define-values (q r) (quotient/remainder N 10))
> (define d (integer->char (+ r (char->integer #\0
> (cond
>   [(<= i 0)
>(loop q (cons d digits) i)]
>   [else
>(string-set! str (- i 1) d)
>(loop q '() (- i 1))])])))]))
>
> (module+ test
>   (require rackunit)
>   (check-equal? (number->string* 1234567890987654321)
> (number->string 1234567890987654321))
>   (for ([x (in-range 1000)])
> (check-equal? (number->string* x )
>   (number->string x
>
> (define iterations 100)
> (define number-to-convert 123)
>
> (collect-garbage)
> (time
>  (for ([x (in-range iterations)])
>(number->string 100)))
>
> (collect-garbage)
> (time
>  (for ([x (in-range iterations)])
>(number->string* number-to-convert)))
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] New website design feedback

2016-12-29 Thread 'John Clements' via Racket Users

> On Dec 29, 2016, at 09:46, Matthew Butterick  wrote:
> 
> 
>> On Dec 23, 2016, at 6:55 AM, Greg Trzeciak  wrote:
>> 
>> 1. There is one thing that frustrates me most when I stumble upon new 
>> website/package/repository for the first time and I have no previous 
>> knowledge of its content. It is due to the amount of time it takes me to get 
>> an answer to a simple question: "What am I looking at?". 
> 
> We will be adding something like that shortly.

Let me add my thanks to everyone else’s; I really appreciate the work that 
you’ve put into this. Making everyone happy is the hardest part!

John Clements



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Add fns or at least sample code for getting column names from table?

2016-12-29 Thread 'John Clements' via Racket Users

> On Dec 28, 2016, at 12:51, David Storrs  wrote:
> 
> There's also this:
> 
> (query-rows db
>"
>SELECT column_name
>   FROM information_schema.columns
>   WHERE table_schema = 'your_schema'
> AND table_name   = 'your_table'
> “)

I’m guessing that that one’s postgresql-only, especially given the 
‘table_schema’ element.

John



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Fix Ctr+F search on the new website?

2016-12-29 Thread Philip McGrath
I can confirm that Command F searching for "extensive" with
Chrome 55.0.2883.95 on Mac OS Sierra 10.12.1 gives me this problem: it
finds one match (under the "Batteries Included") image, but I can't see the
highlighting until I hover over the image.

-Philip

On Thu, Dec 29, 2016 at 11:42 AM, Leif Andersen 
wrote:

> > (For instance, Chrome on Mac OS does not have this problem.)
>
> Really? I get the same problem on Chrome on Mac OS. That's bizarre.
>
> Namely, chrome 55.0.2883.95, and OS X El Capitan.
>
> I also get it with Firefox 50.1 on OS X El Capitan
>
> I have not tried it anywhere else.
>
> > What are you doing on the Racket home page anyhow? ;)
>
> Tee hee. Well, in that specific instance I was helping someone find the
> mailing list page.
>
> But since I'm nearly blind I like to test our stuff for accessibility
> concerns.
>
>
> ~Leif Andersen
>
> On Thu, Dec 29, 2016 at 12:29 PM, Matthew Butterick  wrote:
>
>>
>> On Dec 28, 2016, at 6:18 AM, Leif Andersen  wrote:
>>
>> I noticed that Ctr+F based searching is kind of uncomfortable on the new
>> website. Namely, if I am searching for a word that is located below one of
>> the images, it gets highlighted like you would expect, but the image
>> doesn't actually disappear. Thus I need to play whack-a-mole to find the
>> highlighted text myself.
>>
>> Instead, would it be possible to have the image disappear when the
>> relevant text is highlighted?
>>
>>
>> It's helpful to me if reports like this include browser / OS details, as
>> they don't all behave the same way. (For instance, Chrome on Mac OS does
>> not have this problem.)
>>
>> As Georges said, I don't know of any way to reveal-as-you-search.
>>
>> I think I can change it so the hover-box text doesn't show up in the
>> search results* though I'm not sure that would necessarily be an
>> improvement.
>>
>> What are you doing on the Racket home page anyhow? ;)
>>
>> * a div set to "display: none" will not be searched
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] New website design feedback

2016-12-29 Thread Matthew Butterick

> On Dec 23, 2016, at 6:55 AM, Greg Trzeciak  wrote:
> 
> 1. There is one thing that frustrates me most when I stumble upon new 
> website/package/repository for the first time and I have no previous 
> knowledge of its content. It is due to the amount of time it takes me to get 
> an answer to a simple question: "What am I looking at?". 

We will be adding something like that shortly.



> 2. Greyed out code snippets - I am not a fan of too much greyed out text or 
> code. It causes unnecessary eye strain. If this has to stay maybe make it not 
> AS GREY as it is right now.

I darkened them a bit. But grey text has been used in screen interfaces for 30 
yrs to indicate de-emphasis, and is widely used on today's web (e.g. Github). 
That particular horse is long out of the barn. 



> 3. I understand other pages like documentation (or rather its out of place 
> top black Racket bar) and Packages will also have a look overhaul. If that's 
> the case than one word: great! Especially that the old Packages (pkgs...) 
> looks now terribly outdated

Docs has been updated. Pkgs soon.




> On Dec 24, 2016, at 6:05 PM, George Neuner  wrote:
> At the top of the #lang(uage) example section, I would add a line
> about how "Racket is many languages in one" (or similar), and then at
> the end of the section add a blurb about how you can "make [your own]
> languages".

We will be adding something like that shortly.




>  I would add another link to the
> Documentation section (or more likely point the "Documentation" link
> again to the Software section so both are on screen together).

If I can find a way to fit in a Docs link in the top bar, I will do that. 
That's probably worthwhile.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Fix Ctr+F search on the new website?

2016-12-29 Thread Leif Andersen
> (For instance, Chrome on Mac OS does not have this problem.)

Really? I get the same problem on Chrome on Mac OS. That's bizarre.

Namely, chrome 55.0.2883.95, and OS X El Capitan.

I also get it with Firefox 50.1 on OS X El Capitan

I have not tried it anywhere else.

> What are you doing on the Racket home page anyhow? ;)

Tee hee. Well, in that specific instance I was helping someone find the
mailing list page.

But since I'm nearly blind I like to test our stuff for accessibility
concerns.


~Leif Andersen

On Thu, Dec 29, 2016 at 12:29 PM, Matthew Butterick  wrote:

>
> On Dec 28, 2016, at 6:18 AM, Leif Andersen  wrote:
>
> I noticed that Ctr+F based searching is kind of uncomfortable on the new
> website. Namely, if I am searching for a word that is located below one of
> the images, it gets highlighted like you would expect, but the image
> doesn't actually disappear. Thus I need to play whack-a-mole to find the
> highlighted text myself.
>
> Instead, would it be possible to have the image disappear when the
> relevant text is highlighted?
>
>
> It's helpful to me if reports like this include browser / OS details, as
> they don't all behave the same way. (For instance, Chrome on Mac OS does
> not have this problem.)
>
> As Georges said, I don't know of any way to reveal-as-you-search.
>
> I think I can change it so the hover-box text doesn't show up in the
> search results* though I'm not sure that would necessarily be an
> improvement.
>
> What are you doing on the Racket home page anyhow? ;)
>
> * a div set to "display: none" will not be searched
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Fix Ctr+F search on the new website?

2016-12-29 Thread Matthew Butterick

> On Dec 28, 2016, at 6:18 AM, Leif Andersen  wrote:
> 
> I noticed that Ctr+F based searching is kind of uncomfortable on the new 
> website. Namely, if I am searching for a word that is located below one of 
> the images, it gets highlighted like you would expect, but the image doesn't 
> actually disappear. Thus I need to play whack-a-mole to find the highlighted 
> text myself.
> 
> Instead, would it be possible to have the image disappear when the relevant 
> text is highlighted? 


It's helpful to me if reports like this include browser / OS details, as they 
don't all behave the same way. (For instance, Chrome on Mac OS does not have 
this problem.)

As Georges said, I don't know of any way to reveal-as-you-search.

I think I can change it so the hover-box text doesn't show up in the search 
results* though I'm not sure that would necessarily be an improvement.

What are you doing on the Racket home page anyhow? ;)

* a div set to "display: none" will not be searched

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Racket-ese for Scheme `define-record-type' protocol?

2016-12-29 Thread Eric Eide
Matthew Flatt  writes:

> The separate `make-racr-specification` function is how I would write
> it, including using `make-` as a prefix.

Thank you for the help!

-- 
---
Eric Eide   . University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Fix Ctr+F search on the new website?

2016-12-29 Thread Dupéron Georges
Good catch!

I looked this up a bit, unfortunately it seems that there is no reliable way to 
detect when the browser's search feature is started, let alone know where the 
results are and which one is currently highlighted.

None of the options available is entirely satisfactory:
* Use JavaScript to detect when Ctrl+F, "/" and similar search keys are 
pressed, shortly followed by a loss of focus as described in [1]. When this 
happens, force all the boxes to be visible. As said in [1], this won't work 
when the search function is invoked via the menu, or with non-standard search 
keys
* Use display:none instead of or in addition to opacity:0. This will make the 
text non-searchable, which kinda solves the "invisible text found" issue, but 
is not really what we want. It would also most likely prevent the text from 
being read by screen readers, which is bad on the accessibility side.
* Change the design to always show the text, at least with a 30% opacity or 
something (like is done for the source code boxes).
* Use the CSS below to make the text's color a transparent one, instead of 
having the whole box transparent. It seems that both Chromium and Firefox 
highlight text with the color rgba(0,0,0,0), see the attached screenshots. It 
doesn't show up the whole text where the match was found, but at least it's 
very clear where one should put the mouse to see the full text, instead of 
playing whack-a-mole

.feature > .inner a {
color:rgba(0,0,0,0);
transition: color 0.3s ease, background 0.3s ease;
}

.feature > .inner {
opacity: 1; /* was 0 */
color:rgba(0,0,0,0);
background:rgba(255,255,255,0);
transition: color 0.3s ease, background 0.3s ease;
}

.feature:hover > .inner a {
color:rgb(6, 121, 167);
transition: color 0.3s ease;
}

.feature:hover > .inner {
color:black;
background:rgba(255,255,255,1);
transition: color 0.3s ease, background 0.3s ease;
}

It might however be unwise to rely on that behaviour. An alternative would be 
to use opaque white text (and transition it to opaque black on hover), and in 
the non-hovered state put the image *on top* of the white text (so that the 
text doesn't leave white artefacts on the picture), using an empty :after 
pseudo-element or a :before + a z-index. Aligning the :before or :after element 
properly turns out to be a pain, though (especially since the title line does 
need the image as a "real" background, and only the "main" part of the box need 
the image atop the white text when unhovered, but below the text when hovered).


[1] http://stackoverflow.com/a/6680403/324969

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [racket-users] Racket-ese for Scheme `define-record-type' protocol?

2016-12-29 Thread Matthew Flatt
The `#:guard` option doesn't let you change the arity of the
constructor, so I don't think that's what Eric wants.

The separate `make-racr-specification` function is how I would write
it, including using `make-` as a prefix.

At Thu, 29 Dec 2016 10:53:49 +0100, "Jos Koot" wrote:
> Doesn't (struct ... #:guard guard-proc ...) not do what you want?
> See the doc on struct.
> Jos
> 
> -Original Message-
> From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On 
> Behalf Of Eric Eide
> Sent: jueves, 29 de diciembre de 2016 2:55
> To: Racket Users
> Subject: [racket-users] Racket-ese for Scheme `define-record-type' protocol?
> 
> Hi!  I'm translating a R6RS Scheme program to Racket, and I have a question
> about the best "Racket-ese" translation for Scheme's `define-record-type'.
> 
> Consider the following R6RS definition:
> 
> -
>  (define-record-type racr-specification
>(fields (mutable specification-phase) rules-table (mutable start-symbol))
>(opaque #t)(sealed #t)
>(protocol
> (lambda (new)
>   (lambda ()
> (new 1 (make-eq-hashtable 50) racr-nil)
> -
> 
> What is the Racket translation of the protocol specification?  Reading the
> online Racket docs, I don't see how to specify a different (and fresh per
> instance) value for every field within Racket's `struct` form.  (#:auto and
> #:auto-value are not what I want; I need different values, and fresh values,
> for every created instance.)
> 
> I guess I could "cheat" by defining the "expected" constructor myself:
> 
> -
> (define (make-racr-specification)
>   (racr-specification 1 (make-eq-hashtable 50) racr-nil))
> -
> 
> But this seems common enough that it would be built into `struct` in some way?
> Or maybe `struct` isn't what I want at all?
> 
> Thanks ---
> 
> Eric.
> (a Racket newbie)
> 
> -- 
> ---
> Eric Eide   . University of Utah School of 
> Computing
> http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 
> FAX

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [racket-users] Racket-ese for Scheme `define-record-type' protocol?

2016-12-29 Thread Jos Koot
Doesn't (struct ... #:guard guard-proc ...) not do what you want?
See the doc on struct.
Jos

-Original Message-
From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On 
Behalf Of Eric Eide
Sent: jueves, 29 de diciembre de 2016 2:55
To: Racket Users
Subject: [racket-users] Racket-ese for Scheme `define-record-type' protocol?

Hi!  I'm translating a R6RS Scheme program to Racket, and I have a question
about the best "Racket-ese" translation for Scheme's `define-record-type'.

Consider the following R6RS definition:

-
 (define-record-type racr-specification
   (fields (mutable specification-phase) rules-table (mutable start-symbol))
   (opaque #t)(sealed #t)
   (protocol
(lambda (new)
  (lambda ()
(new 1 (make-eq-hashtable 50) racr-nil)
-

What is the Racket translation of the protocol specification?  Reading the
online Racket docs, I don't see how to specify a different (and fresh per
instance) value for every field within Racket's `struct` form.  (#:auto and
#:auto-value are not what I want; I need different values, and fresh values,
for every created instance.)

I guess I could "cheat" by defining the "expected" constructor myself:

-
(define (make-racr-specification)
  (racr-specification 1 (make-eq-hashtable 50) racr-nil))
-

But this seems common enough that it would be built into `struct` in some way?
Or maybe `struct` isn't what I want at all?

Thanks ---

Eric.
(a Racket newbie)

-- 
---
Eric Eide   . University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.