Re: [racket-users] find-seconds daylight saving

2016-11-08 Thread Ryan Culpepper

On 11/08/2016 11:24 PM, George Neuner wrote:

[...]

- I need to turn the UTC datetimes on all the results back into local
times with the right time zone


Does the following do what you want?

  (require srfi/19)

  ;; date-at-tz : Date Integer -> Date
  ;; Returns date of equivalent instant in given timezone.
  (define (date-at-tz d tz)
(let ([t (date->time-utc d)])
  (time-utc->date t tz)))

  (define fmt "~Y-~m-~d ~H:~M:~S~z")
  (define s1 "2016-11-09 01:12:00Z")
  (define d1 (string->date s1 fmt))
  (define d2 (date-at-tz d1 (* -5 60 60)))

  (date->string d1 fmt)
  ;; => "2016-11-09 01:23:00Z"
  (date->string d2 fmt)
  ;; => "2016-11-08 20:23:00-0500"
  (equal? (date->time-utc d1) (date->time-utc d2))
  ;; => #t

Another option is to let PostgreSQL do it for you using AT TIME ZONE (or 
the timezone function):


  select ('2016-11-09 01:23:00Z'::timestamptz)
at time zone 'us/eastern';
  => 2016-11-08 20:23:00

But beware that PostgreSQL interprets numerical timezones backwards 
(sometimes?) (see 
https://www.postgresql.org/message-id/20151021034109.3017@wrigleys.postgresql.org). 
I've read that thread and the docs and I still can't make sense of it.


Ryan

--
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: Round-tripping binary data through the web server

2016-11-08 Thread George Neuner

Hi David,

On 11/8/2016 9:17 PM, David Storrs wrote:
Thanks, George, that's helpful. How is your data being transported, 
though? You're returning a response object instead of an xexpr, but I 
don't see where it's being encoded.


It's just a raw byte string, out of a database.  It gets uploaded to me 
originally as multipart form data.  Thanks to the webserver, I see it as 
just another argument.  Fortunately the size is suitably limited - I 
wouldn't know how to get hold of the input port to suck in something 
really enormous.


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] find-seconds daylight saving

2016-11-08 Thread George Neuner

Hi Jon,

On 11/8/2016 6:28 PM, Jon Zeppieri wrote:


George, these are not correct results. The UTC offset is correct,
but the time fields are not -- under the assumption that you're
trying to round-trip them unchanged. (But maybe that's not a
correct assumption.) At any rate, I think your original example
demonstrates a problem with seconds->date on Windows.


Sorry, that was confusing. What I meant to say was: the results are 
correct (given the treatment of the original date fields as UTC and 
the treatment of the resulting seconds as local), but based on your 
original post, I don't think they're the results you were after. But 
I'm not certain of that.


- Jon


What I'm trying to do is the following:

- I'm given 2 datetimes as iso8601 -MM-DD HH:MM strings, and a time 
zone offset

- create UTC datetimes from the strings and tz
- query a database returning records between the 2 UTC datetimes

OK that was pretty easy.  I believe I need to get [or look up somehow] a 
separate tz for each date string because the range may span both 
standard and daylight time, but at least I can get this far.


Now the hard part:

- I need to turn the UTC datetimes on all the results back into local 
times with the right time zone


