Re: [ANN] Chord 0.2.1 - making WebSockets look like core.async channels in CLJ+CLJS

2013-12-02 Thread Henrik Eneroth
Cool! I presume you're restricted to EDN on the channels though, right? 

On Saturday, November 30, 2013 5:23:17 PM UTC+1, James Henderson wrote:
>
> https://github.com/james-henderson/chord
>
> Chord is a library for making WebSockets look like simple core.async 
> channels in Clojure (using http-kit) and ClojureScript. 
>
> Basic usage:
>
> Leiningen: 
>
> [jarohen/chord "0.2.1"]
>
> ClojureScript:
>
> (:require [chord.client :refer [ws-ch]]
>   [cljs.core.async :refer [! put! close!]])(:require-macros 
> [cljs.core.async.macros :refer [go]])
> (go
>  (let [ws ((>! ws "Hello server!")
>(loop []
>  (when-let [{:keys [message]} ((js/console.log "Got message from server:" message)
>(recur)
>
>
> Clojure (a wrapper around http-kit's 'with-channel'):
>
> (:require [chord.http-kit :refer [with-channel]]
>   [clojure.core.async :refer [! put! close! go]])
> (defn your-handler [req]
>   (with-channel req ws-ch
> (go
>   (let [{:keys [message]} ( (println "Message received from client:" message)
> (>! ws-ch "Hello client from server!")
> (close! ws-ch)
>
>
> There's more documentation and a few code examples on the Github page, and 
> a full example project in the repo. 
>
> Feedback is *always very welcome* - either here, through Github in the 
> usual way or (if it fits into 140 chars!) Twitter.
>
> Version 0.2.1 brings the ability to specify custom buffered channels - 
> thanks to Timo Sulg for the PR!
>
> James (@jarohen)
>

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


Import dbpediad data into Neo4j using clojure

2013-12-02 Thread Himakshi Mangal
Hi.. 

I am using clojure to import dbpedia dat into neo4j..

Here's the code:

(ns opal.dbpedia
  (:use [clojure.tools.logging :only [log]])
  (:require [clojure.java.io :as io])
  (:import [uk.ac.manchester.cs.owl.owlapi.turtle.parser TurtleParser]
   [org.neo4j.unsafe.batchinsert BatchInserters]
   [org.neo4j.graphdb DynamicRelationshipType]))

;; PARSING METHODS

(defn get-next-tuple
  [parser]
  (let [last-item (atom nil)
tuple (atom [])]
(while (and (not= "." @last-item)
(not= "" @last-item))
  (reset! last-item
  (-> parser
(.getNextToken)
(.toString)))
  (swap! tuple conj @last-item))
(when-not (empty? (first @tuple)) ; .getNextToken returns "" once you 
are out of data
  @tuple)))

(defn seq-of-parser
  [parser]
  (if-let [next-tuple (get-next-tuple parser)]
(lazy-cat [next-tuple]
  (seq-of-parser parser

(defn parse-file
  [filename]
  (seq-of-parser
(TurtleParser.
  (io/input-stream filename

;; BATCH UPSERT METHODS

(def id-map (atom nil))
(defn insert-resource-node!
  [inserter res]
  (if-let [id (get @id-map res)]
; If the resource has aleady been added, just return the id.
id
; Otherwise, add the node for the node, and remember its id for later.
(let [id (.createNode inserter {"resource" res})]
  (swap! id-map #(assoc! % res id))
  id)))

(defn connect-resource-nodes!
  [inserter node1 node2 label]
  (let [relationship (DynamicRelationshipType/withName label)]
(.createRelationship inserter node1 node2 relationship nil)))

(defn insert-tuple!
  [inserter tuple]
  ; Get the resource and label names out of the tuple.
  (let [[resource-1 label resource-2 & _ ] tuple
; Upsert the resource nodes.
node-1 (insert-resource-node! inserter resource-1)
node-2 (insert-resource-node! inserter resource-2)]
; Connect the nodes with an edge.
(connect-resource-nodes! inserter node-1 node-2 label)))

(defn -main [graph-path & files]
  (let [inserter (BatchInserters/inserter graph-path)]
(doseq [file files]
  (log :debug (str "Loading file: " file))
  (let [c (atom 0)]
(doseq [tuple (parse-file file)]
  (if (= (mod @c 1) 0)
(log :debug (str file ": " @c)))
  (swap! c inc)
  (insert-tuple! inserter tuple
(log :debug "Loading complete.")
(log :debug "Shutting down.")
(.shutdown inserter)
(log :debug "Shutdown complete!")))

I am getting the following errors: 
IllegalAccessError Transient used by non-owner thread 
 clojure.lang.PersistentArrayMap$TransientArrayMap.ensureEditable 
(PersistentArrayMap.java:449) at line

& 


IllegalArgumentException No matching method found: createNode for class 
org.neo4j.unsafe.batchinsert.BatchInserterImpl 
 clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:53)


Can you please tell me what is that i am doing wrong. Or am i missing 
something?
Please help

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


Import dbpedia data into neo4j using clojure

2013-12-02 Thread Himakshi Mangal
Hi...


I am using clojure to import dbpedia data into neo4j.

Here's the code:
(ns opal.dbpedia
  (:use [clojure.tools.logging :only [log]])
  (:require [clojure.java.io :as io])
  (:import [uk.ac.manchester.cs.owl.owlapi.turtle.parser TurtleParser]
   [org.neo4j.unsafe.batchinsert BatchInserters]
   [org.neo4j.graphdb DynamicRelationshipType]))

;; PARSING METHODS

(defn get-next-tuple
  [parser]
  (let [last-item (atom nil)
tuple (atom [])]
(while (and (not= "." @last-item)
(not= "" @last-item))
  (reset! last-item
  (-> parser
(.getNextToken)
(.toString)))
  (swap! tuple conj @last-item))
(when-not (empty? (first @tuple)) ; .getNextToken returns "" once you 
are out of data
  @tuple)))

(defn seq-of-parser
  [parser]
  (if-let [next-tuple (get-next-tuple parser)]
(lazy-cat [next-tuple]
  (seq-of-parser parser

(defn parse-file
  [filename]
  (seq-of-parser
(TurtleParser.
  (io/input-stream filename

;; BATCH UPSERT METHODS

(def id-map (atom nil))
(defn insert-resource-node!
  [inserter res]
  (if-let [id (get @id-map res)]
; If the resource has aleady been added, just return the id.
id
; Otherwise, add the node for the node, and remember its id for later.
(let [id (.createNode inserter {"resource" res})]
  (swap! id-map #(assoc! % res id))
  id)))

(defn connect-resource-nodes!
  [inserter node1 node2 label]
  (let [relationship (DynamicRelationshipType/withName label)]
(.createRelationship inserter node1 node2 relationship nil)))

(defn insert-tuple!
  [inserter tuple]
  ; Get the resource and label names out of the tuple.
  (let [[resource-1 label resource-2 & _ ] tuple
; Upsert the resource nodes.
node-1 (insert-resource-node! inserter resource-1)
node-2 (insert-resource-node! inserter resource-2)]
; Connect the nodes with an edge.
(connect-resource-nodes! inserter node-1 node-2 label)))

(defn -main [graph-path & files]
  (let [inserter (BatchInserters/inserter graph-path)]
(doseq [file files]
  (log :debug (str "Loading file: " file))
  (let [c (atom 0)]
(doseq [tuple (parse-file file)]
  (if (= (mod @c 1) 0)
(log :debug (str file ": " @c)))
  (swap! c inc)
  (insert-tuple! inserter tuple
(log :debug "Loading complete.")
(log :debug "Shutting down.")
(.shutdown inserter)
(log :debug "Shutdown complete!")))

I am getting the following errors:

IllegalAccessError Transient used by non-owner thread 
 clojure.lang.PersistentArrayMap$TransientArrayMap.ensureEditable 
(PersistentArrayMap.java:449) 

&&


IllegalArgumentException No matching method found: createNode for class 
org.neo4j.unsafe.batchinsert.BatchInserterImpl 
 clojure.lang.Reflector.invokeMatchingMethod


Can anyone please help me in this.. Am doing something wrong or am i 
missing something.. I am completely new to clojure. Is there a working 
example for this?


Please help..

Thanks 


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


Re: [ANN] Chord 0.2.1 - making WebSockets look like core.async channels in CLJ+CLJS

2013-12-02 Thread James Henderson
Unfortunately Chord only accepts raw strings on the channel at the moment - 
I've been using pr-str and read-string around EDN messages until now. 

It's a great idea to be able to format/parse different message formats 
automatically though and something that IMO Chord should provide. I've 
added a GitHub issue  - 
watch this space!

Thanks,

James

On Monday, 2 December 2013 09:38:50 UTC, Henrik Eneroth wrote:
>
> Cool! I presume you're restricted to EDN on the channels though, right? 
>
> On Saturday, November 30, 2013 5:23:17 PM UTC+1, James Henderson wrote:
>>
>> https://github.com/james-henderson/chord
>>
>> Chord is a library for making WebSockets look like simple core.async 
>> channels in Clojure (using http-kit) and ClojureScript. 
>>
>> Basic usage:
>>
>> Leiningen: 
>>
>> [jarohen/chord "0.2.1"]
>>
>> ClojureScript:
>>
>> (:require [chord.client :refer [ws-ch]]
>>   [cljs.core.async :refer [! put! close!]])(:require-macros 
>> [cljs.core.async.macros :refer [go]])
>> (go
>>  (let [ws (>(>! ws "Hello server!")
>>(loop []
>>  (when-let [{:keys [message]} (>(js/console.log "Got message from server:" message)
>>(recur)
>>
>>
>> Clojure (a wrapper around http-kit's 'with-channel'):
>>
>> (:require [chord.http-kit :refer [with-channel]]
>>   [clojure.core.async :refer [! put! close! go]])
>> (defn your-handler [req]
>>   (with-channel req ws-ch
>> (go
>>   (let [{:keys [message]} (> (println "Message received from client:" message)
>> (>! ws-ch "Hello client from server!")
>> (close! ws-ch)
>>
>>
>> There's more documentation and a few code examples on the Github page, 
>> and a full example project in the repo. 
>>
>> Feedback is *always very welcome* - either here, through Github in the 
>> usual way or (if it fits into 140 chars!) Twitter.
>>
>> Version 0.2.1 brings the ability to specify custom buffered channels - 
>> thanks to Timo Sulg for the PR!
>>
>> James (@jarohen)
>>
>

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


graphs library?

2013-12-02 Thread Paweł Rozynek
hello

quick question: is there any good graphs related library? the one that 
implements data structures and search/traverse or some other algorithms in 
a nice fashion. googling found me nothing useful for my simple needs, neo4j 
client libs at best.

thanks for responses
PR

-- 
-- 
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 for the Brave and True, an online book for beginners

2013-12-02 Thread Daniel Higginbotham
Thanks, Paddy! It's very encouraging to hear such positive feedback :) I'm 
glad it was useful for you!

Daniel


On Sunday, December 1, 2013 7:51:35 PM UTC-5, Paddy Gallagher wrote:
>
> Daniel,
>
> I've just finished reading this series and thought it was superb. The 
> Emacs chapters in particular were a massive help. I'm a complete newbie 
> with Emacs and the detail here was pitched just perfectly. It got me 
> exactly what I needed to start to become productive very quickly. 
>
> I highly recommend it as a resource both for the excellent 
> content/philosophy and humour :)
>
> It personally made my introductory Clojure learning experience a very 
> enjoyable one. 
>
> Thanks Daniel and hello from London :)
>
> cheers
>
> Paddy
>
> On Monday, September 2, 2013 4:35:52 PM UTC+1, Daniel Higginbotham wrote:
>>
>> Hi all,
>>
>> I've been putting together http://www.braveclojure.com/ and would love 
>> feedback. I've tried to make it entertaining and super beginner-friendly.
>>
>> Thanks!
>> Daniel
>>
>

-- 
-- 
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: graphs library?

2013-12-02 Thread keeds
Plenty here?: http://clojurewerkz.org/

On Monday, 2 December 2013 14:01:12 UTC, Paweł Rozynek wrote:
>
> hello
>
> quick question: is there any good graphs related library? the one that 
> implements data structures and search/traverse or some other algorithms in 
> a nice fashion. googling found me nothing useful for my simple needs, neo4j 
> client libs at best.
>
> thanks for responses
> PR
>

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


Re: [ANN] Chord 0.2.1 - making WebSockets look like core.async channels in CLJ+CLJS

2013-12-02 Thread Henrik Eneroth
Since we don't really care what the data looks like while it's on the wire, 
it could even be byte code in order to compress data. But it's certainly 
nice if it's possible to use EDN in any case.

Also, you could consider whether it'd be worthwhile interacting with 
something like SockJS in order to get wider platform support. 

On Monday, December 2, 2013 2:02:35 PM UTC+1, James Henderson wrote:
>
> Unfortunately Chord only accepts raw strings on the channel at the moment 
> - I've been using pr-str and read-string around EDN messages until now. 
>
> It's a great idea to be able to format/parse different message formats 
> automatically though and something that IMO Chord should provide. I've 
> added a GitHub issue  - 
> watch this space!
>
> Thanks,
>
> James
>
> On Monday, 2 December 2013 09:38:50 UTC, Henrik Eneroth wrote:
>>
>> Cool! I presume you're restricted to EDN on the channels though, right? 
>>
>> On Saturday, November 30, 2013 5:23:17 PM UTC+1, James Henderson wrote:
>>>
>>> https://github.com/james-henderson/chord
>>>
>>> Chord is a library for making WebSockets look like simple core.async 
>>> channels in Clojure (using http-kit) and ClojureScript. 
>>>
>>> Basic usage:
>>>
>>> Leiningen: 
>>>
>>> [jarohen/chord "0.2.1"]
>>>
>>> ClojureScript:
>>>
>>> (:require [chord.client :refer [ws-ch]]
>>>   [cljs.core.async :refer [! put! close!]])(:require-macros 
>>> [cljs.core.async.macros :refer [go]])
>>> (go
>>>  (let [ws (>>(>! ws "Hello server!")
>>>(loop []
>>>  (when-let [{:keys [message]} (>>(js/console.log "Got message from server:" message)
>>>(recur)
>>>
>>>
>>> Clojure (a wrapper around http-kit's 'with-channel'):
>>>
>>> (:require [chord.http-kit :refer [with-channel]]
>>>   [clojure.core.async :refer [! put! close! go]])
>>> (defn your-handler [req]
>>>   (with-channel req ws-ch
>>> (go
>>>   (let [{:keys [message]} (>> (println "Message received from client:" message)
>>> (>! ws-ch "Hello client from server!")
>>> (close! ws-ch)
>>>
>>>
>>> There's more documentation and a few code examples on the Github page, 
>>> and a full example project in the repo. 
>>>
>>> Feedback is *always very welcome* - either here, through Github in the 
>>> usual way or (if it fits into 140 chars!) Twitter.
>>>
>>> Version 0.2.1 brings the ability to specify custom buffered channels - 
>>> thanks to Timo Sulg for the PR!
>>>
>>> James (@jarohen)
>>>
>>

-- 
-- 
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] lein-sync 0.2

2013-12-02 Thread Phillip Lord


This is the second release of lein sync. It includes a major bugfix, and
updates for Cider.


https://github.com/phillord/lein-sync

>From the readme!



A leiningen plugin to enable syncing an existing Clojure REPL to the current
leiningen project using pomegranate.

Sometimes, when you do not control the launch of the JVM which is running your
REPL. This might be because the JVM was launched some time ago, or for
instance, because you are running a Clojure REPL inside an application with a
complex launch procedure. One solution is to reach for
[pomegranate](https://github.com/cemerick/pomegranate) which allows you to
dynamically expand the classpath or to add Maven dependencies; you can add
pomegranate to the classpath of the JVM which launches the REPL once, then do
what ever you want later.

This is okay as a quick fix, but if you need to do this often, it's painful.
What you really want to do is create a new leiningen project, and add all of
the tools and scripts that you use regularly to this. lein-sync is for this
purpose; it generates a file `.sync.clj` which when evaled in the REPL will
sync dependencies and classpaths to those of the current project.

-- 
-- 
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: graphs library?

2013-12-02 Thread Thomas Heller
https://github.com/aysylu/loom is pretty neat.

On Monday, December 2, 2013 3:54:25 PM UTC+1, keeds wrote:
>
> Plenty here?: http://clojurewerkz.org/
>
> On Monday, 2 December 2013 14:01:12 UTC, Paweł Rozynek wrote:
>>
>> hello
>>
>> quick question: is there any good graphs related library? the one that 
>> implements data structures and search/traverse or some other algorithms in 
>> a nice fashion. googling found me nothing useful for my simple needs, neo4j 
>> client libs at best.
>>
>> thanks for responses
>> PR
>>
>

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


reduce vs fold

2013-12-02 Thread cloverethos
Hi everyone,

Let d be some map, says {1 3/5, 2 1/5, 3 1/5}
why
(reduce + (map #(% 1) d)) => 1
while
(fold + (map #(% 1) d)) => ArityException Wrong number of args (2) passed to

The reduce,fold, and map are those in the reducers namespace.

Can someone explain to me? Thanks 
-
Caleb

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


clojure.zip branch? and next behaviour

2013-12-02 Thread Milton Silva
I was trying to write a function next-branch.

I wrote somthing like:
(use 'clojure.zip)
(def zp (seq-zip '(+ 1 2 (+ 3 4) (+ 5 6
(defn next-branch [loc] (second (filter branch? (iterate next loc

(next-branch (next-branch (next-branch zp)))
this results in: NullPointerException   clojure.zip/branch? (zip.clj:73)

Reading the docs of next "returns a distinguished loc", this seams to imply 
next should always return a loc even when at the end. The docs of branch? 
"Returns 
true if the node at loc is a branch" seam to imply any loc will do.

So this would lead me to concluded that next always returns a "loc" and 
since branch? is supposed to take a "loc" it should work.

Why doesn't next return a loc at the end? Looking at the code I know "why" 
but is it intended to be this way? If so 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: [ANN] Optimus - a Ring middleware for frontend performance optimization.

2013-12-02 Thread Howard M. Lewis Ship


On Wednesday, 27 November 2013 11:11:56 UTC-8, Magnar Sveen wrote:
>
>
> On Wednesday, November 27, 2013 1:08:34 PM UTC+1, Stefan Kamphausen wrote:
>  
>
>> Howard has quite some experience with this and I'd expect he put a great 
>> deal of that into the new library. :-)
>>
>  
> Indeed. There's certainly a lot of care that's been put into the features 
> that are in Twixt now. :-)
>

I'd say that Optimus has a lot of great features, and so does Twixt.  

w.r.t. gzip; for assets, which are effectively static, it is silly to burn 
CPU to compress them on each request, so the gzip is at that level to 
support caching of the gzipped content.  You will certainly want gzip 
support for dynamic content.

Of course, in an AngularJS app, all your templates are static content 
(assets) as well, so you just want to gzip your JSON or EDN responses.

>From a cursory view of the Optimus readme, there's just differences in 
priorities of certain features; also  Twixt serves assets from 
META-INF/assets, not from a disk folder. That was actually the reason to 
move off of Dieter; that was not possible, and we had restrictions in our 
deployment model that required it.

Twixt is more interested in providing a development-time work cycle where 
changed assets are recompiled and otherwise reconstituted.  I don't want to 
have to bounce my app just because a stylesheet changed ... but in 
production, I don't want to burn cycles checking to see if files that will 
never change, have changed.



> - Magnar
>

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


Re: [ANN] Optimus - a Ring middleware for frontend performance optimization.

2013-12-02 Thread Howard M. Lewis Ship


On Monday, 25 November 2013 18:12:28 UTC-8, Paul Biggar wrote:
>
> [FYI: I'm the author/forker of stefon]
>
> These libraries aren't bad, but to be honest, I think we've done it all 
> wrong. We're just all scratching our own itches, not writing reusable 
> components (unlike most of the rest of the clojure web ecosystem).
>
> If you look at stefon, you get a set of non-composable functions, designed 
> for my exact use case. Optimus, cornet, and dieter all suffer from the same 
> problems.
>
> Cornet, supports compilation (with different compiler and versions from 
> stefon), serving assets, and configuring itself from a JVM command line. It 
> also has :dev and :prod modes (though these mean "dont minify" and "do 
> minify". It does split out the functions in a slightly composable way (you 
> can have `(wrap-lesscss-processor loader :mode :dev)`), but those still use 
> :mode.
>
> Stefon supports: concatenating JS and CSS, compiling less, coffeescript, 
> hamlcoffee, minification using Closure compiler (currently broken), some 
> trivial css minification, cache-busting and expiry headers, and asset 
> references (eg data-uri to put the contents of one asset in another). It 
> also supports caching compilation and clj-v8 for speed, and expiration 
> headers and cache busting. It has precompilation for production use with a 
> CDN).
>
> Dieter is basically like stefon, but older and less maintained, and some 
> different choices around precompilation.
>
> Optimus supports concatenating, minification, cache busting, expiry 
> headers, and something angular specific. Also assets dont have to be files 
> on disk, and a there's a list of a dozen or so other features that contrast 
> it to stefon or cornet in a neutral way (neither decision is right or 
> wrong, just different).
>
> So basically stefon supports all high level use cases, optimus support all 
> of them except compilation, cornet supports most of it but not cache 
> busting. But where we do support the same things, we do it in many 
> different ways.
>
> So my problem here is that we've each chosen to couple everything 
> together. If you want to use stefon's CDN feature in production, with 
> optimus' dev asset serving, with cornet's minification, you're out of luck.
>
> Weavejester made a critique of stefon on reddit [1] a while back. He made 
> the point "why isn't this just middleware", by which I believe he means 
> "why cant this all be split up into composable functions?"
>
> He's right. We should, IMO, stop doing what we're doing, and rebuild our 
> projects into a set of composable components that play well together:
>
> - a choice of caching middlewares
> - a choice of minifying middlewares
> - a choice of asset compilers (including different versions and 
> implementations) (also some way for them to interact to support a pipeline)
> - a choice of precompilation/CDN and compiling on the server
> - composable optimizations (caching compilations)
> - a choice of how to concatenate assets
>
> I don't really know how to do this though, just that they should be 
> different libraries, and that all orthogonal feature sets should be 
> composable. I'd love to hear people's thoughts on how we can accomplish 
> this.
>
> [1] 
> http://www.reddit.com/r/Clojure/comments/1n1n0p/circlecistefon_asset_pipeline_for_clojure_closely/ccexi3a
>

I got some feedback along these lines for Twixt, from technomancy.

I rewrote most of the code and was pleased with the result.

The approach I took was to have an "asset pipeline" that was used by Twixt; 
it was built by the application (there's a default for most cases). The 
asset pipeline works much like the Ring request pipeline, you can add 
middleware to it.

Even the default pipeline understands production mode vs. development mode, 
which is (currently) mostly a question of what gets cached and when the 
cache is checked to see if it is dirty, if at all.

 

>
> On Monday, 25 November 2013 11:10:54 UTC-8, Magnar Sveen wrote:
>>
>> Hi Jason! 
>>
>> Magnar, could you talk a little about how your project is better 
>>> than/different from Stefon/dieter and cornet? I feel like we have a lot of 
>>> these projects now, all doing mostly the same thing.
>>>
>>
>> Thanks for asking. I'll try to shed some light on the differences as I 
>> see them, and hopefully the people behind Dieter/Stefon (they're very 
>> similar) can add some details into their thinking. I haven't seen Comet, 
>> and google didn't help much either. Can you share a link?
>>
>> As for Optimus vs Stefon: First of all it's a difference in focus. Stefon 
>> focuses on being an asset pipeline modelled after Sprockets in Rails. It 
>> lets you write LESS, CoffeeScript, Haml - turning it into CSS and 
>> JavaScript. Optimus is not about transpiling from other languages, but 
>> about frontend optimization. As such, it rewrites your urls to include 
>> cache busters and serves your assets with far-future expires headers, so 
>> they can be cached a

Re: 2013 State of Clojure & ClojureScript survey results

2013-12-02 Thread Alex Miller
Two follow-ups categorizing results from the "missing language" and 
"weaknesses" questions:

http://tech.puredanger.com/2013/11/19/state-of-clojure-language-features/
http://tech.puredanger.com/2013/12/01/clj-problems/

Alex

On Monday, November 18, 2013 1:32:56 PM UTC-6, Chas Emerick wrote:
>
> Results of this year's survey are available here: 
>
>
> http://cemerick.com/2013/11/18/results-of-the-2013-state-of-clojure-clojurescript-survey/
>  
>
> Thank you to all that participated! 
>
> Best, 
>
> - 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: [ANN] Slamhound 1.5.0 + screencast + Vim plugin

2013-12-02 Thread guns
On Mon 2 Dec 2013 at 12:42:46AM -0800, Patrick Kristiansen wrote:

> On Sun, Dec 1, 2013, at 05:16 PM, guns wrote:
>
> > I hope you find this information useful. Exactly one year ago I
> > became very unsatisfied with Vim for working with Clojure, and toyed
> > with Emacs for a bit (evil-mode). It was nice, but I decided to stay
> > with Vim and create the tools that I felt I was missing. Today, I am
> > a very happy hacker!
>
> Well, I'm familiar with both your static Clojure files for Vim (which
> I know Meikel Brandmeyer is the original author of) and vim-sexp, and
> these make me a happy hacker too :-)

Ah, sorry for the lengthy ad for vim-sexp then :)

> Thanks for your work. I really appreciate it. Especially thanks for
> getting good enough to write VimScript, which I haven't had the
> courage for yet. ;-)

Yes, VimScript is pretty terrible; it actually reminds me quite a bit of
PHP. When Github used to list the supposed favorite languages of users,
my top language was listed as VimL, which was embarassing.

That said, there's still lots of low-hanging fruit as far as Vim/Clojure
plugins, so such projects are well-appreciated the dozens of us in the
community.

Thanks for trying Slamhound!

guns


pgpWCbf66WU2n.pgp
Description: PGP signature


Re: [ANN] Buffy The ByteBuffer Slayer, Clojure library to working with binary data

2013-12-02 Thread Alex P
It's different in a way we manipulate the data:

We've opted out for default-lazy way (you're getting and setting separate 
values instead of serialising/deserialising an entire payload).

Another difference is that we don't have Lamina as a loaded artifact (which 
may not be an issue for majority of people, but was for us 
because of an internal version conflict with some other library). 
Obviously, there are ways around it, but we tried to bring in minimum
possible amount of dependencies, and be able to use it with Netty4 (which 
is currently underrepresented in Clojure world).

There are other subtle difference, but I don't think they're worth 
mentioning, Gloss is a great library, but Buffy is doing things in a subtly
different way. Main purpose (as we're using it) - for off-heap storage / 
data structures, and for binary protocol implementations in Clojure
(right now, we have a sketch of Cassandra binary protocol implemented on 
top of Buffy, although I'm not sure wether it's going to be
production-ready any time soon).


Thanks for props!

On Saturday, November 30, 2013 10:33:31 PM UTC+1, Thomas wrote:
>
> Looks really really great and could you please explain how it differs from 
> gloss [1]. Any advantages? Disadvantages?
>
> Thanks
> Thomas
>
> [1] 
> https://github.com/ztellman/gloss
>
> On Friday, November 29, 2013 10:15:45 PM UTC, Alex P wrote:
>>
>> Buffy [1] is a Clojure library to work with Binary Data, write complete 
>> binary protocol implementations
>> in clojure, store your complex data structures in an off-heap chache, 
>> read binary files and do
>> everything you would usually do `ByteBuffer`.
>>
>> Main features & motivation to write it
>>
>>   * partial deserialization (read and deserialise parts of a byte buffer)
>>   * named access (access parts of your buffer by names)
>>   * composing/decomposing from key/value pairs
>>   * pretty hexdump
>>   * many useful default types that you can combine and extend easily
>>
>> Data types include:
>>
>>   * primitives, such as `int32`, `boolean`, `byte`, `short`, `medium`, 
>> `float`, `long`
>>   * arbitrary-length `string`
>>   * byte arrays
>>   * composite types (combine any of primitives together)
>>   * repeated type (repeat any primitive arbitrary amount of times in 
>> payload)
>>   * enum type (for mapping between human-readable and binary 
>> representation of constants)
>>
>> Buffy has been serving us well for recent time, and no major issues were 
>> revealed. However, until 
>> it reaches GA, we can't guarantee 100% backward compatibility, although 
>> we're thought it through
>> very well and used our best knowledge to make it right.
>>
>> Buffy is a ClojureWerkz project, same as Monger, Elastisch, Cassaforte, 
>> Neocons, Meltdown and
>> many others. 
>>
>> [1] https://github.com/clojurewerkz/buffy
>> [2] http://clojurewerkz.org
>>
>> -- 
>>
>> Alex P
>>
>> http://clojurewerkz.org
>>
>> http://twitter.com/ifesdjeen
>>
>

-- 
-- 
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: I need a vector not a list?

2013-12-02 Thread Alex Miller
Actually, I'd say seqs are very much *unlike* iterators in other languages 
(Java in particular). 

Iterators - stateful cursors that conflate iteration with a check for 
whether more elements exist
Seqs - immutable persistent views of a collection that separate iteration 
from checking for more elements

http://clojure.org/sequences


On Sunday, December 1, 2013 6:22:57 PM UTC-6, James Reeves wrote:
>
> Seqs in Clojure are very much like iterators in other languages. They're 
> an abstraction for navigating a sequential data structure.
>
> Also because values in Clojure are immutable, you rarely, if at all, 
> encounter situations where those objects need to be copied. Why would you, 
> when you can just reference the original object, secure in the knowledge 
> that its value cannot change.
>
> - James
>
>
> On 1 December 2013 20:15, Andy Smith 
> > wrote:
>
>> Can a seq be thought of as a kind of a list of pointers to the original 
>> vector elements then? If so, then does an operation on a vector, (e.g. 
>> reverse), cause clojure to internally generate a seq of pointers to the 
>> original vector elements? In other words seqs seem to provide a layer of 
>> indirection to avoid the need to copy elements of the original collection?
>>
>>
>> On Saturday, 30 November 2013 21:31:34 UTC, Jim foo.bar wrote:
>>
>>> On Sat, 30 Nov 2013 13:15:33 -0800 (PST) 
>>> Andy Smith  wrote: 
>>>
>>> > but 
>>> > my question is really about the more general case of any function 
>>> > that manipulates a vector e.g. the following also returns a list 
>>> > rather than a vector as desired, 
>>>
>>> In Clojure you rarely have to worry about types. All the 
>>> data-structures fall under a common set of abstractions and in 
>>> particular the ISeq interface. Strictly speaking map returns a seq not 
>>> a list. In fact a lazy seq...this is by design so further operations 
>>> can be applied lazily later...if you use eager operations like mapv 
>>> exclusively you lose the ability to aggregate operations without cost. 
>>> hope that clarifies it... 
>>>
>>>
>>> Jim 
>>>
>>  -- 
>> -- 
>> 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.


Recruiter claims to be Rick Hickey's sister

2013-12-02 Thread Alan Shaw
Can I get a quick reality check on this?
Thanks!

-A

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


Recruiter claims to be Rich Hickey's sister

2013-12-02 Thread Alan Shaw
Can I get a quick reality check on this?
Thanks!

-A

-- 
-- 
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: Recruiter claims to be Rick Hickey's sister

2013-12-02 Thread Robert Levy
Yes Alan, Jenn Hillner is Rich Hickey's sister. I've worked with her on
finding a job before, and highly recommend.

-Rob


On Mon, Dec 2, 2013 at 2:18 PM, Alan Shaw  wrote:

> Can I get a quick reality check on this?
> Thanks!
>
> -A
>
> --
> --
> 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: Recruiter claims to be Rick Hickey's sister

2013-12-02 Thread Alan Shaw
Great, thanks a lot Robert!


On Mon, Dec 2, 2013 at 3:06 PM, Robert Levy  wrote:

> Yes Alan, Jenn Hillner is Rich Hickey's sister. I've worked with her on
> finding a job before, and highly recommend.
>
> -Rob
>
>
> On Mon, Dec 2, 2013 at 2:18 PM, Alan Shaw  wrote:
>
>> Can I get a quick reality check on this?
>> Thanks!
>>
>> -A
>>
>> --
>> --
>> 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: I need a vector not a list?

2013-12-02 Thread James Reeves
Perhaps I should have said that seqs fulfil the same role as iterators do,
rather than claiming they're alike :)

- James


On 2 December 2013 21:42, Alex Miller  wrote:

> Actually, I'd say seqs are very much *unlike* iterators in other languages
> (Java in particular).
>
> Iterators - stateful cursors that conflate iteration with a check for
> whether more elements exist
> Seqs - immutable persistent views of a collection that separate iteration
> from checking for more elements
>
> http://clojure.org/sequences
>
>
> On Sunday, December 1, 2013 6:22:57 PM UTC-6, James Reeves wrote:
>
>> Seqs in Clojure are very much like iterators in other languages. They're
>> an abstraction for navigating a sequential data structure.
>>
>> Also because values in Clojure are immutable, you rarely, if at all,
>> encounter situations where those objects need to be copied. Why would you,
>> when you can just reference the original object, secure in the knowledge
>> that its value cannot change.
>>
>> - James
>>
>>
>> On 1 December 2013 20:15, Andy Smith  wrote:
>>
>>> Can a seq be thought of as a kind of a list of pointers to the original
>>> vector elements then? If so, then does an operation on a vector, (e.g.
>>> reverse), cause clojure to internally generate a seq of pointers to the
>>> original vector elements? In other words seqs seem to provide a layer of
>>> indirection to avoid the need to copy elements of the original collection?
>>>
>>>
>>> On Saturday, 30 November 2013 21:31:34 UTC, Jim foo.bar wrote:
>>>
 On Sat, 30 Nov 2013 13:15:33 -0800 (PST)
 Andy Smith  wrote:

 > but
 > my question is really about the more general case of any function
 > that manipulates a vector e.g. the following also returns a list
 > rather than a vector as desired,

 In Clojure you rarely have to worry about types. All the
 data-structures fall under a common set of abstractions and in
 particular the ISeq interface. Strictly speaking map returns a seq not
 a list. In fact a lazy seq...this is by design so further operations
 can be applied lazily later...if you use eager operations like mapv
 exclusively you lose the ability to aggregate operations without cost.
 hope that clarifies it...


 Jim

>>>  --
>>> --
>>> 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: Import dbpedia data into neo4j using clojure

2013-12-02 Thread Joel Holdbrooks
I'm not certain where the Transient error is coming from but as far as 
Neo4J is concerned have you considered using the neocons library to help 
you with your import? It provides a decent wrapper for working with Neo4J 
and perhaps it will spare you some headache. IIRC it does batch inserts. 
Have a look: https://github.com/michaelklishin/neocons

On Monday, December 2, 2013 2:11:53 AM UTC-8, Himakshi Mangal wrote:
>
> Hi...
>
>
> I am using clojure to import dbpedia data into neo4j.
>
> Here's the code:
> (ns opal.dbpedia
>   (:use [clojure.tools.logging :only [log]])
>   (:require [clojure.java.io :as io])
>   (:import [uk.ac.manchester.cs.owl.owlapi.turtle.parser TurtleParser]
>[org.neo4j.unsafe.batchinsert BatchInserters]
>[org.neo4j.graphdb DynamicRelationshipType]))
>
> ;; PARSING METHODS
>
> (defn get-next-tuple
>   [parser]
>   (let [last-item (atom nil)
> tuple (atom [])]
> (while (and (not= "." @last-item)
> (not= "" @last-item))
>   (reset! last-item
>   (-> parser
> (.getNextToken)
> (.toString)))
>   (swap! tuple conj @last-item))
> (when-not (empty? (first @tuple)) ; .getNextToken returns "" once you 
> are out of data
>   @tuple)))
>
> (defn seq-of-parser
>   [parser]
>   (if-let [next-tuple (get-next-tuple parser)]
> (lazy-cat [next-tuple]
>   (seq-of-parser parser
>
> (defn parse-file
>   [filename]
>   (seq-of-parser
> (TurtleParser.
>   (io/input-stream filename
>
> ;; BATCH UPSERT METHODS
>
> (def id-map (atom nil))
> (defn insert-resource-node!
>   [inserter res]
>   (if-let [id (get @id-map res)]
> ; If the resource has aleady been added, just return the id.
> id
> ; Otherwise, add the node for the node, and remember its id for later.
> (let [id (.createNode inserter {"resource" res})]
>   (swap! id-map #(assoc! % res id))
>   id)))
>
> (defn connect-resource-nodes!
>   [inserter node1 node2 label]
>   (let [relationship (DynamicRelationshipType/withName label)]
> (.createRelationship inserter node1 node2 relationship nil)))
>
> (defn insert-tuple!
>   [inserter tuple]
>   ; Get the resource and label names out of the tuple.
>   (let [[resource-1 label resource-2 & _ ] tuple
> ; Upsert the resource nodes.
> node-1 (insert-resource-node! inserter resource-1)
> node-2 (insert-resource-node! inserter resource-2)]
> ; Connect the nodes with an edge.
> (connect-resource-nodes! inserter node-1 node-2 label)))
>
> (defn -main [graph-path & files]
>   (let [inserter (BatchInserters/inserter graph-path)]
> (doseq [file files]
>   (log :debug (str "Loading file: " file))
>   (let [c (atom 0)]
> (doseq [tuple (parse-file file)]
>   (if (= (mod @c 1) 0)
> (log :debug (str file ": " @c)))
>   (swap! c inc)
>   (insert-tuple! inserter tuple
> (log :debug "Loading complete.")
> (log :debug "Shutting down.")
> (.shutdown inserter)
> (log :debug "Shutdown complete!")))
>
> I am getting the following errors:
>
> IllegalAccessError Transient used by non-owner thread 
>  clojure.lang.PersistentArrayMap$TransientArrayMap.ensureEditable 
> (PersistentArrayMap.java:449) 
>
> &&
>
>
> IllegalArgumentException No matching method found: createNode for class 
> org.neo4j.unsafe.batchinsert.BatchInserterImpl 
>  clojure.lang.Reflector.invokeMatchingMethod
>
>
> Can anyone please help me in this.. Am doing something wrong or am i 
> missing something.. I am completely new to clojure. Is there a working 
> example for this?
>
>
> Please help..
>
> Thanks 
>
>
>

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


Re: I need a vector not a list?

2013-12-02 Thread Andy Smith
Great point...

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