setting a default route in noir

2012-07-13 Thread Chris McBride
I have a lot of defpages that have a long part of the url in common (ex. 
"/client/:clientid/someresource/"). So I made a function to encapsulate the 
beginning of the URL, but the defpage macro expects a string and not a 
function call. Is there an easy way to have the begging of the route be the 
same? I'm sure there is a way to do it with middleware but is there a 
faster way using pre-route or something similar?

-- 
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: Getting started

2012-05-10 Thread Chris McBride
Also you generally don't invoke the clojure jar directly. Instead have lein 
do that for you. 
http://www.unexpected-vortices.com/clojure/brief-beginners-guide/development-env.html#clojure-projects

On Thursday, May 10, 2012 4:53:51 AM UTC-4, Zeno wrote:
>
> Hi, 
> I have downloaded and unzipped Clojure 1.4.0 but when trying "java -cp 
> clojure-1.4.0.jar clojure.main" as stated on the getting started page 
> I get the following. 
>
> D:\Profiles\rcarthur\My Documents\Clojure1_4\clojure-1.4.0>java -cp 
> clojure-1.4.0.jar clojure.main 
>
> Exception in thread "main" java.lang.NoClassDefFoundError: clojure/ 
> main 
> Caused by: java.lang.ClassNotFoundException: clojure.main 
> at java.net.URLClassLoader$1.run(URLClassLoader.java:200) 
> at java.security.AccessController.doPrivileged(Native Method) 
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188) 
> at java.lang.ClassLoader.loadClass(ClassLoader.java:307) 
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java: 
> 301) 
> at java.lang.ClassLoader.loadClass(ClassLoader.java:252) 
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java: 
> 320) 
> Could not find the main class: clojure.main.  Program will exit. 
>
> Any clues as to what I might be doing wrong? 
>
> Regards

-- 
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: Polymorphic namespaces?

2012-03-28 Thread Chris McBride
I'm not trying to do anything in particular. I do OO programming at work and 
it's been pounded in my head that loose coupling is better than gift coupling. 
I've found it useful on a few occasions. One example, in the frontend we wrap 
all the database calls in a caching layer but we don't need that when the same 
code runs in the backend. I wouldnt know how to do this with clojure. 

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


Polymorphic namespaces?

2012-03-28 Thread Chris McBride
I was wondering how dependency injection is done in Clojure since functions 
live in static namespaces. It seems like this could be achieved by having a 
macro that can use runtime information to determine the mapping between a 
namespace and its implementation. Does this make sense? Is there a better 
way to dependency injection in Clojure?

-- 
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: Parallel SSH and system monitoring in Clojure

2012-03-16 Thread Chris McBride
Wow thats surprisingly similar, I didn't realize this existed. Thanks.

On Mar 15, 10:11 pm, dennis zhuang  wrote:
> There is a clojure-control:https://github.com/killme2008/clojure-control
>
> 2012/3/16 Chris McBride 
>
>
>
>
>
>
>
>
>
> > Hi,
>
> >   I releases two simple clojure libraries to help running commands
> > via SSH on multiple servers. Hopefully someone will find it useful.
>
> >http://info.rjmetrics.com/blog/bid/54114/Parallel-SSH-and-system-moni...
> >  https://github.com/RJMetrics/Parallel-SSH
> >  https://github.com/RJMetrics/Server-Stats
>
> > Best,
> > Chris McBride
>
> > --
> > 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
>
> --
> 庄晓丹
> Email:        killme2...@gmail.com xzhu...@avos.com
> Site:          http://fnil.net
> Twitter:      @killme2008

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


Parallel SSH and system monitoring in Clojure

2012-03-15 Thread Chris McBride
Hi,

   I releases two simple clojure libraries to help running commands
via SSH on multiple servers. Hopefully someone will find it useful.

   
http://info.rjmetrics.com/blog/bid/54114/Parallel-SSH-and-system-monitoring-in-Clojure
   https://github.com/RJMetrics/Parallel-SSH
   https://github.com/RJMetrics/Server-Stats

Best,
Chris McBride

-- 
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: Serializing ClojureScript data structures

2012-03-02 Thread Chris McBride
Ok Thanks

