Re: datomic question

2013-03-04 Thread edward
Thanks very much Michael and Jonas.

On Monday, 4 March 2013 07:20:24 UTC, Jonas wrote:

 Hi

 You can use the tempid (
 http://docs.datomic.com/clojure/index.html#datomic.api/tempid) function 
 to generate new temporary ids.

 Jonas

 On Monday, March 4, 2013 8:50:56 AM UTC+2, edw...@kenworthy.info wrote:

 Okay, I think I understand that.

 Does that mean this code could never work as intended in a Clojure 
 program, only at the repl (which seems a bit of a limitation) or is there a 
 way to make it work as intended, generating a different id each time? Or is 
 the whole approach taken in this code flawed?

 On Sunday, 3 March 2013 21:59:45 UTC, Michał Marczyk wrote:

 #db/id ... is a tagged literal. It gets read in as an id object with 
 some integer inside. The way this happens is that the reader looks up 
 a data reader function associated with the symbol db/id in the map 
 held by the var *data-readers* and passes to it the result of parsing 
 the rest of the literal (a vector holding the keyword :db.part/db in 
 this case). Importantly, this function is not pure and the integer it 
 uses will be different on each invocation. (Given this form of the 
 #db/id literal; you can also specify a particular number yourself -- 
 #db/id [:db.part/db some-number-here].) 

 In any case, once the reader reads in your code including some 
 particular id, the compiler will compile the result preserving the 
 particular values it sees, so it will embed code to construct *exactly 
 this* id in the compiled output. Thus you end up with a particular id 
 hardwired into the first version of your function. 

 With the second version, if you invoke it multiple times at the REPL, 
 you ask the reader for a new id at each invocation, so it works as you 
 expect. If instead you were to use it inside a function like so: 

 (defn foo [] 
   (make-column-schema #db/id [:db.part/db] :results/subject 
 :db.type/string)), 

 then again the same id would be used for every (foo) call. 

 Cheers, 
 Michał 


 On 3 March 2013 21:58,  edw...@kenworthy.info wrote: 
  So, I am studying a piece of code from the web. I've dissected most of 
 it 
  and am in the process of re-factoring it. 
  
  What I don't understand is why one version works and the other 
 doesn't. 
  
  So for both: 
  
  (ns gcse-results.core (:use [datomic.api :only [q db] :as d]) (:use 
  quil.core)) 
  
  This doesn't work: 
  
  (defn make-column-schema [db-ident db-type] 
  {:db/id #db/id[:db.part/db] 
  :db/ident db-ident 
  :db/valueType db-type 
  :db/cardinality :db.cardinality/one 
  :db.install/_attribute :db.part/db}) 
  
  Each call to: 
  
  (make-column-schema :results/subject :db.type/string) 
  
  The value of #db/id[:db.part/db] is the same. 
  
  And this works: 
  
  (defn make-column-schema [db-id db-ident db-type] 
  {:db/id db-id 
  :db/ident db-ident 
  :db/valueType db-type 
  :db/cardinality :db.cardinality/one 
  :db.install/_attribute :db.part/db}) 
  
  Each call to: (make-column-schema #db/id[:db.part/db] :results/subject 
  :db.type/string) 
  
  The value of #db/id[:db.part/db] is the different, as expected. 
  
  Now I thought that I understood #db/id[:db.part/db] (call to a Java 
  constructor) but obviously my understanding is flawed as I would 
 expect both 
  of these functions to produce the same thing, but they don't so 
 there's 
  obviously some gap in my understanding. 
  
  Help? 
  
  -- 
  -- 
  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: Wrong clojure version depending on lein dependencies

2013-03-04 Thread Frank Siebenlist
Excellent - thanks for letting me know - Frank.


On Mar 3, 2013, at 11:37 PM, Tassilo Horn t...@gnu.org wrote:

 Frank Siebenlist frank.siebenl...@gmail.com writes:
 
 Hi Frank,
 
 clj-ns-browser 1.3.1 is released and addresses this issue by upgrading
 the project's dependencies to seesaw 1.4.3.
 
 With 1.3.1 I could remove all the :excusions again and it still picked
 the right clojure version (1.5.0).
 
 Thanks,
 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: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Wolodja Wentland
On Sat, Mar 02, 2013 at 17:42 -0600, Nelson Morris wrote:

  Or is this a bug in leiningen's dependency resolution?

 Unfortunately it's behaviour defined by maven.  In order to be compatible
 lein has to do the same thing.

 I've written up a few things about version ranges at
 http://nelsonmorris.net/2012/07/31/do-not-use-version-ranges-in-project-clj.html
 and in some other mailing list threads.  

I would like to note that there is /nothing/ wrong with version ranges in
general and it would be very good if the Clojure tooling would actually
support proper and expressive dependency definitions. Unfortunately it does
not, which seems to be a bug in maven or in the fact that Clojure relies on
this. It is also ridiculous that RC or alpha/beta releases are treated in the
same way as actual ones.

Maybe it would be good to think about how this unfortunate behaviour can be
fixed, rather than relying on having to hardcode very specific dependencies.
(as in dependency on X.Y.Z even though the library in question provides a
stable API in all X.* releases)

I think this would have the following positive effects:

* Projects don't have to constantly monitor new releases of new libraries
  and bug authors of libraries they use to do the same

* Library authors would be more concerned about providing a stable
  interface for all releases that fall into a certain version span

* Packaging software and tools by downstream distributions (e.g. Debian,
  Ubuntu, …), so that Clojure software can be easily used by people that
  are /not/ familiar with Clojure can still easily use software written in
  it, would be much easier.

* Deployment would be more predictable as people know that they target
  only stable releases.

I know that I am coming from a different culture than the Let's package
everything in a jar and it is good, but I believe that there is merit in
stabilizing APIs and in relying on libraries that honour this. I am also aware
that my experience with Python's batteries included, Haskell's platform,
C's SONAMEs or Debian's packaging system might have spoiled me, but still ...

It is up to a community to fix things that are broken in their toolset and Do
not use version ranges is IMHO the wrong answer.
-- 
Wolodja babi...@gmail.com

4096R/CAF14EFC
081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC


signature.asc
Description: Digital signature


Re: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Meikel Brandmeyer (kotarak)
Hi,

Am Montag, 4. März 2013 13:00:31 UTC+1 schrieb Wolodja Wentland:


 It is up to a community to fix things that are broken in their toolset and 
 Do 
 not use version ranges is IMHO the wrong answer. 


Huge +1.

I was about to blog in favour of version ranges. As I'm a toolmaker myself, 
I wanted to first spike a proof-of-concept of a saner dependency resolution 
library (it can't be thaaat hard, right? kind of run-up-a-wall-soon 
project). However now I will blog anyway and get to code later on.

Having detailed dependency reports with sane information as they were added 
lately to leiningen and gradle are a first step. A sane resolution strategy 
is the next. (Funnily ivy already seems to provide 
thathttp://www.docjar.com/docs/api/org/apache/ivy/plugins/conflict/LatestCompatibleConflictManager.html
...)

Meikel

-- 
-- 
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: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Chas Emerick
On Mar 4, 2013, at 7:36 AM, Meikel Brandmeyer (kotarak) wrote:

 Hi,
 
 Am Montag, 4. März 2013 13:00:31 UTC+1 schrieb Wolodja Wentland:
 
 It is up to a community to fix things that are broken in their toolset and 
 Do 
 not use version ranges is IMHO the wrong answer. 
 
 
 Huge +1.
 
 I was about to blog in favour of version ranges. As I'm a toolmaker myself, I 
 wanted to first spike a proof-of-concept of a saner dependency resolution 
 library (it can't be thaaat hard, right? kind of run-up-a-wall-soon 
 project). However now I will blog anyway and get to code later on.
 
 Having detailed dependency reports with sane information as they were added 
 lately to leiningen and gradle are a first step. A sane resolution strategy 
 is the next. (Funnily ivy already seems to provide that...)

FWIW, contributors to Pomegranate and Leiningen are working on general 
solutions to this sort of madness, but the use of version ranges will always be 
largely unwarranted, especially in published libraries.

There are a lot of reasons for this, but #1 for me is that few people 
understand the implications of version ranges, either downstream of their 
published libraries or when they are consuming a library and place a range 
around its resolution.  If you do, and your team does, then by all means, go 
hog-wild with version ranges in your in-house libraries and applications, where 
you can control versioning schemes, correspondences between APIs and versions, 
and so on.  However, none of those standards apply in the commons, so ranges 
like the one that provoked the problem in this case ([org.clojure/clojure 
[1.2,1.5)]) are counterproductive (i.e. there is no reason to prospectively 
exclude an unreleased version unless you're certain that API changes will break 
the library in question).  Granted, the fallback resolution of the 
Leiningen/Pomegranate/Aether triad fall down badly, which exacerbates the 
problem; again, that's being worked on, but the solution still won't help in 
this situation where a library blocks out e.g. 1.5.0, but a downstream 
user/library explicitly specifies 1.5.0.

I feel like I'm light-years OT, so I won't wade into the Ivy vs. Aether morass; 
suffice it to say, if there were a silver bullet — and there's not — Ivy 
wouldn't be it.

Cheers,

- Chas

-- 
-- 
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: Wrong clojure version depending on lein dependencies

2013-03-04 Thread Hugo Duncan
Meikel Brandmeyer (kotarak) m...@kotka.de writes:

 Hi,

 Am Montag, 4. März 2013 13:00:31 UTC+1 schrieb Wolodja Wentland:

 It is up to a community to fix things that are broken in their toolset and 
 Do not use version ranges is IMHO the wrong answer. 

 Huge +1.

Fixing version ranges seems like a good idea (e.g. I just ended up with
commons-logging on the classpath, I think due to clojure 1.5.0 being
released).  Maven's answer to these issues seems to be use
dependencyManagement [1].

I still think the valid use cases of version ranges are quite limited
though.  When does using version ranges make sense? Or thinking from a
lein perspective, what features does lein need to provide for specifying
dependency versions, and are version ranges the best way of expressing
these?

Hugo

[1] 
http://www.sonatype.com/books/mvnref-book/reference/pom-relationships-sect-project-dependencies.html#pom-relationships-sect-version-ranges

-- 
-- 
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: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Meikel Brandmeyer (kotarak)
Hi Chas,

Am Montag, 4. März 2013 14:33:29 UTC+1 schrieb Chas Emerick:

 There are a lot of reasons for this, but #1 for me is that few people 
 understand the implications of version ranges, either downstream of their 
 published libraries or when they are consuming a library and place a range 
 around its resolution.  If you do, and your team does, then by all means, 
 go hog-wild with version ranges in your in-house libraries and 
 applications, where you can control versioning schemes, correspondences 
 between APIs and versions, and so on.  However, none of those standards 
 apply in the commons, so ranges like the one that provoked the problem in 
 this case ([org.clojure/clojure [1.2,1.5)]) are counterproductive (i.e. 
 there is no reason to prospectively exclude an unreleased version unless 
 you're certain that API changes will break the library in question). 
  Granted, the fallback resolution of the Leiningen/Pomegranate/Aether triad 
 fall down badly, which exacerbates the problem; again, that's being worked 
 on, but the solution still won't help in this situation where a library 
 blocks out e.g. 1.5.0, but a downstream user/library explicitly specifies 
 1.5.0.


Ok. So instead of the range I specify [org.clojure/clojure 1.2]. What 
does that mean? Now I either excluded *all* clojure versions not= 1.2 or 
the version number doesn't mean anything. Then we should get rid of it 
completely and just specify the dependency without it. (It seems there 
maven poms which do exactly that? o.O)

The range [1.2;1.5) means that the library was tested with 1.2 up to 1.4 
and - believing in semver - their patchlevel children. 1.5 (was at that 
time) not released, yet. So compatibility couldn't be guaranteed. For me 
this is a reasonable approach. Sure. It might work with 1.5. Everyone is 
free to place an exclusion to help the system resolve the conflict. But you 
must be aware you might run into trouble.

If I follow your approach I must provide 4 branches of a library which 
basically consists of a single function: one branch per supported clojure 
version (so far). This is ridiculous. Or - as I said - we let all hope go 
and don't specify the version, only the dependency on the library itself.

I see we have a different basic idea of what a version range should mean. 
For me it's a promise that my library will work with the versions 
specified. If one wants to use a version outside the range, that *might* be 
ok, but one should be aware and pointed to that fact and the decision to do 
so should be explicit!

I'm probably just a pessimist, while you are an optimist.

Meikel

-- 
-- 
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: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Michał Marczyk
Hi Wolodja,

It's useful to note that you can use the currently preferred fixed
version specifiers and still have your dependencies and the top-level
project depend on multiple versions of a library (the common case is
multiple versions of Clojure specified as dependencies).

Also, you can specify a baseline version requirement in project.clj
and then still specify tests for your library including alternative
version sets; that makes explicit what has been tested and what simply
might work.

Apart from noting the above, I have to say I simply don't see the
benefit of version ranges. Here's a bunch of comments on the list of
positive effects:

On 4 March 2013 13:00, Wolodja Wentland babi...@gmail.com wrote:
 I think this would have the following positive effects:

 * Projects don't have to constantly monitor new releases of new libraries
   and bug authors of libraries they use to do the same

That is true today in the sense that if your code works now, it will
continue to work regardless of which libraries release new versions,
as long as you don't change your :dependencies in project.clj or the
equivalent for your build tool.

On the other hand, if you care about securing your project, pulling in
the latest bugfixes etc., you will need to monitor new releases
anyway, regardless of the version numbering scheme used by their
maintainers.

 * Library authors would be more concerned about providing a stable
   interface for all releases that fall into a certain version span

Those library authors who care about this already act in this way.

 * Packaging software and tools by downstream distributions (e.g. Debian,
   Ubuntu, …), so that Clojure software can be easily used by people that
   are /not/ familiar with Clojure can still easily use software written in
   it, would be much easier.

Are people actually using package managers for Java libraries and
applications much, beyond a small number of special cases like
LibreOffice (which therefore can totally be packaged überjar-like)?

 * Deployment would be more predictable as people know that they target
   only stable releases.

In the absence of version ranges, that seems to be true today...?

 I know that I am coming from a different culture than the Let's package
 everything in a jar and it is good, but I believe that there is merit in
 stabilizing APIs and in relying on libraries that honour this. I am also aware
 that my experience with Python's batteries included, Haskell's platform,
 C's SONAMEs or Debian's packaging system might have spoiled me, but still ...

Here's a relevant link to a post on Yesod's blog from April 2012 (one
of top Haskell web frameworks):

http://www.yesodweb.com/blog/2012/04/cabal-meta

And here's an interesting quote (again, this is from Yesod's own
blog): Even with all these tools, one day I found myself completely
incapable of installng Yesod from source.

I know Cabal is improving and it actually has a shot at solving some
truly interesting problems with dependency handling, but right now I
find it surprising that one could feel spoiled by using it to the
point of feeling discomfort in Clojure land. (We actually have it
simpler for example in that we don't have to deal much with
assumptions baked into previously compiled artefacts; I'm not knocking
Cabal here in any way, just noting that it's not all that rosy.)

 It is up to a community to fix things that are broken in their toolset and Do
 not use version ranges is IMHO the wrong answer.

There's value in using Maven simply for the easy interop with the vast
Java ecosystem behind it. Maven's (Aether's?) handling of version
ranges appears to be counterintuitive. I'm not sure to which degree
this can be fixed on the Leiningen / Pomegranate side, but if we do
expend effort fixing that, what can we expect to get in return?

Cheers,
Michał


 --
 Wolodja babi...@gmail.com

 4096R/CAF14EFC
 081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC

-- 
-- 
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: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Wolodja Wentland
On Mon, Mar 04, 2013 at 08:33 -0500, Chas Emerick wrote:

 FWIW, contributors to Pomegranate and Leiningen are working on general
 solutions to this sort of madness, but the use of version ranges will always 
 be
 largely unwarranted, especially in published libraries.

 There are a lot of reasons for this, but #1 for me is that few people
 understand the implications of version ranges, either downstream of their
 published libraries or when they are consuming a library and place a range
 around its resolution.

I can not really agree with this as there are also a lot of authors of
libraries who do take versioning serious and who wouldn't, for example, break
API compatibility in a minor version. (e.g. between X.Y.Z and X.Y.Z+1 or even
X.Y+1). It would be wonderful if I, as a consumer or that library, could
simply state that my code works with all versions in the X.* version range
(but for example that it is not expected to work with X+1.*).

The specification of dependencies has to be done on a per-library basis and
will, naturally, take the versioning scheme of the specific library into
account. If I know that I can trust the author of the library to /not/ break
API compatibility in future minor releases I want to express that. I might
have even tested my code against a specific version range and want to
communicate that.

I think that the ability to specify ranges like this would actually increase
pressure to adhere to reasonable versioning schemes and, ultimately, even
better code in the community. (Simply because downstream consumers would
complain bitterly about API changes in minor releases that break their code).

 However, none of those standards apply in the commons, so ranges
 like the one that provoked the problem in this case ([org.clojure/clojure 
 [1.2,1.5)]) are counterproductive (i.e. there is no reason to prospectively
 exclude an unreleased version unless you're certain that API changes will 
 break
 the library in question).

I agree completely that it does not make sense to proactively /exclude/ a
specific unreleased version from being used, but it also doesn't make sense to
depend on *one* very specific version. It is also ridiculous that there is no
differentiation between release candidates and proper releases, but that is,
yet, another can of worms.

Things that most commonly have to be expressed are. for example, the
following:

* I need at least version 1.4 to work correctly and I know that everything
  older than 2.0 won't work

* My library wraps the 3.* range of releases of the Java library
  foo-to-be-wrapped and I have enough test cases to be sure of that

…

I would love if I wouldn't have to start every week with running lein outdated
and then guessing which of the libraries can be updated without breaking
something. I want my code to simply run on the newest version of the libraries
that I (and their upstream) support. If one of those versions breaks my code
that would be bug that has to be fixed.

I am well aware that the current toolset is not ideal for these situations and
that this is also a bit of a culture clash, but there is nothing inherently
wrong with being able to specify versions in a more expressive way. The
current toolset might not be ideal, but that is a problem of the toolset and
the way software is being distributed, not with the scheme itself.
-- 
Wolodja babi...@gmail.com

4096R/CAF14EFC
081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC


signature.asc
Description: Digital signature


Re: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Wolodja Wentland
On Mon, Mar 04, 2013 at 06:01 -0800, Meikel Brandmeyer (kotarak) wrote:
 Ok. So instead of the range I specify [org.clojure/clojure 1.2]. What does
 that mean? Now I either excluded *all* clojure versions not= 1.2 or the 
 version
 number doesn't mean anything. Then we should get rid of it completely and just
 specify the dependency without it. (It seems there maven poms which do exactly
 that? o.O)
 
 The range [1.2;1.5) means that the library was tested with 1.2 up to 1.4 and -
 believing in semver - their patchlevel children. 1.5 (was at that time) not
 released, yet. So compatibility couldn't be guaranteed. For me this is a
 reasonable approach. Sure. It might work with 1.5. Everyone is free to place 
 an
 exclusion to help the system resolve the conflict. But you must be aware you
 might run into trouble.
 
 If I follow your approach I must provide 4 branches of a library which
 basically consists of a single function: one branch per supported clojure
 version (so far). This is ridiculous. Or - as I said - we let all hope go and
 don't specify the version, only the dependency on the library itself.
 
 I see we have a different basic idea of what a version range should mean. For
 me it's a promise that my library will work with the versions specified. If 
 one
 wants to use a version outside the range, that *might* be ok, but one should 
 be
 aware and pointed to that fact and the decision to do so should be explicit!
 
 I'm probably just a pessimist, while you are an optimist.

Exactly! Thank you for stating this so clearly.
-- 
Wolodja babi...@gmail.com

4096R/CAF14EFC
081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC


signature.asc
Description: Digital signature


Re: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Michał Marczyk
On 4 March 2013 15:01, Meikel Brandmeyer (kotarak) m...@kotka.de wrote:
 The range [1.2;1.5) means that the library was tested with 1.2 up to 1.4 and
 - believing in semver - their patchlevel children. 1.5 (was at that time)
 not released, yet. So compatibility couldn't be guaranteed. For me this is a
 reasonable approach. Sure. It might work with 1.5. Everyone is free to place
 an exclusion to help the system resolve the conflict. But you must be aware
 you might run into trouble.

Better yet, you can specify a test matrix for your library. Of course
there's a bit of a combinatorial problem here, which however is not
solved by the version ranges: in fact to be thorough you should
probably run your tests with any valid selection of versions for the
dependencies -- imagine if you have ten ranges including two actually
released versions each specified in your project.clj...

But even overlooking that, using a baseline version and explicit tests
(or, failing that, a line in the README) to document what's the
minimum requirement and what has been tested seems sane to me *and* it
allows us to reuse the Maven infrastructure. What's there to be gained
by insisting on an improved version range handling?

Also, what impact would version ranges have on repeatability of builds?

Cheers,
M.

-- 
-- 
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: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Marko Topolnik
On Monday, March 4, 2013 3:01:13 PM UTC+1, Meikel Brandmeyer (kotarak) 
wrote:


 The range [1.2;1.5) means that the library was tested with 1.2 up to 1.4 
 and - believing in semver - their patchlevel children. 1.5 (was at that 
 time) not released, yet. So compatibility couldn't be guaranteed. For me 
 this is a reasonable approach. Sure. It might work with 1.5. Everyone is 
 free to place an exclusion to help the system resolve the conflict. But you 
 must be aware you might run into trouble.


This resembles Java's checked exceptions: the user should be warned; in 
reality it just causes frustrations. Libraries break even when they are 
within the declared range: nobody can predict all the interactions. On the 
other hand, most of the time an upgrade wouldn't hurt, but is prevented by 
a defensive version range, and this actually breaks down the whole build 
due to a lower bound by another library.

If a feature ends up having to be defused more often than it provides 
value, then it's not a feature. I second Chas' preference of innocent 
until proven guilty or, as you put it, optimism. 

-- 
-- 
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: byte-array woes

2013-03-04 Thread Karsten Schmidt
Hi Frank, I've added a patch to CLJ-766 with a potential fix. Also,
Andy F. kindly pointed out that interested parties should vote on that
issue to help increase its visibility...

Add your 2 cents here (provided you've a CA):
http://dev.clojure.org/jira/browse/CLJ-766

Best, K.
--
Karsten Schmidt
http://postspectacular.com | http://toxiclibs.org | http://toxi.co.uk


On 3 March 2013 00:01, Frank Siebenlist frank.siebenl...@gmail.com wrote:
 I just ran into that issue while I was constructing byte-arrays for 
 secure-hash test cases.

 Ended-up using (byte-array (vector-of :byte 1 2 3 4)) to avoid writing the 
 (byte-array [(byte 1)(byte 2)(byte 3)(byte 4)]).

 Transparently adding valid byte-number values to a byte-array makes sense and 
 would be helpful.

 Thanks, FrankS.


 On Mar 2, 2013, at 2:49 PM, Karsten Schmidt i...@toxi.co.uk wrote:

 Thanks, Marko! I'd count this as a sort of bug though... at least in
 terms of consistency, since it breaks expected behaviour as
 established by other common array c'tor functions:

 (int-array [1 2 3]) = ok
 (long-array [1 2 3]) = ok
 (float-array [1 2 3]) = ok
 (double-array [1 2 3]) = ok
 (byte-array [1 2 3]) = fail
 (short-array [1 2 3]) = fail
 (char-array [1 2 3]) = fail, but bearable since you'd use shorts
 anyway if you specify chars as numbers

 I had a look at clojure.lang.Numbers.java and found a fix for both
 bytes  shorts:

 Whereas all the working array c'tors functions are using this pattern:

 array[i] = ((Number)s.first()).intValue();

 ... the byte-array  short-array versions attempt to cast the sequence
 items directly, i.e.

 array[i] = (Byte)s.first();

 Changing this to the first pattern (via Number) fixes the issue and
 I'll submit a patch for this...

 Hth! K.
 --
 Karsten Schmidt
 http://postspectacular.com | http://toxiclibs.org | http://toxi.co.uk

 On 2 March 2013 18:43, Marko Topolnik marko.topol...@gmail.com wrote:
 On Saturday, March 2, 2013 6:22:51 PM UTC+1, Karsten Schmidt wrote:


 Is that a bug or can someone please explain why bytes seem to require
 special treatment in Clojure?


 Calling it a bug wouldn't be entirely fair since it's a missing feature. I'd
 say this is filable as an enhancement request.

 -Marko

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



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

Re: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Wolodja Wentland
On Mon, Mar 04, 2013 at 15:04 +0100, Michał Marczyk wrote:

 On the other hand, if you care about securing your project, pulling in
 the latest bugfixes etc., you will need to monitor new releases
 anyway, regardless of the version numbering scheme used by their
 maintainers.

And then release a new version for every new release of one of my depedencies?

  * Library authors would be more concerned about providing a stable
interface for all releases that fall into a certain version span
 
 Those library authors who care about this already act in this way.

Exactly and I would like to take advantage of this. I also think that
establishing reasonable versioning and using version ranges as the norm would
increase the pressure to, well, adhere to the norm by making sure that one
does not break backward compatibility in a minor release.

  * Packaging software and tools by downstream distributions (e.g. Debian,
Ubuntu, …), so that Clojure software can be easily used by people that
are /not/ familiar with Clojure can still easily use software written 
  in
it, would be much easier.
 
 Are people actually using package managers for Java libraries and
 applications much, beyond a small number of special cases like
 LibreOffice (which therefore can totally be packaged überjar-like)?

Yes, a lot of people don't really care in which language a tool is written
(nor should they) and simply want to install that software using their
preferred packaging system.

One reason for the need to not ship the same library all over again and in
using version ranges is one of security. Imagine if a library is found to be
buggy in version 1.2.3 and that a bugfix is available in 1.2.4. In order to
take advantage of this one can either upgrade that single library on a system
and /all other/ applications and libraries using this would be patched
immediately or you could force every consumer to change their dependency on
1.2.3 to 1.2.4 and release a new version.

  * Deployment would be more predictable as people know that they target
only stable releases.

 In the absence of version ranges, that seems to be true today...?

Yes, it is. But then, the environment changes (see above), whereas some of
your assumptions about it might not.

To give an example: I could write code against the standard library that ships
with Python 2.7. I would expect that my code runs with all releases in the
2.7.* version range and would like to express that.

See, for example, http://www.python.org/dev/peps/pep-0426/#version-scheme
for a relevant PEP in the Python community and I am sure you'll find many
other examples for other languages.

 Here's a relevant link to a post on Yesod's blog from April 2012 (one
 of top Haskell web frameworks):
 
 http://www.yesodweb.com/blog/2012/04/cabal-meta
 
 And here's an interesting quote (again, this is from Yesod's own
 blog): Even with all these tools, one day I found myself completely
 incapable of installng Yesod from source.
 
 I know Cabal is improving and it actually has a shot at solving some
 truly interesting problems with dependency handling, but right now I
 find it surprising that one could feel spoiled by using it to the
 point of feeling discomfort in Clojure land. (We actually have it
 simpler for example in that we don't have to deal much with
 assumptions baked into previously compiled artefacts; I'm not knocking
 Cabal here in any way, just noting that it's not all that rosy.)

Fair enough :)
-- 
Wolodja babi...@gmail.com

4096R/CAF14EFC
081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC


signature.asc
Description: Digital signature


Re: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread David Powell
On Mon, Mar 4, 2013 at 2:01 PM, Meikel Brandmeyer (kotarak) 
m...@kotka.dewrote:

 Hi Chas,

 Am Montag, 4. März 2013 14:33:29 UTC+1 schrieb Chas Emerick:

 There are a lot of reasons for this, but #1 for me is that few people
 understand the implications of version ranges, either downstream of their
 published libraries or when they are consuming a library and place a range
 around its resolution.  If you do, and your team does, then by all means,
 go hog-wild with version ranges in your in-house libraries and
 applications, where you can control versioning schemes, correspondences
 between APIs and versions, and so on.  However, none of those standards
 apply in the commons, so ranges like the one that provoked the problem in
 this case ([org.clojure/clojure [1.2,1.5)]) are counterproductive (i.e.
 there is no reason to prospectively exclude an unreleased version unless
 you're certain that API changes will break the library in question).
  Granted, the fallback resolution of the Leiningen/Pomegranate/Aether triad
 fall down badly, which exacerbates the problem; again, that's being worked
 on, but the solution still won't help in this situation where a library
 blocks out e.g. 1.5.0, but a downstream user/library explicitly specifies
 1.5.0.


 Ok. So instead of the range I specify [org.clojure/clojure 1.2]. What
 does that mean? Now I either excluded *all* clojure versions not= 1.2 or
 the version number doesn't mean anything. Then we should get rid of it
 completely and just specify the dependency without it. (It seems there
 maven poms which do exactly that? o.O)


(Disclaimer - I'm no Maven expert)

1.2 in this case is a soft dependency on 1.2.  This is probably what
you want.


http://docs.codehaus.org/display/MAVEN/Dependency+Mediation+and+Conflict+Resolution#DependencyMediationandConflictResolution-DependencyVersionRanges


This differs from [1.2,1.5), which is a hard dependency of 1.2 = ver 
1.5

I don't know the exact details, but a soft dependency basically means, that
the library would like 1.2, but if something else ends up requiring 1.3 or
something, then that will be ok.  This way the top-level application can
ultimately decide which versions are included.  This seems to be the most
flexible, and repeatable option.


Version ranges aren't for communicating what versions of libraries you have
tested against - that is best done out-of-band.  If you include a version
range, like the one above, you are saying that you want the software to
fail to build if something ends up requiring 1.5.  This probably isn't
useful, as it will just lead to difficult to fix problems for library
consumers.  I guess the only time you might want a maximum version to be
specified, is if that version exists, and is known to be incompatible with
your library.

-- 
-- 
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: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Chas Emerick
On Mar 4, 2013, at 9:01 AM, Meikel Brandmeyer (kotarak) wrote:

 Hi Chas,
 
 Am Montag, 4. März 2013 14:33:29 UTC+1 schrieb Chas Emerick:
 There are a lot of reasons for this, but #1 for me is that few people 
 understand the implications of version ranges, either downstream of their 
 published libraries or when they are consuming a library and place a range 
 around its resolution.  If you do, and your team does, then by all means, go 
 hog-wild with version ranges in your in-house libraries and applications, 
 where you can control versioning schemes, correspondences between APIs and 
 versions, and so on.  However, none of those standards apply in the commons, 
 so ranges like the one that provoked the problem in this case 
 ([org.clojure/clojure [1.2,1.5)]) are counterproductive (i.e. there is no 
 reason to prospectively exclude an unreleased version unless you're certain 
 that API changes will break the library in question).  Granted, the fallback 
 resolution of the Leiningen/Pomegranate/Aether triad fall down badly, which 
 exacerbates the problem; again, that's being worked on, but the solution 
 still won't help in this situation where a library blocks out e.g. 1.5.0, but 
 a downstream user/library explicitly specifies 1.5.0.
 
 Ok. So instead of the range I specify [org.clojure/clojure 1.2]. What 
 does that mean? Now I either excluded *all* clojure versions not= 1.2 or the 
 version number doesn't mean anything. Then we should get rid of it completely 
 and just specify the dependency without it. (It seems there maven poms which 
 do exactly that? o.O)
 
 The range [1.2;1.5) means that the library was tested with 1.2 up to 1.4 and 
 - believing in semver - their patchlevel children. 1.5 (was at that time) not 
 released, yet. So compatibility couldn't be guaranteed. For me this is a 
 reasonable approach. Sure. It might work with 1.5. Everyone is free to place 
 an exclusion to help the system resolve the conflict. But you must be aware 
 you might run into trouble.
 
 If I follow your approach I must provide 4 branches of a library which 
 basically consists of a single function: one branch per supported clojure 
 version (so far). This is ridiculous. Or - as I said - we let all hope go and 
 don't specify the version, only the dependency on the library itself.
 
 I see we have a different basic idea of what a version range should mean. For 
 me it's a promise that my library will work with the versions specified. If 
 one wants to use a version outside the range, that *might* be ok, but one 
 should be aware and pointed to that fact and the decision to do so should be 
 explicit!
 
 I'm probably just a pessimist, while you are an optimist.

AFAICT, the vast majority of Leiningen users (same goes for Maven users as 
well) expect the dependency vector [org.clojure/clojure 1.2.0] to establish a 
lower bound, the equivalent of [1.2.0,).  Further, people expect the maximum 
of all overlapping requirements to be taken (so transitive dependencies 
requiring e.g. 1.2.0, 1.3.0, and 1.4.0 would resolve to 1.4.0), and for 
the dependencies specified in the root of the tree (i.e. the current 
project.clj) to override everything else, so specifying 1.3.1 in the current 
project would be the equivalent of [1.3.1] (this is equivalent to having 
implicit dependencyManagement in Maven, for those that know/care what that 
means).

That's just my personal observation, but others that have done work in this 
area seem to agree on the general outline.  Further, it *should* be compatible 
with the existing Aether/Maven ecosystem that we're playing in; there, bare 
version numbers are purely advisory, so constraining them to set a lower bound 
is sane.  We'll see what happens when such a dependency resolution scheme is 
tested against the current defaults.

Re: what version numbers *should* mean, etc., at least when it comes to 
publicly-published libraries: I don't think it's a matter of optimism vs. 
pessimism.  A minor point is that, if you release a library with a constraint 
of [1.2.0,1.5.0), then to get an updated version that has an updated 
constraint, users may (will inevitably) have to swallow API or semantic changes 
that are orthogonal to the notion of tested with.  More importantly, users of 
libraries are always going to upgrade their dependencies faster than those 
dependencies' authors can qualify new releases against *their* dependencies.  
Indeed, given the way things work these days, projects constantly rely upon 
others' rarely-maintained work: people's interests and priorities shift, but if 
their libraries continue to work, then requiring everyone else to either wait 
for a new release (and for all intervening transitive dependencies to update 
accordingly) or manually override version ranges is counterproductive.  Signal 
re: breakage caused by some version X of a library will always propagate faster 
(and probably more accurately) by users bumping into things than by a careful 
author 

Re: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Wolodja Wentland
On Mon, Mar 04, 2013 at 14:42 +, David Powell wrote:

 1.2 in this case is a soft dependency on 1.2.  This is probably what you
 want.
 
 http://docs.codehaus.org/display/MAVEN/
 Dependency+Mediation+and+Conflict+Resolution#
 DependencyMediationandConflictResolution-DependencyVersionRanges

Then why declare a versioned dependency in the first place?
-- 
Wolodja babi...@gmail.com

4096R/CAF14EFC
081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC


signature.asc
Description: Digital signature


Re: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Marko Topolnik
On Monday, March 4, 2013 3:42:56 PM UTC+1, David Powell wrote:


 Version ranges aren't for communicating what versions of libraries you 
 have tested against - that is best done out-of-band.  If you include a 
 version range, like the one above, you are saying that you want the 
 software to fail to build if something ends up requiring 1.5.  This 
 probably isn't useful, as it will just lead to difficult to fix problems 
 for library consumers.


The left-bounded, right-unbounded range seems to be the best practice since 
we always know the lowest acceptable version. 
 

 I guess the only time you might want a maximum version to be specified, is 
 if that version exists, and is known to be incompatible with your library.


Even here we shouldn't be too eager: only if the *official API* of a 
dependency acquires a breaking change should we use an upper bound; if 
there's just a single version out there that fails due to a bug, no action 
should be taken.

-Marko

-- 
-- 
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: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread David Powell
On Mon, Mar 4, 2013 at 2:55 PM, Wolodja Wentland babi...@gmail.com wrote:

 On Mon, Mar 04, 2013 at 14:42 +, David Powell wrote:

  1.2 in this case is a soft dependency on 1.2.  This is probably what
 you
  want.
 
  http://docs.codehaus.org/display/MAVEN/
  Dependency+Mediation+and+Conflict+Resolution#
  DependencyMediationandConflictResolution-DependencyVersionRanges

 Then why declare a versioned dependency in the first place?


It effectively declares a lower-bound on the version number.

-- 
Dave

-- 
-- 
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: [GSoC 2013] CinC

2013-03-04 Thread Aaron Cohen
I think there probably is pretty easily a few months work there.

If more work were needed, it would be interesting to try to get the
clojurescript and clojure compilers using the same front-end. I'm fairly
confident that's at least a summer's work. :)

--Aaron


On Sat, Mar 2, 2013 at 11:05 AM, Ambrose Bonnaire-Sergeant 
abonnaireserge...@gmail.com wrote:

 Is there enough to do here for a few months work? I've added a new project
 here:

 http://dev.clojure.org/display/community/Project+Ideas#ProjectIdeas-ClojureinClojure

 Feel free to change it Aaron.

 Thanks,
 Ambrose

 On Sat, Mar 2, 2013 at 2:11 PM, Aaron Cohen aa...@assonance.org wrote:

 I'd really like to see this happen actually.

 If there's interest I'd be happy to help or mentor.

 The current status is that I have a commit that needs finishing to
 implement letfn and I believe that was the last major special form that
 needed implementing in the compiler.

 Next up would be figuring out how to bootstrap a little better. It would
 also be nice to pull in the work that's been done recently on the reader in
 clojure and datastructures in clojure.


 On Sat, Mar 2, 2013 at 12:50 AM, Ambrose Bonnaire-Sergeant 
 abonnaireserge...@gmail.com wrote:

 Hi,

 I think completing Aaron Cohen's CinC implementation would be a
 fantastic GSoC 2013 project.

 https://github.com/remleduff/CinC

 Is Aaron willing to mentor this project? If the core.typed proposal
 isn't chosen, I would be interested in
 this project also as a student.

 Thoughts?

 Thanks,
 Ambrose


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




-- 
-- 
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: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Wolodja Wentland
On Mon, Mar 04, 2013 at 09:54 -0500, Chas Emerick wrote:
 AFAICT, the vast majority of Leiningen users (same goes for Maven users as
 well) expect the dependency vector [org.clojure/clojure 1.2.0] to establish 
 a
 lower bound, the equivalent of [1.2.0,).  Further, people expect the maximum
 of all overlapping requirements to be taken (so transitive dependencies
 requiring e.g. 1.2.0, 1.3.0, and 1.4.0 would resolve to 1.4.0), and 
 for
 the dependencies specified in the root of the tree (i.e. the current
 project.clj) to override everything else, so specifying 1.3.1 in the current
 project would be the equivalent of [1.3.1] (this is equivalent to having
 implicit dependencyManagement in Maven, for those that know/care what that
 means).

[…]

 I agree that some indication of which libraries have been tested with which
 dependencies would be *great*.  But that's part of a wide class of 
 verification
 objectives I think that must be totally separate use cases from the
 (relatively) simple dependency resolution one that version numbers aim to
 support.

Thanks for this mail! I think it is very helpful in the debate. The notion of
soft dependencies seems to be quite ridiculous (as you could just have an
unversioned one), but the real problem seem to be that there is no way to
express the notion of:

I (should) work with all stable releases in the 1.4.* branch of libfoo

among many other reasonable schemes.
-- 
Wolodja babi...@gmail.com

4096R/CAF14EFC
081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC


signature.asc
Description: Digital signature


Re: [GSoC 2013] CinC

2013-03-04 Thread Ambrose Bonnaire-Sergeant
Any prospective students interested?

On Mon, Mar 4, 2013 at 11:04 PM, Aaron Cohen aa...@assonance.org wrote:

 I think there probably is pretty easily a few months work there.

 If more work were needed, it would be interesting to try to get the
 clojurescript and clojure compilers using the same front-end. I'm fairly
 confident that's at least a summer's work. :)

 --Aaron


 On Sat, Mar 2, 2013 at 11:05 AM, Ambrose Bonnaire-Sergeant 
 abonnaireserge...@gmail.com wrote:

 Is there enough to do here for a few months work? I've added a new
 project here:

 http://dev.clojure.org/display/community/Project+Ideas#ProjectIdeas-ClojureinClojure

 Feel free to change it Aaron.

 Thanks,
 Ambrose

 On Sat, Mar 2, 2013 at 2:11 PM, Aaron Cohen aa...@assonance.org wrote:

 I'd really like to see this happen actually.

 If there's interest I'd be happy to help or mentor.

 The current status is that I have a commit that needs finishing to
 implement letfn and I believe that was the last major special form that
 needed implementing in the compiler.

 Next up would be figuring out how to bootstrap a little better. It would
 also be nice to pull in the work that's been done recently on the reader in
 clojure and datastructures in clojure.


 On Sat, Mar 2, 2013 at 12:50 AM, Ambrose Bonnaire-Sergeant 
 abonnaireserge...@gmail.com wrote:

 Hi,

 I think completing Aaron Cohen's CinC implementation would be a
 fantastic GSoC 2013 project.

 https://github.com/remleduff/CinC

 Is Aaron willing to mentor this project? If the core.typed proposal
 isn't chosen, I would be interested in
 this project also as a student.

 Thoughts?

 Thanks,
 Ambrose


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




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




how to get SHA1 of a string?

2013-03-04 Thread larry google groups

I have been having problems making an API call to Omniture. I have
exchanged a dozen emails with a developer at Omniture, and he gave me
the impression that I was constructing my security codes incorrectly.
So now I am confronting my ignorance over how Java handles certain
conversions.

The developer at Omniture sent me this explanation in an email:

 The security digest is formed from a sha1 hash of the following
string concatenation:
digest = sha1( Binary Nonce + Created Time String + API Secret Hex
String (32 bytes) )  

I have been struggling with this for several days and I have tried at
least (literally) 200 variations on this bit of code:

(let [username (get-in @um/interactions [:omniture-api-
credentials :username])
  secret (get-in @um/interactions [:omniture-api-
credentials :shared-secret])
  nonce (DigestUtils/md5Hex (random-string 32))
  nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
  date-formatter (new SimpleDateFormat -MM-
dd'T'HH:mm:ss'Z')
  created (.format date-formatter (new Date))
  digest-as-string (apply str (.getBytes nonce) created secret)
  digest (.digest (java.security.MessageDigest/getInstance sha1)
digest-as-string)
  header (apply str  UsernameToken Username=\  username  \
PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
Created=\ created \)]
header)


This version gives me:

Exception in the main function:  #ClassCastException
java.lang.ClassCastException: java.lang.String cannot be cast to [B

For a long time I was using this for the last 3 lines:

  digest-as-string (apply str nonce created secret)
  digest (.digest (java.security.MessageDigest/getInstance sha1)
(.getByes digest-as-string))
  header (apply str  UsernameToken Username=\  username  \
PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
Created=\ created \)

Here I wrapped the whole digest-as-string in (.getBytes) so there was
no Java error, but this simply did not work when I pinged Omniture.

In his email, he seems to suggest that the nonce should be binary but
that the date and the secret should be strings:

digest = sha1( Binary Nonce + Created Time String + API Secret Hex
String (32 bytes) )  

But, as I said, when I tried this I got the ClassCastException.

No doubt some of my confusion is due to my ignorance of Java.

I was able to take their sample PHP code and get that to successfully
ping their API, however, my company has an official policy of moving
to the JVM, and of course I have a personal preference to work with
Clojure. So I'd like to figure out how to get this to work in Clojure.
(Needless to say that Omniture doesn't offer sample code in Clojure.)

I have been using clj-http to make the actual POST calls to Omniture.
Since I am on a Mac, I have been using the excellent Charles network
debugger ( http://www.charlesproxy.com/ ) to watch the actual posts
being made. Everything looks correct, except that in the end the
requests fails, apparently because the digest is malformed.

Any suggestions?






-- 
-- 
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.logic: Dividing the knowledge base

2013-03-04 Thread Norman Richards
On Wed, Feb 27, 2013 at 4:03 PM, JvJ kfjwhee...@gmail.com wrote:

 It states that retractions aren't yet implemented.  Is there any way to
 delete facts?


Retractions are now supported.  DB merging and cross-DB logic queries are
still coming.  Feel free to comment on the github issues if you have
specific use cases in mind you would like to see this support.  I have some
specific ideas for things we want to do with this at Threatgrid, but that's
only one use case.

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread Michael Klishin
2013/3/4 larry google groups lawrencecloj...@gmail.com

 Any suggestions?


You can use
https://github.com/clojurewerkz/support/blob/master/src/clojure/clojurewerkz/support/hashing.clj

note that you need to concatenate a byte array and bytes from a string
first.
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
 You can use
https://github.com/clojurewerkz/support/blob/master/src/clojure/cloju...
 note that you need to concatenate a byte array and bytes from a string
 first.


I appreciate your suggestion, but I feel that I need to understand why
I failed when I used these classes:

   (org.apache.commons.codec.binary Base64)
   (org.apache.commons.codec.digest DigestUtils)

If I am doing something fundamentally wrong, then I doubt I'll make
progress simply by using a different library.

--- lawrence





On Mar 4, 10:53 am, Michael Klishin michael.s.klis...@gmail.com
wrote:
 2013/3/4 larry google groups lawrencecloj...@gmail.com

  Any suggestions?

 You can 
 usehttps://github.com/clojurewerkz/support/blob/master/src/clojure/cloju...

 note that you need to concatenate a byte array and bytes from a string
 first.
 --
 MK

 http://github.com/michaelklishinhttp://twitter.com/michaelklishin

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread larry google groups

The developer at Omniture very kindly sent me a follow up email that
gives me a sense of where my mistake might be, though I have no clear
idea how to fix it. I sent him my code and my output, to which he
responded:

 Most things seem in order until I see your wsse header. Its not
correct as both the password digest and nonce values are improperly
encoded. These should be base64 encoded representations of the values.
Neither of these strings are base64 encoded. You can tell a given
string is base64 encoded because it can only have 64 specific
characters in the string:
A-Z
a-z
0-9
+
/
That's 26 + 26 + 10 + 2 = 64  

Sure enough, this is my nonce:

 Nonce=[B@180fad0a

I see his point -- this is not base64. But where did I go wrong? My
code right now, for the nonce, consists of these lines:

nonce (DigestUtils/md5Hex (random-string 32))
nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))

And then this gets added to the header:

header (apply str  UsernameToken Username=\  username  \
PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
Created=\ created \)

So where did I go wrong? Why is this not Base64?






On Mar 4, 10:53 am, Michael Klishin michael.s.klis...@gmail.com
wrote:
 2013/3/4 larry google groups lawrencecloj...@gmail.com

  Any suggestions?

 You can 
 usehttps://github.com/clojurewerkz/support/blob/master/src/clojure/cloju...

 note that you need to concatenate a byte array and bytes from a string
 first.
 --
 MK

 http://github.com/michaelklishinhttp://twitter.com/michaelklishin

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread Michael Klishin
2013/3/4 larry google groups lawrencecloj...@gmail.com

 I appreciate your suggestion, but I feel that I need to understand why
 I failed when I used these classes:


(.digest (java.security.MessageDigest/getInstance sha1)
digest-as-string)

expects its argument to be a byte array:
http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest.html

which can be obtained from a string using String#getBytes.

Also, in

(apply str (.getBytes nonce) created secret)

I am not sure you get what you expect. clojure.core/str will take a string
representation of a byte array and concat it. What you probably want is
to concat all strings and then .getBytes from the result. Compare:

user= (str (.getBytes aa) bb cc)
[B@5d5d0293bbcc
user= (str aa bb cc)
aabbcc
user= (.getBytes (str aa bb cc))
#byte[] [B@d9f8120
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
 expects its argument to be a byte 
 array:http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest

 which can be obtained from a string using String#getBytes.


I appreciate your suggestion. For most of the attempts that I have
made, I have used this code:

 nonce (DigestUtils/md5Hex (random-string 32))
 nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
 date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss'Z')
 created (.format date-formatter (new Date))
 digest-as-string (apply str nonce created secret)
 digest (.digest (java.security.MessageDigest/getInstance sha1)
(.getBytes digest-as-string))

So the SHA1 is given a Byte array. This fails to give me a correctly
formatted digest.





On Mar 4, 11:04 am, Michael Klishin michael.s.klis...@gmail.com
wrote:
 2013/3/4 larry google groups lawrencecloj...@gmail.com

  I appreciate your suggestion, but I feel that I need to understand why
  I failed when I used these classes:

 (.digest (java.security.MessageDigest/getInstance sha1)
 digest-as-string)

 expects its argument to be a byte 
 array:http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest

 which can be obtained from a string using String#getBytes.

 Also, in

 (apply str (.getBytes nonce) created secret)

 I am not sure you get what you expect. clojure.core/str will take a string
 representation of a byte array and concat it. What you probably want is
 to concat all strings and then .getBytes from the result. Compare:

 user= (str (.getBytes aa) bb cc)
 [B@5d5d0293bbcc
 user= (str aa bb cc)
 aabbcc
 user= (.getBytes (str aa bb cc))
 #byte[] [B@d9f8120
 --
 MK

 http://github.com/michaelklishinhttp://twitter.com/michaelklishin

-- 
-- 
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: [GSoC 2013] CinC

2013-03-04 Thread abp
Is this work related?

http://clojurewest.org/sessions#martin
https://github.com/kanaka/clojurescript

On Monday, March 4, 2013 4:15:07 PM UTC+1, Ambrose Bonnaire-Sergeant wrote:

 Any prospective students interested?

 On Mon, Mar 4, 2013 at 11:04 PM, Aaron Cohen aa...@assonance.orgjavascript:
  wrote:

 I think there probably is pretty easily a few months work there.

 If more work were needed, it would be interesting to try to get the 
 clojurescript and clojure compilers using the same front-end. I'm fairly 
 confident that's at least a summer's work. :)
  
 --Aaron


 On Sat, Mar 2, 2013 at 11:05 AM, Ambrose Bonnaire-Sergeant 
 abonnair...@gmail.com javascript: wrote:

 Is there enough to do here for a few months work? I've added a new 
 project here:

 http://dev.clojure.org/display/community/Project+Ideas#ProjectIdeas-ClojureinClojure

 Feel free to change it Aaron.

 Thanks,
 Ambrose

 On Sat, Mar 2, 2013 at 2:11 PM, Aaron Cohen 
 aa...@assonance.orgjavascript:
  wrote:

 I'd really like to see this happen actually.

 If there's interest I'd be happy to help or mentor.

 The current status is that I have a commit that needs finishing to 
 implement letfn and I believe that was the last major special form that 
 needed implementing in the compiler.

 Next up would be figuring out how to bootstrap a little better. It 
 would also be nice to pull in the work that's been done recently on the 
 reader in clojure and datastructures in clojure.


 On Sat, Mar 2, 2013 at 12:50 AM, Ambrose Bonnaire-Sergeant 
 abonnair...@gmail.com javascript: wrote:

 Hi,

 I think completing Aaron Cohen's CinC implementation would be a 
 fantastic GSoC 2013 project.

 https://github.com/remleduff/CinC

 Is Aaron willing to mentor this project? If the core.typed proposal 
 isn't chosen, I would be interested in
 this project also as a student.

 Thoughts?

 Thanks,
 Ambrose


  -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 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 javascript:
 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 javascript:.
 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.comjavascript:
 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 javascript:
 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 javascript:.
 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.comjavascript:
 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 javascript:
 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 javascript:.
 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: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Michał Marczyk
On 4 March 2013 15:30, Wolodja Wentland babi...@gmail.com wrote:
 On Mon, Mar 04, 2013 at 15:04 +0100, Michał Marczyk wrote:

 On the other hand, if you care about securing your project, pulling in
 the latest bugfixes etc., you will need to monitor new releases
 anyway, regardless of the version numbering scheme used by their
 maintainers.

 And then release a new version for every new release of one of my depedencies?

For a security fix, absolutely (although the users should upgrade the
dependency on their side as soon as they learn about the problem
anyway). For a different bug fix, maybe, depending on if you care
about the bug.

  * Library authors would be more concerned about providing a stable
interface for all releases that fall into a certain version span

 Those library authors who care about this already act in this way.

 Exactly and I would like to take advantage of this. I also think that
 establishing reasonable versioning and using version ranges as the norm would
 increase the pressure to, well, adhere to the norm by making sure that one
 does not break backward compatibility in a minor release.

You can take advantage of this by using the new versions without
changing your old code. Having this happen automatically -- as in,
1.4.0 gets pulled during the build on Monday, then 1.4.1 on Tuesday
with no explicit action to cause it on your part -- means throwing
away repeatability of your top-level build. I'm just not convinced
that is a good idea.

 Yes, a lot of people don't really care in which language a tool is written
 (nor should they) and simply want to install that software using their
 preferred packaging system.

Sure, and there's no problem with that:

 One reason for the need to not ship the same library all over again and in
 using version ranges is one of security. Imagine if a library is found to be
 buggy in version 1.2.3 and that a bugfix is available in 1.2.4. In order to
 take advantage of this one can either upgrade that single library on a system
 and /all other/ applications and libraries using this would be patched
 immediately or you could force every consumer to change their dependency on
 1.2.3 to 1.2.4 and release a new version.

The version used by an app is just the version in the jar put on the
classpath by its launcher. For packaged apps, this will tend to be a
symlink to some sort of latest in the 1.4.x branch release jar. The
story for .so files is exactly the same (there's tons of symlinks in
/usr/lib on an Ubuntu system).

And what happens if 1.4.8 actually breaks compatibility with 1.4.7
while introducing a security fix? Well, if you're maintaining the
package, you might actually backport the fix.

Of course that's not very relevant to lots of Clojure software written
today to be deployed to a server / cloud / run locally to crunch
some data etc. where I have see no problem with simply updating the
top-level project.clj / pom.xml.

 To give an example: I could write code against the standard library that ships
 with Python 2.7. I would expect that my code runs with all releases in the
 2.7.* version range and would like to express that.

 See, for example, http://www.python.org/dev/peps/pep-0426/#version-scheme
 for a relevant PEP in the Python community and I am sure you'll find many
 other examples for other languages.

Is it typical of Python packages to use non-trivial ranges? (As in,
version specifiers which are not either == or purely =.) The handful
of packages I've examined tend to be apps and use == or libraries and
use = with no upper bound.

I do recall that pip, virtualenv  friends allow one to pull in the
latest versions of packages easily -- and then to freeze the
requirements for deployment, thereby avoiding headaches with the
equivalent of non-repeatable builds.

On 4 March 2013 16:15, Wolodja Wentland babi...@gmail.com wrote:
 On Mon, Mar 04, 2013 at 09:54 -0500, Chas Emerick wrote:
 […]

 Thanks for this mail! I think it is very helpful in the debate. The notion of
 soft dependencies seems to be quite ridiculous (as you could just have an
 unversioned one), but the real problem seem to be that there is no way to
 express the notion of:

 I (should) work with all stable releases in the 1.4.* branch of libfoo

 among many other reasonable schemes.

I'd say you do this by including [libfoo 1.4.0] in your
:dependencies. If your library then breaks because 1.4.8 comes out
with a breaking change and some project's will have both libfoo-1.4.8
and your library on the classpath, then that is libfoo's fault.

Wrapping up, I'd say that using version ranges feels like imposing
something like semver on your dependencies. Unless you maintain those
dependencies, you simply can't do it. If they follow the convention,
you can take advantage and upgrade to new releases with ease; if they
don't, there's no value in writing down an expectation to the contrary
in your build spec.

Cheers,
Michał

-- 
-- 
You received this message because you 

why do I get Null pointer on this GMT SimpleDateFormat?

2013-03-04 Thread larry google groups
I need to get a GMT date. I found this page on StackOverflow:

http://stackoverflow.com/questions/308683/how-can-i-get-the-current-date-and-time-in-utc-or-gmt-in-java

It gives this example:

SimpleDateFormat dateFormatGmt = new SimpleDateFormat(-MMM-dd
HH:mm:ss);
dateFormatGmt.setTimeZone(TimeZone.getTimeZone(GMT));

I thought I was following it closely with (this is inside of a (let)
statement):

 date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
 gmt-timezone (TimeZone/getTimeZone GMT)
 date-formatter-set-to-gmt-time (.setTimeZone date-formatter gmt-
timezone)
 created (.format date-formatter-set-to-gmt-time (new Date))

but this line:

  created (.format date-formatter-set-to-gmt-time (new Date))

gives me:

java.lang.NullPointerException: null
 Reflector.java:26 clojure.lang.Reflector.invokeInstanceMethod
   omniture.clj:52 mpdv-clojure.omniture/omniture-make-headers-
for-api-call

Can anyone tell me why?







-- 
-- 
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: datomic question

2013-03-04 Thread larry google groups
This page:

http://clojure.org/reader

Offers this explanation of what the # character does:

Dispatch (#)

The dispatch macro causes the reader to use a reader macro from
another table, indexed by the character following #:

#{} - see Sets above

Regex patterns (#pattern)
A regex pattern is read and compiled at read time. The resulting
object is of type java.util.regex.Pattern.

Var-quote (#')
#'x = (var x)

Anonymous function literal (#())
#(...) = (fn [args] (...))
where args are determined by the presence of argument literals taking
the form %, %n or %. % is a synonym for %1, %n designates the nth arg
(1-based), and % designates a rest arg. This is not a replacement for
fn - idiomatic used would be for very short one-off mapping/filter fns
and the like. #() forms cannot be nested.

Ignore next form (#_)
The form following #_ is completely skipped by the reader. (This is a
more complete removal than the comment macro which yields nil).

Although, for me personally, I felt like I better understood the
description given on the EDN page:

https://github.com/edn-format/edn

# dispatch character

Tokens beginning with # are reserved. The character following #
determines the behavior. The dispatches #{ (sets), #_ (discard),
#alphabetic-char (tag) are defined below. # is not a delimiter.

tagged elements
edn supports extensibility through a simple mechanism. # followed
immediately by a symbol starting with an alphabetic character
indicates that that symbol is a tag. A tag indicates the semantic
interpretation of the following element. It is envisioned that a
reader implementation will allow clients to register handlers for
specific tags. Upon encountering a tag, the reader will first read the
next element, then pass the result to the corresponding handler for
further interpretation, and the result of the handler will be the data
value yielded by the tag + tagged element, i.e. reading a tag and
tagged element yields one value. This value is the value to be
returned to the program and is not further interpreted as edn data by
the reader.

This process will bottom out on elements either understood or built-
in.

Thus you can build new distinct readable elements out of (and only out
of) other readable elements, keeping extenders and extension consumers
out of the text business.



On Mar 4, 3:24 am, edw...@kenworthy.info wrote:
 Thanks very much Michael and Jonas.







 On Monday, 4 March 2013 07:20:24 UTC, Jonas wrote:

  Hi

  You can use the tempid (
 http://docs.datomic.com/clojure/index.html#datomic.api/tempid) function
  to generate new temporary ids.

  Jonas

  On Monday, March 4, 2013 8:50:56 AM UTC+2, edw...@kenworthy.info wrote:

  Okay, I think I understand that.

  Does that mean this code could never work as intended in a Clojure
  program, only at the repl (which seems a bit of a limitation) or is there a
  way to make it work as intended, generating a different id each time? Or is
  the whole approach taken in this code flawed?

  On Sunday, 3 March 2013 21:59:45 UTC, Michał Marczyk wrote:

  #db/id ... is a tagged literal. It gets read in as an id object with
  some integer inside. The way this happens is that the reader looks up
  a data reader function associated with the symbol db/id in the map
  held by the var *data-readers* and passes to it the result of parsing
  the rest of the literal (a vector holding the keyword :db.part/db in
  this case). Importantly, this function is not pure and the integer it
  uses will be different on each invocation. (Given this form of the
  #db/id literal; you can also specify a particular number yourself --
  #db/id [:db.part/db some-number-here].)

  In any case, once the reader reads in your code including some
  particular id, the compiler will compile the result preserving the
  particular values it sees, so it will embed code to construct *exactly
  this* id in the compiled output. Thus you end up with a particular id
  hardwired into the first version of your function.

  With the second version, if you invoke it multiple times at the REPL,
  you ask the reader for a new id at each invocation, so it works as you
  expect. If instead you were to use it inside a function like so:

  (defn foo []
    (make-column-schema #db/id [:db.part/db] :results/subject
  :db.type/string)),

  then again the same id would be used for every (foo) call.

  Cheers,
  Michał

  On 3 March 2013 21:58,  edw...@kenworthy.info wrote:
   So, I am studying a piece of code from the web. I've dissected most of
  it
   and am in the process of re-factoring it.

   What I don't understand is why one version works and the other
  doesn't.

   So for both:

   (ns gcse-results.core (:use [datomic.api :only [q db] :as d]) (:use
   quil.core))

   This doesn't work:

   (defn make-column-schema [db-ident db-type]
       {:db/id #db/id[:db.part/db]
       :db/ident db-ident
       :db/valueType db-type
       :db/cardinality :db.cardinality/one
       :db.install/_attribute 

Re: Interesting Light Table post

2013-03-04 Thread larry google groups
 I was thinking a lot after reading the thread Why is this so difficult
 that maybe what we need is a dedicated IDE, something that's built with the
 clojure workflow in mind,


The Clojure workflow, as it has evolved in this community, has mostly
been repl combined with a text editor. And that is exactly what
Light Table is delivering.

The criticisms that were offered were criticisms of Clojure. Two
different people complained that they tried to load their PHP projects
and they found that Light Table offered no tools for PHP. Another guy
asked about Ruby. Another guy asked about Python. No one said, I
think Light Table makes it hard for me to write Clojure code. People
were complaining that their own favorite language was not supported.
And most of that was simply a misunderstanding of what Light Table was
trying to do.

My understanding is that, given enough time, Light Table will
eventually support a large number of languages. Much of the criticism
that was aimed at Light Table simply amounted to people taking an
early beta product and assuming it was a polished, finished 1.0
release.






On Feb 28, 11:54 am, Erlis Vidal er...@erlisvidal.com wrote:
 Hey guys,

 this is in the top of Hacker News right now, it looks very nice:

 http://www.chris-granger.com/2013/02/27/light-table-030-experience/

 I was thinking a lot after reading the thread Why is this so difficult
 that maybe what we need is a dedicated IDE, something that's built with the
 clojure workflow in mind, I don't know... maybe this is the missing piece,
 who knows.

 I was thinking also on how cool would be to have something like the
 Smalltalk environment but a la clojure...

 I'm really excited about this project.

 Good job Chris!

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




Git is a purely functional data structure

2013-03-04 Thread Rich Morin
I found this to be interesting and well written:

  Git is a purely functional data structure
  http://www.jayway.com/2013/03/03/git-is-a-purely-functional-data-structure/

-r

 -- 
http://www.cfcl.com/rdmRich Morin
http://www.cfcl.com/rdm/resume r...@cfcl.com
http://www.cfcl.com/rdm/weblog +1 650-873-7841

Software system design, development, and documentation


-- 
-- 
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 role does a semicolon play in this case?

2013-03-04 Thread John Smith
Hi, I'm reading about Clojure from an O'Reilly book and came across this 
example:

(def a-map {:first-key first-value :second-key second-value third-key 
:third-value fourth-key 4})

Is the semicolon simply part of the atom?  Because {first:key 
first-value...} doesn't work and I get an exception.

-- 
-- 
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: What role does a semicolon play in this case?

2013-03-04 Thread Mauricio Aldazosa
I'm assuming you are talking about the colon :, it means that you are
working with a keyword:
http://clojure.org/data_structures#Data%20Structures-Keywords

-- 
-- 
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: What role does a semicolon play in this case?

2013-03-04 Thread Yves S. Garret
Yes, colon :) .

Thanks for your help.

On Mon, Mar 4, 2013 at 12:30 PM, Mauricio Aldazosa 
mauricio.aldaz...@ciencias.unam.mx wrote:

 I'm assuming you are talking about the colon :, it means that you are
 working with a keyword:
 http://clojure.org/data_structures#Data%20Structures-Keywords

  --
 --
 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: What role does a semicolon play in this case?

2013-03-04 Thread Akhil Wali
Um... Semicolon? where?

The colon indicates a symbol though :)
On Mar 4, 2013 10:55 PM, John Smith yoursurrogate...@gmail.com wrote:

 Hi, I'm reading about Clojure from an O'Reilly book and came across this
example:

 (def a-map {:first-key first-value :second-key second-value
third-key :third-value fourth-key 4})

 Is the semicolon simply part of the atom?  Because {first:key
first-value...} doesn't work and I get an exception.

 --
 --
 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: Interesting Light Table post

2013-03-04 Thread Erlis Vidal
Exactly! Tha'ts why I see a lot of value in this product!

Enabling other languages might be great for Light Table's popularity, but
creating the ultimate clojure experience will do a greater good for the
clojure community.

Now they have two paths, better clojure experience or great popularity,
they cannot have both at the same time at this moment.

It will be interesting to see what one can do with the plugin mechanism,
maybe is up to the clojure community to create the better experience, at
this point I'm just very happy to have something like this, great job guys!


On Mon, Mar 4, 2013 at 12:02 PM, larry google groups 
lawrencecloj...@gmail.com wrote:

  I was thinking a lot after reading the thread Why is this so difficult
  that maybe what we need is a dedicated IDE, something that's built with
 the
  clojure workflow in mind,


 The Clojure workflow, as it has evolved in this community, has mostly
 been repl combined with a text editor. And that is exactly what
 Light Table is delivering.

 The criticisms that were offered were criticisms of Clojure. Two
 different people complained that they tried to load their PHP projects
 and they found that Light Table offered no tools for PHP. Another guy
 asked about Ruby. Another guy asked about Python. No one said, I
 think Light Table makes it hard for me to write Clojure code. People
 were complaining that their own favorite language was not supported.
 And most of that was simply a misunderstanding of what Light Table was
 trying to do.

 My understanding is that, given enough time, Light Table will
 eventually support a large number of languages. Much of the criticism
 that was aimed at Light Table simply amounted to people taking an
 early beta product and assuming it was a polished, finished 1.0
 release.






 On Feb 28, 11:54 am, Erlis Vidal er...@erlisvidal.com wrote:
  Hey guys,
 
  this is in the top of Hacker News right now, it looks very nice:
 
  http://www.chris-granger.com/2013/02/27/light-table-030-experience/
 
  I was thinking a lot after reading the thread Why is this so difficult
  that maybe what we need is a dedicated IDE, something that's built with
 the
  clojure workflow in mind, I don't know... maybe this is the missing
 piece,
  who knows.
 
  I was thinking also on how cool would be to have something like the
  Smalltalk environment but a la clojure...
 
  I'm really excited about this project.
 
  Good job Chris!

 --
 --
 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: how to get SHA1 of a string?

2013-03-04 Thread Aaron Cohen
On Mon, Mar 4, 2013 at 11:12 AM, larry google groups 
lawrencecloj...@gmail.com wrote:

  expects its argument to be a byte array:
 http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest
 
  which can be obtained from a string using String#getBytes.


 I appreciate your suggestion. For most of the attempts that I have
 made, I have used this code:

  nonce (DigestUtils/md5Hex (random-string 32))
  nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))


Is this used somewhere?


  date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss'Z')
  created (.format date-formatter (new Date))
  digest-as-string (apply str nonce created secret)


(str binary-array) returns the toString of the array, which is something
like [B@5d5d0293. That has nothing to do with the contents of the array.
I think you want the base64 encoded string here.

--Aaron

-- 
-- 
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: [GSoC 2013] CinC

2013-03-04 Thread Aaron Cohen
On Mon, Mar 4, 2013 at 11:26 AM, abp abp...@gmail.com wrote:

 Is this work related?

 http://clojurewest.org/sessions#martin
 https://github.com/kanaka/clojurescript


Nope, completely unrelated, though similar work.

--Aaron

-- 
-- 
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: Interesting Light Table post

2013-03-04 Thread larry google groups
 It will be interesting to see what one can do with the plugin
 mechanism,
 maybe is up to the clojure community to create the better experience,
 at
 this point I'm just very happy to have something like this, great job
 guys!


I have learned Clojure over the last 8 months, and I can speak to the
experience of being a noob and trying to come up to speed on this
language. For me, Clojure itself was not the problem. I am on a Mac,
with Homebrew installed, so I read some of the examples online, and I
did brew insall ___ for several different packages, and I read
some books, and I was ready to go. I am not clear why people regard
this as difficult.

What was difficult for me was everything that had to do with Java. I
have had almost no experience with Java, and Clojure depends heavily
on Java. So learning Java, and the JVM, tripped me up repeatedly.

But my experience with Clojure, itself, was relatively smooth,
certainly no harder than learning Ruby or PHP or Python.





On Mar 4, 12:39 pm, Erlis Vidal er...@erlisvidal.com wrote:
 Exactly! Tha'ts why I see a lot of value in this product!

 Enabling other languages might be great for Light Table's popularity, but
 creating the ultimate clojure experience will do a greater good for the
 clojure community.

 Now they have two paths, better clojure experience or great popularity,
 they cannot have both at the same time at this moment.

 It will be interesting to see what one can do with the plugin mechanism,
 maybe is up to the clojure community to create the better experience, at
 this point I'm just very happy to have something like this, great job guys!

 On Mon, Mar 4, 2013 at 12:02 PM, larry google groups 







 lawrencecloj...@gmail.com wrote:
   I was thinking a lot after reading the thread Why is this so difficult
   that maybe what we need is a dedicated IDE, something that's built with
  the
   clojure workflow in mind,

  The Clojure workflow, as it has evolved in this community, has mostly
  been repl combined with a text editor. And that is exactly what
  Light Table is delivering.

  The criticisms that were offered were criticisms of Clojure. Two
  different people complained that they tried to load their PHP projects
  and they found that Light Table offered no tools for PHP. Another guy
  asked about Ruby. Another guy asked about Python. No one said, I
  think Light Table makes it hard for me to write Clojure code. People
  were complaining that their own favorite language was not supported.
  And most of that was simply a misunderstanding of what Light Table was
  trying to do.

  My understanding is that, given enough time, Light Table will
  eventually support a large number of languages. Much of the criticism
  that was aimed at Light Table simply amounted to people taking an
  early beta product and assuming it was a polished, finished 1.0
  release.

  On Feb 28, 11:54 am, Erlis Vidal er...@erlisvidal.com wrote:
   Hey guys,

   this is in the top of Hacker News right now, it looks very nice:

  http://www.chris-granger.com/2013/02/27/light-table-030-experience/

   I was thinking a lot after reading the thread Why is this so difficult
   that maybe what we need is a dedicated IDE, something that's built with
  the
   clojure workflow in mind, I don't know... maybe this is the missing
  piece,
   who knows.

   I was thinking also on how cool would be to have something like the
   Smalltalk environment but a la clojure...

   I'm really excited about this project.

   Good job Chris!

  --
  --
  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, visithttps://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: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
   nonce (DigestUtils/md5Hex (random-string 32))
   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))

 Is this used somewhere?

Yes, at the end, everything gets pulled together in a big string,
which is added as a header to the POST request:

header (apply str  UsernameToken Username=\  username  \
PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
Created=\ created \)

As the developer from Omniture told me:

The nonce is transmitted in the header as base64 encoded. However,
the digest is formed with the raw binary version (aka decoded) version
of the string. The concept you have to understand is that the
authorization server is re-performing these critical steps on the back
end. If a step isn't done exactly in the client, the digest will
mismatch and cause an auth failure.



On Mar 4, 12:49 pm, Aaron Cohen aa...@assonance.org wrote:
 On Mon, Mar 4, 2013 at 11:12 AM, larry google groups 

 lawrencecloj...@gmail.com wrote:
   expects its argument to be a byte array:
 http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest

   which can be obtained from a string using String#getBytes.

  I appreciate your suggestion. For most of the attempts that I have
  made, I have used this code:

   nonce (DigestUtils/md5Hex (random-string 32))
   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))

 Is this used somewhere?

   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss'Z')
   created (.format date-formatter (new Date))
   digest-as-string (apply str nonce created secret)

 (str binary-array) returns the toString of the array, which is something
 like [B@5d5d0293. That has nothing to do with the contents of the array.
 I think you want the base64 encoded string here.

 --Aaron

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
 (str binary-array) returns the toString of the array, which is something
 like [B@5d5d0293. That has nothing to do with the contents of the array.
 I think you want the base64 encoded string here.

Hmm, interesting. I had assumed that I wanted a string run through
SHA1, so I created the string, then called getBytes on it to feed it
to SHA1:

 digest-as-string (apply str nonce created secret)
 digest (.digest (java.security.MessageDigest/getInstance sha1)
(.getBytes digest-as-string))

But this is not working.





On Mar 4, 12:49 pm, Aaron Cohen aa...@assonance.org wrote:
 On Mon, Mar 4, 2013 at 11:12 AM, larry google groups 

 lawrencecloj...@gmail.com wrote:
   expects its argument to be a byte array:
 http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest

   which can be obtained from a string using String#getBytes.

  I appreciate your suggestion. For most of the attempts that I have
  made, I have used this code:

   nonce (DigestUtils/md5Hex (random-string 32))
   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))

 Is this used somewhere?

   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss'Z')
   created (.format date-formatter (new Date))
   digest-as-string (apply str nonce created secret)

 (str binary-array) returns the toString of the array, which is something
 like [B@5d5d0293. That has nothing to do with the contents of the array.
 I think you want the base64 encoded string here.

 --Aaron

-- 
-- 
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: Interesting Light Table post

2013-03-04 Thread BJG145
On Monday, March 4, 2013 6:05:01 PM UTC, larry google groups wrote:

 What was difficult for me was everything that had to do with Java. I 
 have had almost no experience with Java, and Clojure depends heavily 
 on Java. So learning Java, and the JVM, tripped me up repeatedly. 



Amen to that. My problem at the moment is that what I want to do with 
Clojure depends heavily on Java, and I can't really get started with the 
language until I've sussed out the Java/JVM stuff. I can't wait until I get 
that gubbins out the way and can get onto the interesting bit.

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread Frank Siebenlist
Not sure if it's helpful in this context, but I've been playing with a more 
functional 
message-digest/secure-hashing interface recently. 

Please take a look at:

https://github.com/franks42/clj.security.message-digest

It's still a little raw, and probably more educational than practical right 
now, 
but my hope was that if could clarify some of the message-digesting workings.

Would love to get some feedback...

Enjoy, Frank.


On Mar 4, 2013, at 10:09 AM, larry google groups lawrencecloj...@gmail.com 
wrote:

  nonce (DigestUtils/md5Hex (random-string 32))
  nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
 
 Is this used somewhere?
 
 Yes, at the end, everything gets pulled together in a big string,
 which is added as a header to the POST request:
 
 header (apply str  UsernameToken Username=\  username  \
 PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
 Created=\ created \)
 
 As the developer from Omniture told me:
 
 The nonce is transmitted in the header as base64 encoded. However,
 the digest is formed with the raw binary version (aka decoded) version
 of the string. The concept you have to understand is that the
 authorization server is re-performing these critical steps on the back
 end. If a step isn't done exactly in the client, the digest will
 mismatch and cause an auth failure.
 
 
 
 On Mar 4, 12:49 pm, Aaron Cohen aa...@assonance.org wrote:
 On Mon, Mar 4, 2013 at 11:12 AM, larry google groups 
 
 lawrencecloj...@gmail.com wrote:
 expects its argument to be a byte array:
 http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest
 
 which can be obtained from a string using String#getBytes.
 
 I appreciate your suggestion. For most of the attempts that I have
 made, I have used this code:
 
  nonce (DigestUtils/md5Hex (random-string 32))
  nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
 
 Is this used somewhere?
 
  date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss'Z')
  created (.format date-formatter (new Date))
  digest-as-string (apply str nonce created secret)
 
 (str binary-array) returns the toString of the array, which is something
 like [B@5d5d0293. That has nothing to do with the contents of the array.
 I think you want the base64 encoded string here.
 
 --Aaron
 
 -- 
 -- 
 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: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
Frank, I thank you for your suggestion, though at the moment I am
trying to reduce the number of places where I could have made a
mistake, switching to a new interface would increase the number of
places that I might make a mistake. I would be interested in
experimenting with the new interface as soon as I have the current
interface working.


On Mar 4, 1:20 pm, Frank Siebenlist frank.siebenl...@gmail.com
wrote:
 Not sure if it's helpful in this context, but I've been playing with a more 
 functional
 message-digest/secure-hashing interface recently.

 Please take a look at:

 https://github.com/franks42/clj.security.message-digest

 It's still a little raw, and probably more educational than practical right 
 now,
 but my hope was that if could clarify some of the message-digesting workings.

 Would love to get some feedback...

 Enjoy, Frank.

 On Mar 4, 2013, at 10:09 AM, larry google groups lawrencecloj...@gmail.com 
 wrote:







   nonce (DigestUtils/md5Hex (random-string 32))
   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))

  Is this used somewhere?

  Yes, at the end, everything gets pulled together in a big string,
  which is added as a header to the POST request:

  header (apply str  UsernameToken Username=\  username  \
  PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
  Created=\ created \)

  As the developer from Omniture told me:

  The nonce is transmitted in the header as base64 encoded. However,
  the digest is formed with the raw binary version (aka decoded) version
  of the string. The concept you have to understand is that the
  authorization server is re-performing these critical steps on the back
  end. If a step isn't done exactly in the client, the digest will
  mismatch and cause an auth failure.

  On Mar 4, 12:49 pm, Aaron Cohen aa...@assonance.org wrote:
  On Mon, Mar 4, 2013 at 11:12 AM, larry google groups 

  lawrencecloj...@gmail.com wrote:
  expects its argument to be a byte array:
 http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest

  which can be obtained from a string using String#getBytes.

  I appreciate your suggestion. For most of the attempts that I have
  made, I have used this code:

   nonce (DigestUtils/md5Hex (random-string 32))
   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))

  Is this used somewhere?

   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss'Z')
   created (.format date-formatter (new Date))
   digest-as-string (apply str nonce created secret)

  (str binary-array) returns the toString of the array, which is something
  like [B@5d5d0293. That has nothing to do with the contents of the array.
  I think you want the base64 encoded string here.

  --Aaron

  --
  --
  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, visithttps://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: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
So, right now I am using this code:

 (let [username (get-in @um/interactions [:omniture-api-
credentials :username])
  secret (get-in @um/interactions [:omniture-api-credentials :shared-
secret])
  nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
  nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
  date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
  formatter gmt-timezone)
  created (.format date-formatter (new Date))
  digest-as-string (apply str nonce created secret)
  digest (.digest (java.security.MessageDigest/getInstance sha1)
(.getBytes digest-as-string))
  digest-base64 (Base64/encodeBase64 digest)
  header (apply str  UsernameToken Username=\  username  \
PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
Created=\ created \)]
 header)

