This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro defaction [name & params-with-body] | |
(let [params-vector (first params-with-body) | |
params-hash (apply hash-map (flatten (map (fn [p] [p (symbol (str ":" p))]) params-vector))) | |
body (next params-with-body) | |
session (symbol "session")] | |
`(defn ~name [{~params-hash :params, ~session :session}] | |
~@body))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(global-unset-key (kbd "C-c l")) | |
(global-set-key (kbd "C-c l") 'toggle-truncate-lines) | |
(set-face-attribute | |
'default (selected-frame) :font | |
"Consolas 12") | |
(require 'ido) | |
(ido-mode t) | |
(setq ido-enable-flex-matching t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defroutes main-routes | |
(GET "/request" request (str request)) | |
(GET "/my" request "<html><body>Привет, Мир!</body></html>") | |
(route/resources "/") | |
(route/not-found "Page not found")) | |
(defn wrap-codepage [handler] | |
(fn [request] | |
(handler (assoc-in request [:headers :content-type] "text/html; charset=utf-8")))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns webtest.core | |
(:require [pl.danieljanus.tagsoup :as ts] | |
[hiccup.core :as h] | |
[clojure.contrib.duck-streams :as io])) | |
(def data (slurp "data/data.html")) | |
(def parsed (ts/parse-string data)) | |
(def generated (h/html parsed)) | |
(io/spit "data/output.html" generated) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns storm-test.core | |
(:import [backtype.storm StormSubmitter LocalCluster]) | |
(:use [backtype.storm clojure config]) | |
(:gen-class)) | |
(defspout dummy-spout ["data"] | |
[collector] | |
(let [data [2 4 8 16 32 64 128 256 512 1024 4096]] | |
(dorun (map #(do | |
(println (str "Spout: " %)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns storm-test.core | |
(:import [backtype.storm StormSubmitter LocalCluster]) | |
(:use [backtype.storm clojure config]) | |
(:gen-class)) | |
(defspout dummy-spout ["data"] | |
[conf context collector] | |
(let [data [2 4 8 16 32 64 128 256 512 1024 4096]] | |
(dorun (map #(do | |
(println (str "Spout: " %)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def *data* [2 4 8 16 32 64 128 256 512 1024 4096 2 4 8 16 32 64 128 256 512 1024 4096]) | |
(defspout number-spout ["number"] | |
[conf context collector] | |
(spout | |
(nextTuple [] | |
(Thread/sleep 100) | |
(emit-spout! collector [(next *data*)])) | |
(ack [id]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my-copy () | |
(interactive) | |
(search-backward " ") | |
(setq st (point)) | |
(forward-char 1) | |
(search-forward " ") | |
(setq nd (point)) | |
(setq txt (buffer-substring st nd)) | |
(message text)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns ptest.core | |
(:require [the.parsatron :as p])) | |
(p/defparser op [] | |
(p/choice (p/char \+) | |
(p/char \-) | |
(p/char \*) | |
(p/char \/))) | |
(p/defparser number [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns ptest.core | |
(:require [the.parsatron :as p])) | |
(p/defparser op [] | |
(p/choice (p/char \+) | |
(p/char \-))) | |
(p/defparser number [] | |
(p/let->> [d (p/many (p/digit))] | |
(p/always (reduce str d)))) |
OlderNewer