This file contains hidden or 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 clj-arrows.core) | |
;; Take a look at -> http://www.haskell.org/haskellwiki/Arrow_tutorial | |
(defn def-arrow [& opts] | |
(let [opts-map (apply hash-map opts)] | |
{:arr (:arr opts-map) | |
:first (:first opts-map) | |
:second (:second opts-map)})) |
This file contains hidden or 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
#!/bin/sh | |
# change paths according to your repl setup | |
USER_HOME="/Users/antonio.garrote" | |
CLJR_HOME="/Users/antonio.garrote/.cljr" | |
CLASSPATH=src:test:. | |
if [ ! -n "$JVM_OPTS" ]; then | |
JVM_OPTS="-Xmx1G" | |
fi |
This file contains hidden or 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
(add-hook 'clj-mode-hook '(lambda () (linum-mode 1))) | |
(add-hook 'clojure-mode-hook '(lambda () (linum-mode 1))) |
This file contains hidden or 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
;; full screen | |
(defun fullscreen (&optional f) | |
(interactive) | |
(set-frame-parameter f 'fullscreen | |
(if (frame-parameter f 'fullscreen) nil 'fullboth))) | |
(global-set-key [f11] 'fullscreen) | |
(add-hook 'after-make-frame-functions 'fullscreen) |
This file contains hidden or 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
;; Server protocol | |
(defprotocol Server | |
(init [this initial-value] "Invoked when the server starts execution") | |
(handle-call [this request from state] "Invoked when a new synchronous request arrives at the server") | |
(handle-cast [this request state] "Invoked when a new asynchronous request arrives at the server") | |
(handle-info [this request state] "Handles messages distinct to events") | |
(terminate [this state] "Clean up code invoked when the server is going to be terminated externally")) |
This file contains hidden or 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
(time | |
(let [*pdfs-proms* (map (fn [[pdf id]] [pdf id (promise)]) *pdfs*)] | |
(doseq [[pdf id prom] *pdfs-proms*] | |
(future | |
(do | |
(spit (str id ".pdf") (slurp (java.net.URL. pdf))) | |
(deliver prom :ok)))) | |
(doseq [[_ _ prom] *pdfs-proms*] |
This file contains hidden or 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 *reg-nos* [16738 17288 18162 18776 18868 19116 19223 19505]) | |
(def *df-url* "http://www.mapa.es/agricultura/pags/fitos/registro/sustancias/pdf/") | |
(def *pdfs* (map #(list (str *df-url* % ".pdf") %) *reg-nos*)) | |
(time | |
(doseq [[pdf id] *pdfs*] | |
(spit (str id ".pdf") (slurp (java.net.URL. pdf))))) | |
;; Elapsed time 667.91 msecs |
This file contains hidden or 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
;;; Example from 'Applicative Programming with Effects' by McBride & Paterson | |
(use 'clj-control.applicative) | |
(use 'clj-control.core) | |
(use 'clj-control.utils) | |
(defn transpose | |
([matrix] | |
(if (empty? matrix) | |
(repeat '()) |
This file contains hidden or 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 mustang () | |
(interactive) | |
(color-theme-install | |
'(mustang | |
((background-color . "#202020") | |
(background-mode . dark) | |
(cursor-color . "#bdbdbd") | |
(mouse-color . "sienna1") | |
(foreground-color . "#bdbdbd")) | |
(default ((t (:background "#202020")))) |
This file contains hidden or 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
+----------------------+ | |
+-----------------------+ | | | |
| | | Tier 1 Rate disc | | |
| Rate (nil,500) +------------------------------------------------->+ | | |
| | | | | |
+----------+------------+ +-----------+----------+ | |
| |
OlderNewer