but when I print the header to the terminal, I still see values that
should be base64 but are not:

PasswordDigest=[B@3652831e Nonce=[B@631e426e Created=2\
013-03-04T13:26:21

The classes I'm using are, I think, fairly standard:

   (java.security MessageDigest)
   (org.apache.commons.codec.binary Base64)
   (org.apache.commons.codec.digest DigestUtils)


What am I doing wrong?






On Mar 4, 1:20 pm, Frank Siebenlist frank.siebenl...@gmail.com
wrote:
 Not sure if it's helpful in this context, but I've been playing with a more 
 functional
 message-digest/secure-hashing interface recently.

 Please take a look at:

 https://github.com/franks42/clj.security.message-digest

 It's still a little raw, and probably more educational than practical right 
 now,
 but my hope was that if could clarify some of the message-digesting workings.

 Would love to get some feedback...

 Enjoy, Frank.

 On Mar 4, 2013, at 10:09 AM, larry google groups lawrencecloj...@gmail.com 
 wrote:







   nonce (DigestUtils/md5Hex (random-string 32))
   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))

  Is this used somewhere?

  Yes, at the end, everything gets pulled together in a big string,
  which is added as a header to the POST request:

  header (apply str  UsernameToken Username=\  username  \
  PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
  Created=\ created \)

  As the developer from Omniture told me:

  The nonce is transmitted in the header as base64 encoded. However,
  the digest is formed with the raw binary version (aka decoded) version
  of the string. The concept you have to understand is that the
  authorization server is re-performing these critical steps on the back
  end. If a step isn't done exactly in the client, the digest will
  mismatch and cause an auth failure.

  On Mar 4, 12:49 pm, Aaron Cohen aa...@assonance.org wrote:
  On Mon, Mar 4, 2013 at 11:12 AM, larry google groups 

  lawrencecloj...@gmail.com wrote:
  expects its argument to be a byte array:
 http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest

  which can be obtained from a string using String#getBytes.

  I appreciate your suggestion. For most of the attempts that I have
  made, I have used this code:

   nonce (DigestUtils/md5Hex (random-string 32))
   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))

  Is this used somewhere?

   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss'Z')
   created (.format date-formatter (new Date))
   digest-as-string (apply str nonce created secret)

  (str binary-array) returns the toString of the array, which is something
  like [B@5d5d0293. That has nothing to do with the contents of the array.
  I think you want the base64 encoded string here.

  --Aaron

  --
  --
  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, visithttps://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 

Re: Faster lein

2013-03-04 Thread Phil Hagelberg

Buck Golemon writes:

 I take this to mean that there's no widely accepted solution.

The widely-accepted solution is to leave a single process running. It
certainly has limitations, but it's the way most people deal with the
problem.

 Really, I just want `lein run` to be faster. Can someone explain where all 
 this time is spent?

Basically it comes from having to load two JVMs, one for Leiningen
itself and one for the project. Leiningen itself is fairly optimized for
this (fully AOTed, bytecode verification is turned off, fancy warm-up
JIT techniques disabled) which is why it's possible to get `lein
version` to return in under a second in some cases. But there are
various compatibility issues that prevent us from being able to perform
the same optimizations on project JVMs. These are documented on the
Faster page of the Leiningen wiki, and you can do some testing to
determine whether or not they affect your project in particular; if not
then they should provide a good boost.

But nothing will ever come close to the speed of keeping the JVM
resident, which is why I'm working on `:eval-in :nrepl` and lein.el. For
people who don't use Emacs, Jark is the only tool I'm aware of that is
working towards this in a way that's decoupled from the editor. They
could probably use some help both testing and implementing it.

 I hear a lot of talk of compiling, but why would we re-compile things where 
 none of the dependencies have changed?

Performing a full AOT of all your dependencies will help if you have a
large project with lots of dependencies that get loaded at application
boot. But that effect would be something along the lines of bringing
boot down from 20s to 12s rather than bringing it from 5s to 1s.

-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: how to get SHA1 of a string?

2013-03-04 Thread Craig Brozefsky
larry google groups lawrencecloj...@gmail.com writes:

 Hmm, interesting. I had assumed that I wanted a string run through
 SHA1, so I created the string, then called getBytes on it to feed it
 to SHA1:

  digest-as-string (apply str nonce created secret)
  digest (.digest (java.security.MessageDigest/getInstance sha1)
 (.getBytes digest-as-string))


(defn sha1[^bytes b]
  (.digest (doto (java.security.MessageDigest/getInstance SHA-1)
 (.reset)
 (.update b

(defn as-hex [^bytes v]
  (clojure.string/lower-case
   (javax.xml.bind.DatatypeConverter/printHexBinary v)))

(defn sha1-hex [^String v]
  (- (.getBytes v)
  (sha1)
  (as-hex)))

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
Hmm, I finally got a different error message (after days of trying). I
re-read the documentation here:

http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html

and realized I might need to use this method:

encodeBase64String

which returns a string. The method I had been using was giving me
bytes instead of a string.

Now the API servers at Omniture tell me:

{\error\:\The nonce (ZTQxNWI4ZTU0YTQyMGEwZjRmZTY0ZTU0Nzc4MzgzZTQ=)
has already been used\}}

If anyone can suggest a better way to generate a random string, I
would be grateful.




On Mar 4, 1:31 pm, larry google groups lawrencecloj...@gmail.com
wrote:
 So, right now I am using this code:

  (let [username (get-in @um/interactions [:omniture-api-
 credentials :username])
   secret (get-in @um/interactions [:omniture-api-credentials :shared-
 secret])
   nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
   formatter gmt-timezone)
   created (.format date-formatter (new Date))
   digest-as-string (apply str nonce created secret)
   digest (.digest (java.security.MessageDigest/getInstance sha1)
 (.getBytes digest-as-string))
   digest-base64 (Base64/encodeBase64 digest)
   header (apply str  UsernameToken Username=\  username  \
 PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
 Created=\ created \)]
              header)

 but when I print the header to the terminal, I still see values that
 should be base64 but are not:

 PasswordDigest=[B@3652831e Nonce=[B@631e426e Created=2\
 013-03-04T13:26:21

 The classes I'm using are, I think, fairly standard:

    (java.security MessageDigest)
    (org.apache.commons.codec.binary Base64)
    (org.apache.commons.codec.digest DigestUtils)

 What am I doing wrong?

 On Mar 4, 1:20 pm, Frank Siebenlist frank.siebenl...@gmail.com
 wrote:







  Not sure if it's helpful in this context, but I've been playing with a more 
  functional
  message-digest/secure-hashing interface recently.

  Please take a look at:

 https://github.com/franks42/clj.security.message-digest

  It's still a little raw, and probably more educational than practical 
  right now,
  but my hope was that if could clarify some of the message-digesting 
  workings.

  Would love to get some feedback...

  Enjoy, Frank.

  On Mar 4, 2013, at 10:09 AM, larry google groups 
  lawrencecloj...@gmail.com wrote:

    nonce (DigestUtils/md5Hex (random-string 32))
    nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))

   Is this used somewhere?

   Yes, at the end, everything gets pulled together in a big string,
   which is added as a header to the POST request:

   header (apply str  UsernameToken Username=\  username  \
   PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
   Created=\ created \)

   As the developer from Omniture told me:

   The nonce is transmitted in the header as base64 encoded. However,
   the digest is formed with the raw binary version (aka decoded) version
   of the string. The concept you have to understand is that the
   authorization server is re-performing these critical steps on the back
   end. If a step isn't done exactly in the client, the digest will
   mismatch and cause an auth failure.

   On Mar 4, 12:49 pm, Aaron Cohen aa...@assonance.org wrote:
   On Mon, Mar 4, 2013 at 11:12 AM, larry google groups 

   lawrencecloj...@gmail.com wrote:
   expects its argument to be a byte array:
  http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest

   which can be obtained from a string using String#getBytes.

   I appreciate your suggestion. For most of the attempts that I have
   made, I have used this code:

    nonce (DigestUtils/md5Hex (random-string 32))
    nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))

   Is this used somewhere?

    date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss'Z')
    created (.format date-formatter (new Date))
    digest-as-string (apply str nonce created secret)

   (str binary-array) returns the toString of the array, which is something
   like [B@5d5d0293. That has nothing to do with the contents of the 
   array.
   I think you want the base64 encoded string here.

   --Aaron

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

Re: how to get SHA1 of a string?

2013-03-04 Thread Craig Brozefsky

Craig Brozefsky cr...@red-bean.com writes:

..

Sorry, didn't reaze you wanted the output to be base64 encoded, in which
case, add these funcs:

(defn base64-encode [^bytes v]
  (javax.xml.bind.DatatypeConverter/printBase64Binary v))

(defn sha1-base64 [^String v]
  (- (.getBytes v)
  (sha1)
  (base64-encode)))

-- 
Craig Brozefsky cr...@red-bean.com
Premature reification is the root of all evil

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
 Now the API servers at Omniture tell me:

 {\error\:\The nonce (ZTQxNWI4ZTU0YTQyMGEwZjRmZTY0ZTU0Nzc4MzgzZTQ=)
 has already been used\}}


I may have misunderstood this. clj-http defaults to retrying the same
request 4 times, if it gets a 4xx error, so the nonce gets re-used 4
times, which would explain this error on the 2nd, 3rd and 4th
attempt.

Sadly, I can not figure out what the error is on the 1st attempt.




On Mar 4, 1:38 pm, larry google groups lawrencecloj...@gmail.com
wrote:
 Hmm, I finally got a different error message (after days of trying). I
 re-read the documentation here:

 http://commons.apache.org/codec/apidocs/org/apache/commons/codec/bina...

 and realized I might need to use this method:

 encodeBase64String

 which returns a string. The method I had been using was giving me
 bytes instead of a string.

 Now the API servers at Omniture tell me:

 {\error\:\The nonce (ZTQxNWI4ZTU0YTQyMGEwZjRmZTY0ZTU0Nzc4MzgzZTQ=)
 has already been used\}}

 If anyone can suggest a better way to generate a random string, I
 would be grateful.

 On Mar 4, 1:31 pm, larry google groups lawrencecloj...@gmail.com
 wrote:







  So, right now I am using this code:

   (let [username (get-in @um/interactions [:omniture-api-
  credentials :username])
    secret (get-in @um/interactions [:omniture-api-credentials :shared-
  secret])
    nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
    nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
    date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
    formatter gmt-timezone)
    created (.format date-formatter (new Date))
    digest-as-string (apply str nonce created secret)
    digest (.digest (java.security.MessageDigest/getInstance sha1)
  (.getBytes digest-as-string))
    digest-base64 (Base64/encodeBase64 digest)
    header (apply str  UsernameToken Username=\  username  \
  PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
  Created=\ created \)]
               header)

  but when I print the header to the terminal, I still see values that
  should be base64 but are not:

  PasswordDigest=[B@3652831e Nonce=[B@631e426e Created=2\
  013-03-04T13:26:21

  The classes I'm using are, I think, fairly standard:

     (java.security MessageDigest)
     (org.apache.commons.codec.binary Base64)
     (org.apache.commons.codec.digest DigestUtils)

  What am I doing wrong?

  On Mar 4, 1:20 pm, Frank Siebenlist frank.siebenl...@gmail.com
  wrote:

   Not sure if it's helpful in this context, but I've been playing with a 
   more functional
   message-digest/secure-hashing interface recently.

   Please take a look at:

  https://github.com/franks42/clj.security.message-digest

   It's still a little raw, and probably more educational than practical 
   right now,
   but my hope was that if could clarify some of the message-digesting 
   workings.

   Would love to get some feedback...

   Enjoy, Frank.

   On Mar 4, 2013, at 10:09 AM, larry google groups 
   lawrencecloj...@gmail.com wrote:

 nonce (DigestUtils/md5Hex (random-string 32))
 nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))

Is this used somewhere?

Yes, at the end, everything gets pulled together in a big string,
which is added as a header to the POST request:

header (apply str  UsernameToken Username=\  username  \
PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
Created=\ created \)

As the developer from Omniture told me:

The nonce is transmitted in the header as base64 encoded. However,
the digest is formed with the raw binary version (aka decoded) version
of the string. The concept you have to understand is that the
authorization server is re-performing these critical steps on the back
end. If a step isn't done exactly in the client, the digest will
mismatch and cause an auth failure.

On Mar 4, 12:49 pm, Aaron Cohen aa...@assonance.org wrote:
On Mon, Mar 4, 2013 at 11:12 AM, larry google groups 

lawrencecloj...@gmail.com wrote:
expects its argument to be a byte array:
   http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest

which can be obtained from a string using String#getBytes.

I appreciate your suggestion. For most of the attempts that I have
made, I have used this code:

 nonce (DigestUtils/md5Hex (random-string 32))
 nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))

Is this used somewhere?

 date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss'Z')
 created (.format date-formatter (new Date))
 digest-as-string (apply str nonce created secret)

(str binary-array) returns the toString of the array, which is 
something
like [B@5d5d0293. That has nothing to do with the contents of the 
array.
I think you want the base64 encoded string here.

--Aaron

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

Re: how to get SHA1 of a string?

2013-03-04 Thread larry google groups

I am willing to use these functions, but do you have any idea why my
code was wrong? I have the impression that I have somehow ended up
with a binary where I should instead have a string. Using a different
function won't help me if I use it the wrong way.



On Mar 4, 1:43 pm, Craig Brozefsky cr...@red-bean.com wrote:
 Craig Brozefsky cr...@red-bean.com writes:

 ..

 Sorry, didn't reaze you wanted the output to be base64 encoded, in which
 case, add these funcs:

 (defn base64-encode [^bytes v]
   (javax.xml.bind.DatatypeConverter/printBase64Binary v))

 (defn sha1-base64 [^String v]
       (- (.getBytes v)
           (sha1)
           (base64-encode)))

 --
 Craig Brozefsky cr...@red-bean.com
 Premature reification is the root of all evil

-- 
-- 
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] modern-cljs updated to latest libs and plugins

2013-03-04 Thread Giacomo Cosenza
Hello all,
I just published the update of modern-cljs series of tutorials which 
incorporates the latest available libs and plug-ins (e.g. lein-cljsbuild 0.3.0, 
lein-ring 0.8.3, domina 1.0.2-SNAPSHOT, shoreleave 0.3.0, etc,

Hope it helps

Mimmo


https://github.com/magomimmo/modern-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: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
Right now I am using this block of code:

(let [username (get-in @um/interactions [:omniture-api-
credentials :username])
  secret (get-in @um/interactions [:omniture-api-credentials :shared-
secret])
  random-number (math/round (* (rand 1 ) 100))
  nonce (DigestUtils/md5Hex (str random-number))
  nonce-encoded-base64 (Base64/encodeBase64String (.getBytes nonce))
  date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
  created (.format date-formatter (new Date))
  digest-as-string (apply str nonce created secret)
  digest (.digest (java.security.MessageDigest/getInstance sha1)
(.getBytes digest-as-string))
  digest-base64 (Base64/encodeBase64String digest)
  header (apply str  UsernameToken Username=\  username  \
PasswordDigest=\ digest-base64 \ Nonce=\ nonce-encoded-base64
\ Created=\ created \)]
header)

And I get output that contains an equal sign, which I think is
suspect:

PasswordDigest=r+HWjSAk8AUvo/QmKKfbqQFnJ18=
Nonce=NmQxNGUwZjVlMjFhYjE1MzQ4MjUxYTA1MTg1YzE3ZTg=

The developer at Omniture reminded me of the characters allowed into
Base64:

  You can tell a given string is base64 encoded because it can only
have 64 specific characters in the string:
A-Z
a-z
0-9
+
/
That's 26 + 26 + 10 + 2 = 64
http://en.wikipedia.org/wiki/Base64


I assume that means that if I see a = in the string, then it is not
really Base64 encoded?










On Mar 4, 1:43 pm, Craig Brozefsky cr...@red-bean.com wrote:
 Craig Brozefsky cr...@red-bean.com writes:

 ..

 Sorry, didn't reaze you wanted the output to be base64 encoded, in which
 case, add these funcs:

 (defn base64-encode [^bytes v]
   (javax.xml.bind.DatatypeConverter/printBase64Binary v))

 (defn sha1-base64 [^String v]
       (- (.getBytes v)
           (sha1)
           (base64-encode)))

 --
 Craig Brozefsky cr...@red-bean.com
 Premature reification is the root of all evil

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
About this:

 (defn sha1-base64 [^String v]
       (- (.getBytes v)
           (sha1)
           (base64-encode)))

I tried to use it and I got unknown symbol for sha1, which makes
sense. What class are you using for sha1?





On Mar 4, 1:43 pm, Craig Brozefsky cr...@red-bean.com wrote:
 Craig Brozefsky cr...@red-bean.com writes:

 ..

 Sorry, didn't reaze you wanted the output to be base64 encoded, in which
 case, add these funcs:

 (defn base64-encode [^bytes v]
   (javax.xml.bind.DatatypeConverter/printBase64Binary v))

 (defn sha1-base64 [^String v]
       (- (.getBytes v)
           (sha1)
           (base64-encode)))

 --
 Craig Brozefsky cr...@red-bean.com
 Premature reification is the root of all evil

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread Aaron Cohen
I think you should try to avoid the string concatenation games. I'm not
sure what your current code is, but I suspect you're still ending up with
array toString's slipping in.

How about the following?

On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 
lawrencecloj...@gmail.com wrote:

 So, right now I am using this code:

  (let [username (get-in @um/interactions [:omniture-api-
 credentials :username])
   secret (get-in @um/interactions [:omniture-api-credentials :shared-
 secret])
   nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
   formatter gmt-timezone)
   created (.format date-formatter (new Date))


   nonce-bytes (.getBytes nonce)
   created-bytes (.getBytes created)
   secret-bytes (.getBytes secret)
   digest (- (java.security.MessageDigest/getInstance sha1)
.reset
(.update nonce-bytes)
(.update create-bytes)
(.update secret-bytes)
.digest)
digest-base64 (Base64/encodeBase64 digest)

;; Should UsernameToken Username really be unquoted in the following line?
;; All the other variable names are quoted
header (apply str  UsernameToken Username=\  username

;; You may want digest-base64 here?
  \PasswordDigest=\ digest


  \ Nonce=\ nonce-encoded-base64
  \Created=\ created \)]
 header)

-- 
-- 
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: byte-array woes

2013-03-04 Thread Frank Siebenlist
I gave it my vote - thanks for trying to fix this issue - FrankS.

FrankS (from mobile)

On Mar 4, 2013, at 6:30 AM, Karsten Schmidt i...@toxi.co.uk wrote:

 Hi Frank, I've added a patch to CLJ-766 with a potential fix. Also,
 Andy F. kindly pointed out that interested parties should vote on that
 issue to help increase its visibility...
 
 Add your 2 cents here (provided you've a CA):
 http://dev.clojure.org/jira/browse/CLJ-766
 
 Best, K.
 --
 Karsten Schmidt
 http://postspectacular.com | http://toxiclibs.org | http://toxi.co.uk
 
 
 On 3 March 2013 00:01, Frank Siebenlist frank.siebenl...@gmail.com wrote:
 I just ran into that issue while I was constructing byte-arrays for 
 secure-hash test cases.
 
 Ended-up using (byte-array (vector-of :byte 1 2 3 4)) to avoid writing the 
 (byte-array [(byte 1)(byte 2)(byte 3)(byte 4)]).
 
 Transparently adding valid byte-number values to a byte-array makes sense 
 and would be helpful.
 
 Thanks, FrankS.
 
 
 On Mar 2, 2013, at 2:49 PM, Karsten Schmidt i...@toxi.co.uk wrote:
 
 Thanks, Marko! I'd count this as a sort of bug though... at least in
 terms of consistency, since it breaks expected behaviour as
 established by other common array c'tor functions:
 
 (int-array [1 2 3]) = ok
 (long-array [1 2 3]) = ok
 (float-array [1 2 3]) = ok
 (double-array [1 2 3]) = ok
 (byte-array [1 2 3]) = fail
 (short-array [1 2 3]) = fail
 (char-array [1 2 3]) = fail, but bearable since you'd use shorts
 anyway if you specify chars as numbers
 
 I had a look at clojure.lang.Numbers.java and found a fix for both
 bytes  shorts:
 
 Whereas all the working array c'tors functions are using this pattern:
 
 array[i] = ((Number)s.first()).intValue();
 
 ... the byte-array  short-array versions attempt to cast the sequence
 items directly, i.e.
 
 array[i] = (Byte)s.first();
 
 Changing this to the first pattern (via Number) fixes the issue and
 I'll submit a patch for this...
 
 Hth! K.
 --
 Karsten Schmidt
 http://postspectacular.com | http://toxiclibs.org | http://toxi.co.uk
 
 On 2 March 2013 18:43, Marko Topolnik marko.topol...@gmail.com wrote:
 On Saturday, March 2, 2013 6:22:51 PM UTC+1, Karsten Schmidt wrote:
 
 
 Is that a bug or can someone please explain why bytes seem to require
 special treatment in Clojure?
 
 
 Calling it a bug wouldn't be entirely fair since it's a missing feature. 
 I'd
 say this is filable as an enhancement request.
 
 -Marko
 
 --
 --
 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.
 
 --
 --
 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 

Re: how to get SHA1 of a string?

2013-03-04 Thread Aaron Cohen
On Mon, Mar 4, 2013 at 1:54 PM, larry google groups 
lawrencecloj...@gmail.com wrote:


 PasswordDigest=r+HWjSAk8AUvo/QmKKfbqQFnJ18=
 Nonce=NmQxNGUwZjVlMjFhYjE1MzQ4MjUxYTA1MTg1YzE3ZTg=

 The developer at Omniture reminded me of the characters allowed into
 Base64:

   You can tell a given string is base64 encoded because it can only
 have 64 specific characters in the string:
 A-Z
 a-z
 0-9
 +
 /
 That's 26 + 26 + 10 + 2 = 64
 http://en.wikipedia.org/wiki/Base64


 I assume that means that if I see a = in the string, then it is not
 really Base64 encoded?


Every Base64 encoded string I've ever seen ends with at least one =. I
believe it's used for padding.

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread larry google groups

 ;; Should UsernameToken Username really be unquoted in the following line?
 ;; All the other variable names are quoted

Apparently, yes. The developer at Omniture reviewed it and said my
only problem was the way the passwordDigest was created.



On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
 I think you should try to avoid the string concatenation games. I'm not
 sure what your current code is, but I suspect you're still ending up with
 array toString's slipping in.

 How about the following?

 On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 

 lawrencecloj...@gmail.com wrote:
  So, right now I am using this code:

   (let [username (get-in @um/interactions [:omniture-api-
  credentials :username])
    secret (get-in @um/interactions [:omniture-api-credentials :shared-
  secret])
    nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
    nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
    date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
    formatter gmt-timezone)
    created (.format date-formatter (new Date))

    nonce-bytes (.getBytes nonce)
    created-bytes (.getBytes created)
    secret-bytes (.getBytes secret)
    digest (- (java.security.MessageDigest/getInstance sha1)
                     .reset
                     (.update nonce-bytes)
                     (.update create-bytes)
                     (.update secret-bytes)
                     .digest)
     digest-base64 (Base64/encodeBase64 digest)

 ;; Should UsernameToken Username really be unquoted in the following line?
 ;; All the other variable names are quoted
     header (apply str  UsernameToken Username=\  username

 ;; You may want digest-base64 here?
                               \PasswordDigest=\ digest

                               \ Nonce=\ nonce-encoded-base64
                               \Created=\ created \)]
              header)

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread Frank Siebenlist
 digest (- (java.security.MessageDigest/getInstance sha1)
 .reset
 (.update nonce-bytes)
 (.update create-bytes)
 (.update secret-bytes)
 .digest)


There may be an issue with this snippet of code as .update does not return 
anything… i.e. nil.

-FS.



On Mar 4, 2013, at 11:06 AM, larry google groups lawrencecloj...@gmail.com 
wrote:

 
 ;; Should UsernameToken Username really be unquoted in the following line?
 ;; All the other variable names are quoted
 
 Apparently, yes. The developer at Omniture reviewed it and said my
 only problem was the way the passwordDigest was created.
 
 
 
 On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
 I think you should try to avoid the string concatenation games. I'm not
 sure what your current code is, but I suspect you're still ending up with
 array toString's slipping in.
 
 How about the following?
 
 On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 
 
 lawrencecloj...@gmail.com wrote:
 So, right now I am using this code:
 
  (let [username (get-in @um/interactions [:omniture-api-
 credentials :username])
   secret (get-in @um/interactions [:omniture-api-credentials :shared-
 secret])
   nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
   formatter gmt-timezone)
   created (.format date-formatter (new Date))
 
nonce-bytes (.getBytes nonce)
created-bytes (.getBytes created)
secret-bytes (.getBytes secret)
digest (- (java.security.MessageDigest/getInstance sha1)
 .reset
 (.update nonce-bytes)
 (.update create-bytes)
 (.update secret-bytes)
 .digest)
 digest-base64 (Base64/encodeBase64 digest)
 
 ;; Should UsernameToken Username really be unquoted in the following line?
 ;; All the other variable names are quoted
 header (apply str  UsernameToken Username=\  username
 
 ;; You may want digest-base64 here?
   \PasswordDigest=\ digest
 
   \ Nonce=\ nonce-encoded-base64
   \Created=\ created \)]
  header)
 
 -- 
 -- 
 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 1.5 print-table, org-mode babel, and org-mode HTML gen

2013-03-04 Thread Gary Johnson
+1 for org-babel. I put together an example project solving the Potter Kata 
on github several months ago, so if someone is looking for some examples of 
how you might do LP with org-babel, take a look at it here:

  https://github.com/lambdatronic/org-babel-example

  Happy hacking,
~Gary

On Sunday, March 3, 2013 6:03:51 PM UTC-5, greg r wrote:

 Here's a little project I worked on:

 https://github.com/Greg-R/incanterchartcustom

 I'm just now learning git, so I hope the files are intact in the 
 repository.  I cloned to another machine and they appear to be OK.

 The Incanter chart PDF document shows what is possible with regard to 
 documenting code and showing a nice export result.
 The repository also includes the source .org file.  In theory, if you have 
 everything set up correctly you can reproduce the
 PDF document exactly.  Since it is generating PDF charts, there are lots 
 of side-effects and whatever directory you are running
 in will get filled up with the chart files.  I used LaTeX snippets within 
 the org file to include the chart graphics in the exported tex
 file and thus the eventual PDF.

 I don't use C-c C-e p.  This doesn't always work, and I prefer C-c C-e l 
 which exports the .tex file only.  I open the .tex file with
 the Texworks application which has worked really well for me for editing 
 LaTeX documents.  Texworks has the ability to jump between
 the PDF and the .tex file and vice-versa, which makes troubleshooting much 
 easier.

 I did a bunch of data processing for work using org, Clojure, and Incanter 
 to produce reports in PDF.  I created several Leiningen projects
 to attack various aspects of the data manipulation.  Then within Clojure 
 code blocks in org, the various namespaces are used to process
 data at the appropriate points in the document.  None of the output was 
 inserted directly into the org file.  That turned out to be impractical
 as some of the generated documents were hundreds of pages long.  The 
 Clojure/Incanter code chunks generated .tex files which were included
 in the exported output via LaTeX code blocks.  Really in this case the 
 org-babel system operated more as a document/code organizer than
 as a programming system.  But what an organizer it is!!!  I saved 
 hundreds, maybe thousands of man hours of manual document generating.

 There were several technologies to learn to get it all to work in harmony:

 Clojure
 Incanter
 Emacs (24.2) (including some Elisp in the .emacs file)
 org
 babel
 Leiningen
 LaTeX
 Texworks
 nrepl (this will require some extra stuff in the .emacs file to get babel 
 to work)

 It took a lot of work, but I think the org-babel system is really worth it!

 Regards,
 Greg

 On Saturday, March 2, 2013 11:52:07 PM UTC-5, Mark C wrote:

 Worked like a charm. Thanks!

 Babel is fun. I really like the idea of being able to code in multiple 
 languages in one document - and have return values from one feed another. 
 And I just found out you can include TeX too - just starting to play with 
 that. I'd love to hear more about how you use clojure and org mode together.

 Mark




-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread Aaron Cohen
Ah darn, thanks for the catch. The following is uglier but should work I
guess. :\

digest (.digest
   (doto (java.security.MessageDigest/getInstance sha1)
 .reset
 (.update nonce-bytes)
 (.update created-bytes)
 (.update secret-bytes)))


On Mon, Mar 4, 2013 at 2:25 PM, Frank Siebenlist frank.siebenl...@gmail.com
 wrote:

  digest (- (java.security.MessageDigest/getInstance sha1)
  .reset
  (.update nonce-bytes)
  (.update create-bytes)
  (.update secret-bytes)
  .digest)


 There may be an issue with this snippet of code as .update does not
 return anything… i.e. nil.

 -FS.



 On Mar 4, 2013, at 11:06 AM, larry google groups 
 lawrencecloj...@gmail.com wrote:

 
  ;; Should UsernameToken Username really be unquoted in the following
 line?
  ;; All the other variable names are quoted
 
  Apparently, yes. The developer at Omniture reviewed it and said my
  only problem was the way the passwordDigest was created.
 
 
 
  On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
  I think you should try to avoid the string concatenation games. I'm not
  sure what your current code is, but I suspect you're still ending up
 with
  array toString's slipping in.
 
  How about the following?
 
  On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 
 
  lawrencecloj...@gmail.com wrote:
  So, right now I am using this code:
 
   (let [username (get-in @um/interactions [:omniture-api-
  credentials :username])
secret (get-in @um/interactions [:omniture-api-credentials :shared-
  secret])
nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
formatter gmt-timezone)
created (.format date-formatter (new Date))
 
 nonce-bytes (.getBytes nonce)
 created-bytes (.getBytes created)
 secret-bytes (.getBytes secret)
 digest (- (java.security.MessageDigest/getInstance sha1)
  .reset
  (.update nonce-bytes)
  (.update create-bytes)
  (.update secret-bytes)
  .digest)
  digest-base64 (Base64/encodeBase64 digest)
 
  ;; Should UsernameToken Username really be unquoted in the following
 line?
  ;; All the other variable names are quoted
  header (apply str  UsernameToken Username=\  username
 
  ;; You may want digest-base64 here?
\PasswordDigest=\ digest
 
\ Nonce=\ nonce-encoded-base64
\Created=\ created \)]
   header)
 
  --
  --
  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.




-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread Frank Siebenlist
That should work.

No need for .reset though as the initially constructed MessageDigest is already 
in its initial state.

Be careful with .digest as it implicitly resets the MessageDigest, and calling 
it a second time gives you the digest of the initial state which is not what 
you want.

(all that incidental complexity is why I started to write that functional 
interface ;-) )

-FS.


On Mar 4, 2013, at 11:32 AM, Aaron Cohen aa...@assonance.org wrote:

 Ah darn, thanks for the catch. The following is uglier but should work I 
 guess. :\
 
 digest (.digest
(doto (java.security.MessageDigest/getInstance sha1)
  .reset
  (.update nonce-bytes)
  (.update created-bytes)
  (.update secret-bytes)))
 
 
 On Mon, Mar 4, 2013 at 2:25 PM, Frank Siebenlist frank.siebenl...@gmail.com 
 wrote:
  digest (- (java.security.MessageDigest/getInstance sha1)
  .reset
  (.update nonce-bytes)
  (.update create-bytes)
  (.update secret-bytes)
  .digest)
 
 
 There may be an issue with this snippet of code as .update does not return 
 anything… i.e. nil.
 
 -FS.
 
 
 
 On Mar 4, 2013, at 11:06 AM, larry google groups lawrencecloj...@gmail.com 
 wrote:
 
 
  ;; Should UsernameToken Username really be unquoted in the following 
  line?
  ;; All the other variable names are quoted
 
  Apparently, yes. The developer at Omniture reviewed it and said my
  only problem was the way the passwordDigest was created.
 
 
 
  On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
  I think you should try to avoid the string concatenation games. I'm not
  sure what your current code is, but I suspect you're still ending up with
  array toString's slipping in.
 
  How about the following?
 
  On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 
 
  lawrencecloj...@gmail.com wrote:
  So, right now I am using this code:
 
   (let [username (get-in @um/interactions [:omniture-api-
  credentials :username])
secret (get-in @um/interactions [:omniture-api-credentials :shared-
  secret])
nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
formatter gmt-timezone)
created (.format date-formatter (new Date))
 
 nonce-bytes (.getBytes nonce)
 created-bytes (.getBytes created)
 secret-bytes (.getBytes secret)
 digest (- (java.security.MessageDigest/getInstance sha1)
  .reset
  (.update nonce-bytes)
  (.update create-bytes)
  (.update secret-bytes)
  .digest)
  digest-base64 (Base64/encodeBase64 digest)
 
  ;; Should UsernameToken Username really be unquoted in the following 
  line?
  ;; All the other variable names are quoted
  header (apply str  UsernameToken Username=\  username
 
  ;; You may want digest-base64 here?
\PasswordDigest=\ digest
 
\ Nonce=\ nonce-encoded-base64
\Created=\ created \)]
   header)
 
  --
  --
  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.
 
 
 

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

Re: how to get SHA1 of a string?

2013-03-04 Thread larry google groups


I have a feeling you may be correct, so I copy and pasted your code
into mine:

  (let [username (get-in @um/interactions [:omniture-api-
credentials :username])
secret (get-in @um/interactions [:omniture-api-
credentials :shared-secret])
random-number (math/round (* (rand 1 ) 100))
nonce (DigestUtils/md5Hex (str random-number))
nonce-encoded-base64 (base64-encode (.getBytes
nonce))
date-formatter (new SimpleDateFormat -MM-
dd'T'HH:mm:ss)
created (.format date-formatter (new Date))
nonce-as-bytes (.getBytes nonce)
created-as-bytes (.getBytes created)
secret-as-bytes (.getBytes secret)
digest (- (java.security.MessageDigest/
getInstance sha1)
   .reset
   (.update nonce-as-bytes)
   (.update created-as-bytes)
   (.update secret-as-bytes)
   .digest)
header (apply str  UsernameToken Username=\
username  \ PasswordDigest=\ digest \ Nonce=\ nonce-encoded-
base64 \ Created=\ created \)]
header)



but now I get a null pointer exception here:

digest (- (java.security.MessageDigest/
getInstance sha1)
   .reset
   (.update nonce-as-bytes)
   (.update created-as-bytes)
   (.update secret-as-bytes)
   .digest)





On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
 I think you should try to avoid the string concatenation games. I'm not
 sure what your current code is, but I suspect you're still ending up with
 array toString's slipping in.

 How about the following?

 On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 

 lawrencecloj...@gmail.com wrote:
  So, right now I am using this code:

   (let [username (get-in @um/interactions [:omniture-api-
  credentials :username])
    secret (get-in @um/interactions [:omniture-api-credentials :shared-
  secret])
    nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
    nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
    date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
    formatter gmt-timezone)
    created (.format date-formatter (new Date))

    nonce-bytes (.getBytes nonce)
    created-bytes (.getBytes created)
    secret-bytes (.getBytes secret)
    digest (- (java.security.MessageDigest/getInstance sha1)
                     .reset
                     (.update nonce-bytes)
                     (.update create-bytes)
                     (.update secret-bytes)
                     .digest)
     digest-base64 (Base64/encodeBase64 digest)

 ;; Should UsernameToken Username really be unquoted in the following line?
 ;; All the other variable names are quoted
     header (apply str  UsernameToken Username=\  username

 ;; You may want digest-base64 here?
                               \PasswordDigest=\ digest

                               \ Nonce=\ nonce-encoded-base64
                               \Created=\ created \)]
              header)

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread Aaron Cohen
I'm not familiar with the class, but it seems that
MessageDigest/getInstance might retrieve some shared instance that could
theoretically need to be reset, no?


On Mon, Mar 4, 2013 at 2:43 PM, Frank Siebenlist frank.siebenl...@gmail.com
 wrote:

 That should work.

 No need for .reset though as the initially constructed MessageDigest is
 already in its initial state.

 Be careful with .digest as it implicitly resets the MessageDigest, and
 calling it a second time gives you the digest of the initial state which is
 not what you want.

 (all that incidental complexity is why I started to write that
 functional interface ;-) )

 -FS.


 On Mar 4, 2013, at 11:32 AM, Aaron Cohen aa...@assonance.org wrote:

  Ah darn, thanks for the catch. The following is uglier but should work I
 guess. :\
 
  digest (.digest
 (doto (java.security.MessageDigest/getInstance sha1)
   .reset
   (.update nonce-bytes)
   (.update created-bytes)
   (.update secret-bytes)))
 
 
  On Mon, Mar 4, 2013 at 2:25 PM, Frank Siebenlist 
 frank.siebenl...@gmail.com wrote:
   digest (- (java.security.MessageDigest/getInstance sha1)
   .reset
   (.update nonce-bytes)
   (.update create-bytes)
   (.update secret-bytes)
   .digest)
 
 
  There may be an issue with this snippet of code as .update does not
 return anything… i.e. nil.
 
  -FS.
 
 
 
  On Mar 4, 2013, at 11:06 AM, larry google groups 
 lawrencecloj...@gmail.com wrote:
 
  
   ;; Should UsernameToken Username really be unquoted in the
 following line?
   ;; All the other variable names are quoted
  
   Apparently, yes. The developer at Omniture reviewed it and said my
   only problem was the way the passwordDigest was created.
  
  
  
   On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
   I think you should try to avoid the string concatenation games. I'm
 not
   sure what your current code is, but I suspect you're still ending up
 with
   array toString's slipping in.
  
   How about the following?
  
   On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 
  
   lawrencecloj...@gmail.com wrote:
   So, right now I am using this code:
  
(let [username (get-in @um/interactions [:omniture-api-
   credentials :username])
 secret (get-in @um/interactions [:omniture-api-credentials :shared-
   secret])
 nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
 nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
 date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
 formatter gmt-timezone)
 created (.format date-formatter (new Date))
  
  nonce-bytes (.getBytes nonce)
  created-bytes (.getBytes created)
  secret-bytes (.getBytes secret)
  digest (- (java.security.MessageDigest/getInstance sha1)
   .reset
   (.update nonce-bytes)
   (.update create-bytes)
   (.update secret-bytes)
   .digest)
   digest-base64 (Base64/encodeBase64 digest)
  
   ;; Should UsernameToken Username really be unquoted in the
 following line?
   ;; All the other variable names are quoted
   header (apply str  UsernameToken Username=\  username
  
   ;; You may want digest-base64 here?
 \PasswordDigest=\ digest
  
 \ Nonce=\ nonce-encoded-base64
 \Created=\ created \)]
header)
  
   --
   --
   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 

Re: why do I get Null pointer on this GMT SimpleDateFormat?

2013-03-04 Thread Ray Miller
You've assigned to date-formatter-set-to-gmt-time the return value
from the setTimeZone method call. This method returns null, hence the
null pointer exception when you try to call the format method. 'doto'
might help here, like:

(let [gmt-date-formatter (doto (SimpleDateFormat. -MMM-dd HH:mm:ss)
   (.setTimeZone
(TimeZone/getTimeZone GMT)))]
(.format gmt-date-formatter (Date.)))

On 4 March 2013 16:50, larry google groups lawrencecloj...@gmail.com wrote:
 I need to get a GMT date. I found this page on StackOverflow:

 http://stackoverflow.com/questions/308683/how-can-i-get-the-current-date-and-time-in-utc-or-gmt-in-java

 It gives this example:

 SimpleDateFormat dateFormatGmt = new SimpleDateFormat(-MMM-dd
 HH:mm:ss);
 dateFormatGmt.setTimeZone(TimeZone.getTimeZone(GMT));

 I thought I was following it closely with (this is inside of a (let)
 statement):

  date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
  gmt-timezone (TimeZone/getTimeZone GMT)
  date-formatter-set-to-gmt-time (.setTimeZone date-formatter gmt-
 timezone)
  created (.format date-formatter-set-to-gmt-time (new Date))

 but this line:

   created (.format date-formatter-set-to-gmt-time (new Date))

 gives me:

 java.lang.NullPointerException: null
  Reflector.java:26 clojure.lang.Reflector.invokeInstanceMethod
omniture.clj:52 mpdv-clojure.omniture/omniture-make-headers-
 for-api-call

 Can anyone tell me why?







 --
 --
 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: how to get SHA1 of a string?

2013-03-04 Thread Frank Siebenlist
You should get a new, separate instance for every digest you would like to 
generate concurrently. Nothing, i.e. no mutable state, is shared between 
different MessageDigest instances in the subsequent digesting/secure-hashing.

The .reset is only used if you want to give up you current effort without 
generating the final digest with .digest as the latter already does the reset 
implicitly. After the reset you can reuse that same MessageDigest object for a 
new digest.

You can optionally .clone a MessageDigest object is you want to have a final 
digest value for a partial byte-list. For example, if you want the digest for 
both a and abc, you could take a new MessageDigest object, .update it for 
a's bytes, .clone that MessageDigest, use one copy to generate the final 
.digest for a, and use the other copy to add the digest of bc's bytes and 
.digest that.

Ough… hope that's clear...

-FS.


On Mar 4, 2013, at 12:15 PM, Aaron Cohen aa...@assonance.org wrote:

 I'm not familiar with the class, but it seems that MessageDigest/getInstance 
 might retrieve some shared instance that could theoretically need to be 
 reset, no?
 
 
 On Mon, Mar 4, 2013 at 2:43 PM, Frank Siebenlist frank.siebenl...@gmail.com 
 wrote:
 That should work.
 
 No need for .reset though as the initially constructed MessageDigest is 
 already in its initial state.
 
 Be careful with .digest as it implicitly resets the MessageDigest, and 
 calling it a second time gives you the digest of the initial state which is 
 not what you want.
 
 (all that incidental complexity is why I started to write that functional 
 interface ;-) )
 
 -FS.
 
 
 On Mar 4, 2013, at 11:32 AM, Aaron Cohen aa...@assonance.org wrote:
 
  Ah darn, thanks for the catch. The following is uglier but should work I 
  guess. :\
 
  digest (.digest
 (doto (java.security.MessageDigest/getInstance sha1)
   .reset
   (.update nonce-bytes)
   (.update created-bytes)
   (.update secret-bytes)))
 
 
  On Mon, Mar 4, 2013 at 2:25 PM, Frank Siebenlist 
  frank.siebenl...@gmail.com wrote:
   digest (- (java.security.MessageDigest/getInstance sha1)
   .reset
   (.update nonce-bytes)
   (.update create-bytes)
   (.update secret-bytes)
   .digest)
 
 
  There may be an issue with this snippet of code as .update does not 
  return anything… i.e. nil.
 
  -FS.
 
 
 
  On Mar 4, 2013, at 11:06 AM, larry google groups 
  lawrencecloj...@gmail.com wrote:
 
  
   ;; Should UsernameToken Username really be unquoted in the following 
   line?
   ;; All the other variable names are quoted
  
   Apparently, yes. The developer at Omniture reviewed it and said my
   only problem was the way the passwordDigest was created.
  
  
  
   On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
   I think you should try to avoid the string concatenation games. I'm not
   sure what your current code is, but I suspect you're still ending up with
   array toString's slipping in.
  
   How about the following?
  
   On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 
  
   lawrencecloj...@gmail.com wrote:
   So, right now I am using this code:
  
(let [username (get-in @um/interactions [:omniture-api-
   credentials :username])
 secret (get-in @um/interactions [:omniture-api-credentials :shared-
   secret])
 nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
 nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
 date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
 formatter gmt-timezone)
 created (.format date-formatter (new Date))
  
  nonce-bytes (.getBytes nonce)
  created-bytes (.getBytes created)
  secret-bytes (.getBytes secret)
  digest (- (java.security.MessageDigest/getInstance sha1)
   .reset
   (.update nonce-bytes)
   (.update create-bytes)
   (.update secret-bytes)
   .digest)
   digest-base64 (Base64/encodeBase64 digest)
  
   ;; Should UsernameToken Username really be unquoted in the following 
   line?
   ;; All the other variable names are quoted
   header (apply str  UsernameToken Username=\  username
  
   ;; You may want digest-base64 here?
 \PasswordDigest=\ digest
  
 \ Nonce=\ nonce-encoded-base64
 \Created=\ created \)]
header)
  
   --
   --
   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 

Clojurescript bug

2013-03-04 Thread Tom Hall
Hello,

I have just been stuck for ages trying to figure out what was going on
in my first clojurescript application and think I have found a bug.

I took some working game playing code for a simple tictactoe example
and found that I got incorrectly names JS outputted

I have created a project with as little clutter as possible.

The cljs I am runing is at
https://github.com/thattommyhall/cljs-bug/blob/master/src/cljs/aima-clojure/games/tictactoe-frontend.cljs
and the commit that fixes it is
https://github.com/thattommyhall/cljs-bug/commit/f80cdc4e97f94a6228ecf33d58d489af5de56245

It seems to generate
game.aima - clojure$game$Game$moves$arity$2
(ie a subtraction operator) as you can see in the diff.

I worked around it for now by adding an alias (def moves game/moves)
outside and calling that rather than calling game/moves inside the
function.

Pretty sure this is a cljs bug as the clj tests run ok either way.


Cheers,
Tom

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
To be clear about an earlier point, if I do this:

digest-as-string (apply str nonce created secret)

and then print this to the terminal, I can see it really is just a
string made of these 3 items. Just a plain string, exactly what I
assumed.


On Mar 4, 2:25 pm, Frank Siebenlist frank.siebenl...@gmail.com
wrote:
  digest (- (java.security.MessageDigest/getInstance sha1)
                      .reset
                      (.update nonce-bytes)
                      (.update create-bytes)
                      (.update secret-bytes)
                      .digest)

 There may be an issue with this snippet of code as .update does not return 
 anything… i.e. nil.

 -FS.

 On Mar 4, 2013, at 11:06 AM, larry google groups lawrencecloj...@gmail.com 
 wrote:









  ;; Should UsernameToken Username really be unquoted in the following 
  line?
  ;; All the other variable names are quoted

  Apparently, yes. The developer at Omniture reviewed it and said my
  only problem was the way the passwordDigest was created.

  On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
  I think you should try to avoid the string concatenation games. I'm not
  sure what your current code is, but I suspect you're still ending up with
  array toString's slipping in.

  How about the following?

  On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 

  lawrencecloj...@gmail.com wrote:
  So, right now I am using this code:

   (let [username (get-in @um/interactions [:omniture-api-
  credentials :username])
    secret (get-in @um/interactions [:omniture-api-credentials :shared-
  secret])
    nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
    nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
    date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
    formatter gmt-timezone)
    created (.format date-formatter (new Date))

     nonce-bytes (.getBytes nonce)
     created-bytes (.getBytes created)
     secret-bytes (.getBytes secret)
     digest (- (java.security.MessageDigest/getInstance sha1)
                      .reset
                      (.update nonce-bytes)
                      (.update create-bytes)
                      (.update secret-bytes)
                      .digest)
      digest-base64 (Base64/encodeBase64 digest)

  ;; Should UsernameToken Username really be unquoted in the following 
  line?
  ;; All the other variable names are quoted
      header (apply str  UsernameToken Username=\  username

  ;; You may want digest-base64 here?
                                \PasswordDigest=\ digest

                                \ Nonce=\ nonce-encoded-base64
                                \Created=\ created \)]
               header)

  --
  --
  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, visithttps://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: why do I get Null pointer on this GMT SimpleDateFormat?

2013-03-04 Thread larry google groups
Thank you. That is very helpful.

On Mar 4, 3:17 pm, Ray Miller r...@1729.org.uk wrote:
 You've assigned to date-formatter-set-to-gmt-time the return value
 from the setTimeZone method call. This method returns null, hence the
 null pointer exception when you try to call the format method. 'doto'
 might help here, like:

 (let [gmt-date-formatter (doto (SimpleDateFormat. -MMM-dd HH:mm:ss)
                                                    (.setTimeZone
 (TimeZone/getTimeZone GMT)))]
         (.format gmt-date-formatter (Date.)))

 On 4 March 2013 16:50, larry google groups lawrencecloj...@gmail.com wrote:







  I need to get a GMT date. I found this page on StackOverflow:

 http://stackoverflow.com/questions/308683/how-can-i-get-the-current-d...

  It gives this example:

  SimpleDateFormat dateFormatGmt = new SimpleDateFormat(-MMM-dd
  HH:mm:ss);
  dateFormatGmt.setTimeZone(TimeZone.getTimeZone(GMT));

  I thought I was following it closely with (this is inside of a (let)
  statement):

   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
   gmt-timezone (TimeZone/getTimeZone GMT)
   date-formatter-set-to-gmt-time (.setTimeZone date-formatter gmt-
  timezone)
   created (.format date-formatter-set-to-gmt-time (new Date))

  but this line:

    created (.format date-formatter-set-to-gmt-time (new Date))

  gives me:

  java.lang.NullPointerException: null
           Reflector.java:26 clojure.lang.Reflector.invokeInstanceMethod
             omniture.clj:52 mpdv-clojure.omniture/omniture-make-headers-
  for-api-call

  Can anyone tell me why?

  --
  --
  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, visithttps://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: how to get SHA1 of a string?

2013-03-04 Thread Aaron Cohen
Frank pointed out this mistake in my code a little farther in the thread.
Sorry for the confusion.

digest (.digest
   (doto (java.security.MessageDigest/getInstance sha1)
 .reset
 (.update nonce-as-bytes)
 (.update created-as-bytes)
 (.update secret-as-bytes)))


On Mon, Mar 4, 2013 at 3:07 PM, larry google groups 
lawrencecloj...@gmail.com wrote:



 I have a feeling you may be correct, so I copy and pasted your code
 into mine:

   (let [username (get-in @um/interactions [:omniture-api-
 credentials :username])
 secret (get-in @um/interactions [:omniture-api-
 credentials :shared-secret])
 random-number (math/round (* (rand 1 ) 100))
 nonce (DigestUtils/md5Hex (str random-number))
 nonce-encoded-base64 (base64-encode (.getBytes
 nonce))
 date-formatter (new SimpleDateFormat -MM-
 dd'T'HH:mm:ss)
 created (.format date-formatter (new Date))
 nonce-as-bytes (.getBytes nonce)
 created-as-bytes (.getBytes created)
 secret-as-bytes (.getBytes secret)
 digest (- (java.security.MessageDigest/
 getInstance sha1)
.reset
(.update nonce-as-bytes)
(.update created-as-bytes)
(.update secret-as-bytes)
.digest)
 header (apply str  UsernameToken Username=\
 username  \ PasswordDigest=\ digest \ Nonce=\ nonce-encoded-
 base64 \ Created=\ created \)]
 header)



 but now I get a null pointer exception here:

 digest (- (java.security.MessageDigest/
 getInstance sha1)
.reset
(.update nonce-as-bytes)
(.update created-as-bytes)
(.update secret-as-bytes)
.digest)





 On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
  I think you should try to avoid the string concatenation games. I'm not
  sure what your current code is, but I suspect you're still ending up with
  array toString's slipping in.
 
  How about the following?
 
  On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 
 
  lawrencecloj...@gmail.com wrote:
   So, right now I am using this code:
 
(let [username (get-in @um/interactions [:omniture-api-
   credentials :username])
 secret (get-in @um/interactions [:omniture-api-credentials :shared-
   secret])
 nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
 nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
 date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
 formatter gmt-timezone)
 created (.format date-formatter (new Date))
 
 nonce-bytes (.getBytes nonce)
 created-bytes (.getBytes created)
 secret-bytes (.getBytes secret)
 digest (- (java.security.MessageDigest/getInstance sha1)
  .reset
  (.update nonce-bytes)
  (.update create-bytes)
  (.update secret-bytes)
  .digest)
  digest-base64 (Base64/encodeBase64 digest)
 
  ;; Should UsernameToken Username really be unquoted in the following
 line?
  ;; All the other variable names are quoted
  header (apply str  UsernameToken Username=\  username
 
  ;; You may want digest-base64 here?
\PasswordDigest=\ digest
 
\ Nonce=\ nonce-encoded-base64
\Created=\ created \)]
   header)

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

Re: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
I keep trying different things, but I feel like I'm missing some
obvious mistake. Right now my code includes this function:

(defn sha1 [string]
  ;;  2013-03-04 - this function comes from here:
  ;; 
https://github.com/dmitriy-kiriyenko/clojure-api-quiz/blob/master/src/clojure_api_quiz/sha1_url.clj
  (apply str
 (map (partial format %02x)
  (.digest (doto (java.security.MessageDigest/getInstance
SHA-1)
 .reset
 (.update (.getBytes string)))


And then I create the headers like this:

  (let [username (get-in @um/interactions [:omniture-api-
credentials :username])
secret (get-in @um/interactions [:omniture-api-
credentials :shared-secret])
random-number (math/round (* (rand 1 ) 100))
nonce (DigestUtils/md5Hex (str random-number))
nonce-encoded-base64 (base64-encode (.getBytes
nonce))
date-formatter (new SimpleDateFormat -MM-
dd'T'HH:mm:ss)
created (.format date-formatter (new Date))
digest-as-string (apply str nonce created secret)
digest (sha1 digest-as-string)
digest-base64 (base64-encode (.getBytes digest))
header (apply str  UsernameToken Username=\
username  \ PasswordDigest=\ digest-base64 \ Nonce=\ nonce-
encoded-base64 \ Created=\ created \)]
header)

Which gives me, in part:

PasswordDigest=ZDk4NGZlMjgxMDZhMWIxZjZmZGMzYWYwZTY5Mjc1YTY\
xNjc1ODA0Yg== Nonce=ODlmOTY5MGRkMTczZTlkMDU4ZWY0M2JkYTQ5NjFmMzc=

Which still fails to correctly authenticate.









On Mar 4, 10:47 am, larry google groups lawrencecloj...@gmail.com
wrote:
 I have been having problems making an API call to Omniture. I have
 exchanged a dozen emails with a developer at Omniture, and he gave me
 the impression that I was constructing my security codes incorrectly.
 So now I am confronting my ignorance over how Java handles certain
 conversions.

 The developer at Omniture sent me this explanation in an email:

  The security digest is formed from a sha1 hash of the following
 string concatenation:
 digest = sha1( Binary Nonce + Created Time String + API Secret Hex
 String (32 bytes) )  

 I have been struggling with this for several days and I have tried at
 least (literally) 200 variations on this bit of code:

 (let [username (get-in @um/interactions [:omniture-api-
 credentials :username])
       secret (get-in @um/interactions [:omniture-api-
 credentials :shared-secret])
       nonce (DigestUtils/md5Hex (random-string 32))
       nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
       date-formatter (new SimpleDateFormat -MM-
 dd'T'HH:mm:ss'Z')
       created (.format date-formatter (new Date))
       digest-as-string (apply str (.getBytes nonce) created secret)
       digest (.digest (java.security.MessageDigest/getInstance sha1)
 digest-as-string)
       header (apply str  UsernameToken Username=\  username  \
 PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
 Created=\ created \)]
                 header)

 This version gives me:

 Exception in the main function:  #ClassCastException
 java.lang.ClassCastException: java.lang.String cannot be cast to [B

 For a long time I was using this for the last 3 lines:

       digest-as-string (apply str nonce created secret)
       digest (.digest (java.security.MessageDigest/getInstance sha1)
 (.getByes digest-as-string))
       header (apply str  UsernameToken Username=\  username  \
 PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
 Created=\ created \)

 Here I wrapped the whole digest-as-string in (.getBytes) so there was
 no Java error, but this simply did not work when I pinged Omniture.

 In his email, he seems to suggest that the nonce should be binary but
 that the date and the secret should be strings:

 digest = sha1( Binary Nonce + Created Time String + API Secret Hex
 String (32 bytes) )  

 But, as I said, when I tried this I got the ClassCastException.

 No doubt some of my confusion is due to my ignorance of Java.

 I was able to take their sample PHP code and get that to successfully
 ping their API, however, my company has an official policy of moving
 to the JVM, and of course I have a personal preference to work with
 Clojure. So I'd like to figure out how to get this to work in Clojure.
 (Needless to say that Omniture doesn't offer sample code in Clojure.)

 I have been using clj-http to make the actual POST calls to Omniture.
 Since I am on a Mac, I have been using the excellent Charles network
 debugger (http://www.charlesproxy.com/) to watch the actual posts
 being made. Everything looks correct, except that in the end the
 requests fails, apparently because the digest is malformed.

 Any suggestions?

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

Re: how to get SHA1 of a string?

2013-03-04 Thread Frank Siebenlist
Hi Larry,

One approach that helps a lot when trying to figure out where the issue is with 
all that message digesting, is by using well-known test cases. If you look at:

http://en.wikipedia.org/wiki/SHA-1

you will find the test cases:

SHA1(The quick brown fox jumps over the lazy dog) =
2fd4e1c6 7a2d28fc ed849ee1 bb76e739 1b93eb12

and 

SHA1() = 
da39a3ee 5e6b4b0d 3255bfef 95601890 afd80709

If you split up your nonce created secret as partial strings of The quick 
brown fox jumps over the lazy dog, then you know what hex'ified digest to 
expect, and helps you to track-down/eliminate errors.

The empty string digest is also important to have, because the initial 
MessageDigest object, or any reset one, or after a call to .digest, will 
generate that particular digest value. In other words, if you see that digest 
then you're probably working with a (accidentally?) reset MessageDigest object.


Hope that helps.

-FrankS.




On Mar 4, 2013, at 12:38 PM, larry google groups lawrencecloj...@gmail.com 
wrote:

 To be clear about an earlier point, if I do this:
 
digest-as-string (apply str nonce created secret)
 
 and then print this to the terminal, I can see it really is just a
 string made of these 3 items. Just a plain string, exactly what I
 assumed.
 
 
 On Mar 4, 2:25 pm, Frank Siebenlist frank.siebenl...@gmail.com
 wrote:
 digest (- (java.security.MessageDigest/getInstance sha1)
 .reset
 (.update nonce-bytes)
 (.update create-bytes)
 (.update secret-bytes)
 .digest)
 
 There may be an issue with this snippet of code as .update does not return 
 anything… i.e. nil.
 
 -FS.
 
 On Mar 4, 2013, at 11:06 AM, larry google groups lawrencecloj...@gmail.com 
 wrote:
 
 
 
 
 
 
 
 
 
 ;; Should UsernameToken Username really be unquoted in the following 
 line?
 ;; All the other variable names are quoted
 
 Apparently, yes. The developer at Omniture reviewed it and said my
 only problem was the way the passwordDigest was created.
 
 On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
 I think you should try to avoid the string concatenation games. I'm not
 sure what your current code is, but I suspect you're still ending up with
 array toString's slipping in.
 
 How about the following?
 
 On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 
 
 lawrencecloj...@gmail.com wrote:
 So, right now I am using this code:
 
  (let [username (get-in @um/interactions [:omniture-api-
 credentials :username])
   secret (get-in @um/interactions [:omniture-api-credentials :shared-
 secret])
   nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
   formatter gmt-timezone)
   created (.format date-formatter (new Date))
 
nonce-bytes (.getBytes nonce)
created-bytes (.getBytes created)
secret-bytes (.getBytes secret)
digest (- (java.security.MessageDigest/getInstance sha1)
 .reset
 (.update nonce-bytes)
 (.update create-bytes)
 (.update secret-bytes)
 .digest)
 digest-base64 (Base64/encodeBase64 digest)
 
 ;; Should UsernameToken Username really be unquoted in the following 
 line?
 ;; All the other variable names are quoted
 header (apply str  UsernameToken Username=\  username
 
 ;; You may want digest-base64 here?
   \PasswordDigest=\ digest
 
   \ Nonce=\ nonce-encoded-base64
   \Created=\ created \)]
  header)
 
 --
 --
 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, visithttps://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 

Re: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
Thank you for the suggestions. If I do this:

  (let [username (get-in @um/interactions [:omniture-api-
credentials :username])
secret (get-in @um/interactions [:omniture-api-
credentials :shared-secret])
random-number (math/round (* (rand 1 ) 100))
nonce (DigestUtils/md5Hex (str random-number))
nonce-encoded-base64 (base64-encode (.getBytes
nonce))
date-formatter (new SimpleDateFormat -MM-
dd'T'HH:mm:ss)
created (.format date-formatter (new Date))
nonce-as-bytes (.getBytes nonce)
created-as-bytes (.getBytes created)
secret-as-bytes (.getBytes secret)
digest (.digest
(doto (java.security.MessageDigest/
getInstance sha1)
  .reset
  (.update nonce-as-bytes)
  (.update created-as-bytes)
  (.update secret-as-
bytes)))
  ;;  ;;digest-base64 (base64-encode (.getBytes
digest))
header (apply str  UsernameToken Username=\
username  \ PasswordDigest=\ digest \ Nonce=\ nonce-encoded-
base64 \ Created=\ created \)]
header)


I end up with, in part:

PasswordDigest=[B@26f7b2f4
Nonce=Y2MwN2JiYzA5MDlmZjE2ZjExMGYzMjRhODA2Yjc5ODc=
Created=2013-03-04T15:57:52

Which I think is still incorrect.

I also tried this with the PasswordDigest base64 encoded, and that did
not work either.







On Mar 4, 2:43 pm, Frank Siebenlist frank.siebenl...@gmail.com
wrote:
 That should work.

 No need for .reset though as the initially constructed MessageDigest is 
 already in its initial state.

 Be careful with .digest as it implicitly resets the MessageDigest, and 
 calling it a second time gives you the digest of the initial state which is 
 not what you want.

 (all that incidental complexity is why I started to write that functional 
 interface ;-) )

 -FS.

 On Mar 4, 2013, at 11:32 AM, Aaron Cohen aa...@assonance.org wrote:







  Ah darn, thanks for the catch. The following is uglier but should work I 
  guess. :\

  digest (.digest
                 (doto (java.security.MessageDigest/getInstance sha1)
                       .reset
                       (.update nonce-bytes)
                       (.update created-bytes)
                       (.update secret-bytes)))

  On Mon, Mar 4, 2013 at 2:25 PM, Frank Siebenlist 
  frank.siebenl...@gmail.com wrote:
   digest (- (java.security.MessageDigest/getInstance sha1)
                       .reset
                       (.update nonce-bytes)
                       (.update create-bytes)
                       (.update secret-bytes)
                       .digest)

  There may be an issue with this snippet of code as .update does not 
  return anything… i.e. nil.

  -FS.

  On Mar 4, 2013, at 11:06 AM, larry google groups 
  lawrencecloj...@gmail.com wrote:

   ;; Should UsernameToken Username really be unquoted in the following 
   line?
   ;; All the other variable names are quoted

   Apparently, yes. The developer at Omniture reviewed it and said my
   only problem was the way the passwordDigest was created.

   On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
   I think you should try to avoid the string concatenation games. I'm not
   sure what your current code is, but I suspect you're still ending up with
   array toString's slipping in.

   How about the following?

   On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 

   lawrencecloj...@gmail.com wrote:
   So, right now I am using this code:

    (let [username (get-in @um/interactions [:omniture-api-
   credentials :username])
     secret (get-in @um/interactions [:omniture-api-credentials :shared-
   secret])
     nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
     nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
     date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
     formatter gmt-timezone)
     created (.format date-formatter (new Date))

      nonce-bytes (.getBytes nonce)
      created-bytes (.getBytes created)
      secret-bytes (.getBytes secret)
      digest (- (java.security.MessageDigest/getInstance sha1)
                       .reset
                       (.update nonce-bytes)
                       (.update create-bytes)
                       (.update secret-bytes)
                       .digest)
       digest-base64 (Base64/encodeBase64 digest)

   ;; Should UsernameToken Username really be unquoted in the following 
   line?
   ;; All the other variable names are quoted
       header (apply str  UsernameToken Username=\  username

   ;; You may want digest-base64 here?
                                 \PasswordDigest=\ digest

                                 \ Nonce=\ nonce-encoded-base64
                                 \Created=\ created \)]
             

Re: how to get SHA1 of a string?

2013-03-04 Thread Frank Siebenlist
.digest returns a byte array - so your PasswordDigest value is unprintable and 
is not fit for any header/URL.

Not sure what this base64-encode function does exactly, but normally base64 
encoding takes a bunch of bytes already, so the (commented-out) digest-base64 
(base64-encode (.getBytes digest)) does not need the (.getBytes …) 
transformation as your digest consists already of bytes.

Note that base64 encoded stuff is not url/html safe and has to be encoded also 
before sending it over the http-wire.

-FS.


On Mar 4, 2013, at 1:00 PM, larry google groups lawrencecloj...@gmail.com 
wrote:

 Thank you for the suggestions. If I do this:
 
  (let [username (get-in @um/interactions [:omniture-api-
 credentials :username])
secret (get-in @um/interactions [:omniture-api-
 credentials :shared-secret])
random-number (math/round (* (rand 1 ) 100))
nonce (DigestUtils/md5Hex (str random-number))
nonce-encoded-base64 (base64-encode (.getBytes
 nonce))
date-formatter (new SimpleDateFormat -MM-
 dd'T'HH:mm:ss)
created (.format date-formatter (new Date))
nonce-as-bytes (.getBytes nonce)
created-as-bytes (.getBytes created)
secret-as-bytes (.getBytes secret)
digest (.digest
(doto (java.security.MessageDigest/
 getInstance sha1)
  .reset
  (.update nonce-as-bytes)
  (.update created-as-bytes)
  (.update secret-as-
 bytes)))
  ;;  ;;digest-base64 (base64-encode (.getBytes
 digest))
header (apply str  UsernameToken Username=\
 username  \ PasswordDigest=\ digest \ Nonce=\ nonce-encoded-
 base64 \ Created=\ created \)]
header)
 
 
 I end up with, in part:
 
 PasswordDigest=[B@26f7b2f4
 Nonce=Y2MwN2JiYzA5MDlmZjE2ZjExMGYzMjRhODA2Yjc5ODc=
 Created=2013-03-04T15:57:52
 
 Which I think is still incorrect.
 
 I also tried this with the PasswordDigest base64 encoded, and that did
 not work either.
 
 
 
 
 
 
 
 On Mar 4, 2:43 pm, Frank Siebenlist frank.siebenl...@gmail.com
 wrote:
 That should work.
 
 No need for .reset though as the initially constructed MessageDigest is 
 already in its initial state.
 
 Be careful with .digest as it implicitly resets the MessageDigest, and 
 calling it a second time gives you the digest of the initial state which is 
 not what you want.
 
 (all that incidental complexity is why I started to write that functional 
 interface ;-) )
 
 -FS.
 
 On Mar 4, 2013, at 11:32 AM, Aaron Cohen aa...@assonance.org wrote:
 
 
 
 
 
 
 
 Ah darn, thanks for the catch. The following is uglier but should work I 
 guess. :\
 
 digest (.digest
(doto (java.security.MessageDigest/getInstance sha1)
  .reset
  (.update nonce-bytes)
  (.update created-bytes)
  (.update secret-bytes)))
 
 On Mon, Mar 4, 2013 at 2:25 PM, Frank Siebenlist 
 frank.siebenl...@gmail.com wrote:
 digest (- (java.security.MessageDigest/getInstance sha1)
 .reset
 (.update nonce-bytes)
 (.update create-bytes)
 (.update secret-bytes)
 .digest)
 
 There may be an issue with this snippet of code as .update does not 
 return anything… i.e. nil.
 
 -FS.
 
 On Mar 4, 2013, at 11:06 AM, larry google groups 
 lawrencecloj...@gmail.com wrote:
 
 ;; Should UsernameToken Username really be unquoted in the following 
 line?
 ;; All the other variable names are quoted
 
 Apparently, yes. The developer at Omniture reviewed it and said my
 only problem was the way the passwordDigest was created.
 
 On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
 I think you should try to avoid the string concatenation games. I'm not
 sure what your current code is, but I suspect you're still ending up with
 array toString's slipping in.
 
 How about the following?
 
 On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 
 
 lawrencecloj...@gmail.com wrote:
 So, right now I am using this code:
 
  (let [username (get-in @um/interactions [:omniture-api-
 credentials :username])
   secret (get-in @um/interactions [:omniture-api-credentials :shared-
 secret])
   nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
   formatter gmt-timezone)
   created (.format date-formatter (new Date))
 
nonce-bytes (.getBytes nonce)
created-bytes (.getBytes created)
secret-bytes (.getBytes secret)
digest (- (java.security.MessageDigest/getInstance sha1)
 .reset
 (.update nonce-bytes)
   

Re: how to get SHA1 of a string?

2013-03-04 Thread larry google groups

 Be careful with .digest as it implicitly resets the MessageDigest, and
 calling it a second time gives you the digest of the initial state
 which is not what you want.

I am somewhat ignorant of how mutable Java variables behave inside of
Clojure. Can I assume that the instance of MessageDigest disappears as
soon as the function returns? If I call the function again, I am
creating a new instance MessageDigest, and so I don't have to worry
about calling .digest()?



On Mar 4, 2:43 pm, Frank Siebenlist frank.siebenl...@gmail.com
wrote:
 That should work.

 No need for .reset though as the initially constructed MessageDigest is 
 already in its initial state.

 Be careful with .digest as it implicitly resets the MessageDigest, and 
 calling it a second time gives you the digest of the initial state which is 
 not what you want.

 (all that incidental complexity is why I started to write that functional 
 interface ;-) )

 -FS.

 On Mar 4, 2013, at 11:32 AM, Aaron Cohen aa...@assonance.org wrote:







  Ah darn, thanks for the catch. The following is uglier but should work I 
  guess. :\

  digest (.digest
                 (doto (java.security.MessageDigest/getInstance sha1)
                       .reset
                       (.update nonce-bytes)
                       (.update created-bytes)
                       (.update secret-bytes)))

  On Mon, Mar 4, 2013 at 2:25 PM, Frank Siebenlist 
  frank.siebenl...@gmail.com wrote:
   digest (- (java.security.MessageDigest/getInstance sha1)
                       .reset
                       (.update nonce-bytes)
                       (.update create-bytes)
                       (.update secret-bytes)
                       .digest)

  There may be an issue with this snippet of code as .update does not 
  return anything… i.e. nil.

  -FS.

  On Mar 4, 2013, at 11:06 AM, larry google groups 
  lawrencecloj...@gmail.com wrote:

   ;; Should UsernameToken Username really be unquoted in the following 
   line?
   ;; All the other variable names are quoted

   Apparently, yes. The developer at Omniture reviewed it and said my
   only problem was the way the passwordDigest was created.

   On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
   I think you should try to avoid the string concatenation games. I'm not
   sure what your current code is, but I suspect you're still ending up with
   array toString's slipping in.

   How about the following?

   On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 

   lawrencecloj...@gmail.com wrote:
   So, right now I am using this code:

    (let [username (get-in @um/interactions [:omniture-api-
   credentials :username])
     secret (get-in @um/interactions [:omniture-api-credentials :shared-
   secret])
     nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
     nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
     date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
     formatter gmt-timezone)
     created (.format date-formatter (new Date))

      nonce-bytes (.getBytes nonce)
      created-bytes (.getBytes created)
      secret-bytes (.getBytes secret)
      digest (- (java.security.MessageDigest/getInstance sha1)
                       .reset
                       (.update nonce-bytes)
                       (.update create-bytes)
                       (.update secret-bytes)
                       .digest)
       digest-base64 (Base64/encodeBase64 digest)

   ;; Should UsernameToken Username really be unquoted in the following 
   line?
   ;; All the other variable names are quoted
       header (apply str  UsernameToken Username=\  username

   ;; You may want digest-base64 here?
                                 \PasswordDigest=\ digest

                                 \ Nonce=\ nonce-encoded-base64
                                 \Created=\ created \)]
                header)

   --
   --
   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, visithttps://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 

Re: Clojure 1.5 print-table, org-mode babel, and org-mode HTML gen

2013-03-04 Thread Mark C
Very cool. Great looking doc! I just installed LaTeX and TeXworks so it's 
off to play. (Other than incanter I already have the rest working, 
including nrepl -  though I have to start up nrepl with nrepl-jack-in. Is 
that what you were planning on doing? It would be cool to have it launched 
by the first compile!).

On Sunday, March 3, 2013 6:03:51 PM UTC-5, greg r wrote:

 Here's a little project I worked on:

 https://github.com/Greg-R/incanterchartcustom

 I'm just now learning git, so I hope the files are intact in the 
 repository.  I cloned to another machine and they appear to be OK.

 The Incanter chart PDF document shows what is possible with regard to 
 documenting code and showing a nice export result.
 The repository also includes the source .org file.  In theory, if you have 
 everything set up correctly you can reproduce the
 PDF document exactly.  Since it is generating PDF charts, there are lots 
 of side-effects and whatever directory you are running
 in will get filled up with the chart files.  I used LaTeX snippets within 
 the org file to include the chart graphics in the exported tex
 file and thus the eventual PDF.

 I don't use C-c C-e p.  This doesn't always work, and I prefer C-c C-e l 
 which exports the .tex file only.  I open the .tex file with
 the Texworks application which has worked really well for me for editing 
 LaTeX documents.  Texworks has the ability to jump between
 the PDF and the .tex file and vice-versa, which makes troubleshooting much 
 easier.

 I did a bunch of data processing for work using org, Clojure, and Incanter 
 to produce reports in PDF.  I created several Leiningen projects
 to attack various aspects of the data manipulation.  Then within Clojure 
 code blocks in org, the various namespaces are used to process
 data at the appropriate points in the document.  None of the output was 
 inserted directly into the org file.  That turned out to be impractical
 as some of the generated documents were hundreds of pages long.  The 
 Clojure/Incanter code chunks generated .tex files which were included
 in the exported output via LaTeX code blocks.  Really in this case the 
 org-babel system operated more as a document/code organizer than
 as a programming system.  But what an organizer it is!!!  I saved 
 hundreds, maybe thousands of man hours of manual document generating.

 There were several technologies to learn to get it all to work in harmony:

 Clojure
 Incanter
 Emacs (24.2) (including some Elisp in the .emacs file)
 org
 babel
 Leiningen
 LaTeX
 Texworks
 nrepl (this will require some extra stuff in the .emacs file to get babel 
 to work)

 It took a lot of work, but I think the org-babel system is really worth it!

 Regards,
 Greg

 On Saturday, March 2, 2013 11:52:07 PM UTC-5, Mark C wrote:

 Worked like a charm. Thanks!

 Babel is fun. I really like the idea of being able to code in multiple 
 languages in one document - and have return values from one feed another. 
 And I just found out you can include TeX too - just starting to play with 
 that. I'd love to hear more about how you use clojure and org mode together.

 Mark




-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread Frank Siebenlist
Yup, in your case, with:

 digest (.digest
(doto (java.security.MessageDigest/getInstance sha1)
  .reset
  (.update nonce-bytes)
  (.update created-bytes)
  (.update secret-bytes)))


you do not have to worry about calling .digest twice on the same instance.

-FS.



On Mar 4, 2013, at 1:22 PM, larry google groups lawrencecloj...@gmail.com 
wrote:

 
 Be careful with .digest as it implicitly resets the MessageDigest, and
 calling it a second time gives you the digest of the initial state
 which is not what you want.
 
 I am somewhat ignorant of how mutable Java variables behave inside of
 Clojure. Can I assume that the instance of MessageDigest disappears as
 soon as the function returns? If I call the function again, I am
 creating a new instance MessageDigest, and so I don't have to worry
 about calling .digest()?
 
 
 
 On Mar 4, 2:43 pm, Frank Siebenlist frank.siebenl...@gmail.com
 wrote:
 That should work.
 
 No need for .reset though as the initially constructed MessageDigest is 
 already in its initial state.
 
 Be careful with .digest as it implicitly resets the MessageDigest, and 
 calling it a second time gives you the digest of the initial state which is 
 not what you want.
 
 (all that incidental complexity is why I started to write that functional 
 interface ;-) )
 
 -FS.
 
 On Mar 4, 2013, at 11:32 AM, Aaron Cohen aa...@assonance.org wrote:
 
 
 
 
 
 
 
 Ah darn, thanks for the catch. The following is uglier but should work I 
 guess. :\
 
 digest (.digest
(doto (java.security.MessageDigest/getInstance sha1)
  .reset
  (.update nonce-bytes)
  (.update created-bytes)
  (.update secret-bytes)))
 
 On Mon, Mar 4, 2013 at 2:25 PM, Frank Siebenlist 
 frank.siebenl...@gmail.com wrote:
 digest (- (java.security.MessageDigest/getInstance sha1)
 .reset
 (.update nonce-bytes)
 (.update create-bytes)
 (.update secret-bytes)
 .digest)
 
 There may be an issue with this snippet of code as .update does not 
 return anything… i.e. nil.
 
 -FS.
 
 On Mar 4, 2013, at 11:06 AM, larry google groups 
 lawrencecloj...@gmail.com wrote:
 
 ;; Should UsernameToken Username really be unquoted in the following 
 line?
 ;; All the other variable names are quoted
 
 Apparently, yes. The developer at Omniture reviewed it and said my
 only problem was the way the passwordDigest was created.
 
 On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
 I think you should try to avoid the string concatenation games. I'm not
 sure what your current code is, but I suspect you're still ending up with
 array toString's slipping in.
 
 How about the following?
 
 On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 
 
 lawrencecloj...@gmail.com wrote:
 So, right now I am using this code:
 
  (let [username (get-in @um/interactions [:omniture-api-
 credentials :username])
   secret (get-in @um/interactions [:omniture-api-credentials :shared-
 secret])
   nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
   formatter gmt-timezone)
   created (.format date-formatter (new Date))
 
nonce-bytes (.getBytes nonce)
created-bytes (.getBytes created)
secret-bytes (.getBytes secret)
digest (- (java.security.MessageDigest/getInstance sha1)
 .reset
 (.update nonce-bytes)
 (.update create-bytes)
 (.update secret-bytes)
 .digest)
 digest-base64 (Base64/encodeBase64 digest)
 
 ;; Should UsernameToken Username really be unquoted in the following 
 line?
 ;; All the other variable names are quoted
 header (apply str  UsernameToken Username=\  username
 
 ;; You may want digest-base64 here?
   \PasswordDigest=\ digest
 
   \ Nonce=\ nonce-encoded-base64
   \Created=\ created \)]
  header)
 
 --
 --
 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, visithttps://groups.google.com/groups/opt_out.
 
 --
 --
 

Re: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
I finally got this to work. Many thanks for all of the help that I was
given here.

The final, winning combination was:

(let [username (get-in @um/interactions [:omniture-api-
credentials :username])
secret (get-in @um/interactions [:omniture-api-credentials :shared-
secret])
random-number (math/round (* (rand 1 ) 100))
nonce (DigestUtils/md5Hex (str random-number))
nonce-encoded-base64 (base64-encode (.getBytes nonce))
date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
created (.format date-formatter (new Date))
nonce-as-bytes (.getBytes nonce)
created-as-bytes (.getBytes created)
secret-as-bytes (.getBytes secret)
digest (.digest
(doto (java.security.MessageDigest/getInstance
sha1)
 .reset
  (.update nonce-as-bytes)
  (.update created-as-bytes)
   (.update secret-as-bytes)))
digest-base64 (base64-encode digest)
header (apply str  UsernameToken Username=\  username  \
PasswordDigest=\ digest-base64 \ Nonce=\ nonce-encoded-base64
\ Created=\ created \)]
header)



On Mar 4, 10:47 am, larry google groups lawrencecloj...@gmail.com
wrote:
 I have been having problems making an API call to Omniture. I have
 exchanged a dozen emails with a developer at Omniture, and he gave me
 the impression that I was constructing my security codes incorrectly.
 So now I am confronting my ignorance over how Java handles certain
 conversions.

 The developer at Omniture sent me this explanation in an email:

  The security digest is formed from a sha1 hash of the following
 string concatenation:
 digest = sha1( Binary Nonce + Created Time String + API Secret Hex
 String (32 bytes) )  

 I have been struggling with this for several days and I have tried at
 least (literally) 200 variations on this bit of code:

 (let [username (get-in @um/interactions [:omniture-api-
 credentials :username])
       secret (get-in @um/interactions [:omniture-api-
 credentials :shared-secret])
       nonce (DigestUtils/md5Hex (random-string 32))
       nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
       date-formatter (new SimpleDateFormat -MM-
 dd'T'HH:mm:ss'Z')
       created (.format date-formatter (new Date))
       digest-as-string (apply str (.getBytes nonce) created secret)
       digest (.digest (java.security.MessageDigest/getInstance sha1)
 digest-as-string)
       header (apply str  UsernameToken Username=\  username  \
 PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
 Created=\ created \)]
                 header)

 This version gives me:

 Exception in the main function:  #ClassCastException
 java.lang.ClassCastException: java.lang.String cannot be cast to [B

 For a long time I was using this for the last 3 lines:

       digest-as-string (apply str nonce created secret)
       digest (.digest (java.security.MessageDigest/getInstance sha1)
 (.getByes digest-as-string))
       header (apply str  UsernameToken Username=\  username  \
 PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
 Created=\ created \)

 Here I wrapped the whole digest-as-string in (.getBytes) so there was
 no Java error, but this simply did not work when I pinged Omniture.

 In his email, he seems to suggest that the nonce should be binary but
 that the date and the secret should be strings:

 digest = sha1( Binary Nonce + Created Time String + API Secret Hex
 String (32 bytes) )  

 But, as I said, when I tried this I got the ClassCastException.

 No doubt some of my confusion is due to my ignorance of Java.

 I was able to take their sample PHP code and get that to successfully
 ping their API, however, my company has an official policy of moving
 to the JVM, and of course I have a personal preference to work with
 Clojure. So I'd like to figure out how to get this to work in Clojure.
 (Needless to say that Omniture doesn't offer sample code in Clojure.)

 I have been using clj-http to make the actual POST calls to Omniture.
 Since I am on a Mac, I have been using the excellent Charles network
 debugger (http://www.charlesproxy.com/) to watch the actual posts
 being made. Everything looks correct, except that in the end the
 requests fails, apparently because the digest is malformed.

 Any suggestions?

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

Re: Java interop: Can't call public method of non-public class

2013-03-04 Thread Vladimir Tsichevski
I think not. But upgrading to clojure 1.5 will do.

On Friday, March 1, 2013 1:20:57 PM UTC+4, Marko Topolnik wrote:

 I'd say it's a bug. You are invoking a public class's method, which 
 happens to be inherited from a package-private class. Clojure's reflective 
 code accesses the superclass method directly so there's no distinction 
 between direct invocation and invocation through inheritance. 

 If you are interseted in a workaround, type-hinting the code will work (my 
 guess).

 On Friday, March 1, 2013 10:13:57 AM UTC+1, bsmith.occs wrote:

 Simplified, from a more complex example:

 abstract class Bytes {
 public toHexString() { return ...; }
 Bytes { }
 }

 public class Hash extends Bytes {
 public Hash() { super(); }
 }

 This works in Java:

 new Hash().toHexString();

 This fails in Clojure:

 (.toHexString (Hash.))

 IllegalArgumentException Can't call public method of non-public class: 
 public final java.lang.String at.gv.brz.bjuvj.hashpass.Bytes.toHexString()  
 clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88)

 Bug?

 // ben



-- 
-- 
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 1.5 print-table, org-mode babel, and org-mode HTML gen

2013-03-04 Thread Mark C
This is a very helpful example. Along similar lines, I was thinking it 
would be cool to have a document of 4clojure problems/solutions/tests. I 
haven't used tangle/weave yet, which would be pretty useful for that. I 
think it would be a great learning resource to create an org-based book of 
best of idiomatic Clojure solutions to all 4clojure (or Euler) problems 
and solutions. As long as you don't get too mired in what constitutes 
best :)

Btw, it would be interesting to see the resulting pdf from you Kata doc..

M.

On Monday, March 4, 2013 2:25:42 PM UTC-5, Gary Johnson wrote:

 +1 for org-babel. I put together an example project solving the Potter 
 Kata on github several months ago, so if someone is looking for some 
 examples of how you might do LP with org-babel, take a look at it here:

   https://github.com/lambdatronic/org-babel-example

   Happy hacking,
 ~Gary

 On Sunday, March 3, 2013 6:03:51 PM UTC-5, greg r wrote:

 Here's a little project I worked on:

 https://github.com/Greg-R/incanterchartcustom

 I'm just now learning git, so I hope the files are intact in the 
 repository.  I cloned to another machine and they appear to be OK.

 The Incanter chart PDF document shows what is possible with regard to 
 documenting code and showing a nice export result.
 The repository also includes the source .org file.  In theory, if you 
 have everything set up correctly you can reproduce the
 PDF document exactly.  Since it is generating PDF charts, there are lots 
 of side-effects and whatever directory you are running
 in will get filled up with the chart files.  I used LaTeX snippets within 
 the org file to include the chart graphics in the exported tex
 file and thus the eventual PDF.

 I don't use C-c C-e p.  This doesn't always work, and I prefer C-c C-e l 
 which exports the .tex file only.  I open the .tex file with
 the Texworks application which has worked really well for me for editing 
 LaTeX documents.  Texworks has the ability to jump between
 the PDF and the .tex file and vice-versa, which makes troubleshooting 
 much easier.

 I did a bunch of data processing for work using org, Clojure, and 
 Incanter to produce reports in PDF.  I created several Leiningen projects
 to attack various aspects of the data manipulation.  Then within Clojure 
 code blocks in org, the various namespaces are used to process
 data at the appropriate points in the document.  None of the output was 
 inserted directly into the org file.  That turned out to be impractical
 as some of the generated documents were hundreds of pages long.  The 
 Clojure/Incanter code chunks generated .tex files which were included
 in the exported output via LaTeX code blocks.  Really in this case the 
 org-babel system operated more as a document/code organizer than
 as a programming system.  But what an organizer it is!!!  I saved 
 hundreds, maybe thousands of man hours of manual document generating.

 There were several technologies to learn to get it all to work in harmony:

 Clojure
 Incanter
 Emacs (24.2) (including some Elisp in the .emacs file)
 org
 babel
 Leiningen
 LaTeX
 Texworks
 nrepl (this will require some extra stuff in the .emacs file to get babel 
 to work)

 It took a lot of work, but I think the org-babel system is really worth 
 it!

 Regards,
 Greg

 On Saturday, March 2, 2013 11:52:07 PM UTC-5, Mark C wrote:

 Worked like a charm. Thanks!

 Babel is fun. I really like the idea of being able to code in multiple 
 languages in one document - and have return values from one feed another. 
 And I just found out you can include TeX too - just starting to play with 
 that. I'd love to hear more about how you use clojure and org mode together.

 Mark




-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread Frank Siebenlist
Glad Larry has working code now...

As I mentioned before in this thread, I'm working on this functional interface 
for the message-digesting/secure-hashing, and this whole discussion reads like 
a use case for the why? ;-)

It proofs to me that there may be real value in a more user-friendly approach 
than the one offered by java.security.MessageDigest.

So instead of writing:


  (let [...
nonce-as-bytes (.getBytes nonce)
created-as-bytes (.getBytes created)
secret-as-bytes (.getBytes secret)
digest (.digest
  (doto (java.security.MessageDigest/getInstance sha1)
  .reset
   (.update nonce-as-bytes)
   (.update created-as-bytes)
(.update secret-as-bytes)))
 …]


my library lets you write:


  (let […
digest (md/digest :sha-1 :utf-8 nonce created secret)  
 …]


and the advantages of the more functional approach is much more than just 
saving a few lines of code!

Although it still needs some more work, any feedback on 
https://github.com/franks42/clj.security.message-digest; 
is much appreciated.

Regards, FrankS.



On Mar 4, 2013, at 1:31 PM, larry google groups lawrencecloj...@gmail.com 
wrote:

 I finally got this to work. Many thanks for all of the help that I was
 given here.
 
 The final, winning combination was:
 
 (let [username (get-in @um/interactions [:omniture-api-
 credentials :username])
secret (get-in @um/interactions [:omniture-api-credentials :shared-
 secret])
random-number (math/round (* (rand 1 ) 100))
nonce (DigestUtils/md5Hex (str random-number))
nonce-encoded-base64 (base64-encode (.getBytes nonce))
date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
created (.format date-formatter (new Date))
nonce-as-bytes (.getBytes nonce)
created-as-bytes (.getBytes created)
secret-as-bytes (.getBytes secret)
digest (.digest
(doto (java.security.MessageDigest/getInstance
 sha1)
 .reset
  (.update nonce-as-bytes)
  (.update created-as-bytes)
   (.update secret-as-bytes)))
digest-base64 (base64-encode digest)
header (apply str  UsernameToken Username=\  username  \
 PasswordDigest=\ digest-base64 \ Nonce=\ nonce-encoded-base64
 \ Created=\ created \)]
 header)
 
 
 
 On Mar 4, 10:47 am, larry google groups lawrencecloj...@gmail.com
 wrote:
 I have been having problems making an API call to Omniture. I have
 exchanged a dozen emails with a developer at Omniture, and he gave me
 the impression that I was constructing my security codes incorrectly.
 So now I am confronting my ignorance over how Java handles certain
 conversions.
 
 The developer at Omniture sent me this explanation in an email:
 
  The security digest is formed from a sha1 hash of the following
 string concatenation:
 digest = sha1( Binary Nonce + Created Time String + API Secret Hex
 String (32 bytes) )  
 
 I have been struggling with this for several days and I have tried at
 least (literally) 200 variations on this bit of code:
 
 (let [username (get-in @um/interactions [:omniture-api-
 credentials :username])
   secret (get-in @um/interactions [:omniture-api-
 credentials :shared-secret])
   nonce (DigestUtils/md5Hex (random-string 32))
   nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
   date-formatter (new SimpleDateFormat -MM-
 dd'T'HH:mm:ss'Z')
   created (.format date-formatter (new Date))
   digest-as-string (apply str (.getBytes nonce) created secret)
   digest (.digest (java.security.MessageDigest/getInstance sha1)
 digest-as-string)
   header (apply str  UsernameToken Username=\  username  \
 PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
 Created=\ created \)]
 header)
 
 This version gives me:
 
 Exception in the main function:  #ClassCastException
 java.lang.ClassCastException: java.lang.String cannot be cast to [B
 
 For a long time I was using this for the last 3 lines:
 
   digest-as-string (apply str nonce created secret)
   digest (.digest (java.security.MessageDigest/getInstance sha1)
 (.getByes digest-as-string))
   header (apply str  UsernameToken Username=\  username  \
 PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
 Created=\ created \)
 
 Here I wrapped the whole digest-as-string in (.getBytes) so there was
 no Java error, but this simply did not work when I pinged Omniture.
 
 In his email, he seems to suggest that the nonce should be binary but
 that the date and the secret should be strings:
 
 digest = sha1( Binary Nonce + Created Time String + API Secret Hex
 String (32 bytes) )  
 
 But, as I said, when I tried this I got the ClassCastException.
 
 No doubt some of my confusion is due to my ignorance of Java.
 
 I was able to take their sample PHP code and get that to successfully
 ping 

Re: how to get SHA1 of a string?

2013-03-04 Thread Vladimir Tsichevski


On Monday, March 4, 2013 10:54:13 PM UTC+4, larry google groups wrote:

 Right now I am using this block of code: 

 (let [username (get-in @um/interactions [:omniture-api- 
 credentials :username]) 
   secret (get-in @um/interactions [:omniture-api-credentials :shared- 
 secret]) 
   random-number (math/round (* (rand 1 ) 100)) 
   nonce (DigestUtils/md5Hex (str random-number)) 
   nonce-encoded-base64 (Base64/encodeBase64String (.getBytes nonce)) 
   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss) 
   created (.format date-formatter (new Date)) 
   digest-as-string (apply str nonce created secret) 
   digest (.digest (java.security.MessageDigest/getInstance sha1) 
 (.getBytes digest-as-string)) 
   digest-base64 (Base64/encodeBase64String digest) 
   header (apply str  UsernameToken Username=\  username  \ 
 PasswordDigest=\ digest-base64 \ Nonce=\ nonce-encoded-base64 
 \ Created=\ created \)] 
 header) 

 And I get output that contains an equal sign, which I think is 
 suspect: 

 PasswordDigest=r+HWjSAk8AUvo/QmKKfbqQFnJ18= 
 Nonce=NmQxNGUwZjVlMjFhYjE1MzQ4MjUxYTA1MTg1YzE3ZTg= 

 The developer at Omniture reminded me of the characters allowed into 
 Base64: 

   You can tell a given string is base64 encoded because it can only 
 have 64 specific characters in the string: 
 A-Z 
 a-z 
 0-9 
 + 
 / 
 That's 26 + 26 + 10 + 2 = 64 
 http://en.wikipedia.org/wiki/Base64 


 I assume that means that if I see a = in the string, then it is not 
 really Base64 encoded? 


 It is. See  http://en.wikipedia.org/wiki/Base64 , the Padding section.








 On Mar 4, 1:43 pm, Craig Brozefsky cr...@red-bean.com wrote: 
  Craig Brozefsky cr...@red-bean.com writes: 
  
  .. 
  
  Sorry, didn't reaze you wanted the output to be base64 encoded, in which 
  case, add these funcs: 
  
  (defn base64-encode [^bytes v] 
(javax.xml.bind.DatatypeConverter/printBase64Binary v)) 
  
  (defn sha1-base64 [^String v] 
(- (.getBytes v) 
(sha1) 
(base64-encode))) 
  
  -- 
  Craig Brozefsky cr...@red-bean.com 
  Premature reification is the root of all evil 


-- 
-- 
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: Faster lein

2013-03-04 Thread Buck Golemon
On Mon, Mar 4, 2013 at 10:30 AM, Phil Hagelberg p...@hagelb.org wrote:


 Buck Golemon writes:

  I take this to mean that there's no widely accepted solution.

 The widely-accepted solution is to leave a single process running. It
 certainly has limitations, but it's the way most people deal with the
 problem.


Thanks Phil! I posted this question earlier, but it may have gotten lost.

I'm quite interested in the interactive session option, but none of the
mechanics are described.
How would I do the equivalent of `lein run` or `line cljs autobuild` in the
repl?
Did I miss this in the docs somewhere? It's also quite possible that it's
an obvious feature of lisp/clojure that I don't know as a newbie.

-- 
-- 
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: printing and reading functions

2013-03-04 Thread Phil Hagelberg

Dave Sann writes:

 Is there an Jira issue for this?
 Is it worth raising one?

I don't follow Clojure development much these days, but I do recall
Rich's Conj keynote a couple years ago mentioning an interest in
dynamicity knobs that let you tune space/perf vs feature trade-offs.
But that doesn't mean you'll actually get a response if you open an
issue. Depends on your tolerance for Jira I guess.

 I noted that my requirement is slightly different from yours. I want to 
 print the function by name (and namespace) only. Serializable-fn prints the 
 full definition. But this difference is only in print-method - if the 
 meta-data were available on the function, both would be possible depending 
 on need.

Yep, the end result is different, but the strategy of replacing a
clojure.core var with a version that gives enhanced metadata and
checking it from print-meta could be applied, though it has the same
drawback of not applying to defns that are unaware of it.

-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: how to get SHA1 of a string?

2013-03-04 Thread larry google groups

 If you split up your nonce created secret as partial strings of The
 quick brown fox jumps over the lazy dog, then you know
 what hex'ified digest to expect, and helps you to track-down/eliminate errors.

That is a good tip and I'll use it in the future.




On Mar 4, 3:58 pm, Frank Siebenlist frank.siebenl...@gmail.com
wrote:
 Hi Larry,

 One approach that helps a lot when trying to figure out where the issue is 
 with all that message digesting, is by using well-known test cases. If you 
 look at:

 http://en.wikipedia.org/wiki/SHA-1

 you will find the test cases:

 SHA1(The quick brown fox jumps over the lazy dog) =
 2fd4e1c6 7a2d28fc ed849ee1 bb76e739 1b93eb12

 and

 SHA1() =
 da39a3ee 5e6b4b0d 3255bfef 95601890 afd80709

 If you split up your nonce created secret as partial strings of The quick 
 brown fox jumps over the lazy dog, then you know what hex'ified digest to 
 expect, and helps you to track-down/eliminate errors.

 The empty string digest is also important to have, because the initial 
 MessageDigest object, or any reset one, or after a call to .digest, will 
 generate that particular digest value. In other words, if you see that digest 
 then you're probably working with a (accidentally?) reset MessageDigest 
 object.

 Hope that helps.

 -FrankS.

 On Mar 4, 2013, at 12:38 PM, larry google groups lawrencecloj...@gmail.com 
 wrote:







  To be clear about an earlier point, if I do this:

                     digest-as-string (apply str nonce created secret)

  and then print this to the terminal, I can see it really is just a
  string made of these 3 items. Just a plain string, exactly what I
  assumed.

  On Mar 4, 2:25 pm, Frank Siebenlist frank.siebenl...@gmail.com
  wrote:
  digest (- (java.security.MessageDigest/getInstance sha1)
                      .reset
                      (.update nonce-bytes)
                      (.update create-bytes)
                      (.update secret-bytes)
                      .digest)

  There may be an issue with this snippet of code as .update does not 
  return anything… i.e. nil.

  -FS.

  On Mar 4, 2013, at 11:06 AM, larry google groups 
  lawrencecloj...@gmail.com wrote:

  ;; Should UsernameToken Username really be unquoted in the following 
  line?
  ;; All the other variable names are quoted

  Apparently, yes. The developer at Omniture reviewed it and said my
  only problem was the way the passwordDigest was created.

  On Mar 4, 2:02 pm, Aaron Cohen aa...@assonance.org wrote:
  I think you should try to avoid the string concatenation games. I'm not
  sure what your current code is, but I suspect you're still ending up with
  array toString's slipping in.

  How about the following?

  On Mon, Mar 4, 2013 at 1:31 PM, larry google groups 

  lawrencecloj...@gmail.com wrote:
  So, right now I am using this code:

   (let [username (get-in @um/interactions [:omniture-api-
  credentials :username])
    secret (get-in @um/interactions [:omniture-api-credentials :shared-
  secret])
    nonce (DigestUtils/md5Hex (str (math/round (* (rand 1 ) 100
    nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
    date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
    formatter gmt-timezone)
    created (.format date-formatter (new Date))

     nonce-bytes (.getBytes nonce)
     created-bytes (.getBytes created)
     secret-bytes (.getBytes secret)
     digest (- (java.security.MessageDigest/getInstance sha1)
                      .reset
                      (.update nonce-bytes)
                      (.update create-bytes)
                      (.update secret-bytes)
                      .digest)
      digest-base64 (Base64/encodeBase64 digest)

  ;; Should UsernameToken Username really be unquoted in the following 
  line?
  ;; All the other variable names are quoted
      header (apply str  UsernameToken Username=\  username

  ;; You may want digest-base64 here?
                                \PasswordDigest=\ digest

                                \ Nonce=\ nonce-encoded-base64
                                \Created=\ created \)]
               header)

  --
  --
  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, visithttps://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 

Re: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
 Note that base64 encoded stuff is not url/html safe and has to be encoded also
 before sending it over the http-wire.

Hmm, interesting. This is going as the headers in a POST. It did seem
to work the last time I ran it, just now, a few minutes ago.

I am using the clj-http library and my actual POST function is:

(defn omniture-call-api [url-with-queue-method api-payload headers]
  (timbre/spy :debug  return value of omniture-call-api 
  (try+
(http-client/post url-with-queue-method
  {:body api-payload
   :debug true
   :debug-body true
   :insecure true
   :headers {X-Api-Version 2
 X-WSSE headers}
   :content-type :json
   :socket-timeout 4000
   :conn-timeout 4000
   :accept :json
   :client-params
{http.protocol.allow-circular-redirects true
   http.useragent
clj-http}})
(catch Object o (println (pp/pprint o))


The 3rd argument, headers, is what you helped me figure out earlier.



On Mar 4, 4:17 pm, Frank Siebenlist frank.siebenl...@gmail.com
wrote:
 .digest returns a byte array - so your PasswordDigest value is unprintable 
 and is not fit for any header/URL.

 Not sure what this base64-encode function does exactly, but normally base64 
 encoding takes a bunch of bytes already, so the (commented-out) 
 digest-base64 (base64-encode (.getBytes digest)) does not need the 
 (.getBytes …) transformation as your digest consists already of bytes.

 Note that base64 encoded stuff is not url/html safe and has to be encoded 
 also before sending it over the http-wire.

 -FS.

 On Mar 4, 2013, at 1:00 PM, larry google groups lawrencecloj...@gmail.com 
 wrote:







  Thank you for the suggestions. If I do this:

   (let [username (get-in @um/interactions [:omniture-api-
  credentials :username])
                     secret (get-in @um/interactions [:omniture-api-
  credentials :shared-secret])
                     random-number (math/round (* (rand 1 ) 100))
                     nonce (DigestUtils/md5Hex (str random-number))
                     nonce-encoded-base64 (base64-encode (.getBytes
  nonce))
                     date-formatter (new SimpleDateFormat -MM-
  dd'T'HH:mm:ss)
                     created (.format date-formatter (new Date))
                     nonce-as-bytes (.getBytes nonce)
                     created-as-bytes (.getBytes created)
                     secret-as-bytes (.getBytes secret)
                     digest (.digest
                             (doto (java.security.MessageDigest/
  getInstance sha1)
                               .reset
                               (.update nonce-as-bytes)
                               (.update created-as-bytes)
                               (.update secret-as-
  bytes)))
   ;;                  ;;digest-base64 (base64-encode (.getBytes
  digest))
                     header (apply str  UsernameToken Username=\
  username  \ PasswordDigest=\ digest \ Nonce=\ nonce-encoded-
  base64 \ Created=\ created \)]
                 header)

  I end up with, in part:

  PasswordDigest=[B@26f7b2f4
  Nonce=Y2MwN2JiYzA5MDlmZjE2ZjExMGYzMjRhODA2Yjc5ODc=
  Created=2013-03-04T15:57:52

  Which I think is still incorrect.

  I also tried this with the PasswordDigest base64 encoded, and that did
  not work either.

  On Mar 4, 2:43 pm, Frank Siebenlist frank.siebenl...@gmail.com
  wrote:
  That should work.

  No need for .reset though as the initially constructed MessageDigest is 
  already in its initial state.

  Be careful with .digest as it implicitly resets the MessageDigest, and 
  calling it a second time gives you the digest of the initial state which 
  is not what you want.

  (all that incidental complexity is why I started to write that 
  functional interface ;-) )

  -FS.

  On Mar 4, 2013, at 11:32 AM, Aaron Cohen aa...@assonance.org wrote:

  Ah darn, thanks for the catch. The following is uglier but should work I 
  guess. :\

  digest (.digest
                 (doto (java.security.MessageDigest/getInstance sha1)
                       .reset
                       (.update nonce-bytes)
                       (.update created-bytes)
                       (.update secret-bytes)))

  On Mon, Mar 4, 2013 at 2:25 PM, Frank Siebenlist 
  frank.siebenl...@gmail.com wrote:
  digest (- (java.security.MessageDigest/getInstance sha1)
                      .reset
                      (.update nonce-bytes)
                      (.update create-bytes)
                      (.update secret-bytes)
                      .digest)

  There may be an issue with this snippet of code as .update does 

Re: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
 my library lets you write:

   (let […
         digest (md/digest :sha-1 :utf-8 nonce created secret)
          …]


Great. Now that I have the code working I'll switch over to your
library. I felt the need to get a mental picture of what the
underlying Java code was doing, but now that I have that I would
happily switch to a cleaner interface.





On Mar 4, 4:55 pm, Frank Siebenlist frank.siebenl...@gmail.com
wrote:
 Glad Larry has working code now...

 As I mentioned before in this thread, I'm working on this functional 
 interface for the message-digesting/secure-hashing, and this whole discussion 
 reads like a use case for the why? ;-)

 It proofs to me that there may be real value in a more user-friendly 
 approach than the one offered by java.security.MessageDigest.

 So instead of writing:

   (let [...
         nonce-as-bytes (.getBytes nonce)
         created-as-bytes (.getBytes created)
         secret-as-bytes (.getBytes secret)
         digest (.digest
                   (doto (java.security.MessageDigest/getInstance sha1)
                       .reset
                        (.update nonce-as-bytes)
                        (.update created-as-bytes)
                         (.update secret-as-bytes)))
          …]

 my library lets you write:

   (let […
         digest (md/digest :sha-1 :utf-8 nonce created secret)
          …]

 and the advantages of the more functional approach is much more than just 
 saving a few lines of code!

 Although it still needs some more work, any feedback on
 https://github.com/franks42/clj.security.message-digest;
 is much appreciated.

 Regards, FrankS.

 On Mar 4, 2013, at 1:31 PM, larry google groups lawrencecloj...@gmail.com 
 wrote:







  I finally got this to work. Many thanks for all of the help that I was
  given here.

  The final, winning combination was:

  (let [username (get-in @um/interactions [:omniture-api-
  credentials :username])
     secret (get-in @um/interactions [:omniture-api-credentials :shared-
  secret])
     random-number (math/round (* (rand 1 ) 100))
     nonce (DigestUtils/md5Hex (str random-number))
     nonce-encoded-base64 (base64-encode (.getBytes nonce))
     date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
     created (.format date-formatter (new Date))
     nonce-as-bytes (.getBytes nonce)
     created-as-bytes (.getBytes created)
     secret-as-bytes (.getBytes secret)
     digest (.digest
                 (doto (java.security.MessageDigest/getInstance
  sha1)
                      .reset
                       (.update nonce-as-bytes)
                       (.update created-as-bytes)
                        (.update secret-as-bytes)))
     digest-base64 (base64-encode digest)
     header (apply str  UsernameToken Username=\  username  \
  PasswordDigest=\ digest-base64 \ Nonce=\ nonce-encoded-base64
  \ Created=\ created \)]
  header)

  On Mar 4, 10:47 am, larry google groups lawrencecloj...@gmail.com
  wrote:
  I have been having problems making an API call to Omniture. I have
  exchanged a dozen emails with a developer at Omniture, and he gave me
  the impression that I was constructing my security codes incorrectly.
  So now I am confronting my ignorance over how Java handles certain
  conversions.

  The developer at Omniture sent me this explanation in an email:

   The security digest is formed from a sha1 hash of the following
  string concatenation:
  digest = sha1( Binary Nonce + Created Time String + API Secret Hex
  String (32 bytes) )  

  I have been struggling with this for several days and I have tried at
  least (literally) 200 variations on this bit of code:

  (let [username (get-in @um/interactions [:omniture-api-
  credentials :username])
        secret (get-in @um/interactions [:omniture-api-
  credentials :shared-secret])
        nonce (DigestUtils/md5Hex (random-string 32))
        nonce-encoded-base64 (Base64/encodeBase64 (.getBytes nonce))
        date-formatter (new SimpleDateFormat -MM-
  dd'T'HH:mm:ss'Z')
        created (.format date-formatter (new Date))
        digest-as-string (apply str (.getBytes nonce) created secret)
        digest (.digest (java.security.MessageDigest/getInstance sha1)
  digest-as-string)
        header (apply str  UsernameToken Username=\  username  \
  PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
  Created=\ created \)]
                  header)

  This version gives me:

  Exception in the main function:  #ClassCastException
  java.lang.ClassCastException: java.lang.String cannot be cast to [B

  For a long time I was using this for the last 3 lines:

        digest-as-string (apply str nonce created secret)
        digest (.digest (java.security.MessageDigest/getInstance sha1)
  (.getByes digest-as-string))
        header (apply str  UsernameToken Username=\  username  \
  PasswordDigest=\ digest \ Nonce=\ nonce-encoded-base64 \
  Created=\ created \)

  Here I wrapped the whole digest-as-string in (.getBytes) so there was
  

Re: how to get SHA1 of a string?

2013-03-04 Thread larry google groups
Frank,

Any idea when you might release your code in a stable form? I am using
this code at work so I am nervous about using code that is still
marked SNAPSHOT. Lein reminds me not to use a SNAPSHOT:

Could not find metadata org.clojars.franks42:clj.security.message-
digest:0.1.0-SNAPSHOT/maven-metadata.xml in central (http://
repo1.maven.org/maven2)
Could not find metadata org.clojars.franks42:clj.security.message-
digest:0.1.0-SNAPSHOT/maven-metadata.xml in central-proxy (https://
repository.sonatype.org/content/repositories/centralm1/)
Retrieving org/clojars/franks42/clj.security.message-digest/0.1.0-
SNAPSHOT/maven-metadata.xml (1k)
from https://clojars.org/repo/
Could not find artifact org.clojars.franks42:clj.security.message-
digest:pom:0.1.0-20130304.220822-1 in central (http://repo1.maven.org/
maven2)
Retrieving org/clojars/franks42/clj.security.message-digest/0.1.0-
SNAPSHOT/clj.security.message-digest-0.1.0-20130304.220822-1.pom (3k)
from https://clojars.org/repo/
Retrieving org/clojure/clojure/1.5.0/clojure-1.5.0.pom (6k)
from http://repo1.maven.org/maven2/
Retrieving org/clojars/franks42/clj.security.message-digest/0.1.0-
SNAPSHOT/clj.security.message-digest-0.1.0-20130304.220822-1.jar (6k)
from https://clojars.org/repo/
Compiling 1 source files to /Users/lkrubner/projects/multi-platform-
data-visualization/mpdv-clojure/target/classes
Release versions may not depend upon snapshots.
Freeze snapshots to dated versions or set the
LEIN_SNAPSHOTS_IN_RELEASE environment variable to override.






On Mar 4, 4:55 pm, Frank Siebenlist frank.siebenl...@gmail.com
wrote:
 Glad Larry has working code now...

 As I mentioned before in this thread, I'm working on this functional 
 interface for the message-digesting/secure-hashing, and this whole discussion 
 reads like a use case for the why? ;-)

 It proofs to me that there may be real value in a more user-friendly 
 approach than the one offered by java.security.MessageDigest.

 So instead of writing:

   (let [...
         nonce-as-bytes (.getBytes nonce)
         created-as-bytes (.getBytes created)
         secret-as-bytes (.getBytes secret)
         digest (.digest
                   (doto (java.security.MessageDigest/getInstance sha1)
                       .reset
                        (.update nonce-as-bytes)
                        (.update created-as-bytes)
                         (.update secret-as-bytes)))
          …]

 my library lets you write:

   (let […
         digest (md/digest :sha-1 :utf-8 nonce created secret)
          …]

 and the advantages of the more functional approach is much more than just 
 saving a few lines of code!

 Although it still needs some more work, any feedback on
 https://github.com/franks42/clj.security.message-digest;
 is much appreciated.

 Regards, FrankS.

 On Mar 4, 2013, at 1:31 PM, larry google groups lawrencecloj...@gmail.com 
 wrote:







  I finally got this to work. Many thanks for all of the help that I was
  given here.

  The final, winning combination was:

  (let [username (get-in @um/interactions [:omniture-api-
  credentials :username])
     secret (get-in @um/interactions [:omniture-api-credentials :shared-
  secret])
     random-number (math/round (* (rand 1 ) 100))
     nonce (DigestUtils/md5Hex (str random-number))
     nonce-encoded-base64 (base64-encode (.getBytes nonce))
     date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
     created (.format date-formatter (new Date))
     nonce-as-bytes (.getBytes nonce)
     created-as-bytes (.getBytes created)
     secret-as-bytes (.getBytes secret)
     digest (.digest
                 (doto (java.security.MessageDigest/getInstance
  sha1)
                      .reset
                       (.update nonce-as-bytes)
                       (.update created-as-bytes)
                        (.update secret-as-bytes)))
     digest-base64 (base64-encode digest)
     header (apply str  UsernameToken Username=\  username  \
  PasswordDigest=\ digest-base64 \ Nonce=\ nonce-encoded-base64
  \ Created=\ created \)]
  header)

  On Mar 4, 10:47 am, larry google groups lawrencecloj...@gmail.com
  wrote:
  I have been having problems making an API call to Omniture. I have
  exchanged a dozen emails with a developer at Omniture, and he gave me
  the impression that I was constructing my security codes incorrectly.
  So now I am confronting my ignorance over how Java handles certain
  conversions.

  The developer at Omniture sent me this explanation in an email:

   The security digest is formed from a sha1 hash of the following
  string concatenation:
  digest = sha1( Binary Nonce + Created Time String + API Secret Hex
  String (32 bytes) )  

  I have been struggling with this for several days and I have tried at
  least (literally) 200 variations on this bit of code:

  (let [username (get-in @um/interactions [:omniture-api-
  credentials :username])
        secret (get-in @um/interactions [:omniture-api-
  credentials 

Re: how to get SHA1 of a string?

2013-03-04 Thread Frank Siebenlist
If your code is for production… do not use my code!

It's pretty much written over the weekend and it's security code, meaning 
that it deserves much more scrutiny than ordinary code.

As mentioned in the readme, it's more an educational exercise, although it 
was good to see you struggling as it validated my concerns about the java 
library's approach ;-)

Don't even know if I'm willing to maintain it either…

Sorry for the bad news - I was just trying to sollicit feedback about 
alternative interfaces for the secure hashing.

Regards, FrankS.


On Mar 4, 2013, at 3:09 PM, larry google groups lawrencecloj...@gmail.com 
wrote:

 Frank,
 
 Any idea when you might release your code in a stable form? I am using
 this code at work so I am nervous about using code that is still
 marked SNAPSHOT. Lein reminds me not to use a SNAPSHOT:
 
 Could not find metadata org.clojars.franks42:clj.security.message-
 digest:0.1.0-SNAPSHOT/maven-metadata.xml in central (http://
 repo1.maven.org/maven2)
 Could not find metadata org.clojars.franks42:clj.security.message-
 digest:0.1.0-SNAPSHOT/maven-metadata.xml in central-proxy (https://
 repository.sonatype.org/content/repositories/centralm1/)
 Retrieving org/clojars/franks42/clj.security.message-digest/0.1.0-
 SNAPSHOT/maven-metadata.xml (1k)
from https://clojars.org/repo/
 Could not find artifact org.clojars.franks42:clj.security.message-
 digest:pom:0.1.0-20130304.220822-1 in central (http://repo1.maven.org/
 maven2)
 Retrieving org/clojars/franks42/clj.security.message-digest/0.1.0-
 SNAPSHOT/clj.security.message-digest-0.1.0-20130304.220822-1.pom (3k)
from https://clojars.org/repo/
 Retrieving org/clojure/clojure/1.5.0/clojure-1.5.0.pom (6k)
from http://repo1.maven.org/maven2/
 Retrieving org/clojars/franks42/clj.security.message-digest/0.1.0-
 SNAPSHOT/clj.security.message-digest-0.1.0-20130304.220822-1.jar (6k)
from https://clojars.org/repo/
 Compiling 1 source files to /Users/lkrubner/projects/multi-platform-
 data-visualization/mpdv-clojure/target/classes
 Release versions may not depend upon snapshots.
 Freeze snapshots to dated versions or set the
 LEIN_SNAPSHOTS_IN_RELEASE environment variable to override.
 
 
 
 
 
 
 On Mar 4, 4:55 pm, Frank Siebenlist frank.siebenl...@gmail.com
 wrote:
 Glad Larry has working code now...
 
 As I mentioned before in this thread, I'm working on this functional 
 interface for the message-digesting/secure-hashing, and this whole 
 discussion reads like a use case for the why? ;-)
 
 It proofs to me that there may be real value in a more user-friendly 
 approach than the one offered by java.security.MessageDigest.
 
 So instead of writing:
 
   (let [...
 nonce-as-bytes (.getBytes nonce)
 created-as-bytes (.getBytes created)
 secret-as-bytes (.getBytes secret)
 digest (.digest
   (doto (java.security.MessageDigest/getInstance sha1)
   .reset
(.update nonce-as-bytes)
(.update created-as-bytes)
 (.update secret-as-bytes)))
  …]
 
 my library lets you write:
 
   (let […
 digest (md/digest :sha-1 :utf-8 nonce created secret)
  …]
 
 and the advantages of the more functional approach is much more than just 
 saving a few lines of code!
 
 Although it still needs some more work, any feedback on
 https://github.com/franks42/clj.security.message-digest;
 is much appreciated.
 
 Regards, FrankS.
 
 On Mar 4, 2013, at 1:31 PM, larry google groups lawrencecloj...@gmail.com 
 wrote:
 
 
 
 
 
 
 
 I finally got this to work. Many thanks for all of the help that I was
 given here.
 
 The final, winning combination was:
 
 (let [username (get-in @um/interactions [:omniture-api-
 credentials :username])
secret (get-in @um/interactions [:omniture-api-credentials :shared-
 secret])
random-number (math/round (* (rand 1 ) 100))
nonce (DigestUtils/md5Hex (str random-number))
nonce-encoded-base64 (base64-encode (.getBytes nonce))
date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
created (.format date-formatter (new Date))
nonce-as-bytes (.getBytes nonce)
created-as-bytes (.getBytes created)
secret-as-bytes (.getBytes secret)
digest (.digest
(doto (java.security.MessageDigest/getInstance
 sha1)
 .reset
  (.update nonce-as-bytes)
  (.update created-as-bytes)
   (.update secret-as-bytes)))
digest-base64 (base64-encode digest)
header (apply str  UsernameToken Username=\  username  \
 PasswordDigest=\ digest-base64 \ Nonce=\ nonce-encoded-base64
 \ Created=\ created \)]
 header)
 
 On Mar 4, 10:47 am, larry google groups lawrencecloj...@gmail.com
 wrote:
 I have been having problems making an API call to Omniture. I have
 exchanged a dozen emails with a developer at Omniture, and he gave me
 the impression that I was 

how do I find an IO exception triggering retries in clj-http?

2013-03-04 Thread larry google groups

So, thanks to Michael Klishin, Aaron Cohen, Frank Siebenlist and Craig
Brozefsky I am now able to correctly ping the Omniture API. But I am
getting a strange behavior from the clj-http library. It makes 4 calls
to the API server, even though the first call is successful.

When I look here:

https://github.com/dakrone/clj-http

I see it says:

;; Apache's http client automatically retries on IOExceptions, if you
;; would like to handle these retries yourself, you can specify a
;; :retry-handler.

So, since it re-tries, I should assume that it is encountering an
IOException. But I get a successful response on the first try, so what
would the IOException be?

Because clj-http uses Slingshot, I have wrapped it in a try+ / catch
Object o block. And I print the o to the terminal, and yet I am not
seeing anything in the terminal. So where is the IOException? How do I
find it?

This is the actual function I use to ping the Omniture API:

(defn omniture-call-api [url-with-queue-method api-payload headers]
  (timbre/spy :debug  return value of omniture-call-api 
  (try+
(http-client/post url-with-queue-method
  {:body api-payload
   :debug true
   :debug-body true
   :insecure true
   :headers {X-Api-Version 2
 X-WSSE headers}
   :content-type :json
   :socket-timeout 4000
   :conn-timeout 4000
   :accept :json
   :client-params
{http.protocol.allow-circular-redirects true
   http.useragent
clj-http}})
(catch Object o (println (pp/pprint o))

If there is an IOException, why doesn't this line catch it?

(catch Object o (println (pp/pprint o))

I read here that catch Object o is the correct way to catch
everything, using Slingshot:

https://github.com/scgilardi/slingshot/issues/24

So why would I not see this error?






-- 
-- 
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: Listing more intuitive install options on the Clojure Downloads page

2013-03-04 Thread Sean Corfield
On Fri, Mar 1, 2013 at 9:58 AM, MC Andre andrew.penneba...@gmail.com wrote:
 I'm sure that Clojure users, especially novices, would appreciate these
 being listed as well-supported options on the official downloads page:

 * Windows chocolatey install clojure
 * Mac OS X brew install clojure
 * Ubuntu apt-get install clojure

Whilst this sort of advice crops up on numerous blogs, the collected
wisdom seems to be don't do that. Clojure itself is just a library
for the JVM and should be treated the way other JVM libraries are
treated.

The thing that needs to be installed - if you don't want to set your
hair on fire - is Leiningen.

We really need the clojure.org downloads page and the clojure.org
getting started page to tell people to use Leiningen and point to
http://leiningen.org (NOT the Github repo like it currently does!!).
clojure.org really is a disaster as far as new Clojure users are
concerned, especially when you compare it to almost the official site
for any other modern language... :(

Getting clojure.org updated seems to be an extremely difficult
process, however...
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
-- 
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: Inserting multiple rows with clj-jdbc

2013-03-04 Thread Sean Corfield
insert-records will use a single with-connection call and a single
transaction to wrap the inserts of all those records (maps).

On Fri, Mar 1, 2013 at 3:57 PM, Jonathon McKitrick jmckitr...@gmail.com wrote:
 Does insert-records with a collection of records have any performance
 advantage over calling insert-values for each row?  Is it only a question of
 network latency?

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





--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
-- 
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: how to get SHA1 of a string?

2013-03-04 Thread Frank Siebenlist
Larry,

What I can advise though, is to look at my library code and it may give you 
different perspectives. 

Furthermore, copy, borrow, and steal what you like and make it your own.

-FS.


On Mar 4, 2013, at 3:17 PM, Frank Siebenlist frank.siebenl...@gmail.com wrote:

 If your code is for production… do not use my code!
 
 It's pretty much written over the weekend and it's security code, meaning 
 that it deserves much more scrutiny than ordinary code.
 
 As mentioned in the readme, it's more an educational exercise, although it 
 was good to see you struggling as it validated my concerns about the java 
 library's approach ;-)
 
 Don't even know if I'm willing to maintain it either…
 
 Sorry for the bad news - I was just trying to sollicit feedback about 
 alternative interfaces for the secure hashing.
 
 Regards, FrankS.
 
 
 On Mar 4, 2013, at 3:09 PM, larry google groups lawrencecloj...@gmail.com 
 wrote:
 
 Frank,
 
 Any idea when you might release your code in a stable form? I am using
 this code at work so I am nervous about using code that is still
 marked SNAPSHOT. Lein reminds me not to use a SNAPSHOT:
 
 Could not find metadata org.clojars.franks42:clj.security.message-
 digest:0.1.0-SNAPSHOT/maven-metadata.xml in central (http://
 repo1.maven.org/maven2)
 Could not find metadata org.clojars.franks42:clj.security.message-
 digest:0.1.0-SNAPSHOT/maven-metadata.xml in central-proxy (https://
 repository.sonatype.org/content/repositories/centralm1/)
 Retrieving org/clojars/franks42/clj.security.message-digest/0.1.0-
 SNAPSHOT/maven-metadata.xml (1k)
   from https://clojars.org/repo/
 Could not find artifact org.clojars.franks42:clj.security.message-
 digest:pom:0.1.0-20130304.220822-1 in central (http://repo1.maven.org/
 maven2)
 Retrieving org/clojars/franks42/clj.security.message-digest/0.1.0-
 SNAPSHOT/clj.security.message-digest-0.1.0-20130304.220822-1.pom (3k)
   from https://clojars.org/repo/
 Retrieving org/clojure/clojure/1.5.0/clojure-1.5.0.pom (6k)
   from http://repo1.maven.org/maven2/
 Retrieving org/clojars/franks42/clj.security.message-digest/0.1.0-
 SNAPSHOT/clj.security.message-digest-0.1.0-20130304.220822-1.jar (6k)
   from https://clojars.org/repo/
 Compiling 1 source files to /Users/lkrubner/projects/multi-platform-
 data-visualization/mpdv-clojure/target/classes
 Release versions may not depend upon snapshots.
 Freeze snapshots to dated versions or set the
 LEIN_SNAPSHOTS_IN_RELEASE environment variable to override.
 
 
 
 
 
 
 On Mar 4, 4:55 pm, Frank Siebenlist frank.siebenl...@gmail.com
 wrote:
 Glad Larry has working code now...
 
 As I mentioned before in this thread, I'm working on this functional 
 interface for the message-digesting/secure-hashing, and this whole 
 discussion reads like a use case for the why? ;-)
 
 It proofs to me that there may be real value in a more user-friendly 
 approach than the one offered by java.security.MessageDigest.
 
 So instead of writing:
 
  (let [...
nonce-as-bytes (.getBytes nonce)
created-as-bytes (.getBytes created)
secret-as-bytes (.getBytes secret)
digest (.digest
  (doto (java.security.MessageDigest/getInstance sha1)
  .reset
   (.update nonce-as-bytes)
   (.update created-as-bytes)
(.update secret-as-bytes)))
 …]
 
 my library lets you write:
 
  (let […
digest (md/digest :sha-1 :utf-8 nonce created secret)
 …]
 
 and the advantages of the more functional approach is much more than just 
 saving a few lines of code!
 
 Although it still needs some more work, any feedback on
 https://github.com/franks42/clj.security.message-digest;
 is much appreciated.
 
 Regards, FrankS.
 
 On Mar 4, 2013, at 1:31 PM, larry google groups lawrencecloj...@gmail.com 
 wrote:
 
 
 
 
 
 
 
 I finally got this to work. Many thanks for all of the help that I was
 given here.
 
 The final, winning combination was:
 
 (let [username (get-in @um/interactions [:omniture-api-
 credentials :username])
   secret (get-in @um/interactions [:omniture-api-credentials :shared-
 secret])
   random-number (math/round (* (rand 1 ) 100))
   nonce (DigestUtils/md5Hex (str random-number))
   nonce-encoded-base64 (base64-encode (.getBytes nonce))
   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
   created (.format date-formatter (new Date))
   nonce-as-bytes (.getBytes nonce)
   created-as-bytes (.getBytes created)
   secret-as-bytes (.getBytes secret)
   digest (.digest
   (doto (java.security.MessageDigest/getInstance
 sha1)
.reset
 (.update nonce-as-bytes)
 (.update created-as-bytes)
  (.update secret-as-bytes)))
   digest-base64 (base64-encode digest)
   header (apply str  UsernameToken Username=\  username  \
 PasswordDigest=\ digest-base64 \ Nonce=\ nonce-encoded-base64
 \ Created=\ created \)]
 

Re: Clojurescript bug

2013-03-04 Thread Michał Marczyk
This particular problem goes away if you use ClojureScript release
1586 *and* rename the directory

  src/cljs/aima-clojure

to

  src/cljs/aima_clojure

and the file

  tictactoe-frontend.cljs

to

  tictactoe_frontend.cljs

Maybe we should warn on encountering filenames with dashes, or else
treat them as equivalent to underscores?

Cheers,
Michał


On 4 March 2013 21:35, Tom Hall thattommyh...@gmail.com wrote:
 Hello,

 I have just been stuck for ages trying to figure out what was going on
 in my first clojurescript application and think I have found a bug.

 I took some working game playing code for a simple tictactoe example
 and found that I got incorrectly names JS outputted

 I have created a project with as little clutter as possible.

 The cljs I am runing is at
 https://github.com/thattommyhall/cljs-bug/blob/master/src/cljs/aima-clojure/games/tictactoe-frontend.cljs
 and the commit that fixes it is
 https://github.com/thattommyhall/cljs-bug/commit/f80cdc4e97f94a6228ecf33d58d489af5de56245

 It seems to generate
 game.aima - clojure$game$Game$moves$arity$2
 (ie a subtraction operator) as you can see in the diff.

 I worked around it for now by adding an alias (def moves game/moves)
 outside and calling that rather than calling game/moves inside the
 function.

 Pretty sure this is a cljs bug as the clj tests run ok either way.


 Cheers,
 Tom

 --
 --
 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: Clojurescript bug

2013-03-04 Thread Michał Marczyk
PS. Incidentally, cljs-1450 has a bug which causes it to emit the
unmunged property name regardless of the filenames used. The relevant
ticket is CLJS-336, fixed in 9824dbd7c8ac658ebc2d5bc9fa6b5b898f17f659
(releases = 1503).


On 5 March 2013 01:06, Michał Marczyk michal.marc...@gmail.com wrote:
 This particular problem goes away if you use ClojureScript release
 1586 *and* rename the directory

   src/cljs/aima-clojure

 to

   src/cljs/aima_clojure

 and the file

   tictactoe-frontend.cljs

 to

   tictactoe_frontend.cljs

 Maybe we should warn on encountering filenames with dashes, or else
 treat them as equivalent to underscores?

 Cheers,
 Michał


 On 4 March 2013 21:35, Tom Hall thattommyh...@gmail.com wrote:
 Hello,

 I have just been stuck for ages trying to figure out what was going on
 in my first clojurescript application and think I have found a bug.

 I took some working game playing code for a simple tictactoe example
 and found that I got incorrectly names JS outputted

 I have created a project with as little clutter as possible.

 The cljs I am runing is at
 https://github.com/thattommyhall/cljs-bug/blob/master/src/cljs/aima-clojure/games/tictactoe-frontend.cljs
 and the commit that fixes it is
 https://github.com/thattommyhall/cljs-bug/commit/f80cdc4e97f94a6228ecf33d58d489af5de56245

 It seems to generate
 game.aima - clojure$game$Game$moves$arity$2
 (ie a subtraction operator) as you can see in the diff.

 I worked around it for now by adding an alias (def moves game/moves)
 outside and calling that rather than calling game/moves inside the
 function.

 Pretty sure this is a cljs bug as the clj tests run ok either way.


 Cheers,
 Tom

 --
 --
 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: core.logic: Dividing the knowledge base

2013-03-04 Thread JvJ
Thanks so much!  I'll check it out tomorrow!

On Monday, 4 March 2013 10:51:48 UTC-5, Norman Richards wrote:



 On Wed, Feb 27, 2013 at 4:03 PM, JvJ kfjwh...@gmail.com javascript:wrote:

 It states that retractions aren't yet implemented.  Is there any way to 
 delete facts?


 Retractions are now supported.  DB merging and cross-DB logic queries are 
 still coming.  Feel free to comment on the github issues if you have 
 specific use cases in mind you would like to see this support.  I have some 
 specific ideas for things we want to do with this at Threatgrid, but that's 
 only one use case.
  

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




  1   2   >