This part is driving me nuts.  Nothing seems to work exactly right. 
(seconds->date ... #T) seems to get the numbers right, but not always 
the timezone, and in any case it is limited to the local timezone of the 
machine - useless if local *is* UTC, and since I can't specify an 
arbitrary timezone, I can't use it in a server side application.


What I have tried so far amounts to:  [reformatted a bit]

(let* [
   (tz  -4)

   (offset  (* 60 60 tz))
   (d   (make-time 'time-duration 0 offset))
   (date-in (sql-datetime->srfi-date ... ));; date comes in here

   (t1(date->time-utc date-in))
   (t2(add-duration t1 d))
   (date1-lcl (time-utc->date t2 offset))
   (date1-utc (time-utc->date t2 0 ))

   (t3(date->seconds date-in))
   (t4(+ t3 offset))
   (date2-lcl (seconds->date t4 #t))
   (date2-utc (seconds->date t4 #f))

   (date3-lcl (date* (date-second date-in)
 (date-minute date-in)
 (date-hour   date-in)
 (date-daydate-in)
 (date-month  date-in)
 (date-year   date-in)
 0
 0
 #f
 offset
 0
 "LCL" ))
   (date3-utc (date* (date-second date-in)
 (date-minute date-in)
 (date-hour   date-in)
 (date-daydate-in)
 (date-month  date-in)
 (date-year   date-in)
 0
 0
 #f
 0
 0
 "UTC"
 ))

  ]
  (printf "UTC input : ~s ~s~n" date-in (date->string date-in   "~1 
~2"))

  (printf "~n")
  (printf "srfi tz   : ~s ~s~n" date1-lcl (date->string date1-lcl 
"~1 ~2"))
  (printf "srfi 0: ~s ~s~n" date1-utc (date->string date1-utc 
"~1 ~2"))

  (printf "~n")
  (printf "s->d #t   : ~s ~s~n" date2-lcl (date->string date2-lcl 
"~1 ~2"))
  (printf "s->d #f   : ~s ~s~n" date2-utc (date->string date2-utc 
"~1 ~2"))

  (printf "~n")
  (printf "date* ofst: ~s ~s~n" date3-lcl (date->string date3-lcl 
"~1 ~2"))
  (printf "date* 0   : ~s ~s~n" date3-utc (date->string date3-utc 
"~1 ~2"))


  )


=>

UTC input : #(struct:date* 0 0 4 12 11 2016 6 316 #f 0 0 "") "2016-11-12 
04:00:00Z"


srfi tz   : #(struct:date* 0 0 20 11 11 2016 5 315 #f -14400 0 "")  
"2016-11-11 20:00:00-0400"
srfi 0: #(struct:date* 0 0 0 12 11 2016 6 316 #f 0 0 "")
"2016-11-12 00:00:00Z"


s->d #t   : #(struct:date* 0 0 0 12 11 2016 6 316 #t -14400 0 "Eastern 
Daylight Time") "2016-11-12 00:00:00-0400"
s->d #f   : #(struct:date* 0 0 5 12 11 2016 6 316 #f 0 0 
"UTC")"2016-11-12 05:00:00Z"


date* ofst: #(struct:date* 0 0 4 12 11 2016 0 0 #f -14400 0 "LCL") 
"2016-11-12 04:00:00-0400"
date* 0   : #(struct:date* 0 0 4 12 11 2016 0 0 #f 0 0 "UTC") 
"2016-11-12 04:00:00Z"




I've been thinking I should look into Gregor, but a brief skimming of 
its docs was daunting.


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 

Re: [racket-users] Selecting certain items from a list

2016-11-08 Thread Meino . Cramer
Hi Matthias,

thanks for your reply ! :)


I am learning a lot especially from examples like you gave me!
:)

Cheers
Meino





Matthias Felleisen  [16-11-09 04:04]:
> 
> > On Nov 8, 2016, at 9:36 PM, meino.cra...@gmx.de wrote:
> > 
> > Hi,
> > 
> > From a list of items I want to select certain items. The selecting
> > criterion is the index (nth item).
> > 
> > From this list and from articles on the internet I think that indexing
> > a list and processing a list by index is not a good idea -- at least
> > it seems not to be very "lisp-y" or "racket-y"...
> > 
> > Other options I found:
> > * Convert the list into a vektor, select the indices and convert back.
> > * Do index based list processing none the less.
> > * ...?
> > 
> > Unfortunately there is no other criterion to select the items.
> 
> Here is a way to use indexing into a list w/o incurring much of an overhead: 
> 
> #lang racket
> 
> (module+ test
>   (require rackunit))
> 
> ;; [forall X] [Listof X] N N -> [Listof X]
> 
> (module+ test
>   (check-equal? (pick-from-list-between '(a b c d) 1 2) '(b c)))
> 
> (define (pick-from-list-between lox lower upper)
>   (for/list ((x lox) (i (in-naturals)) #:when (<= lower i upper))
> x))
> 
> 
> — Matthias, not like the rest of the country watching election results roll 
> in 

-- 
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] Selecting certain items from a list

2016-11-08 Thread Matthias Felleisen

> On Nov 8, 2016, at 9:36 PM, meino.cra...@gmx.de wrote:
> 
> Hi,
> 
> From a list of items I want to select certain items. The selecting
> criterion is the index (nth item).
> 
> From this list and from articles on the internet I think that indexing
> a list and processing a list by index is not a good idea -- at least
> it seems not to be very "lisp-y" or "racket-y"...
> 
> Other options I found:
> * Convert the list into a vektor, select the indices and convert back.
> * Do index based list processing none the less.
> * ...?
> 
> Unfortunately there is no other criterion to select the items.

Here is a way to use indexing into a list w/o incurring much of an overhead: 

#lang racket

(module+ test
  (require rackunit))

;; [forall X] [Listof X] N N -> [Listof X]

(module+ test
  (check-equal? (pick-from-list-between '(a b c d) 1 2) '(b c)))

(define (pick-from-list-between lox lower upper)
  (for/list ((x lox) (i (in-naturals)) #:when (<= lower i upper))
x))


— Matthias, not like the rest of the country watching election results roll in 

-- 
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] Selecting certain items from a list

2016-11-08 Thread Meino . Cramer
Hi,

>From a list of items I want to select certain items. The selecting
criterion is the index (nth item).

>From this list and from articles on the internet I think that indexing
a list and processing a list by index is not a good idea -- at least
it seems not to be very "lisp-y" or "racket-y"...

Other options I found:
* Convert the list into a vektor, select the indices and convert back.
* Do index based list processing none the less.
* ...?

Unfortunately there is no other criterion to select the items.


What is the adiviced way to do what I want to accomplish?

Thanks a lot for any help!
Cheers
Meino









-- 
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: Round-tripping binary data through the web server

2016-11-08 Thread David Storrs
Thanks everyone.  This was exactly what I needed to get my brain in gear.
It's working now -- I really appreciate the help.

On Tue, Nov 8, 2016 at 8:48 PM, David Storrs  wrote:

>
>
> On Tue, Nov 8, 2016 at 6:03 PM, George Neuner 
> wrote:
>
>> Hi David,
>>
>> HTTP is printable characters only.  In general you need to do something
>> like base64 encode raw byte data to get it across in any kind JSON wrapping.
>>
>>
>> I'm not messing with XML, but I use the following for binary imagery:
>>
>> (send/back
>>  (if success
>>  ; succeeded
>>  (response/full 200 #"OK"
>> (current-seconds)
>> #"application/octet-stream"
>> '()
>> `(,result))
>>  ; failed
>>  (response/full 404 #"REQUESTED OBJECT NOT FOUND"
>> (current-seconds)
>> #"application/text"
>> '()
>> '())
>>  ))
>>
>> where "result" is the image bytestring I'm sending.  This appears to the
>> browser as if it is downloading a file, and is compatible with HTML img
>> tags, etc.
>>
>>
>> Maybe you don't need the XML wrapping?  Or do it in 2 steps - send meta
>> data as XML, and the raw bytes separately?
>>
>
> Thanks, George, that's helpful. How is your data being transported,
> though? You're returning a response object instead of an xexpr, but I don't
> see where it's being encoded.
>
>
>
>
>
>>
>> George
>>
>>
>>
>> On 11/8/2016 5:26 PM, David Storrs wrote:
>>
>> I'm still working with the protocol-buffers code in (planet
>> murphy/protobuf).  I want the web server to return a deserialized protocol
>> buffer struct, then have the client deserialize it.  I cannot make this
>> work, and the problem is clearly due to the data being mangled by
>> retrieving it from the HTTP port.  How can I send binary data in an HTTP
>> response and retrieve it on the other end without it being modified on the
>> way?
>>
>> This is how the original request is made:
>>   (define p
>> (post-impure-port
>>  (string->url "http://localhost:25678/file-chunk-info;)
>>  (serialize-pbuf proto-buff-struct)))
>>
>> Here's the function that generates the response:
>>
>> (define/contract (send-response-pbuf msg-func thk)
>>   (->* (procedure? (-> any)) () response?)
>>   (define msg-name (symbol->string (object-name msg-func)))
>>   (response/xexpr `(html (body (p ,(~a msg-name  " processed"
>>   #:mime-type (string->bytes/utf-8
>> "application/octet-stream")
>>   #:headers (list
>>  (header #"Transfer-Encoding"
>>  #"identity")
>>  (header #"Content-Encoding"
>>  #"identity")
>>  (header #"X-protocol-buffer-response"
>>  (serialize-pbuf (thk))
>> Here's what I've tried, none of which worked
>>
>> *) Basics
>> - Verifying that the data arrives on the server intact. It does.
>> - Verifying that (deserialize (serialize x)) works.  It does.
>> - Verifying that putting the data into a manually-constructed (response)
>> struct, then pulling it out and deserializing it works. It does.
>>
>> *) Headers on the response
>> - Setting Content-Type to application/octet-stream
>> - Setting Transfer-Encoding to identity
>> - Setting Content-Encoding to identity
>>
>> *) Retrieving the data client side through the post-impure-port
>> - Pull the data out with (hash-ref (heads-string->dict (port->string p))
>> 'X-my-custom-header)
>> - Parse the data manually using regexp-match against (port->bytes p)
>> - Retrieve the data with (port->bytes-lines p) and deserialize the
>> individual
>>
>> The error it's failing with is " does not match expected data type",
>> which means "you've given me a blob of bytes that cannot be parsed into the
>> structure that you want me to parse them into."
>>
>> It only fails on protocol-buffer types that have embedded protocol-buffer
>> messages, for what that's worth.
>>
>> This would be trivial if I could get the original response object before
>> it was turned into a port, but I don't see how to do that.
>>
>> I am absolutely at my wits end, and I know this has to be simple.  What
>> am I missing?
>>
>> Dave
>>
>>
>>
>

-- 
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] Round-tripping binary data through the web server

2016-11-08 Thread David Storrs
On Tue, Nov 8, 2016 at 6:03 PM, George Neuner > wrote:

> Hi David,
>
> HTTP is printable characters only.  In general you need to do something
> like base64 encode raw byte data to get it across in any kind JSON wrapping.
>
>
> I'm not messing with XML, but I use the following for binary imagery:
>
> (send/back
>  (if success
>  ; succeeded
>  (response/full 200 #"OK"
> (current-seconds)
> #"application/octet-stream"
> '()
> `(,result))
>  ; failed
>  (response/full 404 #"REQUESTED OBJECT NOT FOUND"
> (current-seconds)
> #"application/text"
> '()
> '())
>  ))
>
> where "result" is the image bytestring I'm sending.  This appears to the
> browser as if it is downloading a file, and is compatible with HTML img
> tags, etc.
>
>
> Maybe you don't need the XML wrapping?  Or do it in 2 steps - send meta
> data as XML, and the raw bytes separately?
>

Thanks, George, that's helpful. How is your data being transported, though?
You're returning a response object instead of an xexpr, but I don't see
where it's being encoded.





>
> George
>
>
>
> On 11/8/2016 5:26 PM, David Storrs wrote:
>
> I'm still working with the protocol-buffers code in (planet
> murphy/protobuf).  I want the web server to return a deserialized protocol
> buffer struct, then have the client deserialize it.  I cannot make this
> work, and the problem is clearly due to the data being mangled by
> retrieving it from the HTTP port.  How can I send binary data in an HTTP
> response and retrieve it on the other end without it being modified on the
> way?
>
> This is how the original request is made:
>   (define p
> (post-impure-port
>  (string->url "http://localhost:25678/file-chunk-info;)
>  (serialize-pbuf proto-buff-struct)))
>
> Here's the function that generates the response:
>
> (define/contract (send-response-pbuf msg-func thk)
>   (->* (procedure? (-> any)) () response?)
>   (define msg-name (symbol->string (object-name msg-func)))
>   (response/xexpr `(html (body (p ,(~a msg-name  " processed"
>   #:mime-type (string->bytes/utf-8
> "application/octet-stream")
>   #:headers (list
>  (header #"Transfer-Encoding"
>  #"identity")
>  (header #"Content-Encoding"
>  #"identity")
>  (header #"X-protocol-buffer-response"
>  (serialize-pbuf (thk))
> Here's what I've tried, none of which worked
>
> *) Basics
> - Verifying that the data arrives on the server intact. It does.
> - Verifying that (deserialize (serialize x)) works.  It does.
> - Verifying that putting the data into a manually-constructed (response)
> struct, then pulling it out and deserializing it works. It does.
>
> *) Headers on the response
> - Setting Content-Type to application/octet-stream
> - Setting Transfer-Encoding to identity
> - Setting Content-Encoding to identity
>
> *) Retrieving the data client side through the post-impure-port
> - Pull the data out with (hash-ref (heads-string->dict (port->string p))
> 'X-my-custom-header)
> - Parse the data manually using regexp-match against (port->bytes p)
> - Retrieve the data with (port->bytes-lines p) and deserialize the
> individual
>
> The error it's failing with is " does not match expected data type",
> which means "you've given me a blob of bytes that cannot be parsed into the
> structure that you want me to parse them into."
>
> It only fails on protocol-buffer types that have embedded protocol-buffer
> messages, for what that's worth.
>
> This would be trivial if I could get the original response object before
> it was turned into a port, but I don't see how to do that.
>
> I am absolutely at my wits end, and I know this has to be simple.  What am
> I missing?
>
> Dave
>
>
>

-- 
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: Round-tripping binary data through the web server

2016-11-08 Thread Jack Firth
HTTP headers are ASCII characters only (more accurately, ISO-8859-1 - slight 
differences from ASCII). So your protobuf message stored in the header may get 
bytes above the 127-character range of ASCII mangled. There's a few other 
issues here:

1. You're including the protobuf serialization in a header. Don't do this. 
Headers are for metadata, not data. The protobuf *is* your data, send that as 
the body.
2. The response you're using is HTML describing which message you processed, 
which you could/should do with a Content-Type header instead.

My recommendation: use your own custom Content-Type subtype of octet-stream and 
use a parameter to state the name of the message type you decoded, like 
"application/vnd.some-fancy-name-specific-to-your-project+octet-stream; 
message-type=foo-message". Then send the serialized bytes as your response 
bytes, without any sort of wrapping in HTML at all.

Also, remember to include a Content-Length header!

-- 
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] find-seconds daylight saving

2016-11-08 Thread Jon Zeppieri
On Tue, Nov 8, 2016 at 6:26 PM, Jon Zeppieri  wrote:

>
>
> On Tue, Nov 8, 2016 at 6:18 PM, George Neuner 
> wrote:
>
>>
>> On 11/8/2016 2:29 PM, Robby Findler wrote:
>>
>>> find-seconds returns a number, not a date? Maybe seconds->date is the
>>> culprit here?
>>>
>>> Robby
>>>
>>
>> Spoke too soon.  1 combination gets it right:  (seconds->date
>> (find-seconds ... #F) #T).
>>
>> Note that (for me)  Nov 6 should be DST [until 2AM], but Nov 7 should be
>> EST.
>>
>>   --
>> (require racket/date)
>>
>> (seconds->date (find-seconds 0 0 0 6 11 2016 #f) #f)
>> (seconds->date (find-seconds 0 0 0 6 11 2016 #f) #t)
>> (seconds->date (find-seconds 0 0 0 6 11 2016 #t) #f)
>> (seconds->date (find-seconds 0 0 0 6 11 2016 #t) #t)
>> (displayln "")
>> (seconds->date (find-seconds 0 0 0 7 11 2016 #f) #f)
>> (seconds->date (find-seconds 0 0 0 7 11 2016 #f) #t)
>> (seconds->date (find-seconds 0 0 0 7 11 2016 #t) #f)
>> (seconds->date (find-seconds 0 0 0 7 11 2016 #t) #t)
>>
>> =>
>> date* 0 0 0 6 11 2016 0 310 #f 0 0 "UTC")
>> (date* 0 0 20 5 11 2016 6 309 #t -14400 0 "Eastern Daylight Time")
>> (date* 0 0 4 6 11 2016 0 310 #f 0 0 "UTC")
>> (date* 0 0 0 6 11 2016 0 310 #t -14400 0 "Eastern Daylight Time")
>>
>> (date* 0 0 0 7 11 2016 1 311 #f 0 0 "UTC")
>> (date* 0 0 19 6 11 2016 0 310 #f -18000 0 "Eastern Standard Time")
>> (date* 0 0 5 7 11 2016 1 311 #f 0 0 "UTC")
>> (date* 0 0 0 7 11 2016 1 311 #t -14400 0 "Eastern Daylight Time")
>>   --
>>
>>
>
> George, these are not correct results. The UTC offset is correct, but the
> time fields are not -- under the assumption that you're trying to
> round-trip them unchanged. (But maybe that's not a correct assumption.) At
> any rate, I think your original example demonstrates a problem with
> seconds->date on Windows.
>
>
>


Sorry, that was confusing. What I meant to say was: the results are correct
(given the treatment of the original date fields as UTC and the treatment
of the resulting seconds as local), but based on your original post, I
don't think they're the results you were after. But I'm not certain of that.

- Jon

-- 
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] find-seconds daylight saving

2016-11-08 Thread Jon Zeppieri
On Tue, Nov 8, 2016 at 6:18 PM, George Neuner  wrote:

>
> On 11/8/2016 2:29 PM, Robby Findler wrote:
>
>> find-seconds returns a number, not a date? Maybe seconds->date is the
>> culprit here?
>>
>> Robby
>>
>
> Spoke too soon.  1 combination gets it right:  (seconds->date
> (find-seconds ... #F) #T).
>
> Note that (for me)  Nov 6 should be DST [until 2AM], but Nov 7 should be
> EST.
>
>   --
> (require racket/date)
>
> (seconds->date (find-seconds 0 0 0 6 11 2016 #f) #f)
> (seconds->date (find-seconds 0 0 0 6 11 2016 #f) #t)
> (seconds->date (find-seconds 0 0 0 6 11 2016 #t) #f)
> (seconds->date (find-seconds 0 0 0 6 11 2016 #t) #t)
> (displayln "")
> (seconds->date (find-seconds 0 0 0 7 11 2016 #f) #f)
> (seconds->date (find-seconds 0 0 0 7 11 2016 #f) #t)
> (seconds->date (find-seconds 0 0 0 7 11 2016 #t) #f)
> (seconds->date (find-seconds 0 0 0 7 11 2016 #t) #t)
>
> =>
> date* 0 0 0 6 11 2016 0 310 #f 0 0 "UTC")
> (date* 0 0 20 5 11 2016 6 309 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 4 6 11 2016 0 310 #f 0 0 "UTC")
> (date* 0 0 0 6 11 2016 0 310 #t -14400 0 "Eastern Daylight Time")
>
> (date* 0 0 0 7 11 2016 1 311 #f 0 0 "UTC")
> (date* 0 0 19 6 11 2016 0 310 #f -18000 0 "Eastern Standard Time")
> (date* 0 0 5 7 11 2016 1 311 #f 0 0 "UTC")
> (date* 0 0 0 7 11 2016 1 311 #t -14400 0 "Eastern Daylight Time")
>   --
>
>

George, these are not correct results. The UTC offset is correct, but the
time fields are not -- under the assumption that you're trying to
round-trip them unchanged. (But maybe that's not a correct assumption.) At
any rate, I think your original example demonstrates a problem with
seconds->date on Windows.

-- 
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] find-seconds daylight saving

2016-11-08 Thread George Neuner


On 11/8/2016 2:29 PM, Robby Findler wrote:

find-seconds returns a number, not a date? Maybe seconds->date is the
culprit here?

Robby


Spoke too soon.  1 combination gets it right:  (seconds->date 
(find-seconds ... #F) #T).


Note that (for me)  Nov 6 should be DST [until 2AM], but Nov 7 should be 
EST.


  --
(require racket/date)

(seconds->date (find-seconds 0 0 0 6 11 2016 #f) #f)
(seconds->date (find-seconds 0 0 0 6 11 2016 #f) #t)
(seconds->date (find-seconds 0 0 0 6 11 2016 #t) #f)
(seconds->date (find-seconds 0 0 0 6 11 2016 #t) #t)
(displayln "")
(seconds->date (find-seconds 0 0 0 7 11 2016 #f) #f)
(seconds->date (find-seconds 0 0 0 7 11 2016 #f) #t)
(seconds->date (find-seconds 0 0 0 7 11 2016 #t) #f)
(seconds->date (find-seconds 0 0 0 7 11 2016 #t) #t)

=>
date* 0 0 0 6 11 2016 0 310 #f 0 0 "UTC")
(date* 0 0 20 5 11 2016 6 309 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 4 6 11 2016 0 310 #f 0 0 "UTC")
(date* 0 0 0 6 11 2016 0 310 #t -14400 0 "Eastern Daylight Time")

(date* 0 0 0 7 11 2016 1 311 #f 0 0 "UTC")
(date* 0 0 19 6 11 2016 0 310 #f -18000 0 "Eastern Standard Time")
(date* 0 0 5 7 11 2016 1 311 #f 0 0 "UTC")
(date* 0 0 0 7 11 2016 1 311 #t -14400 0 "Eastern Daylight Time")
  --

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] Round-tripping binary data through the web server

2016-11-08 Thread George Neuner

Hi David,

HTTP is printable characters only.  In general you need to do something 
like base64 encode raw byte data to get it across in any kind JSON wrapping.



I'm not messing with XML, but I use the following for binary imagery:

(send/back
 (if success
 ; succeeded
 (response/full 200 #"OK"
(current-seconds)
#"application/octet-stream"
'()
`(,result))
 ; failed
 (response/full 404 #"REQUESTED OBJECT NOT FOUND"
(current-seconds)
#"application/text"
'()
'())
 ))

where "result" is the image bytestring I'm sending.  This appears to the 
browser as if it is downloading a file, and is compatible with HTML img 
tags, etc.



Maybe you don't need the XML wrapping?  Or do it in 2 steps - send meta 
data as XML, and the raw bytes separately?


George


On 11/8/2016 5:26 PM, David Storrs wrote:
I'm still working with the protocol-buffers code in (planet 
murphy/protobuf).  I want the web server to return a deserialized 
protocol buffer struct, then have the client deserialize it.  I cannot 
make this work, and the problem is clearly due to the data being 
mangled by retrieving it from the HTTP port.  How can I send binary 
data in an HTTP response and retrieve it on the other end without it 
being modified on the way?


This is how the original request is made:
  (define p
(post-impure-port
 (string->url "http://localhost:25678/file-chunk-info;)
 (serialize-pbuf proto-buff-struct)))

Here's the function that generates the response:

(define/contract (send-response-pbuf msg-func thk)
  (->* (procedure? (-> any)) () response?)
  (define msg-name (symbol->string (object-name msg-func)))
  (response/xexpr `(html (body (p ,(~a msg-name  " processed"
  #:mime-type (string->bytes/utf-8 
"application/octet-stream")

  #:headers (list
 (header #"Transfer-Encoding"
 #"identity")
 (header #"Content-Encoding"
 #"identity")
 (header #"X-protocol-buffer-response"
 (serialize-pbuf (thk))
Here's what I've tried, none of which worked

*) Basics
- Verifying that the data arrives on the server intact. It does.
- Verifying that (deserialize (serialize x)) works. It does.
- Verifying that putting the data into a manually-constructed 
(response) struct, then pulling it out and deserializing it works. It 
does.


*) Headers on the response
- Setting Content-Type to application/octet-stream
- Setting Transfer-Encoding to identity
- Setting Content-Encoding to identity

*) Retrieving the data client side through the post-impure-port
- Pull the data out with (hash-ref (heads-string->dict (port->string 
p)) 'X-my-custom-header)

- Parse the data manually using regexp-match against (port->bytes p)
- Retrieve the data with (port->bytes-lines p) and deserialize the 
individual


The error it's failing with is " does not match expected data 
type", which means "you've given me a blob of bytes that cannot be 
parsed into the structure that you want me to parse them into."


It only fails on protocol-buffer types that have embedded 
protocol-buffer messages, for what that's worth.


This would be trivial if I could get the original response object 
before it was turned into a port, but I don't see how to do that.


I am absolutely at my wits end, and I know this has to be simple.  
What am I missing?


Dave


--
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] POST requests never bound?

2016-11-08 Thread Ben Greenman
Here!
https://github.com/racket/web-server/blob/master/web-server-doc/web-server/scribblings/dispatch.scrbl

(If you install `raco-find-collection`, then running `raco fc web-server`
should bring you close to the right place.)

On Tue, Nov 8, 2016 at 4:38 PM, Luke  wrote:

> I'd be happy to do do it.
>
> I've spent a little time digging around for the appropriate place, but
> nothing seems obvious. Would you (or someone else?) mind giving me a
> pointer to help me see where such an update most likely belongs?
>
> --
> 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] find-seconds daylight saving

2016-11-08 Thread George Neuner


On 11/8/2016 2:29 PM, Robby Findler wrote:

find-seconds returns a number, not a date? Maybe seconds->date is the
culprit here?

Robby


Possibly.  But both functions take an optional local-time? parameter.  
The various combinations don't seem to affect the time zone wrt daylight 
saving.


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] find-seconds daylight saving

2016-11-08 Thread Jon Zeppieri
I think Robby is right and the problem is here:
https://github.com/racket/racket/blob/4ce947da74d09abc9cda10a14e7407cda9386a44/racket/src/racket/src/fun.c#L9876

Well, that and the next line. There's only a `return 1;` for the case where
the given day-of-month is less than the DST change's day-of-month, but no
`return 0;` for the case where it's greater. All of the other comparisons
use the `dtxCOMP` macro, which handles both cases:

```
# define dtxCOMP(f) if (a->f < b->f) return 1; if (a->f > b->f) return 0;
```

Does that sound right? I don't have a Windows system at the moment, and I
can't reproduce on OS X.


- Jon




On Tue, Nov 8, 2016 at 2:29 PM, Robby Findler 
wrote:

> find-seconds returns a number, not a date? Maybe seconds->date is the
> culprit here?
>
> Robby
>
> On Tue, Nov 8, 2016 at 12:32 PM, George Neuner 
> wrote:
> >
> > Racket 6.6 on Windows 7.
> >
> > find-seconds is getting the time zone wrong when local-time? is #t.
> > Somehow it is in daylight saving all through November.
> >
> > When local-time? is #f (UTC) the time zone and hour offset are
> > correct. [At least for "fall back", didn't check "spring ahead"]
> >
> >
> >
> > (for* [(m '(11 12))
> >(d (in-range 1 31))
> >#:unless [and (= m 12)(> d 5)]
> >   ]
> >   (println (seconds->date (find-seconds 0 0 0 d m 2016 #t
> >
> > =>
> > (date* 0 0 0 1 11 2016 2 305 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 2 11 2016 3 306 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 3 11 2016 4 307 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 4 11 2016 5 308 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 5 11 2016 6 309 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 6 11 2016 0 310 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 7 11 2016 1 311 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 8 11 2016 2 312 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 9 11 2016 3 313 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 10 11 2016 4 314 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 11 11 2016 5 315 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 12 11 2016 6 316 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 13 11 2016 0 317 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 14 11 2016 1 318 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 15 11 2016 2 319 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 16 11 2016 3 320 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 17 11 2016 4 321 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 18 11 2016 5 322 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 19 11 2016 6 323 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 20 11 2016 0 324 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 21 11 2016 1 325 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 22 11 2016 2 326 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 23 11 2016 3 327 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 24 11 2016 4 328 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 25 11 2016 5 329 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 26 11 2016 6 330 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 27 11 2016 0 331 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 28 11 2016 1 332 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 29 11 2016 2 333 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 30 11 2016 3 334 #t -14400 0 "Eastern Daylight Time")
> > (date* 0 0 0 1 12 2016 4 335 #f -18000 0 "Eastern Standard Time")
> > (date* 0 0 0 2 12 2016 5 336 #f -18000 0 "Eastern Standard Time")
> > (date* 0 0 0 3 12 2016 6 337 #f -18000 0 "Eastern Standard Time")
> > (date* 0 0 0 4 12 2016 0 338 #f -18000 0 "Eastern Standard Time")
> > (date* 0 0 0 5 12 2016 1 339 #f -18000 0 "Eastern Standard Time")
> >
> >
> > 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.
>
> --
> 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.


[racket-users] Round-tripping binary data through the web server

2016-11-08 Thread David Storrs
I'm still working with the protocol-buffers code in (planet
murphy/protobuf).  I want the web server to return a deserialized protocol
buffer struct, then have the client deserialize it.  I cannot make this
work, and the problem is clearly due to the data being mangled by
retrieving it from the HTTP port.  How can I send binary data in an HTTP
response and retrieve it on the other end without it being modified on the
way?

This is how the original request is made:
  (define p
(post-impure-port
 (string->url "http://localhost:25678/file-chunk-info;)
 (serialize-pbuf proto-buff-struct)))

Here's the function that generates the response:

(define/contract (send-response-pbuf msg-func thk)
  (->* (procedure? (-> any)) () response?)
  (define msg-name (symbol->string (object-name msg-func)))
  (response/xexpr `(html (body (p ,(~a msg-name  " processed"
  #:mime-type (string->bytes/utf-8
"application/octet-stream")
  #:headers (list
 (header #"Transfer-Encoding"
 #"identity")
 (header #"Content-Encoding"
 #"identity")
 (header #"X-protocol-buffer-response"
 (serialize-pbuf (thk))
Here's what I've tried, none of which worked

*) Basics
- Verifying that the data arrives on the server intact. It does.
- Verifying that (deserialize (serialize x)) works.  It does.
- Verifying that putting the data into a manually-constructed (response)
struct, then pulling it out and deserializing it works. It does.

*) Headers on the response
- Setting Content-Type to application/octet-stream
- Setting Transfer-Encoding to identity
- Setting Content-Encoding to identity

*) Retrieving the data client side through the post-impure-port
- Pull the data out with (hash-ref (heads-string->dict (port->string p))
'X-my-custom-header)
- Parse the data manually using regexp-match against (port->bytes p)
- Retrieve the data with (port->bytes-lines p) and deserialize the
individual

The error it's failing with is " does not match expected data type",
which means "you've given me a blob of bytes that cannot be parsed into the
structure that you want me to parse them into."

It only fails on protocol-buffer types that have embedded protocol-buffer
messages, for what that's worth.

This would be trivial if I could get the original response object before it
was turned into a port, but I don't see how to do that.

I am absolutely at my wits end, and I know this has to be simple.  What am
I missing?

Dave

-- 
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] All members of a list between two items

2016-11-08 Thread David Storrs
Right, I forgot about dropf and friends.  I was looking at drop, which
requires me to know the index.  Yes, that works fine.  Thanks.

On Tue, Nov 8, 2016 at 4:56 PM, Vincent St-Amour <
stamo...@eecs.northwestern.edu> wrote:

> There's no built-in function that does exactly that.
>
> It's pretty straightforward to implement using a combination of `dropf`
> and `dropf-right`, though.
>
> Vincent
>
>
>
> On Tue, 08 Nov 2016 15:50:56 -0600,
> David Storrs wrote:
> >
> > Given a list of arbitrary data, I'd like to be able to say "look through
> > the list for X and Y; give me everything between them." Ideally there
> > would be a way to specify inclusive/exclusive on that.
> >
> > Example: (between-items '(a b c d e f) 'b 'e) => '(b c d e)
> >
> > Ideally it would also have a simple method for specifying which, if
> > either, of the predicate-triggering items should be included in the
> > return value. That way you could do:
> >
> > Example: (between-items '(a b c d e f) 'b 'e #:start #f) => '(c d e)
> > Example: (between-items '(a b c d e f) 'b 'e #:end #f) => '(b c d)
> > Example: (between-items '(a b c d e f) 'b 'e #:start #f #:end #f) => '(c
> > d)
> >
> > I could write this manually, but I wonder if there is a simple Racket
> > way?
> >
> > --
> > 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] All members of a list between two items

2016-11-08 Thread Vincent St-Amour
There's no built-in function that does exactly that.

It's pretty straightforward to implement using a combination of `dropf`
and `dropf-right`, though.

Vincent



On Tue, 08 Nov 2016 15:50:56 -0600,
David Storrs wrote:
> 
> Given a list of arbitrary data, I'd like to be able to say "look through
> the list for X and Y; give me everything between them." Ideally there
> would be a way to specify inclusive/exclusive on that.
> 
> Example: (between-items '(a b c d e f) 'b 'e) => '(b c d e)
> 
> Ideally it would also have a simple method for specifying which, if
> either, of the predicate-triggering items should be included in the
> return value. That way you could do: 
> 
> Example: (between-items '(a b c d e f) 'b 'e #:start #f) => '(c d e)
> Example: (between-items '(a b c d e f) 'b 'e #:end #f) => '(b c d)
> Example: (between-items '(a b c d e f) 'b 'e #:start #f #:end #f) => '(c
> d)
> 
> I could write this manually, but I wonder if there is a simple Racket
> way?
> 
> -- 
> 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.


[racket-users] All members of a list between two items

2016-11-08 Thread David Storrs
Given a list of arbitrary data, I'd like to be able to say "look through
the list for X and Y; give me everything between them."  Ideally there
would be a way to specify inclusive/exclusive on that.

Example:  (between-items '(a b c d e f) 'b 'e) => '(b c d e)

Ideally it would also have a simple method for specifying which, if either,
of the predicate-triggering items should be included in the return value.
That way you could do:

Example:  (between-items '(a b c d e f) 'b 'e #:start #f) => '(c d e)
Example:  (between-items '(a b c d e f) 'b 'e #:end #f) => '(b c d)
Example:  (between-items '(a b c d e f) 'b 'e #:start #f #:end #f) => '(c d)

I could write this manually, but I wonder if there is a simple Racket way?

-- 
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] POST requests never bound?

2016-11-08 Thread Luke
I'd be happy to do do it.

I've spent a little time digging around for the appropriate place, but nothing 
seems obvious. Would you (or someone else?) mind giving me a pointer to help me 
see where such an update most likely belongs?

-- 
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] find-seconds daylight saving

2016-11-08 Thread Robby Findler
find-seconds returns a number, not a date? Maybe seconds->date is the
culprit here?

Robby

On Tue, Nov 8, 2016 at 12:32 PM, George Neuner  wrote:
>
> Racket 6.6 on Windows 7.
>
> find-seconds is getting the time zone wrong when local-time? is #t.
> Somehow it is in daylight saving all through November.
>
> When local-time? is #f (UTC) the time zone and hour offset are
> correct. [At least for "fall back", didn't check "spring ahead"]
>
>
>
> (for* [(m '(11 12))
>(d (in-range 1 31))
>#:unless [and (= m 12)(> d 5)]
>   ]
>   (println (seconds->date (find-seconds 0 0 0 d m 2016 #t
>
> =>
> (date* 0 0 0 1 11 2016 2 305 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 2 11 2016 3 306 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 3 11 2016 4 307 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 4 11 2016 5 308 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 5 11 2016 6 309 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 6 11 2016 0 310 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 7 11 2016 1 311 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 8 11 2016 2 312 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 9 11 2016 3 313 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 10 11 2016 4 314 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 11 11 2016 5 315 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 12 11 2016 6 316 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 13 11 2016 0 317 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 14 11 2016 1 318 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 15 11 2016 2 319 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 16 11 2016 3 320 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 17 11 2016 4 321 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 18 11 2016 5 322 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 19 11 2016 6 323 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 20 11 2016 0 324 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 21 11 2016 1 325 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 22 11 2016 2 326 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 23 11 2016 3 327 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 24 11 2016 4 328 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 25 11 2016 5 329 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 26 11 2016 6 330 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 27 11 2016 0 331 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 28 11 2016 1 332 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 29 11 2016 2 333 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 30 11 2016 3 334 #t -14400 0 "Eastern Daylight Time")
> (date* 0 0 0 1 12 2016 4 335 #f -18000 0 "Eastern Standard Time")
> (date* 0 0 0 2 12 2016 5 336 #f -18000 0 "Eastern Standard Time")
> (date* 0 0 0 3 12 2016 6 337 #f -18000 0 "Eastern Standard Time")
> (date* 0 0 0 4 12 2016 0 338 #f -18000 0 "Eastern Standard Time")
> (date* 0 0 0 5 12 2016 1 339 #f -18000 0 "Eastern Standard Time")
>
>
> 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.

-- 
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] Code in The Seasoned Schemer not accessible from REPL in Geiser or Dr. Racket

2016-11-08 Thread Matthias Felleisen

The proper way to reproduce the code is to enter the abbreviations for the 
TSS-specific functions and to ‘copy’ the code unaltered: 

#lang racket

(define atom? symbol?)
(define t #true)
(define-syntax-rule (letcc k e) (call/cc (lambda (k) e)))

(define rember1*
  (lambda (a l)
(letrec
  ((R (lambda (l oh)
 (cond 
   ((null? l)
(oh (quote no)))
   ((atom? (car l))
(if (eq? (car l) a)
(cdr l)
(cons (car l)
  (R (cdr l) oh
   (t
 (let ((new-car
 (letcc oh
   (R (car l)
 oh
   (if (atom? new-car)
   (cons (car l)
 (R (cdr l) oh))
   (cons new-car
 (cdr l)
  (let ((new-l (letcc oh (R l oh
(if (atom? new-l)
l
new-l)

The text of function definition is from the source text of the book, and it 
works as expected. 

Enjoy — Matthias




> On Nov 8, 2016, at 1:48 PM, Ian Thomas  wrote:
> 
> Hello list,
> 
> I've been working through The Seasoned Schemer and have come across code that 
> I can't access in the Racket REPL: specifically, the version of rember1* 
> shown on p. 139 of the 17th chapter.
> 
> I'm not sure why there is a complaint about the 'oh' variable being unbound 
> in the last let form. 
> 
> Any suggestions/explanations would be most welcome. 
> 
> 
> Geiser error message.
> racket@> ,enter 
> "/Users/ian/src/Scheme/books/the_seasoned_schemer/017_we_change_therefore_we_are.rkt"
> 017_we_change_therefore_we_are.rkt:226:28: oh: unbound identifier in module
>  in: oh
>  context...:
>   /Applications/Racket v6.6/collects/racket/private/more-scheme.rkt:261:28
>   standard-module-name-resolver
>   /Users/ian/.emacs.d/geiser/scheme/racket/geiser/user.rkt:54:0: enter!
>   /Applications/Racket v6.6/collects/racket/private/misc.rkt:88:7
> 
> Dr. Racket message.
> oh: unbound identifier in module in: oh
> 
> 
> Below is the code.
> ;;rember1*
>  
> (define rember1*
>  (lambda (l a)
>(letrec ([R (lambda (l oh)
>  (cond
>   [(null? l)
>(oh (quote no))]
>   [(atom? (car l))
>(if (eq? (car l)
> a)
>(cdr l)
>(cons (car l)
>  (R (cdr l)
> oh)))]
>   [else
>(let ([new-car (call/cc oh
>(R (car l)
>   oh))])
>  (if (atom? new-car)
>  (cons (car l)
>(R (cdr l)
>   oh))
>  (cons new-car
>(cdr l]))])
>  (let ([new-l (call/cc oh
>(R l
>   oh))])
>(if (atom? new-l)
>l
>new-l)
> 
> -- 
> 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] Code in The Seasoned Schemer not accessible from REPL in Geiser or Dr. Racket

2016-11-08 Thread Vincent St-Amour
Ian,

`oh` is indeed unbound inside the call to `call/cc`.

`oh` is only bound within the body of the `lambda` that is on the
right-hand side of the `letrec`; it is not bound in the body of the
`letrec`, which is where the call to `call/cc` is.

I don't have my copy of TSS handy. Did you make a mistake while
transcribing the program?

Vincent




On Tue, 08 Nov 2016 12:48:14 -0600,
Ian Thomas wrote:
> 
> Hello list,
> 
> I've been working through The Seasoned Schemer and have come across code that 
> I can't access in the Racket REPL: specifically, the version of rember1* 
> shown on p. 139 of the 17th chapter.
> 
> I'm not sure why there is a complaint about the 'oh' variable being unbound 
> in the last let form. 
> 
> Any suggestions/explanations would be most welcome. 
> 
> 
> Geiser error message.
> racket@> ,enter 
> "/Users/ian/src/Scheme/books/the_seasoned_schemer/017_we_change_therefore_we_are.rkt"
> 017_we_change_therefore_we_are.rkt:226:28: oh: unbound identifier in module
>   in: oh
>   context...:
>/Applications/Racket v6.6/collects/racket/private/more-scheme.rkt:261:28
>standard-module-name-resolver
>/Users/ian/.emacs.d/geiser/scheme/racket/geiser/user.rkt:54:0: enter!
>/Applications/Racket v6.6/collects/racket/private/misc.rkt:88:7
> 
> Dr. Racket message.
> oh: unbound identifier in module in: oh
> 
> 
> Below is the code.
> ;;rember1*
>  
> (define rember1*
>   (lambda (l a)
> (letrec ([R (lambda (l oh)
>   (cond
>[(null? l)
> (oh (quote no))]
>[(atom? (car l))
> (if (eq? (car l)
>  a)
> (cdr l)
> (cons (car l)
>   (R (cdr l)
>  oh)))]
>[else
> (let ([new-car (call/cc oh
> (R (car l)
>oh))])
>   (if (atom? new-car)
>   (cons (car l)
> (R (cdr l)
>oh))
>   (cons new-car
> (cdr l]))])
>   (let ([new-l (call/cc oh
> (R l
>oh))])
> (if (atom? new-l)
> l
> new-l)
> 
> -- 
> 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] POST requests never bound?

2016-11-08 Thread Matthew Butterick

On Nov 7, 2016, at 11:25 PM, Luke  wrote:
> Answer here for any other scheme illiterates that stumble over this.
>   [("sign-in") #:method "post" sign-in-post]

I encourage you to post an example to the docs for `dispatch-rules`. There, 
your wisdom will have the greatest likely audience. Here, it is likely to melt 
into the churning froth.

-- 
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] Code in The Seasoned Schemer not accessible from REPL in Geiser or Dr. Racket

2016-11-08 Thread Ian Thomas
Hello list,

I've been working through The Seasoned Schemer and have come across code that I 
can't access in the Racket REPL: specifically, the version of rember1* shown on 
p. 139 of the 17th chapter.

I'm not sure why there is a complaint about the 'oh' variable being unbound in 
the last let form. 

Any suggestions/explanations would be most welcome. 


Geiser error message.
racket@> ,enter 
"/Users/ian/src/Scheme/books/the_seasoned_schemer/017_we_change_therefore_we_are.rkt"
017_we_change_therefore_we_are.rkt:226:28: oh: unbound identifier in module
  in: oh
  context...:
   /Applications/Racket v6.6/collects/racket/private/more-scheme.rkt:261:28
   standard-module-name-resolver
   /Users/ian/.emacs.d/geiser/scheme/racket/geiser/user.rkt:54:0: enter!
   /Applications/Racket v6.6/collects/racket/private/misc.rkt:88:7

Dr. Racket message.
oh: unbound identifier in module in: oh


Below is the code.
;;rember1*  
   
(define rember1*
  (lambda (l a)
(letrec ([R (lambda (l oh)
  (cond
   [(null? l)
(oh (quote no))]
   [(atom? (car l))
(if (eq? (car l)
 a)
(cdr l)
(cons (car l)
  (R (cdr l)
 oh)))]
   [else
(let ([new-car (call/cc oh
(R (car l)
   oh))])
  (if (atom? new-car)
  (cons (car l)
(R (cdr l)
   oh))
  (cons new-car
(cdr l]))])
  (let ([new-l (call/cc oh
(R l
   oh))])
(if (atom? new-l)
l
new-l)

-- 
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] find-seconds daylight saving

2016-11-08 Thread George Neuner

Racket 6.6 on Windows 7.

find-seconds is getting the time zone wrong when local-time? is #t.
Somehow it is in daylight saving all through November.  

When local-time? is #f (UTC) the time zone and hour offset are
correct. [At least for "fall back", didn't check "spring ahead"]



(for* [(m '(11 12))
   (d (in-range 1 31))
   #:unless [and (= m 12)(> d 5)]
  ]
  (println (seconds->date (find-seconds 0 0 0 d m 2016 #t

=>
(date* 0 0 0 1 11 2016 2 305 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 2 11 2016 3 306 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 3 11 2016 4 307 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 4 11 2016 5 308 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 5 11 2016 6 309 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 6 11 2016 0 310 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 7 11 2016 1 311 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 8 11 2016 2 312 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 9 11 2016 3 313 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 10 11 2016 4 314 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 11 11 2016 5 315 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 12 11 2016 6 316 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 13 11 2016 0 317 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 14 11 2016 1 318 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 15 11 2016 2 319 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 16 11 2016 3 320 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 17 11 2016 4 321 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 18 11 2016 5 322 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 19 11 2016 6 323 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 20 11 2016 0 324 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 21 11 2016 1 325 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 22 11 2016 2 326 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 23 11 2016 3 327 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 24 11 2016 4 328 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 25 11 2016 5 329 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 26 11 2016 6 330 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 27 11 2016 0 331 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 28 11 2016 1 332 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 29 11 2016 2 333 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 30 11 2016 3 334 #t -14400 0 "Eastern Daylight Time")
(date* 0 0 0 1 12 2016 4 335 #f -18000 0 "Eastern Standard Time")
(date* 0 0 0 2 12 2016 5 336 #f -18000 0 "Eastern Standard Time")
(date* 0 0 0 3 12 2016 6 337 #f -18000 0 "Eastern Standard Time")
(date* 0 0 0 4 12 2016 0 338 #f -18000 0 "Eastern Standard Time")
(date* 0 0 0 5 12 2016 1 339 #f -18000 0 "Eastern Standard Time")


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.