On Mar 2, 11:19 am, David Nolen  wrote:
> pr-str will do what you want. That said we should probably add toString
> methods to the core datatypes to prevent this surprise.
>
> David
>
>
>
>
>
>
>
> On Fri, Mar 2, 2012 at 11:14 AM, Chris McBride  wrote:
> > In Clojure (str {:a 1}) returns "{:a 1}".
> > In ClojureScript (str {:a 1}) returns "[Object object]".
>
> > As a result, in order to send data to and from the server I've been
> > doing this: (goog.json/serialize (cljs->js x)). This seems like
> > unnecessary overhead to convert everything a JS object first, is there
> > a technical reason why ClojureScript behaves differently here? Or has
> > this just not been implemented yet?
>
> > 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 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


Serializing ClojureScript data structures

2012-03-02 Thread Chris McBride
In Clojure (str {:a 1}) returns "{:a 1}".
In ClojureScript (str {:a 1}) returns "[Object object]".

As a result, in order to send data to and from the server I've been
doing this: (goog.json/serialize (cljs->js x)). This seems like
unnecessary overhead to convert everything a JS object first, is there
a technical reason why ClojureScript behaves differently here? Or has
this just not been implemented yet?

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


Is it possible to run the ClojureScript compiler in browser via a Java Applet?

2012-02-28 Thread Chris McBride
I saw Chris Granger's recent post on hackernews sparked some debates
about the merit of being able to compile the language in-browser for
dev purposes. Since the compiler is written in Clojure, would this be
easy to accomplish via a java applet? Sort of like this scheme REPL
(http://sisc-scheme.org/sisc-online.php).

-- 
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: ClojureScript "use" statement not working

2012-02-25 Thread Chris McBride
Thanks,

Also, having a line number that corresponds to my source would be
helpful.

On Feb 25, 4:41 pm, Cedric Greevey  wrote:
> On Sat, Feb 25, 2012 at 4:04 PM, Mark Rathwell  
> wrote:
> > You must (:use ... :only ...) with ClojureScript
>
> "nth not supported on this type: Symbol" is not a very helpful error
> message for diagnosing this problem.

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


ClojureScript "use" statement not working

2012-02-25 Thread Chris McBride
I have a namespace statement like this:

(ns alephtest.websocket
  (:require [alephtest.js-utils :as util]))

If I change this to:

(ns alephtest.websocket
  (:use alephtest.js-utils))

I get this stack trace from the cljsbuild plugin (it took me a while
to figure what was causing this):

java.lang.UnsupportedOperationException: nth not supported on this
type: Symbol
  RT.java:835 clojure.lang.RT.nthFrom
  RT.java:785 clojure.lang.RT.nth
 compiler.clj:820 cljs.compiler/eval1118[fn]
core.clj:2432 clojure.core/map[fn]
  LazySeq.java:42 clojure.lang.LazySeq.sval
  LazySeq.java:60 clojure.lang.LazySeq.seq
  RT.java:466 clojure.lang.RT.seq
 core.clj:133 clojure.core/seq
 core.clj:600 clojure.core/apply
core.clj:2459 clojure.core/mapcat
  RestFn.java:423 clojure.lang.RestFn.invoke
 compiler.clj:820 cljs.compiler/eval1118[fn]
 protocols.clj:64 clojure.core.protocols/fn
 protocols.clj:11 clojure.core.protocols/fn[fn]
core.clj:5995 clojure.core/reduce
 compiler.clj:831 cljs.compiler/eval1118[fn]
 MultiFn.java:177 clojure.lang.MultiFn.invoke
compiler.clj:1040 cljs.compiler/analyze-seq
compiler.clj:1093 cljs.compiler/analyze
compiler.clj:1086 cljs.compiler/analyze
compiler.clj:1153 cljs.compiler/compile-file*
compiler.clj:1191 cljs.compiler/compile-file
compiler.clj:1251 cljs.compiler/compile-root
  closure.clj:350 cljs.closure/compile-dir
  closure.clj:382 cljs.closure/eval1687[fn]
  closure.clj:261 cljs.closure/eval1618[fn]
  closure.clj:396 cljs.closure/eval1674[fn]
  closure.clj:261 cljs.closure/eval1618[fn]
  closure.clj:830 cljs.closure/build
  core.clj:71 cljsbuild.core/compile-cljs
 core.clj:183 cljsbuild.core/run-compiler
 NO_SOURCE_FILE:1 user/eval2057[fn]
 core.clj:158 cljsbuild.core/in-threads[fn]
core.clj:1817 clojure.core/binding-conveyor-fn[fn]
  AFn.java:18 clojure.lang.AFn.call
  FutureTask.java:303 java.util.concurrent.FutureTask
$Sync.innerRun
  FutureTask.java:138 java.util.concurrent.FutureTask.run
  ThreadPoolExecutor.java:886 java.util.concurrent.ThreadPoolExecutor
$Worker.runTask
  ThreadPoolExecutor.java:908 java.util.concurrent.ThreadPoolExecutor
$Worker.run
  Thread.java:662 java.lang.Thread.run

Are use statements support in ClojureScript?

-- 
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: conj doesnt work consistently on records

2012-01-06 Thread Chris McBride
Ohh, ok that makes sense now. Thanks.

On Jan 6, 1:01 pm, Meikel Brandmeyer  wrote:
> Hi,
>
> Am 06.01.2012 um 18:23 schrieb Chris McBride:
>
> > (defrecord Person [name address])
>
> > (def bob (map->Person {:name "bob"}))
>
> > (prn (conj bob {:address "123 main st"}))  ;#user.Person{:name
> > "bob", :address "123 main st"}
> > (prn (conj {:address "123 main st"} bob))  ;{:name "bob", :address
> > nil}
>
> > The first print statement behaves how I would expect, the second one
> > does not. Why wouldnt it fill the address field on the map?
>
> The address field on the record is nil. Hence it overwrites the address field 
> of the map. Think of merge. This has nothing to do with records. It's the 
> same with maps.
>
> user=> (conj {:a nil} {:a 1})
> {:a 1}
> user=> (conj {:a 1} {:a nil})
> {:a nil}
>
> The fields in records are always there. Unlike maps where there are only the 
> keys you specified.
>
> user=> (map->Person {:name "Meikel"})
> #user.Person{:name "Meikel", :address nil}
>
> Hope this helps.
>
> Sincerely
> 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


