Your very first steps with Clojure
;;
$> lein repl into-1 ;; ;; This will create a Clojure project (a folder with a common structure) named 'into-1' ;; $ >
1
(ns prisoners.core) | |
;; | |
;; Clojure experiment on 100 prisoners problem. | |
;; | |
;; See https://en.wikipedia.org/wiki/100_prisoners_problem | |
;; | |
(defn best-tries | |
"Returns the infinite sequence of drawers contents a prisoner will get. |
On the criteria to be used in decomposing systems into modules – David Parnas | |
http://sunnyday.mit.edu/16.355/parnas-criteria.html | |
A Note On Distributed Computing – Jim Waldo, Geoff Wyant, Ann Wollrath, Sam Kendall | |
http://web.cs.wpi.edu/~cs3013/a11/Papers/Waldo_NoteOnDistributedComputing.pdf | |
The Next 700 Programming Languages – P. J. Landin | |
http://thecorememory.com/Next_700.pdf | |
Can Programming Be Liberated from the von Neumann Style? – John Backus |
https://owensd.io/?p=1156&utm_source=dlvr.it&utm_medium=twitter |
# Elastic search version | |
curl 'localhost:9200' | |
# List all indices | |
$ curl 'localhost:9200/_cat/indices?v' | |
# this shows the status | |
# e.g: | |
# health status index pri rep docs.count docs.deleted store.size pri.store.size | |
# close .kibana | |
# green open resources-index 3 0 20416 0 7.7mb 7.7mb |
user=> (require '[clojure.spec :as s]) | |
nil | |
user=> (s/def ::big #(< 10 %)) | |
:user/big | |
user=> (s/valid? ::big 10) | |
false | |
user=> (s/valid? ::big 100) | |
true | |
user=> (s/def ::big-or-even (s/or ::big even?)) |
(-> (hmac/hash "foo bar" "mysecretkey" :sha256) | |
(codecs/bytes->hex)) | |
=> "61849448bdbb67b39d609471eead667e65b0d1b9e01b1c3bf7aa56b83e9c8083" | |
;; so far, so good | |
(hmac/verify "foo bar" "61849448bdbb67b39d609471eead667e65b0d1b9e01b1c3bf7aa56b83e9c8083" "mysecretkey" :sha256) | |
=> false | |
;; should be true, no? | |
(def bytes-hash (hmac/hash "foo bar" "mysecretkey" :sha256)) |
Your very first steps with Clojure
;;
$> lein repl into-1 ;; ;; This will create a Clojure project (a folder with a common structure) named 'into-1' ;; $ >
1
(defn clojurify | |
[exp] | |
(cond | |
(instance? java.util.Map exp) (into {} (for [[k v] exp] [(keyword k) v])) | |
(instance? java.util.List exp) (into [] exp) | |
:else exp)) | |
(defn walk-to-clojure-map | |
[java-map] | |
(clojure.walk/prewalk clojurify java-map)) |
require 'nokogiri' | |
require 'open-uri' | |
@plays = {} | |
def extract_plays(url, i) | |
doc = Nokogiri::HTML(open(url)) | |
artist_names = doc.xpath("//a[contains(@href,'artist')]").collect {|node| node.text.strip} |
Minimal setup to reproduce the problem. Note that that with Java 1.7 this works fine.
$ java -version
java version "1.8.0_40-ea"
Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b18, mixed mode)