Re: avoiding repetition in ns declarations

2014-01-24 Thread Konrad Hinsen
--On 23 janvier 2014 13:08:57 + Phillip Lord 
 wrote:



The nstools library lets you do exactly that:

  https://code.google.com/p/clj-nstools/


That looks nice; why not open up the reference-map though, so that it
would become extensible.


That's a good idea. Just making it public is risky, as any module could 
mess up the namespace definition system shared by everybody. You'd want 
something like subclassing (sorry for the OO jargon).


The tricky part is how one would actually use such extensions. Current 
nstools is already a bit messy, since you must put a (clojure.core/use 
'nstools.ns) in every source file before the (ns+ ...) form. An extension 
to nstools would require a second line before (ns+ ...). What I'd prefer is 
an extension mechanism in Clojure's built-in ns macro, which would permit a 
much nicer implementation of nstools.


Konrad.



--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups "Clojure" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: semantics of >! on closed channels

2014-01-24 Thread John Szakmeister
On Thu, Jan 23, 2014 at 9:17 PM, Cedric Greevey  wrote:
> [meta, but about something apparently triggered by the message, from this
> thread, that I'm quoting]
>
> Why did reading this post cause gmail to go bonkers? I saw this thread had
> new articles since earlier today, brought it up, and read the previous
> message, then just after I'd scrolled down to this one, leaned back, and
> started reading it the browser just suddenly began spinning on its own and
> navigated by itself. Apparently about 10 seconds after I sat back
> *something* input a click on the little down-triangle in the upper right
> corner of the page and then clicked "sign out" because it went to the gmail
> login page. And a second or so before that the chat thingy at the left
> crashed as a popup there distracted me by appearing suddenly and saying
> something like "Oops, problem connecting to chat".

GMail's sessions time out periodically.  I forget the interval (or if
it's random... it seems to be at times), but when it does, it has
similar behavior to what you've described.  Chat goes a little wonky,
and then you're brought to the sign in page some moments later.  I
think the behavior is slightly worse if you have two accounts in GMail
(I have a regular GMail account and one that's in the Apps for
Business).  They sometimes interact badly, especially around starting
and ending sessions.

-John

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANN?]: ring-jetty-adapter with jetty 9.1.x

2014-01-24 Thread Andrey Antukh
Just renamed, thanks for suggestion!

Andrey.


2014/1/23 James Reeves 

> You might want to give it a different name, like ring-jetty9-adapter,
> otherwise it might be confused with the ring-jetty-adapter package in Ring
> itself.
>
> - James
>
>
> On 23 January 2014 22:39, Andrey Antukh  wrote:
>
>> Hi!
>>
>> I have port the current ring-jetty-adapter from current ring repository
>> to use jetty 9.1.1 version.
>>
>> I understand that current ring-jetty-adapter uses 7.6.x branch for java
>> 1.5 compatibility, but in environments when all apps runs over jdk7, jetty
>> 9.x seems more modern environment.
>>
>> if the main project in a future is going to have intention to update to
>> Jetty 9.x, I will mark my package/library as deprecated.
>>
>> https://github.com/niwibe/ring-jetty-adapter
>>
>> Greetings.
>> Andrey
>> --
>> Andrey Antukh - Андрей Антух -  / <
>> n...@niwi.be>
>> http://www.niwi.be 
>> https://github.com/niwibe
>>
>> --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Andrey Antukh - Андрей Антух -  / 
http://www.niwi.be 
https://github.com/niwibe

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: avoiding repetition in ns declarations

2014-01-24 Thread Mark Engelberg
I thought clj-nstools was for Clojure 1.2 only.  Not true?


On Thu, Jan 23, 2014 at 1:07 AM, Konrad Hinsen <
googlegro...@khinsen.fastmail.net> wrote:

> --On 21 janvier 2014 23:15:50 -0800 t x  wrote:
>
>I have the following problem:
>>
>> (ns foo.bar
>>   ...
>>   ...
>>   ... )
>>
>> There's basically 10 lines of require that I want as part of nearly
>> _every_ ns I declare is there a way to define some soft of alias /
>> abbrevraviation that is used in namespaces at will?
>>
>
> The nstools library lets you do exactly that:
>
>   https://code.google.com/p/clj-nstools/
>
> Konrad.
>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANN?]: ring-jetty-adapter with jetty 9.1.x

2014-01-24 Thread Max Penet
FYI there is also this one on github: 
 https://github.com/sunng87/ring-jetty9-adapter 

On Thursday, January 23, 2014 11:39:45 PM UTC+1, Andrey Antukh wrote:
>
> Hi!
>
> I have port the current ring-jetty-adapter from current ring repository to 
> use jetty 9.1.1 version.
>
> I understand that current ring-jetty-adapter uses 7.6.x branch for java 
> 1.5 compatibility, but in environments when all apps runs over jdk7, jetty 
> 9.x seems more modern environment.
>
> if the main project in a future is going to have intention to update to 
> Jetty 9.x, I will mark my package/library as deprecated.
>
> https://github.com/niwibe/ring-jetty-adapter
>
> Greetings.
> Andrey
> -- 
> Andrey Antukh - Андрей Антух - > / <
> ni...@niwi.be >
> http://www.niwi.be 
> https://github.com/niwibe
>  

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANN?]: ring-jetty-adapter with jetty 9.1.x

2014-01-24 Thread Andrey Antukh
Oh!

Thanks! Sorry for the noise.
I've definitely made ​​a bad search, thought id did not exist.

I will remove my package and use the existent ;)

Andrey


2014/1/24 Max Penet 

> FYI there is also this one on github:
> https://github.com/sunng87/ring-jetty9-adapter
>
> On Thursday, January 23, 2014 11:39:45 PM UTC+1, Andrey Antukh wrote:
>
>> Hi!
>>
>> I have port the current ring-jetty-adapter from current ring repository
>> to use jetty 9.1.1 version.
>>
>> I understand that current ring-jetty-adapter uses 7.6.x branch for java
>> 1.5 compatibility, but in environments when all apps runs over jdk7, jetty
>> 9.x seems more modern environment.
>>
>> if the main project in a future is going to have intention to update to
>> Jetty 9.x, I will mark my package/library as deprecated.
>>
>> https://github.com/niwibe/ring-jetty-adapter
>>
>> Greetings.
>> Andrey
>> --
>> Andrey Antukh - Андрей Антух -  / > >
>> http://www.niwi.be 
>> https://github.com/niwibe
>>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Andrey Antukh - Андрей Антух -  / 
http://www.niwi.be 
https://github.com/niwibe

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Tassilo Horn
Hi all,

in the following, set is clojure.set, and r is clojure.core reducers.

Why is

user> (reduce set/intersection (map set [[1 2] [3 1] [1 3]]))
#{1}

but

user> (reduce set/intersection (r/map set [[1 2] [3 1] [1 3]]))
ArityException Wrong number of args (0) passed to: set$intersection
clojure.lang.AFn.throwArity (AFn.java:437)

The clojure.core/reduce docs state that when there's no init value, the
reduce function is called with the first two elements of the coll.

The behavior of calling the reduce function with no arguments to create
an init value is specified for r/reduce, but I'm not using that.

Is that a bug, or should I not expect that clojure.core/reduce works
with reducible collections?  (I've not followed which reducer changes
were made in clojure 1.5.1.)

Bye,
Tassilo

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Rename file uploaded

2014-01-24 Thread The Dude (Abides)
Hi, I'm new to clojure and am trying to rename an uploaded file with a 
unique identifier such as a long time stamp as follows:

(defn add-timestamp [filename]
 (let [ext-position (.lastIndexOf filename ".")
   timestamp(tc/to-long (time/now))]
   (if (pos? ext-position)
 (str (.substring filename 0 ext-position)
  "-" timestamp (.substring filename ext-position))
 (str filename "-" timestamp

(defn handle-upload [filename]
 (upload-file (gallery-path) (add-timestamp filename))
 (resp/redirect "/upload"))

However the above throws an error as follows:

java.lang.IllegalArgumentException
No matching method found: lastIndexOf for class 
clojure.lang.PersistentArrayMap

Would appreciate any feedback on what I may be doing wrong in the 
add-timestamp function.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


clojure debugging repl

2014-01-24 Thread t x
Hi,

  One thing I miss from pre-Clojure scheme days is as follows:

## What I want

1 => (foo) ;; I'm calling foo at the repl
... foo executes ...
... at some point, an exception is thrown ...

2 => my interpreter _starts a new repl_
  * at the point where the exception was thrown
  * lets me examine local environment variables
  * lets me execute commands
  * lets me "resume" the execution


## Why "it can't work"

Now, I understand why this can not work in general in Clojure, i.e. the
following example:

(defn foo []
  (.someJavaFunctionThatThrowsException object))

In this case, the above is impossible since the exception is thrown from
_java land_ rather than Clojure land.


## Why it might work

Now, I'm not writing any code in java. The work I'm doing is pure clojure.
I can throw when the exception is thrown.


Is there some library, where instead of doing

(defn foo []
  ...
  (throw (ex-data ...))
  ...)

I instead do:

(defn foo []
  ...
  (something-went-wrong-please-fire-up-a-repl)
  ...)

?

Thanks!

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: avoiding repetition in ns declarations

2014-01-24 Thread Phillip Lord
Konrad Hinsen  writes:

> --On 23 janvier 2014 13:08:57 + Phillip Lord
>  wrote:
>
>>> The nstools library lets you do exactly that:
>>>
>>>   https://code.google.com/p/clj-nstools/
>>
>> That looks nice; why not open up the reference-map though, so that it
>> would become extensible.
>
> That's a good idea. Just making it public is risky, as any module could mess
> up the namespace definition system shared by everybody. You'd want something
> like subclassing (sorry for the OO jargon).


You could use ::keyword rather than :keyword, or at least put this as a
suggestion. You can't enforce this, but the :private true is a
suggestion as well, and can be worked around.


> The tricky part is how one would actually use such extensions. Current nstools
> is already a bit messy, since you must put a (clojure.core/use 'nstools.ns) in
> every source file before the (ns+ ...) form. An extension to nstools would
> require a second line before (ns+ ...). What I'd prefer is an extension
> mechanism in Clojure's built-in ns macro, which would permit a much nicer
> implementation of nstools.


Yep, this is true. When I wrote my toy namespace form, I eval'd
arguments sequentially. So, you can then do something like this...

;; in namespace.imports
(defn tawny-read []
  (use-only
   (req tawny.read)
   'defread))


;; in "bob"
(newnamespacet
 bob
 (req namespace.imports)
 (namespace.imports/tawny-read))

The point is that the (req namespace.imports) line requires
namespace.imports before (namespace.imports/tawny-read) is eval'd. So
the second form works as well.

Of course, this gives a very procedural aspects to the form: the same
thing backward:

(newnamespacet
 bob
 (namespace.imports/tawny-read)
 (req namespace.imports))

would fail.

The rest of my examples are here:

https://github.com/phillord/namespace-experiments

Phil

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: avoiding repetition in ns declarations

2014-01-24 Thread Konrad Hinsen
--On 24 Jan 2014 00:58:46 -0800 Mark Engelberg  
wrote:



I thought clj-nstools was for Clojure 1.2 only.  Not true?


I have used it with Clojure 1.3 without modifications. I haven't
done any major Clojure project with later Clojure releases, so I don't
if it works with a current setup. It shouldn't be difficult to port if
necessary.

Since my impression is that nobody else but me is using it, maintenance 
follows a simple "personal needs" approach.


Konrad.

--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups "Clojure" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


ANN: Cloact is now Reagent 0.2.0

2014-01-24 Thread Dan Holmsand
Cloact, a minimalistic interface between React.js and ClojureScript, is now 
called Reagent (the old name was bad in all sorts of ways).

There is also a new little demo of how to implement undo for Reagent components 
here:

http://holmsand.github.io/reagent/news/cloact-reagent-undo-demo.html

The new project page is here:

https://github.com/holmsand/reagent

Cheers,

/dan

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ANN: Cloact is now Reagent 0.2.0

2014-01-24 Thread Shashy Dass
Thanks for this great library and the very detailed posts about how to use 
it.
I've been experimenting with some of my toy apps and Cloact, now REagent 
really helped clean up a lot of non-essential complexity.

Shashy

On Friday, January 24, 2014 7:52:39 AM UTC-5, Dan Holmsand wrote:
>
> Cloact, a minimalistic interface between React.js and ClojureScript, is 
> now called Reagent (the old name was bad in all sorts of ways). 
>
> There is also a new little demo of how to implement undo for Reagent 
> components here: 
>
> http://holmsand.github.io/reagent/news/cloact-reagent-undo-demo.html 
>
> The new project page is here: 
>
> https://github.com/holmsand/reagent 
>
> Cheers, 
>
> /dan 
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Looking for a reference binary parsing

2014-01-24 Thread Kashyap CK
Hi,
I need to write a parser for MP4 - essentially, read an MP4 file and create 
an in-memory representation of its structure.
I'd appreciate it very much if I could get some suggestions on libraries 
that I could use for this.
Is there a https://github.com/youngnh/parsatron like library that works on 
binary files as well?
Regards,
Kashyap

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for a reference binary parsing

2014-01-24 Thread James Reeves
You might want to take a look at Gloss (
https://github.com/ztellman/gloss) and Buffy (
https://github.com/clojurewerkz/buffy ).

- James


On 24 January 2014 15:08, Kashyap CK  wrote:

> Hi,
> I need to write a parser for MP4 - essentially, read an MP4 file and
> create an in-memory representation of its structure.
> I'd appreciate it very much if I could get some suggestions on libraries
> that I could use for this.
> Is there a https://github.com/youngnh/parsatron like library that works
> on binary files as well?
> Regards,
> Kashyap
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ANN: Cloact is now Reagent 0.2.0

2014-01-24 Thread Shashy Dass
Thanks for a great library and the fantastic documentation too.
Reagent is fantastic.

Shashy

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ClojureScript] Re: ANN: Cloact is now Reagent 0.2.0

2014-01-24 Thread Dan Holmsand

On 24 jan 2014, at 16:32, ritchie turner  wrote:
> Thanks for this library, i like the simplicity.
> 
> One issue, I'm trying to add a non standard attr during rendering but it's 
> being dropped, is that a bug or a feature :) ?

Thanks!

Turns out its both bug and feature...

Non standard attributes are not allowed by React itself, so that is a feature. 
:)

But you *should* be able to add attributes starting with data- and aria-, but 
that turns out to be broken in Reagent currently. I've added an issue for that 
here:

https://github.com/holmsand/reagent/issues/6

As a workaround, you could always set the attribute manually, for example like 
this:

(defn img-wrap [props]
  [:img props])

(def prod-code-img
  (with-meta img-wrap
{:component-did-mount
 (fn [this]
   (.setAttribute (reagent/dom-node this)
  "prod-code"
  (:prod-code (reagent/props this}))

and then use prod-code-img like this:

[prod-code-img {:prod-code "foo" :src "bar"}]

/dan

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
The reason you can't get this to work is that r/map returns a  
not a  for reduce to operate on.  I'm not sure of a solution because 
I'm not familiar with core.reducers.  But reading this: 
http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html
 informed 
me of your problems.  Sorry I can only point you in the right direction 
rather than provide a solution.



On Friday, January 24, 2014 5:26:11 AM UTC-5, Tassilo Horn wrote:
>
> Hi all, 
>
> in the following, set is clojure.set, and r is clojure.core reducers. 
>
> Why is 
>
> user> (reduce set/intersection (map set [[1 2] [3 1] [1 3]])) 
> #{1} 
>
> but 
>
> user> (reduce set/intersection (r/map set [[1 2] [3 1] [1 3]])) 
> ArityException Wrong number of args (0) passed to: set$intersection 
> clojure.lang.AFn.throwArity (AFn.java:437) 
>
> The clojure.core/reduce docs state that when there's no init value, the 
> reduce function is called with the first two elements of the coll. 
>
> The behavior of calling the reduce function with no arguments to create 
> an init value is specified for r/reduce, but I'm not using that. 
>
> Is that a bug, or should I not expect that clojure.core/reduce works 
> with reducible collections?  (I've not followed which reducer changes 
> were made in clojure 1.5.1.) 
>
> Bye, 
> Tassilo 
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Tassilo Horn
Jarrod Swart  writes:

> The reason you can't get this to work is that r/map returns a  
> not a  for reduce to operate on.

Ah, indeed.  I couldn't see the forest for the trees.

> I'm not sure of a solution because I'm not familiar with
> core.reducers.

This works:

  (reduce set/intersection (r/foldcat (r/map set [[1 2] [3 1] [1 3]])))

Bye,
Tassilo

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
Ah cool, thanks for posting your solution!

On Friday, January 24, 2014 3:29:49 PM UTC-5, Tassilo Horn wrote:
>
> Jarrod Swart > writes: 
>
> > The reason you can't get this to work is that r/map returns a 
>  
> > not a  for reduce to operate on. 
>
> Ah, indeed.  I couldn't see the forest for the trees. 
>
> > I'm not sure of a solution because I'm not familiar with 
> > core.reducers. 
>
> This works: 
>
>   (reduce set/intersection (r/foldcat (r/map set [[1 2] [3 1] [1 3]]))) 
>
> Bye, 
> Tassilo 
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: semantics of >! on closed channels

2014-01-24 Thread Cedric Greevey
That shouldn't affect anything until the next time I try to navigate, say
to the next thread with unread messages.

Something caused the browser to spontaneously start navigating on its own.
I didn't click a link and get redirected to the signin page at that time.
It went there all by itself without my hands even being on the keyboard or
mouse.

Web browsers are not supposed to have minds of their own and start browsing
around by themselves.

Now it is possible that the session had timed out while I was reading those
messages, and a prank navigation-triggering thingy thus triggered the
signin page instead of doing something else ... which, if anything, is
worrying. If the session had not been timed out at the time the prank input
was generated, could it have taken gmail actions on my behalf such as
deleting messages or even sending mail impersonating me? As it is it cost
me my read/unread information for this thread at the time, and I had to
review the whole thing to find the messages it had marked read that I
hadn't actually read. Rather rude.

I'd like to know how to protect myself against any message display
triggering any kind of auto-navigation by the browser, partly because it
clearly can cause inconvenience (what if this thread had been one of the
real long ones, with 50+ messages, and I'd lost my place in that?) and
partly because of the risk of the auto-navigation command being the
equivalent of a phantom click on "delete" or "send" or something. Even if
the cause in this case was something that would have been harmless even
without a timed-out session preventing it from doing anything but send me
to the gmail login prompt, the next time might be something more malicious,
and might happen without the session being timed out.



On Fri, Jan 24, 2014 at 3:20 AM, John Szakmeister wrote:

> On Thu, Jan 23, 2014 at 9:17 PM, Cedric Greevey 
> wrote:
> > [meta, but about something apparently triggered by the message, from this
> > thread, that I'm quoting]
> >
> > Why did reading this post cause gmail to go bonkers? I saw this thread
> had
> > new articles since earlier today, brought it up, and read the previous
> > message, then just after I'd scrolled down to this one, leaned back, and
> > started reading it the browser just suddenly began spinning on its own
> and
> > navigated by itself. Apparently about 10 seconds after I sat back
> > *something* input a click on the little down-triangle in the upper right
> > corner of the page and then clicked "sign out" because it went to the
> gmail
> > login page. And a second or so before that the chat thingy at the left
> > crashed as a popup there distracted me by appearing suddenly and saying
> > something like "Oops, problem connecting to chat".
>
> GMail's sessions time out periodically.  I forget the interval (or if
> it's random... it seems to be at times), but when it does, it has
> similar behavior to what you've described.  Chat goes a little wonky,
> and then you're brought to the sign in page some moments later.  I
> think the behavior is slightly worse if you have two accounts in GMail
> (I have a regular GMail account and one that's in the Apps for
> Business).  They sometimes interact badly, especially around starting
> and ending sessions.
>
> -John
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Rename file uploaded

2014-01-24 Thread Jarrod Swart
It works for me.  I am guessing you are not passing in a string when you 
are calling (add-timstamp filename).  Which is to say that your param 
'filename' is a map not a string.

If you are passing in a map of the upload information you need to grab the 
filename for your let:

(let [ext-postion (.lastIndexOf (:filename filename) ".")
  ...)

Hope that helps.

On Friday, January 24, 2014 3:31:42 AM UTC-5, The Dude (Abides) wrote:
>
> Hi, I'm new to clojure and am trying to rename an uploaded file with a 
> unique identifier such as a long time stamp as follows:
>
> (defn add-timestamp [filename]
>  (let [ext-position (.lastIndexOf filename ".")
>timestamp(tc/to-long (time/now))]
>(if (pos? ext-position)
>  (str (.substring filename 0 ext-position)
>   "-" timestamp (.substring filename ext-position))
>  (str filename "-" timestamp
>
> (defn handle-upload [filename]
>  (upload-file (gallery-path) (add-timestamp filename))
>  (resp/redirect "/upload"))
>
> However the above throws an error as follows:
>
> java.lang.IllegalArgumentException
> No matching method found: lastIndexOf for class 
> clojure.lang.PersistentArrayMap
>
> Would appreciate any feedback on what I may be doing wrong in the 
> add-timestamp function.
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Cedric Greevey
An interesting question this raises is if there is any sensible way to
define (intersection). It would need to behave as an identity element for
intersection, so would need to behave as a set (so, (set? (intersection))
=> truthy) that contained everything (so, (contains? (intersection) foo) =>
foo no matter what foo is; (partial contains? (intersection)) => identity).
The problem would be what to do with seq? Ideally an infinite seq that will
produce any particular value after finite time would be produced, but
there's no way to sensibly produce "any particular value" given the wide
variety of constructor semantics, builders, factory methods, things not
known to this particular runtime instance but that conceptually exist
somewhere, etc.; of course, the seq return is a dummy of sorts anyway since
you couldn't really use it sensibly to it might as well just return
(range). Printing should likely be overridden to just print
"(intersection)" rather than b0rk the REPL with a neverending stream of
integers (or whatever).

But then it also subtly violates another property of Clojure set objects:
if (= a b), (not (identical? a b)), and (identical? (a-set a) a), then
(identical? (a-set b) a) and thus (not (identical? (a-set b) b)). The
latter is true under the hypothesis for every "real" set but would be false
for (intersection).

Perhaps this is why (intersection) is not supported at this time, even
though (union) returns an empty set object, the identity element for the
union operation.


On Fri, Jan 24, 2014 at 3:34 PM, Jarrod Swart  wrote:

> Ah cool, thanks for posting your solution!
>
> On Friday, January 24, 2014 3:29:49 PM UTC-5, Tassilo Horn wrote:
>
>> Jarrod Swart  writes:
>>
>> > The reason you can't get this to work is that r/map returns a
>> 
>> > not a  for reduce to operate on.
>>
>> Ah, indeed.  I couldn't see the forest for the trees.
>>
>> > I'm not sure of a solution because I'm not familiar with
>> > core.reducers.
>>
>> This works:
>>
>>   (reduce set/intersection (r/foldcat (r/map set [[1 2] [3 1] [1 3]])))
>>
>> Bye,
>> Tassilo
>>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojure debugging repl

2014-01-24 Thread t x
Found it, apparently it's

debug-repl => swank-clojure => CDT => ritz

It appears cider does not yet support this, so ritz is probably the "most
powerful" at the moment.


On Fri, Jan 24, 2014 at 3:39 AM, t x  wrote:

> Hi,
>
>   One thing I miss from pre-Clojure scheme days is as follows:
>
> ## What I want
>
> 1 => (foo) ;; I'm calling foo at the repl
> ... foo executes ...
> ... at some point, an exception is thrown ...
>
> 2 => my interpreter _starts a new repl_
>   * at the point where the exception was thrown
>   * lets me examine local environment variables
>   * lets me execute commands
>   * lets me "resume" the execution
>
>
> ## Why "it can't work"
>
> Now, I understand why this can not work in general in Clojure, i.e. the
> following example:
>
> (defn foo []
>   (.someJavaFunctionThatThrowsException object))
>
> In this case, the above is impossible since the exception is thrown from
> _java land_ rather than Clojure land.
>
>
> ## Why it might work
>
> Now, I'm not writing any code in java. The work I'm doing is pure clojure.
> I can throw when the exception is thrown.
>
>
> Is there some library, where instead of doing
>
> (defn foo []
>   ...
>   (throw (ex-data ...))
>   ...)
>
> I instead do:
>
> (defn foo []
>   ...
>   (something-went-wrong-please-fire-up-a-repl)
>   ...)
>
> ?
>
> Thanks!
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Is there a good Hive library?

2014-01-24 Thread Gary Zhao
I'm looking a good Clojure Hive library instead of using Java library 
directly. Let me know if you know.

Thanks

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
If I understand you correctly I am in agreement.  I don't think you could 
take this problem to clojure.core.reducers/reduce or fold because the 
problem is inherently sequential is it not?

The reduction is basically (intersection (intersection (intersection A B) 
C) D).  

I was curious of this myself, how do I abstract out the order of the 
(reduce set/intersection ...).  I couldn't think of one.

Breaking this problem out into 'parallel' units of reduction isn't possible 
because the problem is dependent on order.  Which reducers can't have, or 
so I think after what I have read today.

On Friday, January 24, 2014 3:56:23 PM UTC-5, Cedric Greevey wrote:
>
> An interesting question this raises is if there is any sensible way to 
> define (intersection). It would need to behave as an identity element for 
> intersection, so would need to behave as a set (so, (set? (intersection)) 
> => truthy) that contained everything (so, (contains? (intersection) foo) => 
> foo no matter what foo is; (partial contains? (intersection)) => identity). 
> The problem would be what to do with seq? Ideally an infinite seq that will 
> produce any particular value after finite time would be produced, but 
> there's no way to sensibly produce "any particular value" given the wide 
> variety of constructor semantics, builders, factory methods, things not 
> known to this particular runtime instance but that conceptually exist 
> somewhere, etc.; of course, the seq return is a dummy of sorts anyway since 
> you couldn't really use it sensibly to it might as well just return 
> (range). Printing should likely be overridden to just print 
> "(intersection)" rather than b0rk the REPL with a neverending stream of 
> integers (or whatever).
>
> But then it also subtly violates another property of Clojure set objects: 
> if (= a b), (not (identical? a b)), and (identical? (a-set a) a), then 
> (identical? (a-set b) a) and thus (not (identical? (a-set b) b)). The 
> latter is true under the hypothesis for every "real" set but would be false 
> for (intersection).
>
> Perhaps this is why (intersection) is not supported at this time, even 
> though (union) returns an empty set object, the identity element for the 
> union operation.
>
>
> On Fri, Jan 24, 2014 at 3:34 PM, Jarrod Swart 
> > wrote:
>
>> Ah cool, thanks for posting your solution!
>>
>> On Friday, January 24, 2014 3:29:49 PM UTC-5, Tassilo Horn wrote:
>>
>>> Jarrod Swart  writes: 
>>>
>>> > The reason you can't get this to work is that r/map returns a 
>>>  
>>> > not a  for reduce to operate on. 
>>>
>>> Ah, indeed.  I couldn't see the forest for the trees. 
>>>
>>> > I'm not sure of a solution because I'm not familiar with 
>>> > core.reducers. 
>>>
>>> This works: 
>>>
>>>   (reduce set/intersection (r/foldcat (r/map set [[1 2] [3 1] [1 3]]))) 
>>>
>>> Bye, 
>>> Tassilo 
>>>
>>  -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojure debugging repl

2014-01-24 Thread Jarrod Swart
The second version of The Joy of Clojure talks about building a debugging 
repl that allows insertion of breakpoints into code.  Perhaps something 
similar could be done here.

On Friday, January 24, 2014 4:38:59 PM UTC-5, t x wrote:
>
> Found it, apparently it's
>
> debug-repl => swank-clojure => CDT => ritz
>
> It appears cider does not yet support this, so ritz is probably the "most 
> powerful" at the moment.
>
>
> On Fri, Jan 24, 2014 at 3:39 AM, t x >wrote:
>
>> Hi,
>>
>>   One thing I miss from pre-Clojure scheme days is as follows:
>>
>> ## What I want
>>
>> 1 => (foo) ;; I'm calling foo at the repl
>> ... foo executes ...
>> ... at some point, an exception is thrown ...
>>
>> 2 => my interpreter _starts a new repl_
>>   * at the point where the exception was thrown
>>   * lets me examine local environment variables
>>   * lets me execute commands
>>   * lets me "resume" the execution
>>
>>
>> ## Why "it can't work"
>>
>> Now, I understand why this can not work in general in Clojure, i.e. the 
>> following example:
>>
>> (defn foo []
>>   (.someJavaFunctionThatThrowsException object))
>>
>> In this case, the above is impossible since the exception is thrown from 
>> _java land_ rather than Clojure land.
>>
>>
>> ## Why it might work
>>
>> Now, I'm not writing any code in java. The work I'm doing is pure 
>> clojure. I can throw when the exception is thrown.
>>
>>
>> Is there some library, where instead of doing
>>
>> (defn foo []
>>   ...
>>   (throw (ex-data ...))
>>   ...)
>>
>> I instead do:
>>
>> (defn foo []
>>   ...
>>   (something-went-wrong-please-fire-up-a-repl)
>>   ...)
>>
>> ?
>>  
>> Thanks!
>>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Ben Wolfson
On Fri, Jan 24, 2014 at 12:56 PM, Cedric Greevey  wrote:

> An interesting question this raises is if there is any sensible way to
> define (intersection). It would need to behave as an identity element for
> intersection, so would need to behave as a set (so, (set? (intersection))
> => truthy) that contained everything (so, (contains? (intersection) foo) =>
> foo no matter what foo is; (partial contains? (intersection)) => identity).
> The problem would be what to do with seq? Ideally an infinite seq that will
> produce any particular value after finite time would be produced, but
> there's no way to sensibly produce "any particular value" given the wide
> variety of constructor semantics, builders, factory methods, things not
> known to this particular runtime instance but that conceptually exist
> somewhere, etc.; of course, the seq return is a dummy of sorts anyway since
> you couldn't really use it sensibly to it might as well just return
> (range). Printing should likely be overridden to just print
> "(intersection)" rather than b0rk the REPL with a neverending stream of
> integers (or whatever).
>

Why should printing be overridden? If I print (range) I don't get "(range)".

Also, contains? returns true if the first argument contains the second, not
the second; (partial contains? (intersection)) => (constantly true).


> But then it also subtly violates another property of Clojure set objects:
> if (= a b), (not (identical? a b)), and (identical? (a-set a) a), then
> (identical? (a-set b) a) and thus (not (identical? (a-set b) b)). The
> latter is true under the hypothesis for every "real" set but would be false
> for (intersection).
>

Is this a real property of Clojure's sets or an artifact of their present
implementation? Is it something that anything impleneting IPersistentSet
has to promise to uphold?

-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Cedric Greevey
Intersection is associative and commutative: (intersection A B) =
(intersection B A) and (intersection A (intersection B C)) = (intersection
(intersection A B) C) = the elements common to all three sets. So it's
actually perfectly well-founded for use with reducers, at least in
principle, and intersecting A B C D can be parallelized sensibly by
parallel intersecting A B and C D and then intersecting the two resulting
sets.


On Fri, Jan 24, 2014 at 6:43 PM, Jarrod Swart  wrote:

> If I understand you correctly I am in agreement.  I don't think you could
> take this problem to clojure.core.reducers/reduce or fold because the
> problem is inherently sequential is it not?
>
> The reduction is basically (intersection (intersection (intersection A B)
> C) D).
>
> I was curious of this myself, how do I abstract out the order of the
> (reduce set/intersection ...).  I couldn't think of one.
>
> Breaking this problem out into 'parallel' units of reduction isn't
> possible because the problem is dependent on order.  Which reducers can't
> have, or so I think after what I have read today.
>
>
> On Friday, January 24, 2014 3:56:23 PM UTC-5, Cedric Greevey wrote:
>
>> An interesting question this raises is if there is any sensible way to
>> define (intersection). It would need to behave as an identity element for
>> intersection, so would need to behave as a set (so, (set? (intersection))
>> => truthy) that contained everything (so, (contains? (intersection) foo) =>
>> foo no matter what foo is; (partial contains? (intersection)) => identity).
>> The problem would be what to do with seq? Ideally an infinite seq that will
>> produce any particular value after finite time would be produced, but
>> there's no way to sensibly produce "any particular value" given the wide
>> variety of constructor semantics, builders, factory methods, things not
>> known to this particular runtime instance but that conceptually exist
>> somewhere, etc.; of course, the seq return is a dummy of sorts anyway since
>> you couldn't really use it sensibly to it might as well just return
>> (range). Printing should likely be overridden to just print
>> "(intersection)" rather than b0rk the REPL with a neverending stream of
>> integers (or whatever).
>>
>> But then it also subtly violates another property of Clojure set objects:
>> if (= a b), (not (identical? a b)), and (identical? (a-set a) a), then
>> (identical? (a-set b) a) and thus (not (identical? (a-set b) b)). The
>> latter is true under the hypothesis for every "real" set but would be false
>> for (intersection).
>>
>> Perhaps this is why (intersection) is not supported at this time, even
>> though (union) returns an empty set object, the identity element for the
>> union operation.
>>
>>
>> On Fri, Jan 24, 2014 at 3:34 PM, Jarrod Swart  wrote:
>>
>>> Ah cool, thanks for posting your solution!
>>>
>>> On Friday, January 24, 2014 3:29:49 PM UTC-5, Tassilo Horn wrote:
>>>
 Jarrod Swart  writes:

 > The reason you can't get this to work is that r/map returns a
 
 > not a  for reduce to operate on.

 Ah, indeed.  I couldn't see the forest for the trees.

 > I'm not sure of a solution because I'm not familiar with
 > core.reducers.

 This works:

   (reduce set/intersection (r/foldcat (r/map set [[1 2] [3 1] [1 3]])))

 Bye,
 Tassilo

>>>  --
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>>
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com
>>>
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+u...@googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this

Re: clojure debugging repl

2014-01-24 Thread dgrnbrg
I have an implementation of this that's thoroughly integrated into vim.

clojure code: https://github.com/dgrnbrg/redl
vim plugin: https://github.com/dgrnbrg/vim-redl

The code itself is written with core.async, and is capable of monitoring a 
thread, inspecting its stack while its running, stopping it, and 
programmatically creating breakpoints that give you a repl with captured 
locals.

I'd love for this work to be extended to a generic nrepl handler, but I 
don't have the time to do so at the moment.

On Friday, January 24, 2014 6:46:23 PM UTC-5, Jarrod Swart wrote:
>
> The second version of The Joy of Clojure talks about building a debugging 
> repl that allows insertion of breakpoints into code.  Perhaps something 
> similar could be done here.
>
> On Friday, January 24, 2014 4:38:59 PM UTC-5, t x wrote:
>>
>> Found it, apparently it's
>>
>> debug-repl => swank-clojure => CDT => ritz
>>
>> It appears cider does not yet support this, so ritz is probably the "most 
>> powerful" at the moment.
>>
>>
>> On Fri, Jan 24, 2014 at 3:39 AM, t x  wrote:
>>
>>> Hi,
>>>
>>>   One thing I miss from pre-Clojure scheme days is as follows:
>>>
>>> ## What I want
>>>
>>> 1 => (foo) ;; I'm calling foo at the repl
>>> ... foo executes ...
>>> ... at some point, an exception is thrown ...
>>>
>>> 2 => my interpreter _starts a new repl_
>>>   * at the point where the exception was thrown
>>>   * lets me examine local environment variables
>>>   * lets me execute commands
>>>   * lets me "resume" the execution
>>>
>>>
>>> ## Why "it can't work"
>>>
>>> Now, I understand why this can not work in general in Clojure, i.e. the 
>>> following example:
>>>
>>> (defn foo []
>>>   (.someJavaFunctionThatThrowsException object))
>>>
>>> In this case, the above is impossible since the exception is thrown from 
>>> _java land_ rather than Clojure land.
>>>
>>>
>>> ## Why it might work
>>>
>>> Now, I'm not writing any code in java. The work I'm doing is pure 
>>> clojure. I can throw when the exception is thrown.
>>>
>>>
>>> Is there some library, where instead of doing
>>>
>>> (defn foo []
>>>   ...
>>>   (throw (ex-data ...))
>>>   ...)
>>>
>>> I instead do:
>>>
>>> (defn foo []
>>>   ...
>>>   (something-went-wrong-please-fire-up-a-repl)
>>>   ...)
>>>
>>> ?
>>>  
>>> Thanks!
>>>
>>
>>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for a reference binary parsing

2014-01-24 Thread dgrnbrg
I have found Gloss to be a pleasure to work with, and the fact that it 
handles framing, arbitrary header logic, and streaming decoding made it the 
best choice when I was writing codecs for binary formats whose files 
didn't/needed to be streamed, rather than bulk-loaded.

On Friday, January 24, 2014 10:56:23 AM UTC-5, James Reeves wrote:
>
> You might want to take a look at Gloss ( https://github.com/ztellman/gloss) 
> and Buffy ( 
> https://github.com/clojurewerkz/buffy ).
>
> - James
>
>
> On 24 January 2014 15:08, Kashyap CK >wrote:
>
>> Hi,
>> I need to write a parser for MP4 - essentially, read an MP4 file and 
>> create an in-memory representation of its structure.
>> I'd appreciate it very much if I could get some suggestions on libraries 
>> that I could use for this.
>> Is there a https://github.com/youngnh/parsatron like library that works 
>> on binary files as well?
>> Regards,
>> Kashyap
>>
>> -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


ANN: Om 0.3.0

2014-01-24 Thread David Nolen
A few minor simplifications to the Om model in this release. A breaking
change if you were using om.core/bind, om.core/pure-bind or om.core/read -
these complications have been removed.

There's also now a tutorial optimized for Light Table for people want to
understand the Om approach to React without losing time cobbling together a
working environment: http://github.com/swannodette/om/wiki/Tutorial

Have fun!

David

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ClojureScript integration with Emacs/Cider ?

2014-01-24 Thread Gary Trakhman
Bozhidar, I created an issue summing up my concerns:
https://github.com/clojure-emacs/cider/issues/460


On Wed, Jan 22, 2014 at 9:10 AM, Bozhidar Batsov wrote:

> Sorry about the late response, Gary. Would you mind taking the discussion
> over to cider’s issue tracker? (I tend to miss emails, but I don’t miss
> issues :-) ).
>
> The second change seems totally reasonable. I guess ritz’s complete
> middleware returns the completion candidates in some odd format. Regarding
> the tooling-session - why can’t the completions be generated using the
> tooling session with ClojureScript (my knowledge of it is pretty basic). I
> guess this was something to do with piggieback, right?
>
> --
> Cheers,
> Bozhidar
>
> On Saturday, January 18, 2014 at 8:56 PM, Gary Trakhman wrote:
>
> Bozhidar, I had to slightly modify cider-interaction.el to make
> autocomplete work for cljs.
>
> --- cider-interaction.el2014-01-18 13:51:28.082131609 -0500
> +++ /home/gary/.emacs.d/elpa/cider-0.4.0/cider-interaction.el   2014-01-17
> 19:06:45.872591834 -0500
> @@ -469,12 +469,12 @@
>(let ((strlst (plist-get
>   (nrepl-send-request-sync
>(list "op" "complete"
> -"session" (nrepl-current-tooling-session)
> +"session" (nrepl-current-session)
>  "ns" nrepl-buffer-ns
>  "symbol" str))
>   :value)))
>  (when strlst
> -  (car strlst
> +  strlst)))
>
>
> Here's the current implementing code:
>
> https://github.com/gtrak/nrepl-complete/blob/master/src/nrepl_complete/middleware.clj
>
> Here's a screenshot: http://i.imgur.com/GmBJ6Fj.png
>
> It can't be implemented for cljs on the tooling session without sending
> the real session id over somehow, it seems this would be wasteful and not a
> good precedent for other middlewares.
>
> I'd appreciate your thoughts.
>
> I'm also curious what it would take to make the display pretty like
> ac-nrepl, which I had to disable.
>
> As soon as this stuff is finalized, I'll package everything up nice and
> make a first release.
>
>
>
> On Mon, Jan 13, 2014 at 10:21 AM, Gary Trakhman 
> wrote:
>
> Austin's lein-plugin already manipulates project middlewares, so that's an
> easy target.  Onward!
>
>
> On Mon, Jan 13, 2014 at 10:10 AM, Bozhidar Batsov wrote:
>
> Cider’s completion understands a `complete` op, so the middleware is the
> best approach if you ask me. The only reason that there’s also an eval
> based completion mechanism (the one used by default) is that
> clojure-complete is present as a REPLy (which is used by lein) dependency
> and many newcomers have absolutely no idea what an nREPL middleware is.
> Unfortunately it’s hard to balance initial easy of setup and good design
> decisions.
>
> --
> Cheers,
> Bozhidar
>
> On Monday, January 13, 2014 at 4:55 PM, Gary Trakhman wrote:
>
> On talking to Chas,
> https://github.com/cemerick/piggieback/issues/22
>
> it seems like the right approach is to reify ac-nrepl's use of eval into a
> real "complete" op, and reimplement it to use that, then a common
> middleware can either use clojure's environment (clojure-complete) or
> piggieback's compiler state to implement the appropriate auto-complete
> based on the active repl.
>
> The issue here is that clojure's auto-complete takes the JVM state as an
> implicit parameter, whereas cljs-complete requires an 'env' arg that has to
> come from somewhere (piggieback has a var that keeps track of repl session
> state).  Ac-nrepl shouldn't be able to eval code, that means it's being
> coupled to the JVM state, which won't do for cljs or other sorts of
> repls-on-repls.
>
>
>
> On Mon, Jan 13, 2014 at 9:03 AM, Gary Trakhman wrote:
>
> I've released a cljs port of clojure-complete:
>
> Here's the mailing list announcement, also inlined.
>
> https://groups.google.com/forum/#!topic/clojurescript/Dt1s4laHFXc
> cljs-complete, A Clojure library designed to auto-complete clojurescript
> based on cljs compiler state.
>
> - With leiningen:
>  [cljs-complete "0.1.0"]
>
> - Usage
>
> ;; env is pulled from cljs compiler state
> => (completions @cljs.env/*compiler* "al" 'cljs.core)
> ("alength" "alter-meta!")
>
> This is meant to hook into piggieback, that'll be the next thing I try. I
> hope I can get some help with the hairy emacs bits :-).
>
>
> On Tuesday, January 7, 2014 1:54:27 AM UTC-5, Bozhidar Batsov wrote:
>
> I'm cider's maintainer. The problem with code completion for ClojureScript
> is that the default mechanism is based on the Clojure-only library
> https://github.com/ninjudd/clojure-complete. As I don't use ClojureScript
> I haven't paid much attention to it so far. If there is a similar library
> for ClojureScript I might add support for it. Btw, cider will also pick up
> any nREPL middleware that provides a "complete" op - if there is a
> ClojureScript nREPL completion middleware it can be used with cider even
> now. Ideally at some poi

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
Good points.  But the "identity" thing is still what gets me.  What is the 
identity of an intersection?

Like you said it can't be #{}.  If you seed an intersection with #{} you 
get #{}, so you can't intersect from the empty set.  The identity for an 
intersection is whatever the common element is, but how would you know that?

On Friday, January 24, 2014 7:03:40 PM UTC-5, Cedric Greevey wrote:
>
> Intersection is associative and commutative: (intersection A B) = 
> (intersection B A) and (intersection A (intersection B C)) = (intersection 
> (intersection A B) C) = the elements common to all three sets. So it's 
> actually perfectly well-founded for use with reducers, at least in 
> principle, and intersecting A B C D can be parallelized sensibly by 
> parallel intersecting A B and C D and then intersecting the two resulting 
> sets.
>
>
> On Fri, Jan 24, 2014 at 6:43 PM, Jarrod Swart 
> > wrote:
>
>> If I understand you correctly I am in agreement.  I don't think you could 
>> take this problem to clojure.core.reducers/reduce or fold because the 
>> problem is inherently sequential is it not?
>>
>> The reduction is basically (intersection (intersection (intersection A B) 
>> C) D).  
>>
>> I was curious of this myself, how do I abstract out the order of the 
>> (reduce set/intersection ...).  I couldn't think of one.
>>
>> Breaking this problem out into 'parallel' units of reduction isn't 
>> possible because the problem is dependent on order.  Which reducers can't 
>> have, or so I think after what I have read today.
>>
>>
>> On Friday, January 24, 2014 3:56:23 PM UTC-5, Cedric Greevey wrote:
>>
>>> An interesting question this raises is if there is any sensible way to 
>>> define (intersection). It would need to behave as an identity element for 
>>> intersection, so would need to behave as a set (so, (set? (intersection)) 
>>> => truthy) that contained everything (so, (contains? (intersection) foo) => 
>>> foo no matter what foo is; (partial contains? (intersection)) => identity). 
>>> The problem would be what to do with seq? Ideally an infinite seq that will 
>>> produce any particular value after finite time would be produced, but 
>>> there's no way to sensibly produce "any particular value" given the wide 
>>> variety of constructor semantics, builders, factory methods, things not 
>>> known to this particular runtime instance but that conceptually exist 
>>> somewhere, etc.; of course, the seq return is a dummy of sorts anyway since 
>>> you couldn't really use it sensibly to it might as well just return 
>>> (range). Printing should likely be overridden to just print 
>>> "(intersection)" rather than b0rk the REPL with a neverending stream of 
>>> integers (or whatever).
>>>
>>> But then it also subtly violates another property of Clojure set 
>>> objects: if (= a b), (not (identical? a b)), and (identical? (a-set a) a), 
>>> then (identical? (a-set b) a) and thus (not (identical? (a-set b) b)). The 
>>> latter is true under the hypothesis for every "real" set but would be false 
>>> for (intersection).
>>>
>>> Perhaps this is why (intersection) is not supported at this time, even 
>>> though (union) returns an empty set object, the identity element for the 
>>> union operation.
>>>
>>>
>>>  On Fri, Jan 24, 2014 at 3:34 PM, Jarrod Swart  wrote:
>>>
 Ah cool, thanks for posting your solution!

 On Friday, January 24, 2014 3:29:49 PM UTC-5, Tassilo Horn wrote:

> Jarrod Swart  writes: 
>
> > The reason you can't get this to work is that r/map returns a 
>  
> > not a  for reduce to operate on. 
>
> Ah, indeed.  I couldn't see the forest for the trees. 
>
> > I'm not sure of a solution because I'm not familiar with 
> > core.reducers. 
>
> This works: 
>
>   (reduce set/intersection (r/foldcat (r/map set [[1 2] [3 1] [1 
> 3]]))) 
>
> Bye, 
> Tassilo 
>
  -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clo...@googlegroups.com

 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com

 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google 
 Groups "Clojure" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to clojure+u...@googlegroups.com.

 For more options, visit https://groups.google.com/groups/opt_out.

>>>
>>>  -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>>

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Cedric Greevey
No, the identity for intersection is a set that has everything, as
(intersection A Everything) = A no matter what A is.


On Fri, Jan 24, 2014 at 7:38 PM, Jarrod Swart  wrote:

> Good points.  But the "identity" thing is still what gets me.  What is the
> identity of an intersection?
>
> Like you said it can't be #{}.  If you seed an intersection with #{} you
> get #{}, so you can't intersect from the empty set.  The identity for an
> intersection is whatever the common element is, but how would you know that?
>
> On Friday, January 24, 2014 7:03:40 PM UTC-5, Cedric Greevey wrote:
>
>> Intersection is associative and commutative: (intersection A B) =
>> (intersection B A) and (intersection A (intersection B C)) = (intersection
>> (intersection A B) C) = the elements common to all three sets. So it's
>> actually perfectly well-founded for use with reducers, at least in
>> principle, and intersecting A B C D can be parallelized sensibly by
>> parallel intersecting A B and C D and then intersecting the two resulting
>> sets.
>>
>>
>> On Fri, Jan 24, 2014 at 6:43 PM, Jarrod Swart  wrote:
>>
>>> If I understand you correctly I am in agreement.  I don't think you
>>> could take this problem to clojure.core.reducers/reduce or fold because the
>>> problem is inherently sequential is it not?
>>>
>>> The reduction is basically (intersection (intersection (intersection A
>>> B) C) D).
>>>
>>> I was curious of this myself, how do I abstract out the order of the
>>> (reduce set/intersection ...).  I couldn't think of one.
>>>
>>> Breaking this problem out into 'parallel' units of reduction isn't
>>> possible because the problem is dependent on order.  Which reducers can't
>>> have, or so I think after what I have read today.
>>>
>>>
>>> On Friday, January 24, 2014 3:56:23 PM UTC-5, Cedric Greevey wrote:
>>>
 An interesting question this raises is if there is any sensible way to
 define (intersection). It would need to behave as an identity element for
 intersection, so would need to behave as a set (so, (set? (intersection))
 => truthy) that contained everything (so, (contains? (intersection) foo) =>
 foo no matter what foo is; (partial contains? (intersection)) => identity).
 The problem would be what to do with seq? Ideally an infinite seq that will
 produce any particular value after finite time would be produced, but
 there's no way to sensibly produce "any particular value" given the wide
 variety of constructor semantics, builders, factory methods, things not
 known to this particular runtime instance but that conceptually exist
 somewhere, etc.; of course, the seq return is a dummy of sorts anyway since
 you couldn't really use it sensibly to it might as well just return
 (range). Printing should likely be overridden to just print
 "(intersection)" rather than b0rk the REPL with a neverending stream of
 integers (or whatever).

 But then it also subtly violates another property of Clojure set
 objects: if (= a b), (not (identical? a b)), and (identical? (a-set a) a),
 then (identical? (a-set b) a) and thus (not (identical? (a-set b) b)). The
 latter is true under the hypothesis for every "real" set but would be false
 for (intersection).

 Perhaps this is why (intersection) is not supported at this time, even
 though (union) returns an empty set object, the identity element for the
 union operation.


  On Fri, Jan 24, 2014 at 3:34 PM, Jarrod Swart wrote:

> Ah cool, thanks for posting your solution!
>
> On Friday, January 24, 2014 3:29:49 PM UTC-5, Tassilo Horn wrote:
>
>> Jarrod Swart  writes:
>>
>> > The reason you can't get this to work is that r/map returns a
>> 
>> > not a  for reduce to operate on.
>>
>> Ah, indeed.  I couldn't see the forest for the trees.
>>
>> > I'm not sure of a solution because I'm not familiar with
>> > core.reducers.
>>
>> This works:
>>
>>   (reduce set/intersection (r/foldcat (r/map set [[1 2] [3 1] [1
>> 3]])))
>>
>> Bye,
>> Tassilo
>>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
>
> Note that posts from new members are moderated - please be patient
> with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+u...@googlegroups.com.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

  --
>>> --
>>> You received this mess

Re: core.async over websocket + cljs + clojure

2014-01-24 Thread Patrick Logan
  * one side of the channel is in clojure land
  * other side of the channel is in cljs land

Are you implementing coordination across the wire, as if the two channels 
are "the same virtual channel"? If so, read on... otherwise, n/m, sorry if 
I misinterpreted...

CSP-like channels aren't a good across-the-wire abstraction. Their blocking 
semantics are intended to coordinate concurrency within a single runtime.

To be reliable you'd have to introduce addition machinery to account for 
the hazards of distributed systems, so you're probably better off starting 
with an abstraction that has those hazards in mind already.

I'm unsure what the arguments would be in favor of CSP-like behavior across 
distances, especially between a server (clj) and a browser (cljs)?

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Jarrod Swart
Okay, I see now.  

Thanks for the Socratic dialogue, at the onset of the day I knew nothing 
about core.reducers.  I feel fairly conversational now!

On Friday, January 24, 2014 7:44:03 PM UTC-5, Cedric Greevey wrote:
>
> No, the identity for intersection is a set that has everything, as 
> (intersection A Everything) = A no matter what A is.
>
>
> On Fri, Jan 24, 2014 at 7:38 PM, Jarrod Swart 
> > wrote:
>
>> Good points.  But the "identity" thing is still what gets me.  What is 
>> the identity of an intersection?
>>
>> Like you said it can't be #{}.  If you seed an intersection with #{} you 
>> get #{}, so you can't intersect from the empty set.  The identity for an 
>> intersection is whatever the common element is, but how would you know that?
>>
>> On Friday, January 24, 2014 7:03:40 PM UTC-5, Cedric Greevey wrote:
>>
>>> Intersection is associative and commutative: (intersection A B) = 
>>> (intersection B A) and (intersection A (intersection B C)) = (intersection 
>>> (intersection A B) C) = the elements common to all three sets. So it's 
>>> actually perfectly well-founded for use with reducers, at least in 
>>> principle, and intersecting A B C D can be parallelized sensibly by 
>>> parallel intersecting A B and C D and then intersecting the two resulting 
>>> sets.
>>>
>>>
>>> On Fri, Jan 24, 2014 at 6:43 PM, Jarrod Swart  wrote:
>>>
 If I understand you correctly I am in agreement.  I don't think you 
 could take this problem to clojure.core.reducers/reduce or fold because 
 the 
 problem is inherently sequential is it not?

 The reduction is basically (intersection (intersection (intersection A 
 B) C) D).  

 I was curious of this myself, how do I abstract out the order of the 
 (reduce set/intersection ...).  I couldn't think of one.

 Breaking this problem out into 'parallel' units of reduction isn't 
 possible because the problem is dependent on order.  Which reducers can't 
 have, or so I think after what I have read today.


 On Friday, January 24, 2014 3:56:23 PM UTC-5, Cedric Greevey wrote:

> An interesting question this raises is if there is any sensible way to 
> define (intersection). It would need to behave as an identity element for 
> intersection, so would need to behave as a set (so, (set? (intersection)) 
> => truthy) that contained everything (so, (contains? (intersection) foo) 
> => 
> foo no matter what foo is; (partial contains? (intersection)) => 
> identity). 
> The problem would be what to do with seq? Ideally an infinite seq that 
> will 
> produce any particular value after finite time would be produced, but 
> there's no way to sensibly produce "any particular value" given the wide 
> variety of constructor semantics, builders, factory methods, things not 
> known to this particular runtime instance but that conceptually exist 
> somewhere, etc.; of course, the seq return is a dummy of sorts anyway 
> since 
> you couldn't really use it sensibly to it might as well just return 
> (range). Printing should likely be overridden to just print 
> "(intersection)" rather than b0rk the REPL with a neverending stream of 
> integers (or whatever).
>
> But then it also subtly violates another property of Clojure set 
> objects: if (= a b), (not (identical? a b)), and (identical? (a-set a) 
> a), 
> then (identical? (a-set b) a) and thus (not (identical? (a-set b) b)). 
> The 
> latter is true under the hypothesis for every "real" set but would be 
> false 
> for (intersection).
>
> Perhaps this is why (intersection) is not supported at this time, even 
> though (union) returns an empty set object, the identity element for the 
> union operation.
>
>
>  On Fri, Jan 24, 2014 at 3:34 PM, Jarrod Swart wrote:
>
>> Ah cool, thanks for posting your solution!
>>
>> On Friday, January 24, 2014 3:29:49 PM UTC-5, Tassilo Horn wrote:
>>
>>> Jarrod Swart  writes: 
>>>
>>> > The reason you can't get this to work is that r/map returns a 
>>>  
>>> > not a  for reduce to operate on. 
>>>
>>> Ah, indeed.  I couldn't see the forest for the trees. 
>>>
>>> > I'm not sure of a solution because I'm not familiar with 
>>> > core.reducers. 
>>>
>>> This works: 
>>>
>>>   (reduce set/intersection (r/foldcat (r/map set [[1 2] [3 1] [1 
>>> 3]]))) 
>>>
>>> Bye, 
>>> Tassilo 
>>>
>>  -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>>
>> Note that posts from new members are moderated - please be patient 
>> with your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com
>>
>> For more options

Re: clojure debugging repl

2014-01-24 Thread Alexandr Kurilin
I've been looking for a simple and convenient to use clojure debugger for
ages now and would love to hear your recommendations. I'm a vim-fireplace
user as well, if that makes a difference.

I'd love to be able to set breakpoints in a running clojure application,
step through the code and inspect locals and the referencing environment.
Anything that gets me off of the time-consuming process of adding
timbre/clojure.tools.trace statements would be really welcome. Is vim-redl
the closest I can get to that, or is ritz the way to go? Any other
recommendations?

I'll have to checkout JoC2's chapter on that, that sounds really helpful.


On Fri, Jan 24, 2014 at 4:11 PM, dgrnbrg  wrote:

> I have an implementation of this that's thoroughly integrated into vim.
>
> clojure code: https://github.com/dgrnbrg/redl
> vim plugin: https://github.com/dgrnbrg/vim-redl
>
> The code itself is written with core.async, and is capable of monitoring a
> thread, inspecting its stack while its running, stopping it, and
> programmatically creating breakpoints that give you a repl with captured
> locals.
>
> I'd love for this work to be extended to a generic nrepl handler, but I
> don't have the time to do so at the moment.
>
>
> On Friday, January 24, 2014 6:46:23 PM UTC-5, Jarrod Swart wrote:
>>
>> The second version of The Joy of Clojure talks about building a debugging
>> repl that allows insertion of breakpoints into code.  Perhaps something
>> similar could be done here.
>>
>> On Friday, January 24, 2014 4:38:59 PM UTC-5, t x wrote:
>>>
>>> Found it, apparently it's
>>>
>>> debug-repl => swank-clojure => CDT => ritz
>>>
>>> It appears cider does not yet support this, so ritz is probably the
>>> "most powerful" at the moment.
>>>
>>>
>>> On Fri, Jan 24, 2014 at 3:39 AM, t x  wrote:
>>>
 Hi,

   One thing I miss from pre-Clojure scheme days is as follows:

 ## What I want

 1 => (foo) ;; I'm calling foo at the repl
 ... foo executes ...
 ... at some point, an exception is thrown ...

 2 => my interpreter _starts a new repl_
   * at the point where the exception was thrown
   * lets me examine local environment variables
   * lets me execute commands
   * lets me "resume" the execution


 ## Why "it can't work"

 Now, I understand why this can not work in general in Clojure, i.e. the
 following example:

 (defn foo []
   (.someJavaFunctionThatThrowsException object))

 In this case, the above is impossible since the exception is thrown
 from _java land_ rather than Clojure land.


 ## Why it might work

 Now, I'm not writing any code in java. The work I'm doing is pure
 clojure. I can throw when the exception is thrown.


 Is there some library, where instead of doing

 (defn foo []
   ...
   (throw (ex-data ...))
   ...)

 I instead do:

 (defn foo []
   ...
   (something-went-wrong-please-fire-up-a-repl)
   ...)

 ?

 Thanks!

>>>
>>>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Alexandr Kurilin
206.687.8740 | @alex_kurilin  |
blog

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: core.async over websocket + cljs + clojure

2014-01-24 Thread Logan Linn

>
> To be reliable you'd have to introduce addition machinery to account for 
> the hazards of distributed systems, so you're probably better off starting 
> with an abstraction that has those hazards in mind already.


The WebSocket (protocol) is the machinery that's handling this. We aren't 
discussing using CSP to implement the actual network communication. We 
aren't concerned what happens outside of the edges of the system.

Unlike when using actors, with CSP you don't care where a value you took 
from a channel came from, and similarly you don't care where the value you 
put onto a channel goes. The channel is only a primitive for conveyance. 
The application knows nothing of a WebSocket other than what does the put!s 
and take!s.

CSP-like channels aren't a good across-the-wire abstraction. Their blocking 
> semantics are intended to coordinate concurrency within a single runtime.


Coordination is possible through the blocking semantics of CSP, but isn't 
the only mechanism it provides. CSP also facilitates buffered, asynchronous 
operations. I don't see why it would imply anything about a single runtime.
 

On Friday, January 24, 2014 4:45:01 PM UTC-8, Patrick Logan wrote:
>
>   * one side of the channel is in clojure land
>   * other side of the channel is in cljs land
>
> Are you implementing coordination across the wire, as if the two channels 
> are "the same virtual channel"? If so, read on... otherwise, n/m, sorry if 
> I misinterpreted...
>
> CSP-like channels aren't a good across-the-wire abstraction. Their 
> blocking semantics are intended to coordinate concurrency within a single 
> runtime.
>
> To be reliable you'd have to introduce addition machinery to account for 
> the hazards of distributed systems, so you're probably better off starting 
> with an abstraction that has those hazards in mind already.
>
> I'm unsure what the arguments would be in favor of CSP-like behavior 
> across distances, especially between a server (clj) and a browser (cljs)?
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojure debugging repl

2014-01-24 Thread t x
I am willing to buy the book for this chapter alone.

However, looking at http://www.manning.com/fogus2/ I can't seem to find it.
Which chapter is it?



On Fri, Jan 24, 2014 at 3:46 PM, Jarrod Swart  wrote:

> The second version of The Joy of Clojure talks about building a debugging
> repl that allows insertion of breakpoints into code.  Perhaps something
> similar could be done here.
>
>
> On Friday, January 24, 2014 4:38:59 PM UTC-5, t x wrote:
>
>> Found it, apparently it's
>>
>> debug-repl => swank-clojure => CDT => ritz
>>
>> It appears cider does not yet support this, so ritz is probably the "most
>> powerful" at the moment.
>>
>>
>> On Fri, Jan 24, 2014 at 3:39 AM, t x  wrote:
>>
>>> Hi,
>>>
>>>   One thing I miss from pre-Clojure scheme days is as follows:
>>>
>>> ## What I want
>>>
>>> 1 => (foo) ;; I'm calling foo at the repl
>>> ... foo executes ...
>>> ... at some point, an exception is thrown ...
>>>
>>> 2 => my interpreter _starts a new repl_
>>>   * at the point where the exception was thrown
>>>   * lets me examine local environment variables
>>>   * lets me execute commands
>>>   * lets me "resume" the execution
>>>
>>>
>>> ## Why "it can't work"
>>>
>>> Now, I understand why this can not work in general in Clojure, i.e. the
>>> following example:
>>>
>>> (defn foo []
>>>   (.someJavaFunctionThatThrowsException object))
>>>
>>> In this case, the above is impossible since the exception is thrown from
>>> _java land_ rather than Clojure land.
>>>
>>>
>>> ## Why it might work
>>>
>>> Now, I'm not writing any code in java. The work I'm doing is pure
>>> clojure. I can throw when the exception is thrown.
>>>
>>>
>>> Is there some library, where instead of doing
>>>
>>> (defn foo []
>>>   ...
>>>   (throw (ex-data ...))
>>>   ...)
>>>
>>> I instead do:
>>>
>>> (defn foo []
>>>   ...
>>>   (something-went-wrong-please-fire-up-a-repl)
>>>   ...)
>>>
>>> ?
>>>
>>> Thanks!
>>>
>>
>>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Rename file uploaded

2014-01-24 Thread The Dude (Abides)
Hi Jarrod, I tried changing filename to string as follows 

(defn handle-upload [filename]
 (upload-file (gallery-path) (add-timestamp (str filename)))
 (resp/redirect "/upload"))

and still got an error as:

java.lang.NullPointerException


My entire file code is:

(ns pgapp.routes.upload 
  (:require [compojure.core :refer [defroutes GET POST]]
[pgapp.views.layout :as layout]
[noir.io :refer [upload-file resource-path]]
[noir.session :as session]
[noir.response :as resp]
[noir.util.route :refer [restricted]]
[clojure.java.io :as io]
[ring.util.response :refer [file-response]]
[taoensso.timbre :refer [error]]
[pgapp.models.db :as db]
[clj-time.core :as time]
[clj-time.coerce :as tc]
[pgapp.util
:refer [galleries gallery-path thumb-uri thumb-prefix 
unique-prefix]])
   (:import [java.io File FileInputStream FileOutputStream]
javax.imageio.ImageIO))

(use 'ring.middleware.params
'ring.middleware.multipart-params)

(defn upload-page [info]  
  (layout/render "upload.html"))

(defn add-timestamp [filename]
 (let [ext-position (.lastIndexOf filename ".")
   timestamp(tc/to-long (time/now))]
   (if (pos? ext-position)
 (str (.substring filename 0 ext-position)
  "-" timestamp (.substring filename ext-position))
 (str filename "-" timestamp

(defn handle-upload [filename]
 (upload-file (gallery-path) (add-timestamp (str filename)))
 (resp/redirect "/upload"))

(defroutes myapp-routes
  (GET "/upload" [info] (upload-page {:info info}))
  (POST "/upload" [file] (handle-upload file)))

I changed filename to (str filename) in the handle-upload function, but 
still no dice :(

The :refer [galleries gallery-path thumb-uri thumb-prefix unique-prefix]]) 
are just references to file paths in util.clj vs hardcoding them.

I got productive with clojure ref routes, sessions, views with selmer and 
queries either raw or with korma all easy peasy. However this one thing, 
this file upload issue has thrown me for a loop for 3 days now :) It is the 
bane of my existence right now :) 

If I can get a handle on it, am considering creating a library to make this 
easier akin to file upload plugins in ruby world like carrier-wave. Thanks 
for any pointers on what I'm doing wrong with the above code.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Looking for a reference binary parsing

2014-01-24 Thread Kashyap CK
Thank you for the pointers.

Regards,
Kashyap

On Saturday, January 25, 2014 5:43:09 AM UTC+5:30, dgrnbrg wrote:
>
> I have found Gloss to be a pleasure to work with, and the fact that it 
> handles framing, arbitrary header logic, and streaming decoding made it the 
> best choice when I was writing codecs for binary formats whose files 
> didn't/needed to be streamed, rather than bulk-loaded.
>
> On Friday, January 24, 2014 10:56:23 AM UTC-5, James Reeves wrote:
>>
>> You might want to take a look at Gloss ( 
>> https://github.com/ztellman/gloss ) and Buffy ( 
>> https://github.com/clojurewerkz/buffy ).
>>
>> - James
>>
>>
>> On 24 January 2014 15:08, Kashyap CK  wrote:
>>
>>> Hi,
>>> I need to write a parser for MP4 - essentially, read an MP4 file and 
>>> create an in-memory representation of its structure.
>>> I'd appreciate it very much if I could get some suggestions on libraries 
>>> that I could use for this.
>>> Is there a https://github.com/youngnh/parsatron like library that works 
>>> on binary files as well?
>>> Regards,
>>> Kashyap
>>>
>>> -- 
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with 
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to clojure+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Web App structure on server?

2014-01-24 Thread Jarrod Swart
I have a general question about application architecture as it relates to 
deploying to the server.  

Most of my previous development work involved python/php/ruby so we 
typically had:

  1. One massive framework / application complection nightmare
  2. Background scripts run by crons
  
At present I am working on an application for a client, and I am trying to 
weasel in Clojure where I can.  I will likely have to make the Clojure 
aspects a black box.

If I were doing this in another language I would simply write the smaller 
pieces of functionality as python scripts, plop them on the server and then 
set the crons.

How do I do this with Clojure?  If I package each micro-app as an uberjar 
that is a lot of JVM, likely eating at the resources of the poor (see: 
crappy) VPSs this project will likely run on.

Thoughts?

How do you structure web Clojure apps beyond: put the whole thing in a 
servlet\uberjar?

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Rename file uploaded

2014-01-24 Thread Jarrod Swart
Well that isn't quite what I meant.  In that case you are just casting what 
is likely the map of upload data to a string.

Try this:

(defn handle-upload [filename]
   (str filename))

Why?  This will show you what type of data you receiving on upload.  My 
guess is that it is a map containing all the data about the file upload.

Following this: 
http://www.luminusweb.net/docs/static_resources.md#handling_file_uploads should 
help.

In short: you still don't have the right kind of data going into your 
function.  Change your handle-upload to the above and verify that you are 
getting the filename alone in your (let [filename (...)] ...) binding.

Hope that helps.

On Friday, January 24, 2014 11:28:00 PM UTC-5, The Dude (Abides) wrote:
>
> Hi Jarrod, I tried changing filename to string as follows 
>
> (defn handle-upload [filename]
>  (upload-file (gallery-path) (add-timestamp (str filename)))
>  (resp/redirect "/upload"))
>
> and still got an error as:
>
> java.lang.NullPointerException
>
>
> My entire file code is:
>
> (ns pgapp.routes.upload 
>   (:require [compojure.core :refer [defroutes GET POST]]
> [pgapp.views.layout :as layout]
> [noir.io :refer [upload-file resource-path]]
> [noir.session :as session]
> [noir.response :as resp]
> [noir.util.route :refer [restricted]]
> [clojure.java.io :as io]
> [ring.util.response :refer [file-response]]
> [taoensso.timbre :refer [error]]
> [pgapp.models.db :as db]
> [clj-time.core :as time]
> [clj-time.coerce :as tc]
> [pgapp.util
> :refer [galleries gallery-path thumb-uri thumb-prefix 
> unique-prefix]])
>(:import [java.io File FileInputStream FileOutputStream]
> javax.imageio.ImageIO))
>
> (use 'ring.middleware.params
> 'ring.middleware.multipart-params)
>
> (defn upload-page [info]  
>   (layout/render "upload.html"))
>
> (defn add-timestamp [filename]
>  (let [ext-position (.lastIndexOf filename ".")
>timestamp(tc/to-long (time/now))]
>(if (pos? ext-position)
>  (str (.substring filename 0 ext-position)
>   "-" timestamp (.substring filename ext-position))
>  (str filename "-" timestamp
>
> (defn handle-upload [filename]
>  (upload-file (gallery-path) (add-timestamp (str filename)))
>  (resp/redirect "/upload"))
>
> (defroutes myapp-routes
>   (GET "/upload" [info] (upload-page {:info info}))
>   (POST "/upload" [file] (handle-upload file)))
>
> I changed filename to (str filename) in the handle-upload function, but 
> still no dice :(
>
> The :refer [galleries gallery-path thumb-uri thumb-prefix unique-prefix]]) 
> are just references to file paths in util.clj vs hardcoding them.
>
> I got productive with clojure ref routes, sessions, views with selmer and 
> queries either raw or with korma all easy peasy. However this one thing, 
> this file upload issue has thrown me for a loop for 3 days now :) It is the 
> bane of my existence right now :) 
>
> If I can get a handle on it, am considering creating a library to make 
> this easier akin to file upload plugins in ruby world like carrier-wave. 
> Thanks for any pointers on what I'm doing wrong with the above code.
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojure debugging repl

2014-01-24 Thread Jarrod Swart
Its a part of Chapter 17, just so you know its only a small exercise 
showing the beauty of Clojure, Lisp and Macros.  Its only about 6 six 
pages.  The footnote:

The code in this section is based on *debug-repl* created by the amazing 
George Jahad,
extended by Alex Osborne, and integrated into Swank-Clojure by Hugo Duncan.

So maybe check those out.  That said I think its a really good book and 
Manning often has specials going so you get Joy of Clojure 1 & 2 for cheap.

On Friday, January 24, 2014 8:51:16 PM UTC-5, t x wrote:
>
> I am willing to buy the book for this chapter alone.
>
> However, looking at http://www.manning.com/fogus2/ I can't seem to find 
> it. Which chapter is it?
>
>
>
> On Fri, Jan 24, 2014 at 3:46 PM, Jarrod Swart 
> > wrote:
>
>> The second version of The Joy of Clojure talks about building a debugging 
>> repl that allows insertion of breakpoints into code.  Perhaps something 
>> similar could be done here.
>>
>>
>> On Friday, January 24, 2014 4:38:59 PM UTC-5, t x wrote:
>>
>>> Found it, apparently it's
>>>
>>> debug-repl => swank-clojure => CDT => ritz
>>>
>>> It appears cider does not yet support this, so ritz is probably the 
>>> "most powerful" at the moment.
>>>
>>>
>>> On Fri, Jan 24, 2014 at 3:39 AM, t x  wrote:
>>>
 Hi,

   One thing I miss from pre-Clojure scheme days is as follows:

 ## What I want

 1 => (foo) ;; I'm calling foo at the repl
 ... foo executes ...
 ... at some point, an exception is thrown ...

 2 => my interpreter _starts a new repl_
   * at the point where the exception was thrown
   * lets me examine local environment variables
   * lets me execute commands
   * lets me "resume" the execution


 ## Why "it can't work"

 Now, I understand why this can not work in general in Clojure, i.e. the 
 following example:

 (defn foo []
   (.someJavaFunctionThatThrowsException object))

 In this case, the above is impossible since the exception is thrown 
 from _java land_ rather than Clojure land.


 ## Why it might work

 Now, I'm not writing any code in java. The work I'm doing is pure 
 clojure. I can throw when the exception is thrown.


 Is there some library, where instead of doing

 (defn foo []
   ...
   (throw (ex-data ...))
   ...)

 I instead do:

 (defn foo []
   ...
   (something-went-wrong-please-fire-up-a-repl)
   ...)

 ?
  
 Thanks!

>>>
>>>  -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Web App structure on server?

2014-01-24 Thread Mikera
Be careful about "weaselling in" Clojure - If I was your client and you did 
that without consulting me, I'd be pretty annoyed (possibly to the extent 
of not working with you again). Better to be upfront about the good reasons 
for using Clojure (concurrency support, awesome libraries, productivity 
etc.)

On the server architecture side: I think it's preferable to package things 
together into a big JVM instance. Reasons:
- It's relatively easy to make some lightweight compojure routes to bundle 
different APIs / micro-apps together in one app server
- It will make deployment much simpler: you can often get away with 
something as simple as: java -jar myserver.jar
- You'll accumulate less duplication / technical debt if you keep 
everything in sync (library versions, shared utility code etc.)
- A single large JVM instance will have a lot less overhead compared to 
multiple small JVMs
- JVM applications are better suited in general to long-running instances 
rather than small scripts

I'd consider breaking this into multiple instances only if there was a good 
reason, e.g.
- Need for process isolation for security / robustness reasons
- Need to have different lifecycles for different application servers.

Basically you can think of it this way:
- cron jobs => process coordination within the server (perhaps core.async, 
or other scheduling tools)
- python scripts / micro-apps => separate Compojure routes / APIs within 
the server
- hacking at the command line => hacking with the REPL 


On Saturday, 25 January 2014 12:58:03 UTC+8, Jarrod Swart wrote:
>
> I have a general question about application architecture as it relates to 
> deploying to the server.  
>
> Most of my previous development work involved python/php/ruby so we 
> typically had:
>
>   1. One massive framework / application complection nightmare
>   2. Background scripts run by crons
>   
> At present I am working on an application for a client, and I am trying to 
> weasel in Clojure where I can.  I will likely have to make the Clojure 
> aspects a black box.
>
> If I were doing this in another language I would simply write the smaller 
> pieces of functionality as python scripts, plop them on the server and then 
> set the crons.
>
> How do I do this with Clojure?  If I package each micro-app as an uberjar 
> that is a lot of JVM, likely eating at the resources of the poor (see: 
> crappy) VPSs this project will likely run on.
>
> Thoughts?
>
> How do you structure web Clojure apps beyond: put the whole thing in a 
> servlet\uberjar?
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Rename file uploaded

2014-01-24 Thread The Dude (Abides)
Hi Jarrod, you're exactly right, filename feeds the entire map as:

{:size 17401, :tempfile #, :content-type "image/jpeg", :filename 
"AngryBaby4.jpg"}

How can feed it just the :filename portion of the map as string to the 
add-timestamp function? Checking that link right now.

On Friday, January 24, 2014 9:05:35 PM UTC-8, Jarrod Swart wrote:
>
> Well that isn't quite what I meant.  In that case you are just casting 
> what is likely the map of upload data to a string.
>
> Try this:
>
> (defn handle-upload [filename]
>(str filename))
>
> Why?  This will show you what type of data you receiving on upload.  My 
> guess is that it is a map containing all the data about the file upload.
>
> Following this: 
> http://www.luminusweb.net/docs/static_resources.md#handling_file_uploads 
> should 
> help.
>
> In short: you still don't have the right kind of data going into your 
> function.  Change your handle-upload to the above and verify that you are 
> getting the filename alone in your (let [filename (...)] ...) binding.
>
> Hope that helps.
>
> On Friday, January 24, 2014 11:28:00 PM UTC-5, The Dude (Abides) wrote:
>>
>> Hi Jarrod, I tried changing filename to string as follows 
>>
>> (defn handle-upload [filename]
>>  (upload-file (gallery-path) (add-timestamp (str filename)))
>>  (resp/redirect "/upload"))
>>
>> and still got an error as:
>>
>> java.lang.NullPointerException
>>
>>
>> My entire file code is:
>>
>> (ns pgapp.routes.upload 
>>   (:require [compojure.core :refer [defroutes GET POST]]
>> [pgapp.views.layout :as layout]
>> [noir.io :refer [upload-file resource-path]]
>> [noir.session :as session]
>> [noir.response :as resp]
>> [noir.util.route :refer [restricted]]
>> [clojure.java.io :as io]
>> [ring.util.response :refer [file-response]]
>> [taoensso.timbre :refer [error]]
>> [pgapp.models.db :as db]
>> [clj-time.core :as time]
>> [clj-time.coerce :as tc]
>> [pgapp.util
>> :refer [galleries gallery-path thumb-uri thumb-prefix 
>> unique-prefix]])
>>(:import [java.io File FileInputStream FileOutputStream]
>> javax.imageio.ImageIO))
>>
>> (use 'ring.middleware.params
>> 'ring.middleware.multipart-params)
>>
>> (defn upload-page [info]  
>>   (layout/render "upload.html"))
>>
>> (defn add-timestamp [filename]
>>  (let [ext-position (.lastIndexOf filename ".")
>>timestamp(tc/to-long (time/now))]
>>(if (pos? ext-position)
>>  (str (.substring filename 0 ext-position)
>>   "-" timestamp (.substring filename ext-position))
>>  (str filename "-" timestamp
>>
>> (defn handle-upload [filename]
>>  (upload-file (gallery-path) (add-timestamp (str filename)))
>>  (resp/redirect "/upload"))
>>
>> (defroutes myapp-routes
>>   (GET "/upload" [info] (upload-page {:info info}))
>>   (POST "/upload" [file] (handle-upload file)))
>>
>> I changed filename to (str filename) in the handle-upload function, but 
>> still no dice :(
>>
>> The :refer [galleries gallery-path thumb-uri thumb-prefix 
>> unique-prefix]]) are just references to file paths in util.clj vs 
>> hardcoding them.
>>
>> I got productive with clojure ref routes, sessions, views with selmer and 
>> queries either raw or with korma all easy peasy. However this one thing, 
>> this file upload issue has thrown me for a loop for 3 days now :) It is the 
>> bane of my existence right now :) 
>>
>> If I can get a handle on it, am considering creating a library to make 
>> this easier akin to file upload plugins in ruby world like carrier-wave. 
>> Thanks for any pointers on what I'm doing wrong with the above code.
>>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Web App structure on server?

2014-01-24 Thread Jarrod Swart
I appreciate your outlook, and yes I have definitely discussed the pros of 
Clojure.  They are apprehensive in the event they have to outsource 
development work, and I don't blame them.  I'm just going to be a lot 
happier and more productive in Clojure.

Thanks again!



On Saturday, January 25, 2014 12:25:51 AM UTC-5, Mikera wrote:
>
> Be careful about "weaselling in" Clojure - If I was your client and you 
> did that without consulting me, I'd be pretty annoyed (possibly to the 
> extent of not working with you again). Better to be upfront about the good 
> reasons for using Clojure (concurrency support, awesome libraries, 
> productivity etc.)
>
> On the server architecture side: I think it's preferable to package things 
> together into a big JVM instance. Reasons:
> - It's relatively easy to make some lightweight compojure routes to bundle 
> different APIs / micro-apps together in one app server
> - It will make deployment much simpler: you can often get away with 
> something as simple as: java -jar myserver.jar
> - You'll accumulate less duplication / technical debt if you keep 
> everything in sync (library versions, shared utility code etc.)
> - A single large JVM instance will have a lot less overhead compared to 
> multiple small JVMs
> - JVM applications are better suited in general to long-running instances 
> rather than small scripts
>
> I'd consider breaking this into multiple instances only if there was a 
> good reason, e.g.
> - Need for process isolation for security / robustness reasons
> - Need to have different lifecycles for different application servers.
>
> Basically you can think of it this way:
> - cron jobs => process coordination within the server (perhaps core.async, 
> or other scheduling tools)
> - python scripts / micro-apps => separate Compojure routes / APIs within 
> the server
> - hacking at the command line => hacking with the REPL 
>
>
> On Saturday, 25 January 2014 12:58:03 UTC+8, Jarrod Swart wrote:
>>
>> I have a general question about application architecture as it relates to 
>> deploying to the server.  
>>
>> Most of my previous development work involved python/php/ruby so we 
>> typically had:
>>
>>   1. One massive framework / application complection nightmare
>>   2. Background scripts run by crons
>>   
>> At present I am working on an application for a client, and I am trying 
>> to weasel in Clojure where I can.  I will likely have to make the Clojure 
>> aspects a black box.
>>
>> If I were doing this in another language I would simply write the smaller 
>> pieces of functionality as python scripts, plop them on the server and then 
>> set the crons.
>>
>> How do I do this with Clojure?  If I package each micro-app as an uberjar 
>> that is a lot of JVM, likely eating at the resources of the poor (see: 
>> crappy) VPSs this project will likely run on.
>>
>> Thoughts?
>>
>> How do you structure web Clojure apps beyond: put the whole thing in a 
>> servlet\uberjar?
>>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Rename file uploaded

2014-01-24 Thread Jarrod Swart
You need to change your timestamp function to this, my change in bold:

(defn add-timestamp [filename]
 (let [ext-position (.lastIndexOf *(:filename filename)* ".")
   timestamp(tc/to-long (time/now))]
   (if (pos? ext-position)
 (str (.substring filename 0 ext-position)
  "-" timestamp (.substring filename ext-position))
 (str filename "-" timestamp

Do you see why?  The original error you got was telling you that: 
.lasIndexOf is not a method you can call on (what was at the time) a 
clojure map.  Now you are extracting the filename from upload map by using 
the fact that maps are functions of their keys.  .lastIndexOf will now 
operate on a string successfully.

Best,
Jarrod

On Saturday, January 25, 2014 12:36:45 AM UTC-5, The Dude (Abides) wrote:
>
> Hi Jarrod, you're exactly right, filename feeds the entire map as:
>
> {:size 17401, :tempfile #, :content-type "image/jpeg", :filename 
> "AngryBaby4.jpg"}
>
> How can feed it just the :filename portion of the map as string to the 
> add-timestamp function? Checking that link right now.
>
> On Friday, January 24, 2014 9:05:35 PM UTC-8, Jarrod Swart wrote:
>>
>> Well that isn't quite what I meant.  In that case you are just casting 
>> what is likely the map of upload data to a string.
>>
>> Try this:
>>
>> (defn handle-upload [filename]
>>(str filename))
>>
>> Why?  This will show you what type of data you receiving on upload.  My 
>> guess is that it is a map containing all the data about the file upload.
>>
>> Following this: 
>> http://www.luminusweb.net/docs/static_resources.md#handling_file_uploads 
>> should 
>> help.
>>
>> In short: you still don't have the right kind of data going into your 
>> function.  Change your handle-upload to the above and verify that you are 
>> getting the filename alone in your (let [filename (...)] ...) binding.
>>
>> Hope that helps.
>>
>> On Friday, January 24, 2014 11:28:00 PM UTC-5, The Dude (Abides) wrote:
>>>
>>> Hi Jarrod, I tried changing filename to string as follows 
>>>
>>> (defn handle-upload [filename]
>>>  (upload-file (gallery-path) (add-timestamp (str filename)))
>>>  (resp/redirect "/upload"))
>>>
>>> and still got an error as:
>>>
>>> java.lang.NullPointerException
>>>
>>>
>>> My entire file code is:
>>>
>>> (ns pgapp.routes.upload 
>>>   (:require [compojure.core :refer [defroutes GET POST]]
>>> [pgapp.views.layout :as layout]
>>> [noir.io :refer [upload-file resource-path]]
>>> [noir.session :as session]
>>> [noir.response :as resp]
>>> [noir.util.route :refer [restricted]]
>>> [clojure.java.io :as io]
>>> [ring.util.response :refer [file-response]]
>>> [taoensso.timbre :refer [error]]
>>> [pgapp.models.db :as db]
>>> [clj-time.core :as time]
>>> [clj-time.coerce :as tc]
>>> [pgapp.util
>>> :refer [galleries gallery-path thumb-uri thumb-prefix 
>>> unique-prefix]])
>>>(:import [java.io File FileInputStream FileOutputStream]
>>> javax.imageio.ImageIO))
>>>
>>> (use 'ring.middleware.params
>>> 'ring.middleware.multipart-params)
>>>
>>> (defn upload-page [info]  
>>>   (layout/render "upload.html"))
>>>
>>> (defn add-timestamp [filename]
>>>  (let [ext-position (.lastIndexOf filename ".")
>>>timestamp(tc/to-long (time/now))]
>>>(if (pos? ext-position)
>>>  (str (.substring filename 0 ext-position)
>>>   "-" timestamp (.substring filename ext-position))
>>>  (str filename "-" timestamp
>>>
>>> (defn handle-upload [filename]
>>>  (upload-file (gallery-path) (add-timestamp (str filename)))
>>>  (resp/redirect "/upload"))
>>>
>>> (defroutes myapp-routes
>>>   (GET "/upload" [info] (upload-page {:info info}))
>>>   (POST "/upload" [file] (handle-upload file)))
>>>
>>> I changed filename to (str filename) in the handle-upload function, but 
>>> still no dice :(
>>>
>>> The :refer [galleries gallery-path thumb-uri thumb-prefix 
>>> unique-prefix]]) are just references to file paths in util.clj vs 
>>> hardcoding them.
>>>
>>> I got productive with clojure ref routes, sessions, views with selmer 
>>> and queries either raw or with korma all easy peasy. However this one 
>>> thing, this file upload issue has thrown me for a loop for 3 days now :) It 
>>> is the bane of my existence right now :) 
>>>
>>> If I can get a handle on it, am considering creating a library to make 
>>> this easier akin to file upload plugins in ruby world like carrier-wave. 
>>> Thanks for any pointers on what I'm doing wrong with the above code.
>>>
>>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For m

Re: Rename file uploaded

2014-01-24 Thread Jarrod Swart
I'm sorry I glossed over your code.  Leave (add-timestamp) the same but do 
this:

(defn handle-upload [filename]
 (upload-file (gallery-path) (add-timestamp *(:filename filename)*))
 (resp/redirect "/upload"))

On Saturday, January 25, 2014 12:36:45 AM UTC-5, The Dude (Abides) wrote:
>
> Hi Jarrod, you're exactly right, filename feeds the entire map as:
>
> {:size 17401, :tempfile #, :content-type "image/jpeg", :filename 
> "AngryBaby4.jpg"}
>
> How can feed it just the :filename portion of the map as string to the 
> add-timestamp function? Checking that link right now.
>
> On Friday, January 24, 2014 9:05:35 PM UTC-8, Jarrod Swart wrote:
>>
>> Well that isn't quite what I meant.  In that case you are just casting 
>> what is likely the map of upload data to a string.
>>
>> Try this:
>>
>> (defn handle-upload [filename]
>>(str filename))
>>
>> Why?  This will show you what type of data you receiving on upload.  My 
>> guess is that it is a map containing all the data about the file upload.
>>
>> Following this: 
>> http://www.luminusweb.net/docs/static_resources.md#handling_file_uploads 
>> should 
>> help.
>>
>> In short: you still don't have the right kind of data going into your 
>> function.  Change your handle-upload to the above and verify that you are 
>> getting the filename alone in your (let [filename (...)] ...) binding.
>>
>> Hope that helps.
>>
>> On Friday, January 24, 2014 11:28:00 PM UTC-5, The Dude (Abides) wrote:
>>>
>>> Hi Jarrod, I tried changing filename to string as follows 
>>>
>>> (defn handle-upload [filename]
>>>  (upload-file (gallery-path) (add-timestamp (str filename)))
>>>  (resp/redirect "/upload"))
>>>
>>> and still got an error as:
>>>
>>> java.lang.NullPointerException
>>>
>>>
>>> My entire file code is:
>>>
>>> (ns pgapp.routes.upload 
>>>   (:require [compojure.core :refer [defroutes GET POST]]
>>> [pgapp.views.layout :as layout]
>>> [noir.io :refer [upload-file resource-path]]
>>> [noir.session :as session]
>>> [noir.response :as resp]
>>> [noir.util.route :refer [restricted]]
>>> [clojure.java.io :as io]
>>> [ring.util.response :refer [file-response]]
>>> [taoensso.timbre :refer [error]]
>>> [pgapp.models.db :as db]
>>> [clj-time.core :as time]
>>> [clj-time.coerce :as tc]
>>> [pgapp.util
>>> :refer [galleries gallery-path thumb-uri thumb-prefix 
>>> unique-prefix]])
>>>(:import [java.io File FileInputStream FileOutputStream]
>>> javax.imageio.ImageIO))
>>>
>>> (use 'ring.middleware.params
>>> 'ring.middleware.multipart-params)
>>>
>>> (defn upload-page [info]  
>>>   (layout/render "upload.html"))
>>>
>>> (defn add-timestamp [filename]
>>>  (let [ext-position (.lastIndexOf filename ".")
>>>timestamp(tc/to-long (time/now))]
>>>(if (pos? ext-position)
>>>  (str (.substring filename 0 ext-position)
>>>   "-" timestamp (.substring filename ext-position))
>>>  (str filename "-" timestamp
>>>
>>> (defn handle-upload [filename]
>>>  (upload-file (gallery-path) (add-timestamp (str filename)))
>>>  (resp/redirect "/upload"))
>>>
>>> (defroutes myapp-routes
>>>   (GET "/upload" [info] (upload-page {:info info}))
>>>   (POST "/upload" [file] (handle-upload file)))
>>>
>>> I changed filename to (str filename) in the handle-upload function, but 
>>> still no dice :(
>>>
>>> The :refer [galleries gallery-path thumb-uri thumb-prefix 
>>> unique-prefix]]) are just references to file paths in util.clj vs 
>>> hardcoding them.
>>>
>>> I got productive with clojure ref routes, sessions, views with selmer 
>>> and queries either raw or with korma all easy peasy. However this one 
>>> thing, this file upload issue has thrown me for a loop for 3 days now :) It 
>>> is the bane of my existence right now :) 
>>>
>>> If I can get a handle on it, am considering creating a library to make 
>>> this easier akin to file upload plugins in ruby world like carrier-wave. 
>>> Thanks for any pointers on what I'm doing wrong with the above code.
>>>
>>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


What's your testing flow with the current clj tools?

2014-01-24 Thread Alexandr Kurilin
I've been running my app's tests through `lein test` (most often for
specific namespaces) for a long time now, but after reading Leiningen's
recommendationto
run them from the REPL I decided I should figure out how to make this
happen.

I've heard a few options on this subject, and would love to know what you
yourselves use. A couple I stumbled upon were:


   - In your favorite editor with nrepl/cider, do some work in the ns
   you're testing, reload it from within the editor, then switch to the
   testing ns and run (clojure.test/run-tests) from within. Then when you're
   done with your work, run a `lein test` just in case your state while
   nrepling in was corrupted or another ns was affected etc.
   - Use your favorite editor with nrepl/cider to work on the app's ns, but
   then switch to a repl started within `lein repl` in which you're only
   running tests. This potentially helps with a slightly cleaner state. (I'm
   not clear how you'd reload the app's ns without the hassle of having to
   always (require) the right set of changed nses)
   - In a new `lein repl`, use bultitude, load all test nses, use
   clojure.test/run-all-tests with the right regex. Like `lein repl`, minus
   having to spin up a new JVM every time.

I'm currently playing around with the first approach. I'd love to know if I
missed something much more effective, or if I can make this a bit simpler
and less manual. Tips would be greatly welcome.

Cheers!

-- 
Alexandr Kurilin
206.687.8740 | @alex_kurilin  |
blog

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Rename file uploaded

2014-01-24 Thread The Dude (Abides)
Hi Jarrod, thanks for your help. I tried that but got a 

java.lang.NullPointerException error again.

I tried the code without the add-timestamp and still get the 

java.lang.NullPointerException

When I try it as just :filename filename it does in fact show only the file 
name. 

So not sure why this is being so tricky, rest of clojure stuff has been 
very straightforward, this one file load issue is more boilerplate than I'm 
used to in ruby or coldfusion, and it just seems v tricky as the error 
codes are not yielding the source of the problem or maybe I don't yet know 
how to interpret them properly. 

It doesn't seem the problem is in the "add-timestamp" function, as the 
operation croaks even before getting there when I isolate it to just 
'handle-upload' function without ever calling the add-timestamp function. 

I'll post the entire code again just in case you may spot where the error 
maybe. Perhaps the problem is in the libs I'm requiring or importing? Again 
thanks for taking a look, much appreciated.

(ns pgapp.routes.upload
  (:require [compojure.core :refer [defroutes GET POST]]
[pgapp.views.layout :as layout]
[noir.io :refer [upload-file resource-path]]
[noir.session :as session]
[noir.response :as resp]
[noir.util.route :refer [restricted]]
[clojure.java.io :as io]
[ring.util.response :refer [file-response]]
[taoensso.timbre :refer [error]]
[pgapp.models.db :as db]
[clj-time.core :as time]
[clj-time.coerce :as tc]
[pgapp.util
:refer [galleries gallery-path thumb-uri thumb-prefix 
unique-prefix]])
   (:import [java.io File FileInputStream FileOutputStream]
javax.imageio.ImageIO))

(defn upload-page [info]  
  (layout/render "upload.html"))

(defn add-timestamp [filename]
 (let [ext-position (.lastIndexOf filename ".")
   timestamp(tc/to-long (time/now))]
   (if (pos? ext-position)
 (str (.substring filename 0 ext-position)
  "-" timestamp (.substring filename ext-position))
 (str filename "-" timestamp

(defn handle-upload [filename]
 (upload-file (gallery-path) (add-timestamp (:filename filename)))
 (resp/redirect "/upload"))

(defroutes upload-routes
  (GET "/upload" [info] (upload-page {:info info}))
  (POST "/upload" [file] (handle-upload file)))

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Web App structure on server?

2014-01-24 Thread Joshua Ballanco
I just wanted to point out that if you’re looking to write small background 
processes that are more shell-script-y than server-y, you might consider CLJS + 
Node.js. That way you can still leverage Clojure without the need to spin up an 
entire JVM just for a quick cron task.  

Cheers,

Josh


On Saturday, January 25, 2014 at 7:40, Jarrod Swart wrote:

> I appreciate your outlook, and yes I have definitely discussed the pros of 
> Clojure. They are apprehensive in the event they have to outsource 
> development work, and I don't blame them. I'm just going to be a lot happier 
> and more productive in Clojure.
>  
> Thanks again!
>  
>  
>  
> On Saturday, January 25, 2014 12:25:51 AM UTC-5, Mikera wrote:
> > Be careful about "weaselling in" Clojure - If I was your client and you did 
> > that without consulting me, I'd be pretty annoyed (possibly to the extent 
> > of not working with you again). Better to be upfront about the good reasons 
> > for using Clojure (concurrency support, awesome libraries, productivity 
> > etc.)
> >  
> > On the server architecture side: I think it's preferable to package things 
> > together into a big JVM instance. Reasons:
> > - It's relatively easy to make some lightweight compojure routes to bundle 
> > different APIs / micro-apps together in one app server
> > - It will make deployment much simpler: you can often get away with 
> > something as simple as: java -jar myserver.jar
> > - You'll accumulate less duplication / technical debt if you keep 
> > everything in sync (library versions, shared utility code etc.)
> > - A single large JVM instance will have a lot less overhead compared to 
> > multiple small JVMs
> > - JVM applications are better suited in general to long-running instances 
> > rather than small scripts
> >  
> > I'd consider breaking this into multiple instances only if there was a good 
> > reason, e.g.
> > - Need for process isolation for security / robustness reasons
> > - Need to have different lifecycles for different application servers.
> >  
> >  
> > Basically you can think of it this way:
> > - cron jobs => process coordination within the server (perhaps core.async, 
> > or other scheduling tools)
> > - python scripts / micro-apps => separate Compojure routes / APIs within 
> > the server
> > - hacking at the command line => hacking with the REPL  
> >  
> >  
> > On Saturday, 25 January 2014 12:58:03 UTC+8, Jarrod Swart wrote:
> > > I have a general question about application architecture as it relates to 
> > > deploying to the server.  
> > >  
> > > Most of my previous development work involved python/php/ruby so we 
> > > typically had:
> > >  
> > > 1. One massive framework / application complection nightmare
> > > 2. Background scripts run by crons
> > >  
> > > At present I am working on an application for a client, and I am trying 
> > > to weasel in Clojure where I can. I will likely have to make the Clojure 
> > > aspects a black box.
> > >  
> > > If I were doing this in another language I would simply write the smaller 
> > > pieces of functionality as python scripts, plop them on the server and 
> > > then set the crons.
> > >  
> > > How do I do this with Clojure? If I package each micro-app as an uberjar 
> > > that is a lot of JVM, likely eating at the resources of the poor (see: 
> > > crappy) VPSs this project will likely run on.
> > >  
> > > Thoughts?
> > >  
> > > How do you structure web Clojure apps beyond: put the whole thing in a 
> > > servlet\uberjar?  
>  
> --  
> --  
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com 
> (mailto:clojure@googlegroups.com)
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com 
> (mailto:clojure+unsubscr...@googlegroups.com)
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---  
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com 
> (mailto:clojure+unsubscr...@googlegroups.com).
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+u

Re: Web App structure on server?

2014-01-24 Thread Craig

My current approach accords with Mikera's suggestion, and using a single 
package allows me to easily leverage other components (management, database 
etc).  I have an open mind on the future use of isolated scripts (in python 
or whatever), but at the moment I am enjoying the simplicity of developing 
and deploying one artifact.

On Saturday, January 25, 2014 3:58:03 PM UTC+11, Jarrod Swart wrote:
>
> I have a general question about application architecture as it relates to 
> deploying to the server.  
>
> Most of my previous development work involved python/php/ruby so we 
> typically had:
>
>   1. One massive framework / application complection nightmare
>   2. Background scripts run by crons
>   
> At present I am working on an application for a client, and I am trying to 
> weasel in Clojure where I can.  I will likely have to make the Clojure 
> aspects a black box.
>
> If I were doing this in another language I would simply write the smaller 
> pieces of functionality as python scripts, plop them on the server and then 
> set the crons.
>
> How do I do this with Clojure?  If I package each micro-app as an uberjar 
> that is a lot of JVM, likely eating at the resources of the poor (see: 
> crappy) VPSs this project will likely run on.
>
> Thoughts?
>
> How do you structure web Clojure apps beyond: put the whole thing in a 
> servlet\uberjar?
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.