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
cd ~ | |
sudo apt-get update | |
sudo apt-get install openjdk-7-jre-headless -y | |
wget https://github.com/elasticsearch/elasticsearch/archive/v0.20.1.tar.gz -O elasticsearch.tar.gz | |
tar -xf elasticsearch.tar.gz | |
rm elasticsearch.tar.gz | |
sudo mv elasticsearch-* elasticsearch | |
sudo mv elasticsearch /usr/local/share |
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
;; named arguments from the joy of clojure | |
;; the clojure version just feels not elegant, why? | |
;; clojure version | |
(defn slope | |
[& {:keys [p1 p2] :or {p1 [0 0] p2 {1 1}}}] | |
(float (/ (- (p2 1) (p1 1)) | |
(- (p2 0) (p1 0))))) | |
(slope :p1 [4 15] :p2 [3 21]) |
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
(defstruct item :title :current-price) | |
(defstruct bid :user :amount) | |
(def ^:dynamic history ()) | |
(def ^:dynamic droid (struct item "Droid X" 0)) | |
(defn place-offer [offer] | |
(binding [history (cons offer history) | |
droid (assoc droid :current-price (get offer :amount))] | |
(println droid history))) | |
(place-offer {:user "Anthony" :amount 10}) | |
(println droid) |
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 d (delay (println "Running>>>") | |
:done!)) | |
(deref d) | |
(defn get-document | |
[id] | |
{:content (delay (slurp "http://www.baidu.com"))}) | |
(get-document "some-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
(defmacro futures | |
[n & exprs] | |
(vec (for [_ (range n) | |
expr exprs] | |
`(future ~expr)))) | |
(defmacro wait-futures | |
[& args] | |
`(doseq [f# (futures ~@args)] | |
@f#)) |
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
;; Lists | |
(def l (list)) | |
(cons 1 l) | |
(conj (conj l 1) 1) | |
(rest (conj l 1)) | |
(pop l) | |
;; vectors | |
(def v [1 2 3]) |
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
SET @center = GeomFromText('POINT(34 110)'); | |
SET @radius = 30; | |
SET @bbox = CONCAT('POLYGON((', | |
X(@center) - @radius, ' ', Y(@center) - @radius, ',', | |
X(@center) + @radius, ' ', Y(@center) - @radius, ',', | |
X(@center) + @radius, ' ', Y(@center) + @radius, ',', | |
X(@center) - @radius, ' ', Y(@center) + @radius, ',', | |
X(@center) - @radius, ' ', Y(@center) - @radius, '))' | |
); | |
SELECT AsText(point) |
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
(defn memoize [f] | |
(let [mem (atom {})] | |
(fn [& args] | |
(if-let [e (find @mem args)] | |
(val e) | |
(let [ret (apply f args)] | |
(swap! mem assoc args ret) | |
(prn @mem) | |
ret))))) |
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
user> (+ 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M ) | |
0.9M | |
user> (+ 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M ) | |
1.0M | |
user> (+ 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1) | |
1.0 | |
user> (+ 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1) | |
0.9 | |
user> (+ 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1 0.1M) | |
1.0 |
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
102 | |
103 server { | |
104 listen 80; | |
105 server_name bookmarking.curtis.io; | |
106 | |
107 location / { | |
108 expires 24h; | |
109 proxy_pass http://localhost:3000/; | |
110 sendfile on; | |
111 proxy_redirect off; |
OlderNewer