Re: Nginx-Clojure Let You Deploy Clojure Web App on Nginx Without Any Java Web Server
Hi, Thanks for your work on nginx-clojure. It looks great! As I know Nginx spawns many processes(correct me if I am wrong), does that mean, there will be many JVM process? On Tuesday, January 14, 2014 4:44:18 PM UTC+8, Xfeep Zhang wrote: I have done the first one. The result is HEREhttps://github.com/ptaoussanis/clojure-web-server-benchmarks( https://github.com/ptaoussanis/clojure-web-server-benchmarks ) Thanks Taoussanis for his invitation to the project clojure-web-server-benchmarkshttps://github.com/ptaoussanis/clojure-web-server-benchmarkshosted on Github. On Tuesday, January 14, 2014 10:31:03 AM UTC+8, Xfeep Zhang wrote: You're welcome. I think there are several difficult phases : (1) update the test program in clojure-web-server-benchmarkshttps://github.com/ptaoussanis/clojure-web-server-benchmarks, make the some packages to be the latest. (eg. http-kit from 1.3.0-alpha2 -- 2.1.16) and add nginx-php testing (2) test about real world size contents by group eg. tiny, small, medium, huge. (3) test about real world connection circumstances where a lot of connection is inactive but keep open. (4) try some real asynchronous test to fetch external resources (eg. rest service , db) before response to the client. eg. using libdrizzlehttps://launchpad.net/drizzlea no-blocking mysql client from https://launchpad.net/drizzle On Tuesday, January 14, 2014 2:41:50 AM UTC+8, Sergey Didenko wrote: Looks very interesting, thank you for your work! I wonder how this is going to improve latency in comparison to nginx + http-kit for some real world test that is not using heavy DB operations. On Mon, Jan 13, 2014 at 5:57 AM, Xfeep Zhang easy...@163.com wrote: So far I have found why nginx-clojure is slower than http-kit when 1 concurrents. (when = 1000 concurrents nginx-clojure is faster than http-kit.) I have set too many connections per nginx worker (worker_connections = 2) . This make nginx only use one worker to handle ab requests (every request is tiny). I plan to take note of c-erlang-java-performancehttp://timyang.net/programming/c-erlang-java-performance/and fork clojure-web-server-benchmarkshttps://github.com/ptaoussanis/clojure-web-server-benchmarksto do some real world tests. On Sunday, January 12, 2014 11:21:06 PM UTC+8, Xfeep Zhang wrote: Sorry for my mistake! 1. In the static file test, the ring-jetty result is about 10 concurrents. NOT 1 concurrents (Concurrency Level: 10 in the ab report ). 2. In the small string test, All results about three server are about 10 concurrents. NOT 1 concurrents. There are right results about these two mistake : 1. static file test (3) ring-jetty more bad than 10 concurrents === Document Path: / Document Length:29686 bytes *Concurrency Level: 1* Time taken for tests: 6.303 seconds Complete requests: 10 Failed requests:0 Write errors: 0 Total transferred: 298220 bytes HTML transferred: 296860 bytes Requests per second:15864.43 [#/sec] (mean) Time per request: 630.341 [ms] (mean) Time per request: 0.063 [ms] (mean, across all concurrent requests) Transfer rate: 462020.65 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 12 328 535.0 433041 Processing:25 124 112.9 963523 Waiting:8 47 99.4 283523 Total: 52 452 544.51574546 Percentage of the requests served within a certain time (ms) 50%157 66%305 75% 1071 80% 1102 90% 1139 95% 1155 98% 1462 99% 3100 100% 4546 (longest request) 2. simple string (1 concurrents) http-kit is the fastest. But nginx-clojure is too young and has vast room for growth :) (1) nginx-clojure-0.1.0 Document Path: / Document Length:15 bytes *Concurrency Level: 1* Time taken for tests: 2.834 seconds Complete requests: 10 Failed requests:0 Write errors: 0 Total transferred: 1700 bytes HTML transferred: 150 bytes Requests per second:35291.16 [#/sec] (mean) Time per request: 283.357 [ms] (mean) Time per request: 0.028 [ms] (mean, across all concurrent requests) Transfer rate: 5858.88 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 51 118 21.6118 178 Processing:73 150 33.8146 263 Waiting: 42 110 32.0104 246 Total:177 268 25.6269 327 Percentage of the requests served within a certain time (ms) 50%269 66%278 75%285 80%288 90%297 95%309 98%314 99%318 100%327 (longest request)
Re: [ANN] http-kit 2.0.0 released
Hi, just released 2.1.0. [http-kit 2.1.0] ; Add to your project.clj. Compare to 2.0.0, noticeable changes: 1. Much faster: about 30%~80% faster. 2. The client support HTTPS now 3. :as option to do client output coercion Not that noticeable changes: 1. few minor bugs fixes 2. less RAM usage The full update log: https://github.com/http-kit/http-kit/blob/master/history.md Updated client documentation: http://http-kit.org/client.html On Friday, March 29, 2013 2:03:38 PM UTC+8, Feng Shen wrote: Hello folks. I just released version 2.0.0 of http-kit. *2.0.0 (2013/3/29)* 1. Unify WebSocket and HTTP long polling/streaming with Channel protocol and with-channel (API breaks with the RC) 2. WebSocket support sending and receiving binary frame with byte[] 3. Support HTTP streaming 4. WebSocket message ordering is guaranteed by server Updated documentation: http://http-kit.org/server.html Let's build amazing realtime applications with Clojure, using http-kit. The with-channel API is not compatible with the RC releases. The new is better and much easier to understand and use. The old's documentation can be found here http://http-kit.org/server_old.html - feng -- -- 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: http-kit on heroku?
Hi, here is how to do hot code reload: http://http-kit.org/migration.html#reload On Monday, April 15, 2013 12:48:50 PM UTC+8, Wei Hsu wrote: Thanks guys, got it sorted out. If I may ask a followup question, how do you run it in development? Pre-http-kit, I've been using lein ring server, which has a nice feature that reloads code automatically as it is saved so you don't have to restart the server. On Sunday, April 14, 2013 8:39:50 PM UTC-7, Ryan McGowan wrote: Maik is right. However, if you still want an example application you can check out a side project https://github.com/RyanMcG/Cadence of mine. It works just fine on Heroku. Originally it was a noir/jetty application which I have since moved to http-kithttps://github.com/RyanMcG/Cadence/commit/77298c789d0c77e65bc1007e7ae74a70e6161c7fand Compojure. Enjoy :) On Sunday, April 14, 2013 2:36:44 PM UTC-4, Maik Schünemann wrote: I don't have an example of deploying http-kit on Heroku, but I think it should be straightforward - basically your local setup should work on heroku. Just like you can deploy your application, which starts up jetty to heroku I think you can deploy your http-kit application on heroku. The only think to remember is that the port of the server is stored in the port environment variable. So, just try :) On Sat, Apr 13, 2013 at 11:22 PM, Wei Hsu yayi...@gmail.com wrote: Does anyone have an example of deploying http-kit on Heroku? The official example https://devcenter.heroku.com/articles/clojure uses Jetty. -- -- 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: what is a good book about Java queues?
Yes, the javadoc is quite good, paste a link here: http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingQueue.html On Friday, March 8, 2013 4:32:38 AM UTC+8, larry google groups wrote: At some point on this mailist, someone suggested that to best understand concurrency in Java, once should read: Java Concurrency In Practice http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/dp/0321349601/ref=sr_1_1?ie=UTF8qid=1362688125sr=8-1keywords=java+concurrency+in+practice So I read it, but I am surprised that it says fairly little about working with queues. I am curious if anyone would recommend a book for learning more about working with Java queues? I suffer the problem that I learned Clojure without first learning Java, and Clojure leans on Java rather heavily, so I am now trying to come up to speed on Java. -- -- 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: AOT and side-effects associated to ns initialization
Hi, Another option: (ns you.ns // add :aot [you.ns] to project.clj (:gen-class)) (def server (atom nil)) (defn -main [ args]; command line args (reset! server (jetty/run-jetty #'app {:port 8000 :join? false}))) ;;; run it and pass command line arguments java -cp your-aot-compiled.jar you.ns --port 9090 On Thursday, February 28, 2013 8:47:36 AM UTC+8, vemv wrote: So I was playing with AOT for the first time. My main reason to use it is so the consumer Java code doesn't look so alien / run-timey. The thing is, I encountered that the following line causes `lein compile` to hang: (def server (jetty/run-jetty #'app {:port 8000 :join? false})) (for those not familiar with Jetty, the expression causes a web server to launch.) I can sort of see why this code represents a fault, from a compiler's point of view. But OTOH, in e.g. Java it's not that much of a rare practice to bind a the result of a side-effectful op to a variable definition, right? My question is quite simply, why can't the given code compile? It is not entirely clear to me, as I don't thoroughly understand how Clojure's compiler works (or any compiler at all, for that matter). -- -- 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.
Help on drafting a protocol for realtime communication between client and ring server
Hi, I am trying to draft a protocol for realtime communication between client and ring server. http-kit http://http-kit.org/ try to implement the protocol, provide a fast scalable ring adapter with websocket async extension for Clojure web developers. Here is an initial version, any thought/comment/suggestion welcome. (defprotocol Channel Asynchronous channel for HTTP streaming/long polling websocekt (open? [] Tells whether or not this channel is still open) (close [] Closes this channel. If this channel is already closed then invoking this method has no effect. Any further attempt to invoke I/O operations is welcomed by IllegalStateException) (send! [data [close-after-send]] Send data to client. Weclomed by IllegalStateException if already closed If `close-after-send` is true, `close` get called after sent. For Webocket, a text frame is sent to client. For streaming: 1. First call of send!, data expect to be {:headers _ :status _ :body _} or just body. if `close-after-send` is true, a normal HTTP response is assembled and sent to client,useful for HTTP client that does not support chunked encoding(like ab). Otherwise, achunked encoding response is assembled, `close` signals end this response. 2. Any further call, only body(String, File, InputStream, ISeq) is expected.The data is encoded as chunk, sent to client) (on-send [callback] Callback: (fn [data]) Do something with the data (like JSON encoding) before sending it off) (on-mesg [callback] Callback: (fn [message-string]) Set the handler to get notified when there is message from client. Only valid for websocket. For streaming, another HTTP connection can be used to emulate the behaviour) (on-close [callback] Callback: (fn [status]) Set the handler to get notified when channel get closed, by client `close` called. Callback is called once if server and client both close the channel Useful for clean up. Status code: 0 if closed by sever, closed by client: -1 if streaming, websocket: http://tools.ietf.org/html/rfc6455#section-7.4.1;)) Thanks. Feng -- -- 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: Help on drafting a protocol for realtime communication between client and ring server
Opps, this post is intended to be posted on the Ring group, sorry for the noise. On Friday, February 15, 2013 5:50:15 PM UTC+8, Feng Shen wrote: Hi, I am trying to draft a protocol for realtime communication between client and ring server. http-kit http://http-kit.org/ try to implement the protocol, provide a fast scalable ring adapter with websocket async extension for Clojure web developers. Here is an initial version, any thought/comment/suggestion welcome. (defprotocol Channel Asynchronous channel for HTTP streaming/long polling websocekt (open? [] Tells whether or not this channel is still open) (close [] Closes this channel. If this channel is already closed then invoking this method has no effect. Any further attempt to invoke I/O operations is welcomed by IllegalStateException) (send! [data [close-after-send]] Send data to client. Weclomed by IllegalStateException if already closed If `close-after-send` is true, `close` get called after sent. For Webocket, a text frame is sent to client. For streaming: 1. First call of send!, data expect to be {:headers _ :status _ :body _} or just body. if `close-after-send` is true, a normal HTTP response is assembled and sent to client,useful for HTTP client that does not support chunked encoding(like ab). Otherwise, achunked encoding response is assembled, `close` signals end this response. 2. Any further call, only body(String, File, InputStream, ISeq) is expected.The data is encoded as chunk, sent to client) (on-send [callback] Callback: (fn [data]) Do something with the data (like JSON encoding) before sending it off) (on-mesg [callback] Callback: (fn [message-string]) Set the handler to get notified when there is message from client. Only valid for websocket. For streaming, another HTTP connection can be used to emulate the behaviour) (on-close [callback] Callback: (fn [status]) Set the handler to get notified when channel get closed, by client `close` called. Callback is called once if server and client both close the channel Useful for clean up. Status code: 0 if closed by sever, closed by client: -1 if streaming, websocket: http://tools.ietf.org/html/rfc6455#section-7.4.1;)) Thanks. Feng -- -- 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: Building/inserting multiple records
Is it easy (and immutable) to build a collection of records to insert? I've been told CONJ is a good start. map maybe be helpful: (map (fn [d] return-map-of-records) datasets) Does the clojure jdbc interface support insertion of multiple records? I haven't seen such a function yet. clojure.java.jdbc/insert-records On Saturday, February 16, 2013 11:30:08 AM UTC+8, Jonathon McKitrick wrote: I'm iterating a large dataset and inserting a record for each row. After working in a Salesforce environment, I'm thinking it would be better to build a collection of records and insert them in one fell swoop. 1. Is it easy (and immutable) to build a collection of records to insert? I've been told CONJ is a good start. 2. Does the clojure jdbc interface support insertion of multiple records? I haven't seen such a function yet. -- -- 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: Packaging/Deploying Web App
Hi, here is one solution: add (:gen-class) to the main namespace, add something in your project.clj :aot [rssminer.main, rssminer.admin] :main rssminer.main :uberjar-name rssminer-standalone.jar lein uberjar Package up the project files and all dependencies into a jar file java -jar rssminer-standalone.jar Starts your application On Thursday, February 14, 2013 12:47:11 AM UTC+8, Ari wrote: Hi, In my limited experience with Clojure based web apps that are comprised of jetty + ring + compojure I've used the lein-ring plugin to create jars or wars depending on deployment needs. I'm curious to learn: 1. How can I create a deployable jar or war manually (or at least in a less auto-magically way), i.e. without the lein-ring (or lien-war) plugin? 2. How can I create a deployable jar or war -- with or without lein-ring/lein-war -- when the app relies on an alternative adapter such as aleph, http-kit, etc? Thanks. -Ari -- -- 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 + Web Services + Web Sockets
I updated http-kit's server documentation: http://http-kit.org/server.html How http-kit is used to serve both HTTP and websocket: http://http-kit.org/server.html#routing Cheers, Feng On Tuesday, February 12, 2013 7:36:46 AM UTC+8, Ryan T. wrote: Thanks both for your answers. @Bob, I didn't know the existance of http-kit; seems promising. There is also a post 600k concurrent HTTP connections, with Clojure http-kithttp://http-kit.org/600k-concurrent-connection-http-kit.html, very interesting. I also want to add to my own original question, that aleph is capable of doing synchronous and asynchronous requests with the same server and port. All you have to do is to use different endpoints, even though it's possible to have the same one as well. On Tuesday, February 12, 2013 1:22:13 AM UTC+2, Bob Hutchison wrote: On 2013-02-11, at 6:12 PM, Ryan T. areka...@gmail.com wrote: Unless someone has to suggest something better, it seems that the best way to achieve what i want is to use alephhttps://github.com/ztellman/aleph/ which allows you to initialize it with a wrapped ring handler. You might have a look at http://http-kit.org/ Cheers, Bob If you have more details on the issue or alternatives I would love to hear about them. On Tuesday, February 12, 2013 12:54:53 AM UTC+2, Ryan T. wrote: Hello, I am trying to figure out how to setup my clojure project in order to be able to serve both normal http requests which will return json and also handle requests over websockets. Is it possible to do both and listen on same port? or do i need two separate projects? or ? I did find thishttp://blog.jayfields.com/2011/02/clojure-web-socket-introduction.html but from what I read Webbit is not the best solution for what I need. I was hoping to be able to build my clojure project and use jetty in development and tomcat on production. Thank you for your time -- -- 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: Bootstrapping Web Apps
Hi, here is what I did for rssminer (A Clojure web app): https://github.com/shenfeng/rssminer/blob/master/src/rssminer/main.clj define a main function, accept args from stdin, parse them, save the argument, call `start-server`, do init, bind to port, accept request On Wednesday, February 13, 2013 4:10:00 AM UTC+8, Ari wrote: Hi, How does one bootstrap web apps comprised of ring + compojure (and/or aleph) + hbase/mongodb? Is there a best practice or recommended way? For example, in Rails based apps a series of predetermined initialization files are executed to fulfill various tasks, i.e. connect to dbs, message queues, active background jobs, etc. Thanks. -Ari -- -- 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 automatically and idiomatically add newlines to clojure code in emacs
(defun indent-buffer () (interactive) (indent-region (point-min) (point-max))) (defun cleanup-buffer () (interactive) (indent-buffer) (untabify-buffer) (delete-trailing-whitespace)) ;; bind to other key if you like(global-set-key (kbd M-q) 'cleanup-buffer) cleanup-buffer is very fast, I hit it all the time. On Tuesday, February 12, 2013 10:28:43 AM UTC+8, John Fries wrote: Clojure Users, I'm relatively new to clojure and wanted to get some workflow advice. I often find myself staring at something like this: (defun func1 [a b c d] (func5 (let [f (func3 c)] (func2 a b f)) (let [e 5] (func4 c d e and wishing for a function to automatically and idiomatically break it up into multiple lines and indent it: (defun func1 [a b c d] (func5 (let [f (func3 c)] (func2 a b f)) (let [e 5] (func4 c d e I find the latter form more readable, but inserting the newlines by hand is getting repetitive (also, I am not always confident in my choice of idiomatic breakpoints). Once I insert the newlines, I can trigger auto-indentation by hitting M-q (which on my system is mapped to paredit-reindent-defun) or by highlighting the region and hitting M-C-\ (which on my system is indent-region). My question(s) is: How are people currently handling this situation? Is it part of most people's clojure/emacs workflow to 1) Just insert the newlines by hand? (perhaps I'm the only one finding this repetitive) 2) Do people have some accepted pretty printing function they are using within emacs? 3) Is there some larger issue I'm not seeing that maybe makes this whole idea irrelevant? I've seen this document: http://richhickey.github.com/clojure/doc/clojure/pprint/PrettyPrinting.html But I haven't found any guide to using that function *within emacs*. If this is not a common thing to do, then why is it not common? Thanks, John caveat: My init.el is an amalgam of ideas from ESK, prelude and emacs live, so it could be the case that this functionality is provided out of the box, if only I were configured properly. If people have some way of doing this in their emacs environment, a clue as to the kit or configuration you are using would be very much appreciated. -- -- 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 Wiki
http://clojure-docs.org/ = http://clojuredocs.org/ On Friday, February 8, 2013 8:17:41 PM UTC+8, Konrad wrote: Hello, fellow clojurians! For the next couple of months (or until I get a new functional job), I'll be working on honing my clojure skills, starting with getting a perspective of what lies *out there*: events, podcasts, guides, etc. I've created a freely-editable wiki http://clojurewiki.org, just like EmacsWiki http://emacswiki.org and CLiki http://cliki.net, for this purpose, and filled it with I already knew. There are so many cool things that I found by accident (like ClojureGazettehttp://us4.campaign-archive.com/?u=a33b5228d1b5bf2e0c68a83f4id=b25f11a98a), that I wonder how many more I am missing - and everybody is missing! - without such an iniciative. I know there is already a blog aggregator, a couple of websites with courses, a list of meetups, but no single place with everything categorized and neatly divided, which is what I'm building. I've already spent some time on the wiki so to make it worth clicking, but it's still in the beginning and much can be improved, so I invite to come around and participate in shaping it. Advertise your own tool, your own event; add a website you find particularly valuable; tell what you'd like to see! Suggestions and comments are very welcome! -- -- 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: http-kit 2.0.0.RC2, high performance HTTP Server Client for Clojure
Just to add: 2.0.0-RC3 released, with a general purpose timer added: http://http-kit.org/timer.html On Sunday, February 3, 2013 11:20:27 AM UTC+8, Feng Shen wrote: Hi, After extensive test, known bugs fixed, documentation ready, http-kit reaches 2.0.0.RC2 [http-kit 2.0.0-RC2] ; Add to your project.clj Documentation: http://http-kit.org Github: https://github.com/http-kit/http-kit The goal of http-kit is to provide a clean, robust HTTP server/client, with Nginx alike performance and concurrency, for Clojure. The server is ring compliant adapter with async and websocket support. I expect it to be faster than node. The client has a clj-http alike API, asynchronous in nature, synchronous with @promise. I invite everybody who interested to have a look, questions/comments/suggestions/whatever are welcome! Thanks @ptaoussanis and others for their contribution. Feng -- -- 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: Building a REST API / efficient RPC interface in Clojure
Hi, I did something similar during work (we are using Clojure) 1. Use HTTP as the transport: browser ajax call, mobile API call, intertal use 2. JSON as encoding. Javascript support it natively, mobile can decode it easily, Clojure has very good support for it Clojure can decode and encode json*[1]* very efficiently. Nginx can be configured to zip the data to save bandwidth. http-kit*[2]* to do http very efficiently. Compojure[3] can be used to define the mapping cleanly. One API, used everywhere. I am currently writing a lein new template plugin, to setup the config automatically, kills boilerplate, I expect it to be ready in the next few days. [1] https://github.com/clojure/data.json [2] http://http-kit.org [3] https://github.com/weavejester/compojure On Saturday, February 9, 2013 9:54:54 AM UTC+8, Mikera wrote: Hi All, I'm looking for a library (or set of libraries that can easily be composed) that lets me do the following: - Define an API in terms of messages - Maintain a mapping between these messages and specific data types (some Java classes, Clojure data structures etc.) - Also maintain a mapping between the API and handler functions that get called in response to receiving a message - Expose the API as a general purpose REST API for the web - Also expose the same API using some form of efficient binary serialisation for RPC usage FWIW, the objective is make the same API available to both external users and internally within a cluster, without duplicating code but also without adding substantial messaging overhead to internal cluster usage. What would be the best tools / approach in the Clojure ecosystem at the moment for doing something like this? Mike. -- -- 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: Sending Clojure Objects over TCP
slacker - Transparent, non-invasive RPC by clojure and for clojure. https://*github*.com/sunng87/*slacker* * * 1. 2. On Thursday, February 7, 2013 9:16:03 AM UTC+8, JvJ wrote: Does anyone know if there's a simplified networking library that allows this? -- -- 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: Simple Network Messaging
For json, Clojure has a convenient lib: https://github.com/clojure/data.json for networking, how about using HTTP as the transport? Clojure has many libraries for HTTP server client, c# has many libraries too. On Friday, February 8, 2013 5:44:06 AM UTC+8, JvJ wrote: I'm looking to do some simple messaging (json strings) between programs running on the same machine. One will be in C# and one will be in Clojure. Is there a library/set of libraries that could simplify this communication? I haven't done much networking in the past, and I'd like to keep this as painless as possible. 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: Callbacks as Sequences
I did something for a http lib: ;; get them concurrently(let [response1 (http/get http://http-kit.org/;) response2 (http/get http://clojure.org/;)] ;; handle responses one-by-one, waiting for response as necessary ;; other keys :headers :status :error :opts (println response1: (:body @response1)) (println response2: (:body @response2))) On Thursday, February 7, 2013 2:45:36 AM UTC+8, da...@dsargeant.com wrote: I'm not to clojure/clojurescript and was wondering if anyone has taken a crack at writing a macro that transforms callbacks into a sequence. There is an awesome implementationion in LispyScript show here: https://gist.github.com/santoshrajan/3715526. Thanks for help. David -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: ANN: http-kit 2.0.0.RC2, high performance HTTP Server Client for Clojure
Inspired by golang helloworld 45% slower than node.jshttps://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/zeLMYnjO_JA , I did some test, get some numbers, for fun: CPU: Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz RAM: 16G # redis, SET: 217391.30 requests per second# It's the upper limit, probably redis-benchmark -q # nginx, response a file of 1K# Requests per second:148442.25 [#/sec] (mean), ab -n 30 -c 100 -k http://127.0.0.1/ # http-kit (http://http-kit.org) respond hello world# code: https://gist.github.com/4704565# Requests per second:79.02 [#/sec] (mean) ab -n 40 -c 100 -k http://127.0.0.1:8080/ # The hello world go version, with modification of http = net/http # Requests per second:17465.92 [#/sec] (mean) ab -n 10 -c 100 -k http://127.0.0.1:8080/ # node v0.6.19 # Requests per second:12964.05 [#/sec] (mean) ab -n 10 -c 100 -k http://127.0.0.1:8080 On Sunday, February 3, 2013 11:20:27 AM UTC+8, Feng Shen wrote: Hi, After extensive test, known bugs fixed, documentation ready, http-kit reaches 2.0.0.RC2 [http-kit 2.0.0-RC2] ; Add to your project.clj Documentation: http://http-kit.org Github: https://github.com/http-kit/http-kit The goal of http-kit is to provide a clean, robust HTTP server/client, with Nginx alike performance and concurrency, for Clojure. The server is ring compliant adapter with async and websocket support. I expect it to be faster than node. The client has a clj-http alike API, asynchronous in nature, synchronous with @promise. I invite everybody who interested to have a look, questions/comments/suggestions/whatever are welcome! Thanks @ptaoussanis and others for their contribution. Feng -- -- 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: dictionary sort in sortedmap
Hi, 11 2 if string, 11 2 if integer. Your keys are string, convert to integer if need numeric order. On Monday, February 4, 2013 6:37:13 PM UTC+8, Amir Wasim wrote: I want to sort a map by its keys according to dictionary when i do the following (into (sorted-map) {1 A 2 B 11 C 3 D}) the result is {1 A, 11 C, 2 B, 3 D} which is expected result but what i expect is dictionary sort, {1 A, 2 B, 3 D, 11 C}. is there something in clojure or i just go with java Collator 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: Why is this code so slow?
I can only think about a bit faster version: 46555ms = 23846ms for 20 (defn smallest-multiple-of-1-to-n [n] (let [divisors (range 2 (inc n))] (loop [i n] (if (loop [d 2] (cond ( d n) true (not= 0 (mod i d)) false :else (recur (inc d i (recur (inc i)) I am not familiar with how Clojure's numeric works. There should be a faster way of doing it in Clojure. On Sunday, February 3, 2013 10:28:09 AM UTC+8, Alexandros Bantis wrote: Hello all. I'm working through the Project Euler problems in Java, Scala, Clojure (trying to learn all three?!?). I notice that for one particular problem, I use--more or less--a similar algorithm for all three, but the clojure code runs about 20-30 times slower than the java/scala versions. Does anyone have any idea why this might be? It strikes me that it might have something to do with every? but I don't know because I'm a newbie with Clojure. http://stackoverflow.com/questions/14668272/what-can-i-do-to-speed-up-this-code thanks, alex -- -- 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: is intellij idea a good ide for clojure development?
I have programming Clojure for almost 2 years, for a living. Emacs is highly recommended. Emacs Lisp = lisp, Clojure is also Lisp. Emacs has special support for Lisp than others. As for intellj: I think it's quite good. Emacs is the perfect one. On Monday, January 28, 2013 7:37:54 PM UTC+8, HamsterofDeath wrote: the only ides i have used so far for clojure are intellij idea and netbeans. is there one that is a lot better? if yes, why? i am not interested in details or single features, i just want to know if there is some magic editor out there that i should look into because it is *obviously a lot* better - like in you should use an ide for java development instead of notepad -- -- 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 web server benchmarks
Hey, thanks for point out latency, I haven't look at them deeply. Here is how http-kit compare to Nginx when concurrency is 96: Server Software:http-kit Server Hostname:127.0.0.1 Server Port:8087 Document Path: / Document Length:1163 bytes Concurrency Level: 96 Time taken for tests: 2.858 seconds Complete requests: 12 Failed requests:0 Write errors: 0 Keep-Alive requests:12 Total transferred: 15696 bytes HTML transferred: 13956 bytes Requests per second:41981.59 [#/sec] (mean) Time per request: 2.287 [ms] (mean) Time per request: 0.024 [ms] (mean, across all concurrent requests) Transfer rate: 53624.92 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect:00 0.1 0 4 Processing: 12 0.7 2 7 Waiting:12 0.7 2 7 Total: 12 0.7 2 7 *Percentage of the requests served within a certain time (ms)* * 50% 2* * 66% 2* * 75% 2* * 80% 2* * 90% 3* * 95% 4* * 98% 5* * 99% 5* * 100% 7 (longest request) * Server Software:nginx Server Hostname:127.0.0.1 Server Port:8081 Document Path: / Document Length:1163 bytes Concurrency Level: 96 Time taken for tests: 3.492 seconds Complete requests: 12 Failed requests:0 Write errors: 0 Keep-Alive requests:118844 Total transferred: 164754220 bytes HTML transferred: 13956 bytes Requests per second:34365.55 [#/sec] (mean) Time per request: 2.793 [ms] (mean) Time per request: 0.029 [ms] (mean, across all concurrent requests) Transfer rate: 46076.41 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect:00 0.1 0 4 Processing: 03 2.2 2 23 Waiting:03 2.2 2 23 Total: 03 2.2 2 23 *Percentage of the requests served within a certain time (ms)* * 50% 2* * 66% 3* * 75% 4* * 80% 5* * 90% 6* * 95% 7* * 98% 9* * 99% 9* * 100% 23 (longest request)* btw, I am the author of http-kit https://github.com/shenfeng/http-kit: https://github.com/shenfeng/http-kit . http-kit was written from scratch for performance. Clojure web application can be very fast, as fast as Nginx can do. Clojure web application can handle high concurrency as Nginx can do too. On Friday, January 25, 2013 8:14:07 PM UTC+8, hutch wrote: On 2013-01-25, at 6:24 AM, Peter Taoussanis ptaou...@gmail.comjavascript: wrote: I'd consider adding a graph if folks think these numbers are sufficiently interesting? That would be great! This is very important information for me. And, unless things have improved markedly over that last year or so (I hope so), I think you'll be 'amused' by what you see. Cheers, Bob -- -- 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: a question about running embedded jetty
I did not know #'app is for reload. It's very helpful. Thanks. On Saturday, January 19, 2013 5:26:06 PM UTC+8, Baishampayan Ghose wrote: On Sat, Jan 19, 2013 at 5:24 AM, faenvie fanny@gmx.de javascript: wrote: i have learned that for a ring/compojure-app the embedded jetty service can be started like this: (def app (handler/site routes)) (defn start [port] (ring/run-jetty (var app) {:port (or port 8080) :join? false})) can anyone explain, what is the var for ? why '(var app)' or #'app ? i found some remarks about being able to change the app without having to restart the server but how exactly does this relate ? If you pass in the app as it is, then the var gets evaluated to the function that the var refers to and the jetty adapter uses that function to run the server. Now if you recompile your ring handlers (aka functions) the same app var will get rebound to a new function while the jetty server will continue holding on to the old handler function, so if you refresh the page, etc. you won't see the change on your browser. You will have to kill the server and restart jetty. If you pass just the var instead, jetty holds on to the container (the var) and not the value. The jetty-adapter derefs the var on every request and sends the response back. As a result if you recompile your handlers you'll see the effects immediately without restarting the server. The derefing has a penalty, albeit minor. Thus, you may choose to not pass in the app as a var in production deployments. Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- 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: a question about running embedded jetty
Hi: (var app) can be simplified to just app. The detail: app is a function: accept a request map, return a response map. your server's logic is in app. ( see ring spec https://github.com/ring-clojure/ring/blob/master/SPEC for more detail) (var app) or #'app: get the var (clojure.lang.Var) of the function. when (#'app request-map) : will call Var's invoke function: public Object invoke(Object arg1) { return fn().invoke(arg1); } final public IFn fn(){ return (IFn) deref(); } after deref(), you just get app. i found some remarks about being able to change the app without having to restart the server but how exactly does this relate ? Yes. It's possible. The easiest of doing that is by using https://github.com/weavejester/lein-ring On Saturday, January 19, 2013 7:54:08 AM UTC+8, faenvie wrote: dear clojure users, i have learned that for a ring/compojure-app the embedded jetty service can be started like this: (def app (handler/site routes)) (defn start [port] (ring/run-jetty (var app) {:port (or port 8080) :join? false})) can anyone explain, what is the var for ? why '(var app)' or #'app ? i found some remarks about being able to change the app without having to restart the server but how exactly does this relate ? thanks have a successful time -- 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: emacs - how to wean me off the family of Java IDEs
Hi: I use Everything http://www.emacswiki.org/emacs/Everything to find files in project. Just type a part of the name, all files filter by your typing listed for you to choose from. Something like Eclipse's Ctrl +Shift + R (or Command + Shift + R on mac) . But you need some time to set it up. Herehttps://github.com/shenfeng/dotfiles/blob/master/emacs.d/feng-anything.elis my config for your reference. rainbow-delimiters is helpful for my lisp coding. On Wednesday, January 16, 2013 10:29:36 PM UTC+8, Colin Yates wrote: Hi all, After 15 off years of using IDEs I am making the jump into Emacs. I have read http://dev.clojure.org/display/doc/Getting+Started+with+Emacs and https://github.com/technomancy/emacs-starter-kit and I am just at the point where I have stopped yelling at paredit and starting to appreciate its point. My current major stumbling block though is navigating my project. Whilst (I expect) the density and sane namespacing capabilities of Clojure to significantly reduce the number of files, that isn't true of everything. In particular, ExtJS encourages you to follow the one file per class. You don't have to but eventually you will have more than a handful of files regardless. So my questions: - is there a decent project explorer. I really miss the tree on the left, editor on the right layout - is there a decent JS and clojure autocompletion aware plugin - other than paredit, nrepl and clojure-mode (and the excellent coffee-mode for coffeescript), what other plugins should I install Thanks all. Col P.S Please don't turn this into a flame war :) -- 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 (easily) show the advantages of Clojure
How about Clojure's web 1. Plain Clojure function as handler, request and response are just maps, they are printable. 2. Easy testable: handler is a function, pass a request, get the response, assert the response is wanted. 3. Easy mockable: use bindings to mock centain functions. Like talking to a database, read the content of a file. On Wednesday, January 16, 2013 11:08:41 PM UTC+8, Thomas wrote: Hi All, Something that came up last night in the blank? thread. What is a good way to show someone the advantages of Clojure. Something that is simple, not too complicated, easily understood, shows a (significant) benefit, etc. Any ideas? (As said in the other thread, I have used the blank? example from Stuart Halloway to show people the difference). Thomas -- 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 integrate front-end designers into Clojure/Ring/Jetty workflow?
I have some similar experience, put here try to be helpful I am in a team: 1. 1 designer: No experience with Clojure, little knowledge about programming, but knowing HTML CSS well 2. 1 fronend developer: No experience with Clojure, knowing JS HTML well, 3. 2 Clojure coder. Everyone commit code: contribute directly, everybody run the same code! The things we do: 1. A bash script that start the ring web app, like ./scripts/run, for everybody to run the code easily. 2. Templating by Mustache https://github.com/shenfeng/mustache.clj : Mustache is very simple: I managed to explain mustache to them in less than 10 minutes. And reload is easy! (ns .tmpls ;; templates = clojure functions : templates/help.tpl = help (gen-tmpls-from-resources templates [.tpl])) ;;; reload template, put it in your middleware. make sure only execute in dev mode(require :reload '.tmpls) There is another tool I write you may find interesting: http-watcherhttps://github.com/shenfeng/http-watcher Basically, it's a web server for web developers: automatically refresh browser when code changed. It's quite useful for our team. On Friday, January 11, 2013 7:28:02 AM UTC+8, larry google groups wrote: So, I am working on a web app that is buillt with Clojure/Ring/Jetty and, importantly, Enlive. My directory structure is like this: /resources /public /css /js /img /templates /src /discovery core.clj The great thing about Enlive is that the templates are pure HTML. This makes it easier for graphic designers and frontenders to work with them directly. I am working with a designer and frontend developer, who have absolute power over the stuff going into the /resources folder. I have 2 questions: 1.) In my routes, I am using (wrap-resource) instead of (wrap-file). Is there any way to enable live updates, so that if the designer changes the images in /resources/public/img, they can then see the changed images when looking at the app in their browser? Right now I have to recompile the app and restart it for change to be visible to the designer. 2.) I notice that if a change is made in /resources, but no change is made anywhere else, then if I run lein compile nothing happens. Is there a way to force lein to compile? I have little insight about how to build a multiperson workflow while doing Clojure development. One thought I had: I could automate the re- build of the app, and give the designer an easy way to trigger that rebuild (click a button in Jenkins -- easy enough because we rely on Jenkins for all of our builds, and the interface is simple enough for non-programmers to handle). But I would like to hear what other people do. -- 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: Tornado-like async (web) server framework?
I am working on a tiny web server and http client in clojure and java. It's using java's async Socket IO. https://github.com/shenfeng/http-kit The code is mostly written in java, It will expose a nice clojure API. My goal are async, fast, RAM efficiency, clean and compact code. I write it for Rssminer(http://rssminer.net, https://github.com/shenfeng/rssminer). The documentation is not ready. The server's unit test code: https://github.com/shenfeng/http-kit/blob/master/test/me/shenfeng/http/server/server_test.clj The production code of Rssminer is now using: https://github.com/shenfeng/async-http-client https://github.com/shenfeng/async-ring-adapter The two are written on top of netty, a great java NIO framework. I plan to replace it with http-kit. On Apr 16, 9:51 am, Stefan Arentz ste...@arentz.ca wrote: There is a lovely little web server for Python called Tornado. Tornado is an async server that also includes an async http client that plugs right in the server's event loop. This makes it really simple to build scalable web services that call other web services, which is what I mostly use it for. I would love to do the same in Clojure but I have no idea where to start. Ideally I would use an async server or framework in the style of Tornado or Twisted. But since Java has excellent thread support I guess I could also use an http lib that allows me to run requests in parallel. Who has some hints or pointers? S. -- 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
How to write `when-lets`
Clojure core.clj has a macro when-let, I am wondering how to write a macro `when-lets` (when-lets [symbol-1 test-1 symbol-2 test-2 ... ] body ) body only get evaluated when (and test-1 test-2 ) I am thinking about it, anybody has any clue? -- 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: Clojure for large programs
Our codebase is 6.8k kloc of production code, 4k of test code. We use emacs, slime+swank to develop. The editor is great, REPL is great. But lacking debuging and refactoring support is a pain. On Jul 3, 9:26 am, Mark Engelberg mark.engelb...@gmail.com wrote: Ideally, I was hoping to start a more in-depth discussion about the pros and cons of programming in the large in Clojure than just waxing poetic about Clojure/Lisp's capabilities in the abstract :) Yes, much of the initial excitement around Clojure comes from the feeling of Wow, I can do so much with so little code. But at some point, all projects grow. I'm thinking that by now, there may be enough people using Clojure in large projects and on large teams to offer some good feedback about how well that works. My Clojure codebase is somewhere around 2-3kloc and I already feel like I'm bumping up against some frustration when it comes time to refactor, maintain, and extend the code, all while keeping up with ongoing changes to libraries, contrib structures, and Clojure versions. I want to hear war stories from those with even larger code bases than mine. Has it proven to be a major hassle on large projects to avoid circular dependencies in the modules? Are the lack of debugging tools, documentation tools, and refactoring tools holding you back? Anyone miss static typing? One of my main gripes is that some of Clojure's built-ins return nonsensical results (or nil), rather than errors, for certain classes of invalid inputs. To me, one of the main benefits of functional programming is that debugging is generally easier, in large part because failures usually occur within close proximity of the flaw that triggered the failure. Erlang, in particular, has really promoted the idea of fail fast as a way to build robust systems. But Clojure's lack of a fail-fast philosophy has burned me several times, with hard-to-track-down bugs that were far-removed from the actual cause. The larger my code grows, the more this annoys me, reminding me too much of my days tracking down bugs in imperative programs. One specific example of this is get, which returns nil whenever the first input isn't something that supports get. For example, (get 2 2) produces nil. This becomes especially problematic when you pass something to get that seems like it should support get, but doesn't. For example, (get (transient #{1}) 1) produces nil, when there's absolutely no reason to think that (get (transient #{1} 1) would behave any differently from ((transient #{1}) 1). -- 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