Re: [racket-users] Twenty six low-risk ways to use Racket at work You can start right now

2016-09-30 Thread spdegabrielle
OK I've started with: 
https://github.com/racket/racket/wiki/Low-risk-ways-you-can-use-Racket-at-work

Please feel free to edit/delete/move/rearrange as you see fit.

S.

PS Davids thing sounds awesome!
PPS I'm sorry Ju. Please accept my apologies - I don't understand your 
response. Can you try again?

On Thursday, September 29, 2016 at 3:57:19 PM UTC+1, Matthias Felleisen wrote:
> Do you mean to write a Racket version for this? I think that would be 
> amazing! 
> 
> 
> 
> > On Sep 29, 2016, at 4:43 AM, Stephen De Gabrielle  
> > wrote:
> > 
> > Hi all,
> > 
> > I was listening to a podcast about F# That mentioned an article like this
> > As I've used a racket at work a number of times for small job, it occurs to 
> > me that this might be a nice thing to pop on the wiki. Please let me know 
> > if you have any objections. 
> > 
> > Kind regards,
> > 
> > Stephen
> > 
> > Ref 
> > https://fsharpforfunandprofit.com/posts/low-risk-ways-to-use-fsharp-at-work/
> > -- 
> > Kind regards,
> > Stephen
> > --
> > Bigger than Scheme, cooler than Clojure & more fun than CL.(n=1)
> > --
> > 
> > -- 
> > 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] Sending a file via HTML request.

2016-08-23 Thread spdegabrielle
Hi, 

JSON (require json-parsing) see 
https://docs.racket-lang.org/json-parsing/index.html 

I've cribbed the HTML below from 
http://www.w3schools.com/tags/att_input_accept.asp 


On the web server side this SO response seems to answer, 

http://stackoverflow.com/questions/20588641/in-racket-how-do-you-allow-file-upload-to-the-web-server

#lang web-server/insta
(require web-server/formlets)

 ; start: request -> doesn't return
(define (start request)
  (show-page request))

; show-page: request -> doesn't return
(define (show-page request)
  ; Response generator
  (define (response-generator embed/url)
(response/xexpr
 `(html 
   (head (title "File upload example"))
   (body (h1 "File upload example"))
   (form 
([action ,(embed/url upload-handler)]
 [method "POST"]
 [enctype "multipart/form-data"])
,@(formlet-display file-upload-formlet)
(input ([type "submit"] [value "Upload"]))

  (define (upload-handler request)
(define-values (fname fcontents)
  (formlet-process file-upload-formlet request))
(define save-name (string-append "!uploaded-" fname))
(current-directory WORKINGDIR)
(display-to-file fcontents save-name #:exists 'replace)
(response/xexpr
 `(html
   (head (title "File Uploaded"))
   (body (h2 "File uploaded")
 (p ,fname)
 (h2 "File size (bytes)")
 (p ,(number->string (file-size save-name)))

  (send/suspend/dispatch response-generator))


; file-upload-formlet: formlet (binding?)
(define file-upload-formlet
  (formlet
   (div ,{(file-upload) . => . binds})
   ; (formlet-process file-upload-formlet request)
   ; returns the file name and contents:
   (let
   ([fname (bytes->string/utf-8 (binding:file-filename binds))]
[fcontents (binding:file-content binds)])
 (values fname fcontents


(I've not tried this - I'm not sure it is correct)








  
  


Note: The accept attribute of the input tag is not 
supported in Internet Explorer 9 (and earlier versions), and Safari 5 (and 
earlier).
Note: Because of security issues, this example will not 
allow you to upload files.





HTH Stephen


On Tuesday, August 23, 2016 at 3:47:05 PM UTC+1, Normal Loone wrote:
> No, I don't have it in JSON yet. How do I load a file into JSON in racket?
> 
> It's only a text file, although I like to get it zipped first.

-- 
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] How do you use the 'make-brush' '#:transformation' vector[11] argument?

2016-08-17 Thread spdegabrielle
Thanks 

I just found the documentation for 'get-transformation' which details the 
matrix:

http://docs.racket-lang.org/draw/dc___.html#%28meth._%28%28%28lib._racket%2Fdraw..rkt%29._dc~3c~25~3e%29._get-transformation%29%29
 

...and submitted a pull-request to add the link to 'get-transformation' from 
'make-brush': https://github.com/racket/draw/pull/6

Thanks again, 

Stephen


On Wednesday, August 17, 2016 at 12:08:51 PM UTC+1, Jens Axel Søgaard wrote:
> Hi Stephen,
> 
> 
> There is a brief description on transformations in the documentation for the 
> method get-transformation of dc%.
> 
> 
> 
> Basically the vector part is the coefficients   xx xy yx yy x0 y0  (in that 
> order - I think - 
> maybe xy and yx are swapped) of an affine transformation:
> 
> 
> 
>      xnew = xx*x + xy*y + x0
> 
>      ynew = yx*x + yy*y + y0
> 
> The last five numbers sets origin, scale and rotation. These numbers are
> affected by set-origin, set-scale and set-rotation.
> 
> In MetaPict I decided to stick to the affine transformation and ignore the 
> second part:
> 
> 
> 
> (define (set-transformation dc t)
>   (send dc set-transformation 
>         (vector (trans->vector t)
>                 0  0 ; x and y origin
>                 1  1 ; x and y scale
>                 0))) ; rotation
> 
> 
> The code here defines transformations corresponding to the one used in 
> MetaPost:
> 
> 
> https://github.com/soegaard/metapict/blob/master/metapict/trans.rkt
> 
> 
> 
> /Jens Axel
> 
> 
> 
> 
> 2016-08-17 10:54 GMT+02:00 spdegabrielle :
> Hi,
> 
> 
> 
> How do you use the 'make-brush' '#:transformation' vector[11] argument?
> 
> 
> 
> What should the vector contain?
> 
> 
> 
> http://docs.racket-lang.org/draw/Drawing_Functions.html#%28def._%28%28lib._racket%2Fdraw..rkt%29._make-brush%29%29
> 
> 
> 
> Kind regards,
> 
> 
> 
> Stephen
> 
> 
> 
> --
> 
> 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...@googlegroups.com.
> 
> For more options, visit https://groups.google.com/d/optout.
> 
> 
> 
> 
> 
> -- 
> 
> -- 
> Jens Axel Søgaard

-- 
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] How do you use the 'make-brush' '#:transformation' vector[11] argument?

2016-08-17 Thread spdegabrielle
Hi, 

How do you use the 'make-brush' '#:transformation' vector[11] argument?

What should the vector contain? 

http://docs.racket-lang.org/draw/Drawing_Functions.html#%28def._%28%28lib._racket%2Fdraw..rkt%29._make-brush%29%29

Kind regards,

Stephen

-- 
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] Scribble-string->xexpr ?

2015-11-03 Thread spdegabrielle
Hi, 

is there a way to to generate xexprs for consumption of the web server 

I thought making a simple wiki with scribble as the syntax might be fun, but 
I'm tripping at this first hurdle  i.e. (scribblestring->xexpr a-string) ->xexpr

Any suggestions appreciated

Stephen


#lang racket
(require scribble/decode)
(require scribble/render)
;(require scribble/html-render)
;(require scribble/text-render)
(require scribble/markdown-render)

(define a
  "@title{Bottles --- @italic{Abridged}}
@(apply itemlist
  (for/list ([n (in-range 100 0 -1)])
@item{@(format \"~a\" n) bottles.}))")
a

(render (list (decode (decode-string a))) (list "/Users/spdegarielle/Desktop/") 
#:render-mixin render-mixin ) 

-- 
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.