# in one terminal
$ lein deps
$ lein run -m server
# in another terminal
$ curl -i http://localhost:8080/sync
$ curl -i http://localhost:8080/poll
$ curl -i http://localhost:8080/stream
$ ./wsclient ws://localhost:8080/websocket?name=bob
=> hi
;annotation syntax | |
(import [java.lang.annotation Retention RetentionPolicy Target ElementType] | |
[javax.xml.ws WebServiceRef WebServiceRefs]) | |
(definterface Foo (foo [])) | |
;annotation on type | |
(deftype ^{Deprecated true | |
Retention RetentionPolicy/RUNTIME | |
javax.annotation.processing.SupportedOptions ["foo" "bar" "baz"] |
README.html |
# in one terminal
$ lein deps
$ lein run -m server
# in another terminal
$ curl -i http://localhost:8080/sync
$ curl -i http://localhost:8080/poll
$ curl -i http://localhost:8080/stream
$ ./wsclient ws://localhost:8080/websocket?name=bob
=> hi
(defmacro _-> | |
([x] x) | |
([x form] (if (seq? form) | |
(if (seq-utils/includes? form '_) | |
(with-meta `(~@(replace {'_ x} form)) (meta form)) | |
(with-meta `(~(first form) ~x ~@(next form)) (meta form))) | |
(list form x))) | |
([x form & more] `(_-> (_-> ~x ~form) ~@more))) | |
;-> and _-> are almost the same behavior until _ is specified. |
jQuery.format = function(s, args) { | |
return s.replace(/\{([^}]+)\}/g, function(_, match){return args[match] || '';}); | |
}; | |
>> $.format('Hello {world}, {again}', {world: "universe", again: "testing"}); | |
"Hello universe, testing" | |
>> $.format('Hello {0}, {1}', ["foo", "bar"]); | |
"Hello foo, bar" |
(ns `(let* ((nsname '()) | |
(dirs (split-string (buffer-file-name) "/")) | |
(aftersrc nil)) | |
(dolist (dir dirs) | |
(if aftersrc | |
(progn | |
(setq nsname (cons dir nsname)) | |
(setq nsname (cons "." nsname))) | |
(when (or (string= dir "src") (string= dir "test")) | |
(setq aftersrc t)))) |
# install git | |
sudo apt-get install g++ curl libssl-dev apache2-utils | |
sudo apt-get install git-core | |
# download the Node source, compile and install it | |
git clone https://github.com/joyent/node.git | |
cd node | |
./configure | |
make | |
sudo make install | |
# install the Node package manager for later use |
~/$ lein new ring-on-heroku | |
Created new project in: /home/jim/Development/ring-on-heroku | |
~/$ cd ring-on-heroku | |
~/ring-on-heroku$ echo 'web: lein run -m ring-on-heroku.core' > Procfile | |
~/ring-on-heroku$ cat > src/ring_on_heroku/core.clj | |
(ns ring-on-heroku.core | |
(:use ring.util.response | |
ring.adapter.jetty)) | |
(defn app [req] |
curl -XPUT localhost:9200/test | |
curl -XPUT localhost:9200/test/tweet/_mapping -d ' | |
{ | |
"tweet" : { | |
"properties" : { | |
"name" : { | |
"type" : "string" | |
}, | |
"comments" : { | |
"properties" : { |