Re: How to create a core.async channel that will drop messages if no consumer is currently reading from the channel?

2015-01-06 Thread Yehonathan Sharvit
What is the reason for the dropping buffer not supporting size 0? Why the most trivial option of "no buffering" is not supported out of the box by core.async? On Thu, Jan 1, 2015 at 11:31 AM, Jozef Wagner wrote: > Implement a custom buffer type, or use mult. With mult, use tap/untap to > contr

Re: Newbie Gloss questions - dynamic buffer structure

2015-01-06 Thread Zach Tellman
Hey Tzach, If I understand what you're trying to do, you want something like this: [ :uint32 :ubyte ;; or bit-seq, depending (delimited-block (prefix uint24 #(- % 5) #(+ % 5))) ] And then you'll need to parse the final block separately. I've left defining the uint24 as an exercise for the

Re: changing default clojure.pprint/*print-right-margin*

2015-01-06 Thread Mars0i
I'm not sure whether this counts as an answer. I put this definition in a file that my leiningen project loads by default: (defn set-pprint-width "Sets width for pretty-printing with pprint and pp." [cols] (alter-var-root #'clojure.pprint/*print-right-margin* (constantly cols))

changing default clojure.pprint/*print-right-margin*

2015-01-06 Thread Andy L
Hi, Is it possible to change default value of clojure.pprint/*print-right-margin* var and alikes in one place. I use pprint in many places and would like to avoid wrapping it with "binding" in every case. Thanks, Andy -- You received this message because you are subscribed to the Google Groups

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Brian Marick
Akos Gyimesi wrote: every function call has a corresponding mock call in the test, so whenever you modify the implementation (without even changing the top-level result) you have to modify the tests as well, and vica-versa. I once encountered a codebase that had thousands of lines of such "tests"

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Brian Marick
Akos Gyimesi wrote: Now, later that day I decide that I pass the whole user object to the check-pw function. Maybe I want to use the user ID as a salt, or maybe I just want to leave the possibility for checking password expiration, etc. So I modify the test and the implementation of check-pw so

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Akos Gyimesi
Thank you for all the responses! To be honest, I hoped that someone would explain why this mocking style is a good thing, and I just misunderstand something about the "top-down development" that the Midje wiki suggests: https://github.com/marick/Midje/wiki/The-idea-behind-top-down-development Wh

Re: camelize-dasherize - reinventing the wheel?

2015-01-06 Thread Andrey Antukh
Hi! 2015-01-06 20:25 GMT+01:00 Noam Ben-Ari : > Hi, > > I've written a small library (1 ns, 100 lines) to transform nested maps > from "dash-case" keys to "camelCase" keys and back. > > The original use case was taking MySQL records that use camelCase field > names and convert them to dash-case s

Re: camelize-dasherize - reinventing the wheel?

2015-01-06 Thread Thomas Heller
If you want to boost performance a bit just memoize the conversion functions. Memoize makes you vurnable to exploits though, better use something with WeakRefs if you convert anything from untrusted sources (eg. guava CacheBuilder). But given your usecase this will probably be the biggest gain,

Re: Extend causes error in servlet container?

2015-01-06 Thread Ghadi Shayban
Btw, if you own the defrecord, extend a protocol to it directly in its definition, rather than in a separate extend or extend-protocol form. Doing it inline makes the record implement the protocol's backing interface, which will be much more efficient. (If it's not your record you don't really

Re: Extend causes error in servlet container?

2015-01-06 Thread Michael Blume
On further investigation, it looks like you're suffering from http://dev.clojure.org/jira/browse/CLJ-979 -- if I apply the patch for this bug to clojure and recompile your project everything works fine. It looks like this patch *is* slated to make it into Clojure 1.7.0, so that should also make you

Re: Extend causes error in servlet container?

2015-01-06 Thread Michael Blume
TL;DR: If you wait for that lein-ring pull to get merged, you can upgrade lein-ring and your problem will go away. If you wait for Clojure 1.7.0 it's possible your problem will go away, though I'm less confident here (the current alpha doesn't have a fix). If you want your problem to go away *right

Re: Extend causes error in servlet container?

2015-01-06 Thread Michael Blume
lein-ring uses AOT compilation to build war files. AOT compilation in clojure is, well, problematic sometimes. Fortunately it can almost always be avoided using clever indirection. For example: https://github.com/pdenhaan/extend-test/pull/1 builds a war that works =) I've got a pull open against

Re: camelize-dasherize - reinventing the wheel?

2015-01-06 Thread Noam Ben-Ari
Thanks for this, Andy. I see it uses postwalk and recursion for nested maps, so it will eventually blow up the stack. Probably faster than a zipper though. Also, for changing case it uses a custom split and join instead of regex, a very interesting approach. I won't be using it directly though

Re: camelize-dasherize - reinventing the wheel?

2015-01-06 Thread Andy Fingerhut
I have not used it, but from the docs it appears there is at least some overlap with this library: https://github.com/qerub/camel-snake-kebab It mentions in its docs that it avoids using regex's. Andy On Tue, Jan 6, 2015 at 11:25 AM, Noam Ben-Ari wrote: > Hi, > > I've written a small libr

camelize-dasherize - reinventing the wheel?

2015-01-06 Thread Noam Ben-Ari
Hi, I've written a small library (1 ns, 100 lines) to transform nested maps from "dash-case" keys to "camelCase" keys and back. The original use case was taking MySQL records that use camelCase field names and convert them to dash-case so they don't stick out like a sore thumb in my code. Simi

Re: Clatrix Multiplication Matrix

2015-01-06 Thread Byan Jati
Solved bro! I think the error comes because my Ubuntu that should equipped with fortranlib3 library. Clatrix work like a charm! Thanks for the response On Sunday, January 4, 2015 6:12:43 AM UTC-5, Byan Jati wrote: > > I have 2 matrix, matrix A = [[1 2 3][4 5 6]] and matrix B = [[10 20][20 > 30

Re: A (foolish) plan to re-invent IO on top of core.async

2015-01-06 Thread Josh Kamau
There is also vertx.io with the clojure module. Josh On Tue, Jan 6, 2015 at 3:43 PM, Max Penet wrote: > Jet is already very usable and used in production by some notable > projects/clients. > I am also working on improving the backpressure story on all fronts at the > moment (matter of few days

Q: How to parse stream of text (from java.io.Reader) via instaparse with minimal input consuption

2015-01-06 Thread henrik42
Hi all, I want to parse a stream of text which comes from a java.io.Reader with https://github.com/Engelberg/instaparse. But the stream of text will only start with what can be parsed by my grammar. The rest of the text stream must be consumed/parsed with some other grammar. I know of instpars

Extend causes error in servlet container?

2015-01-06 Thread peter . denhaan
I'm a relative newcomer to Clojure, and I'm puzzled by problems I have using extend in a webapp. Any help would be hugely appreciated. My use case is basically this: (defrecord FooRecord [msg]) (defprotocol FooProtocol (bar [foo] "to use with extend-type")) (extend FooRecord FooProtocol

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Colin Yates
+1 - I think we are saying the same thing (not sure if you meant to reply to me?) On 6 January 2015 at 14:35, Timothy Baldridge wrote: > I think the answer to questions like this is that you are testing the wrong > thing, or more correctly you are writing incomplete tests. > > In your example, yo

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Timothy Baldridge
I think the answer to questions like this is that you are testing the wrong thing, or more correctly you are writing incomplete tests. In your example, you stubbed out check-pw. But calling check-pw has a contract, a contract that (at the moment) only exists in your head, but a contract none-the-l

Re: hash function behaves different with empty vector in clojure and clojurescript

2015-01-06 Thread David Nolen
Fixed in master thanks to Michal Marczyk! David On Tue, Jan 6, 2015 at 3:05 AM, Fluid Dynamics wrote: > On Monday, January 5, 2015 2:27:03 PM UTC-5, Feng Xue wrote: >> >> These days, I was trying to utilize function hash in >> clojure/clojurescript to generate unique id, but it turns out this f

Re: Clatrix Multiplication Matrix

2015-01-06 Thread Byan Jati
I just want to perform matrix multiplication by mmul with Matrix A and B (mmul A B), but i got this error : java.lang.UnsatisfiedLinkError : org.jblas.NativeBlas.dgemm(CCIIID[DII[DIID[DII)V (Unknown Source) org.jblas.NativeBlas.dgemm . . . blablabla I'm using [net.mikera/core.matrix "0.32.1"]

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Colin Yates
I don't think there is an easy answer here, and note that this is a problem generic to mocking (i.e. not clojure or midje specific). The usual advice applies though: - do you really need to mock? Unit testing is about the coarseness of granularity which is defined more by cohesion and abstract

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Jonathon McKitrick
Akos, that is exactly the kind of problem I'm talking about! Right down to the detail about stopping work and returning to the project later, and seeing all the tests pass! -- Jonathon McKitrick On Tue, Jan 6, 2015 at 3:22 AM, Akos Gyimesi wrote: > > On Sat, Jan 3, 2015, at 02:46 AM, Brian M

Re: Please critique my code (barber problem with core.async)

2015-01-06 Thread Gary Verhaegen
I'd suggest taking a look at the alts! function in core.async (or the equivalent alt! macro). On Monday, 5 January 2015, Thomas wrote: > Thank you all for you valuable feedback. I really appreciate it and the > suggestions are really good. > > Thomas > > -- > You received this message because yo

Re: A (foolish) plan to re-invent IO on top of core.async

2015-01-06 Thread Max Penet
Jet is already very usable and used in production by some notable projects/clients. I am also working on improving the backpressure story on all fronts at the moment (matter of few days at most). -- You received this message because you are subscribed to the Google Groups "Clojure" group. To p

Re: A (foolish) plan to re-invent IO on top of core.async

2015-01-06 Thread Andrey Antukh
Some jetty adapters also supports the async interface using core.async: https://github.com/mpenet/jet. Also, for async database access, I'm currently working on suricatta library (sql toolkit on top of JOOQ) and it exposes a simple async interface for execute queries asynchronously in a shared thr

Re: A (foolish) plan to re-invent IO on top of core.async

2015-01-06 Thread Jozef Wagner
AFAIK https://github.com/ztellman/aleph is the current best async IO library. Jozef On Tue, Jan 6, 2015 at 7:20 AM, Ricardo Gomez wrote: > There are, it'll just never happen. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-06 Thread Akos Gyimesi
On Sat, Jan 3, 2015, at 02:46 AM, Brian Marick wrote: > > > I use TDD and mocking/stubbing (conjure) to test each layer of my code. > > The problem is when I change the function signature and the tests do not > > break, because the mocks/stubs do not know when their argument lists no > > longer a

Re: hash function behaves different with empty vector in clojure and clojurescript

2015-01-06 Thread Fluid Dynamics
On Monday, January 5, 2015 2:27:03 PM UTC-5, Feng Xue wrote: > > These days, I was trying to utilize function hash in clojure/clojurescript > to generate unique id, but it turns out this function has very strange > behaviour to empty vector parsed from read-string in cljs with in clj. > > In cloj