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
(defvar-local sw1nn/adoc-remappings nil) | |
(defcustom sw1nn/adoc-hide-faces | |
'(markup-meta-face markup-meta-hide-face) | |
"faces to hide in adoc" | |
:group 'sw1nn | |
:type 'list | |
) | |
(defun sw1nn/adoc-hide-meta-characters () |
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 regroup | |
(:require [clojure.string :as str] | |
[clojure.test.check :as tc] | |
[clojure.test.check.generators :as gen] | |
[clojure.test.check.properties :as prop] | |
)) | |
(defn regroup [s n] | |
(let [patt (re-pattern (str "(?x:\n" |
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
;; Assumes https://github.com/jstepien/flames available | |
;; requires http://riemann.io to be installed. | |
(def flames (atom nil)) | |
(defn flames-start! [] | |
;; We resolve explicitly here, to avoid warnings when not working | |
;; with flamegraphs | |
(if-not @flames | |
(let [config {:port 54321, :host "localhost"}] | |
(reset! flames ((requiring-resolve 'flames.core/start!) config)) |
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
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts, | |
that detects and handles AJAXed content. | |
Usage example: | |
waitForKeyElements ( | |
"div.comments" | |
, commentCallbackFunction | |
); |
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 euler-fizz-buzz) | |
;; Inspired by http://philcrissman.net/posts/eulers-fizzbuzz/ | |
(defn mod-pow [b e m] (long (.modPow (biginteger b) (biginteger e) (biginteger m)))) | |
(defn fizz-buzz [] (map #({6 "Fizz" 10 "Buzz" 0 "FizzBuzz"} (mod-pow % 4 15) %) (range 1 100))) | |
;;https://en.wikipedia.org/wiki/Euler%27s_totient_function | |
;;https://oeis.org/A000010 |
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 parse-rfc7231-accept-charset [s] | |
(->> s | |
(re-seq rfc-7231-re) | |
(keep #(vector (.group % "charset") | |
(some-> (.group % "weight") | |
Float/parseFloat))) | |
(into {}))) |
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 re-seq | |
"Returns a lazy sequence of successive matches of pattern in string, | |
using java.util.regex.Matcher.find(), each such match processed with | |
re-groups." | |
{:added "1.0" | |
:static true} | |
[^java.util.regex.Pattern re s] | |
(let [m (re-matcher re s)] | |
((fn step [] | |
(when (. m (find)) |
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 input ", \t, , , UTF-8;q=0.8,shift_JIS;q=0.4,a,b") | |
(def rfc-7231-re #"(?x) | |
(?: | |
\s* # OWS | |
(?<charset>\*|[\p{Alnum}!\#\$\%\&'\*\+\-\.\^_\`\|\~]+) | |
(?i: | |
;q= | |
(?<weight>0\.\d{1,3}|1\.0{1,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
(def input ", \t, , , UTF-8;q=0.8,shift_JIS;q=0.4,a,b") | |
(def rfc-7231-re #"(?x) | |
(?: | |
\s* # OWS | |
(?<charset>\*|[\w\d_-]+) | |
(?i: | |
;q= | |
(?<weight>0\.\d{1,3}|1\.0{1,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
fn solution01() -> u64 { | |
INPUT.iter().fold(0, |a, line| { | |
let ref words: Vec<&str> = line.split_whitespace().collect(); | |
let uniq_words: BTreeSet<&&str> = words.into_iter().collect(); | |
if words.len() == uniq_words.len() { | |
a + 1 | |
} else { | |
a | |
} | |
}) |
NewerOlder