Fork me on GitHub
#clojure
<
2015-12-13
>
val_waeselynck09:12:20

@misha I doubt it but wrapping with your own factory function is really not hard :)

Pablo Fernandez10:12:26

How do I make figwheel pick up my custom ring handler?

Pablo Fernandez10:12:50

When trying to run lein release, I’m getting this error: java.lang.Exception: Couldn't commit. git exit code: 1

Pablo Fernandez10:12:32

Anybody seen it before? I don’t know why it can’t commit, but also, there’s nothing to commit.

misha10:12:11

@val_waeselynck: the whole point is to keep the factory-fn name. Of course I can create unlimited factories with the names different from ->User, but my snippet above throws ArityException

misha10:12:50

(defn ->User
  ([email name]
    {:email email :name name})
  ([email]
    (->User email nil)))
does it, but I was wondering whether there is a way to extend existing function's arity w/o rewriting it

thheller10:12:48

@misha I'd recommend using (map->User {:email ...}) since you can name arguments, the ->User factory fn is based on ordering and (->User name) will yield problems while (map->User {:name ...}) just works

misha11:12:38

@thheller: one of the points of records - some shortcut when it comes to building one : ), so for 1-3 fields I'd rather use ->factory-fn, than map-> fn. For larger records – map-> is the way to go for sure.

roelof12:12:19

@sveri : my question is that in this html template a lot of <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> , <li><a href="//laboutique.lemonstand.com/login" title="Login / Register">Login / Register</a></li> and <img src="//d151ufcidijoq9.cloudfront.net/store-ctymko-test-52d08555555ba/themes/la-boutique-2ndreview/resources/images/logo.png" alt="La Boutique" /> are used and I cannot find it how to make these tags work on my selmer template

sveri13:12:36

@roelof: You can put them inside the template as they are

roelof13:12:31

oke, thanks

roelof13:12:20

@sveri: and I can still put all the javascript and so on in resources ?

roelof13:12:43

I will give selmer a second try

ul14:12:45

i'm totally lost:

boot.user=> (def ^:dynamic x nil)
#'boot.user/x
boot.user=> (binding [x 1] (println x))
1
nil
boot.user=> (binding [x 1] (for [i (range 2)] (println x)))
nil nil
(nil nil)

ul14:12:00

why binding is not preserved in for?

jaen14:12:36

I'd hazard a guess that's because it returns a lazy list.

jaen14:12:15

The for is in the scope of the binding, but the part when REPL prints the list - is not. And you get the root value.

jaen14:12:43

If you doall the for it should return what you expect.

ul14:12:46

hmmm... sounds like a truth, putting inside doall “fixed” this

ul14:12:54

thank you!

jaen14:12:57

No problem

jaen14:12:42

For example if you sued doseq it would also work as you expected, since it's eager.

val_waeselynck15:12:12

@misha your last snippet will create hash-maps, not records. I would use something like:

(def ->User 
  (let [old-fn ->User] 
    (fn 
      ([email name] (old-fn email name))
      ([user] (->User user nil)))
    ))

val_waeselynck15:12:50

but I'd totally prefer map->User indeed

codemartin16:12:47

Hi! I'm building a plugin system. Having problems understanding ns and what functions are available to call at what times. Specifically, since I am getting Caused by: java.lang.RuntimeException: Unable to resolve symbol: str in this context. The load-package! functions looks like this

(defn load-package!
  "Loads a ns at file-path, and return its ns declaration"
  [file-path]
  {:pre [string?]}
  (load-file file-path)
  (let [ns (clojure.tools.namespace.file/read-file-ns-decl file-path)]
    (println (str "Initializing package: " (second ns)))
    (require (second ns))
    ns))

codemartin16:12:42

My question is: how can I have the standard library available in the packages? And how can I make it so that packages can require my programs core namespace? (`rad.core` in this case)

codemartin16:12:06

clojure.tools.namespace.file/read-file-ns-decl returns a normal ( ) unevaluated list, where the first symbol is ns. Code as data, etc...

meow16:12:52

Anyone have an elegant approach to the manipulation of a normalized value? For example, I have a function that receives normalized values between 0.0 and 1.0 that I want to use as args to some other function but I want to feed the other function values between say 0.3 and 0.9.

meow16:12:02

I could use some min/max for clamping, but I really want to change the scale so I still get the same spread of values, if that makes sense.

jaen16:12:53

Why not multiply by width of the range and add offset of min value?

meow16:12:55

Similarly, I'd like to be able to shift values as if they circled around. So for that I could add some offset value, like 0.25, and then do (mod val 1) so that it wraps around...

meow16:12:02

@jaen: because I'm tired and was thinking maybe there was a generalized need for this kind of thing that I could get some ideas from. simple_smile

meow16:12:29

I'd rather not have to think it all through. 😉

jaen16:12:31

Ah, I see.

jaen16:12:09

If it's supposed to be generalised then I guess the value would need to tag it's limits around so you could manipulate them. But this would be relatively slow (couldn't be unboxed), so that's probably a bad idea.

meow16:12:59

I'm doing color manipulations where the hue, saturation and value must all be provided as normalized values. I'm determining them using characteristics of polygons that I've also got in normalized form, like the face normal. But I don't want to make use of the whole range of saturation, for example, because at the extremes the color is no longer interesting.

danmidwood16:12:14

Hey all, does anyone know which profile lein new runs as? I'm trying to track down why a project has been built from a development version of a template

jaen16:12:56

Then hmmm, maybe some sort of composable generators? So you could create a generator, compose it with things like scale, shift, clamp, and so on and then call the resulting function to obtain a value?

meow16:12:08

I was thinking this might be typical of some more generalized need to modify normalized values.

meow16:12:19

@jaen: Yeah, I'm trying to be creative so composable functions, or a transducer type approach would be nice.

meow16:12:53

I don't want to write all this myself if there is already a library out there.

danmidwood16:12:17

nvm, it seems that it was just because the template had been locally installed

amacdougall16:12:06

@ikitommi: Sorry for the delayed response, but your suggestion of using defroutes* worked perfectly. I'm now using this:

(context* "/api" []
  (context* "/users" []
    users-routes) ; as defined in a different namespace
  (context* "/videos" []
    videos-routes))

pleasetrythisathome16:12:56

@meow: hope it's useful! let me know how it goes

pleasetrythisathome16:12:18

i've been thinking of adding some more functionality for combining interpolators and general helpers to make things a little higher level

pleasetrythisathome16:12:22

but have been really busy

meow16:12:26

@pleasetrythisathome: do you think it will be a good fit for what I'm trying to do?

meow16:12:10

sweet. I'll give it a shot and let you know what I think. Thanks. simple_smile

pleasetrythisathome16:12:40

no prob. let me know if i can help with understanding anything

meow16:12:16

I want more control over the color I apply to the polygon faces. simple_smile

pleasetrythisathome16:12:56

there's an example on extending to garden to do more complex blending

pleasetrythisathome16:12:22

garden's color stuff is pretty solid, + more complex interpolators and you should be able to do pretty much anything

meow16:12:33

Oh, nice. I'm using Karsten's http://thi.ng color library, but it will be easy to use your example there as well.

pvinis17:12:51

can i have breakpoints in lighttable?

meow22:12:02

What has 88,320 faces, 132,480 edges and 44,044 vertices?

meow22:12:20

also available in Premium Silver

Nikita A Dudnik23:12:21

silver version looks rad!