conj doesnt work consistently on records

2012-01-06 Thread Chris McBride
(defrecord Person [name address])

(def bob (map->Person {:name "bob"}))

(prn (conj bob {:address "123 main st"}))  ;#user.Person{:name
"bob", :address "123 main st"}
(prn (conj {:address "123 main st"} bob))  ;{:name "bob", :address
nil}


The first print statement behaves how I would expect, the second one
does not. Why wouldnt it fill the address field on the map?

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


Strange eval behavior on user-defined macros

2011-12-26 Thread Chris McBride
I'm working on a project where I want to use clojure macros in part of
my config file that I eval at runtime. However, I'm getting an "Unable
to resolve symbol" exception. So I made a test case to reproduce it
below:

(ns test.core (:gen-class))

(defmacro make-list [& body]
`(list ~@body))

(defn  stuff[]
(prn (eval (read-string "(make-list 1 2 3)"

(defn -main [& args] (stuff))
(-main)

When I run this file through the clojure interpreter I get the output
"(1 2 3)" from the -main call. Now if I do 'lein run' with my 'main'
namespace defined as test.core, I get this output:

(1 2 3)
Exception in thread "main" java.lang.RuntimeException: Unable to
resolve symbol: make-list in this context, compiling:(NO_SOURCE_PATH:
1)
at clojure.lang.Compiler.analyze(Compiler.java:6235)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3452)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6411)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5572)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5008)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3629)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6407)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.eval(Compiler.java:6462)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at test.core$stuff.invoke(core.clj:7)
at test.core$_main.doInvoke(core.clj:9)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.Var.invoke(Var.java:397)
at user$eval46.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6465)
at clojure.lang.Compiler.eval(Compiler.java:6455)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at clojure.main$eval_opt.invoke(main.clj:296)
at clojure.main$initialize.invoke(main.clj:315)
at clojure.main$null_opt.invoke(main.clj:348)
at clojure.main$main.doInvoke(main.clj:426)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:405)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: Unable to resolve symbol: make-
list in this context
at clojure.lang.Util.runtimeException(Util.java:156)
at clojure.lang.Compiler.resolveIn(Compiler.java:6720)
at clojure.lang.Compiler.resolve(Compiler.java:6664)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:6625)
at clojure.lang.Compiler.analyze(Compiler.java:6198)
... 31 more

 So first I get the "(1 2 3)" output from clojure calling -main when
it reads the file, but it seems like when lein calls -main it can't
resolve the symbol. Is this a limitation of java since this is at
runtime and macros have to be expanded at read-time? Or is this a bug?

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