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
import lombok.EqualsAndHashCode; | |
import lombok.ToString; | |
import java.util.Optional; | |
import java.util.function.BiFunction; | |
import java.util.function.Function; | |
import java.util.stream.Stream; | |
public class App { | |
public static void main(String[] args) { |
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 core | |
(:require | |
[clj-http.client :as http] | |
[cheshire.core :as json] | |
[ring.adapter.jetty :refer [run-jetty]])) | |
;; Clojure sequences can be chunked in batches of 32 items | |
;; for the test I want to emit items one at a time | |
;; https://stackoverflow.com/a/3409568/187261 | |
(defn unchunk [s] |
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
// ==UserScript== | |
// @name AoC stats tree | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description Render AoC stats as christmass tree | |
// @author nbardiuk | |
// @match https://adventofcode.com/*/stats | |
// @license MIT License | |
// @copyright Copyright (C) 2020, by Nazarii Bardiuk | |
// @grant none |
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
#!/usr/bin/env -S clj -Sdeps '{:deps {clj-http/clj-http {:mvn/version "3.11.0"} cheshire/cheshire {:mvn/version "5.10.0"}}}' | |
(require '[clj-http.client :as http]) | |
(require '[cheshire.core :as json]) | |
(require '[clojure.pprint :refer [pprint]]) | |
(let [url (or (first *command-line-args*) "https://httpbin.org/get?q=a") | |
{:keys [body headers]} (http/get url)] | |
(pprint headers) | |
(pprint (json/decode body))) |
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
.PHONY: tdd | |
tdd: .nrepl-port | |
watchexec --clear --no-shell rep '(repl/refresh)(doto "$(only)" (run-tests))' | |
.PHONY: kill-repl | |
kill-repl: | |
@if [ -f .nrepl-port ];\ | |
then\ | |
kill $$(lsof -ti ":$$(cat .nrepl-port)" -sTCP:LISTEN) ;\ | |
fi |
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- slide [window x] | |
(-> window (subvec 1) (conj x))) | |
(defn- windows [n xs] | |
(let [first-window (vec (take n xs)) | |
the-rest (drop n xs)] | |
(when (and (< 0 n) (= n (count first-window))) | |
(reductions slide first-window the-rest)))) | |
(defn- avarage [xs] |
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
" paste escaped java/javascript string | |
nmap <leader>jp :call setreg('e', json_encode(@+))\| normal "ep<CR> | |
xmap <leader>jp :<C-U>call setreg('e', json_encode(@+))\| normal gv"ep<CR> | |
nmap <leader>jP :call setreg('e', json_encode(@+))\| normal "eP<CR> | |
" yank unescaped java/javascript string | |
xmap <leader>jy :<C-U>execute 'normal! gv"ey'\| :call setreg('+', json_decode(@e))<CR> |
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
" emulate text object for pair of elements | |
" i.e. key/value binding/expr test/expr | |
" | |
" pair forward | |
xmap <buffer> ip <Plug>(sexp_inner_element)<Plug>(sexp_move_to_next_element_tail) | |
omap <buffer> ip :<C-U>normal vip<CR> | |
" pair backward | |
xmap <buffer> iP <Plug>(sexp_inner_element)o<Plug>(sexp_move_to_prev_element_head) | |
omap <buffer> iP :<C-U>normal viP<CR> |
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
import java.util.Arrays; | |
import java.util.function.BiFunction; | |
import java.util.function.Function; | |
class Scratch { | |
public static void main(String[] args) { | |
Monoid<Integer> sum = Monoid.of(0, Integer::sum); | |
Fold<String, Integer> sumStrings = Fold.of(Integer::parseInt, sum); | |
Integer result = sumStrings.fold(Arrays.asList("1", "2", "3")); | |
System.out.println(result); |
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
let defaultengine="duckduckgo" | |
let smoothscroll="true" | |
let scrollduration="200" | |
map J nextTab | |
map K previousTab |
NewerOlder