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
class Movie { | |
String name | |
URL url | |
} | |
def downloads = new File('downloads') | |
downloads.mkdirs() | |
"http://portal.regiojet.cz/files/movies/".toURL().text.findAll(~/(?<=href=")([\S^"]*)(?=")/) | |
.parallelStream() |
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 jsArr | |
"Recursively converts a sequential object into a JavaScript array" | |
[seq] | |
(.array (vec (map #(if (sequential? %) (jsArr %) %) | |
seq)))) | |
(defn jsObj | |
"Convert a clojure map into a JavaScript object" | |
[obj] | |
(.strobj (into {} (map (fn [[k v]] |
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
; note: this iteration doesn't work properly. | |
; looks like i don't understand exactly how react.js works for settings dom element properties | |
(set! exports {}) | |
; react macros... | |
(defmacro hash-map-pairs | |
"make a hash map from its arguments. each argument is a tuple (key value)" |
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
#lang racket | |
;; Fusable Streams, after Coutts, Leshchinskiy and Stewart 2007. | |
;; Haskell: | |
;; data Stream a where Stream :: (s -> Step s a) -> s -> Stream a | |
;; data Step s a = Yield a s | Skip s | Done | |
;; Clojure transducers support: | |
;; - early termination | |
;; - completion cleanup |
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
<!-- Add the following lines to theme's html code right before </head> --> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> | |
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script> | |
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script> | |
<!-- | |
Usage: just add <div class="gist">[gist URL]</div> | |
Example: <div class="gist">https://gist.github.com/1395926</div> | |
--> |
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
;; | |
;; http://johnj.com/from-elegance-to-speed.html | |
;; | |
;; The Clojure version | |
;; ------------------- | |
(ns smt | |
(:require [net.cgrand.xforms :as x] | |
[criterium.core :as c :refer [quick-bench]])) |
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
IAMUSERID %{NUMBER:iam_user_id} | |
IAMUSERNAME [a-zA-Z0-9._-]+ | |
IAMUSER arn:aws:iam::%{IAMUSERID}:user/%{IAMUSERNAME:iam_user_name} | |
S3TYPE (?:OBJECT) | |
S3OP [a-zA-z]+ | |
S3SOAPOPERATION (?:SOAP\.%{S3OP}) | |
S3RESTOPERATION (?:REST\.%{S3OP}\.%{S3TYPE}) | |
S3WEBSITEOPERATION (?:WEBSITE\.%{S3OP}\.%{S3TYPE}) | |
S3OPERATION (?:%{S3SOAPOPERATION}|%{S3RESTOPERATION}|%{S3WEBSITEOPERATION}) |
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
IAMUSERID %{NUMBER:iam_user_id} | |
IAMUSERNAME [a-zA-Z0-9._-]+ | |
IAMUSER arn:aws:iam::%{IAMUSERID}:user/%{IAMUSERNAME:iam_user_name} | |
S3TYPE [a-zA-z_]+ | |
S3OP [a-zA-z]+ | |
S3SOAPOPERATION (?:SOAP\.%{S3OP}) | |
S3RESTOPERATION (?:REST\.%{S3OP}(\.%{S3TYPE})?) | |
S3WEBSITEOPERATION (?:WEBSITE\.%{S3OP}\.%{S3TYPE}) | |
S3OPERATION (?:%{S3SOAPOPERATION}|%{S3RESTOPERATION}|%{S3WEBSITEOPERATION}) |
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 left-join | |
"When passed 2 rels, returns the rel corresponding to the natural | |
left-join. When passed an additional keymap, joins on the corresponding | |
keys." | |
([xrel yrel] | |
(if (and (seq xrel) (seq yrel)) | |
(let [ks (intersection (set (keys (first xrel))) | |
(set (keys (first yrel)))) | |
idx (index yrel ks)] | |
(reduce (fn [ret x] |
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 stats) | |
(defn mode [vs] | |
(let [fs (frequencies vs)] | |
(first (last (sort-by second fs))))) | |
(defn quantile | |
([p vs] | |
(let [svs (sort vs)] | |
(quantile p (count vs) svs (first svs) (last svs)))) |
OlderNewer