Fork me on GitHub
#beginners
<
2017-02-02
>
zcassini00:02:33

I need to check if a valid date is given to me in a GET request. I know I can use the Validateur library, but is this something that Spec might handle now?

seancorfield00:02:18

Not directly, but you can write a conforming spec that would attempt to parse the date (it comes in as a string) and produce either an #inst (`java.util.Date`) or :clojure.spec/invalid.

seancorfield00:02:52

So you’ll still need to write some date parsing code (based on either clj-time or date-clj probably).

zcassini00:02:43

yeah at the moment, i do a lil regex to make sure it comes in the right format, but I should check to make sure its a real date. i haven't explored spec yet and wasn't sure if it would be somethjing I should use here.

zcassini00:02:27

so far I've liked the clj-time lib

zcassini00:02:34

thanks for sharing that

zcassini01:02:29

I wasn't having much luck with protorepl and cljs/figwheel. But I enjoyed using it in conjuction with the proton plugin for Atom. Made atom feel like spacemacs.

roelof06:02:35

Someone who have worked with ez-web. as a example they said I could do this

(= (paginate (range 101) 10 5)

roelof06:02:00

but I cannot find out what the numbers 101 , 10 and 5 means exactly

eslachance07:02:38

especially the one that starts a line 15/16 seems clear enough to me at least

roelof08:02:09

@eslachance so

(paginate (range 15) 1 7)  
gives
[6 5 4 3 2 1] 

roelof08:02:54

where as

(paginate (range 15) 3 3) `` `   gives   
[2 1] `

roelof08:02:47

and

p5 (paginate (range 15) 1 1)] 
gives
[]  
`

roelof08:02:52

very wierd.

roelof08:02:03

the example from the readme

(= (paginate (range 101) 10 5) 
gives this as I understand it well
{:prev-seq (4 3 2 1), :next-seq (6 7 8 9 10 11), :pages 11, :page 5, :next 6, :prev 4} 

roelof08:02:17

that is a whole other output

roelof08:02:58

there it looks if the 10 is the number of numbers you want to see

roelof08:02:14

and the 5 seems to be the current page

roelof08:02:33

the 101 I do not have a clue

roelof15:02:56

Am I right if I want to do in Atom I need a prompt to do lein koan run

roelof15:02:06

and I cannot do it with protorepl ?

roelof16:02:47

Why do I see here this error : Unable to resolve symbol: catch in this context,

roelof16:02:15

with this code :

` "But watch out if you try to pop nothing"
  (= "No dice!" (try)
          (pop '())
          (catch IllegalStateException e
            "No dice!"))  

dpsutton16:02:26

because its not in a try block

roelof16:02:35

Wierd, Atom does place the ) still after the try

roelof16:02:48

Thanks, I have now parinfer : paren instead of parinfer : ident

dpsutton16:02:02

what do you mean atom places it there?

roelof16:02:51

the last ) is supposed to as last but on some way atom parinfer places it right after the try part

dpsutton16:02:57

i don't believe any packages will move things for you but rather let you move them in structural ways

roelof16:02:56

Then you do not believe it, I saw it myself, I transfer the ) to the last position and saw that the ) was placed back after the try part

roelof17:02:01

I have this html part :

<ul class="pagination">
  <li><a href="#">1</a></li>
  <li><a href="#">2</a></li>
  <li><a href="#">3</a></li>
  <li><a href="#">4</a></li>
  <li><a href="#">5</a></li>
</ul>

roelof17:02:25

now when the current page is > 6 then I wan to display 1 - 10

roelof17:02:24

when the current page is between 6 and 466 then I want to display 4 numbers before it , the number itself and 4 numbers behind it

roelof17:02:00

when the number between 466 and 470 I want to see 460 - 470

roelof17:02:26

How can I make it work that I use the html part once instead of 3 copies in a big if then part ?

roelof18:02:32

or can I do something like this in selmer :

(defn boundries 
 [pagenumber] 
 (if (pagenumber < 6) 
    range(1 - 10) 
  else (if pagenumber >= 6 and pagenumber <= 466) 
      range((- pagenumber 4) (+ pagenumber 4))
  else 
      range(460 470)))) 

<ul class="pagination">
   (for [x [(boundries)]   
        <li><a href="localhost/page?="+str(x) > x </a></li> [)
</ul>  

roelof18:02:00

This is written out of my head so there can be some unbalanced parentheses

roelof18:02:07

it about the idea

curlyfry20:02:42

@roelof @dpsutton Sounds like you have parinfer turned on, roelof. It will insert parentheses in the "right" places based on indentation https://shaunlebron.github.io/parinfer/

curlyfry20:02:20

So not that weird, rather very intentional 🙂

roelof20:02:40

@curlyfry yes. I have parinfer turned on.

roelof20:02:32

On atom I could use it in two "taste": parinfer : paren and parinfer : indent

roelof20:02:48

so it could be that the last one looks at the intendation

roelof21:02:51

No body who can help me with my pagination problem ?