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
;; there are quite a few cases where this code would not work, use with caution and check the macro expansion | |
(require '[clojure.walk :as walk]) | |
(defn- clean-dont [form] | |
(walk/postwalk | |
(fn [form] | |
(if (and (list? form) (= 'dont (first form))) | |
(second form) | |
form)) |
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
;;; strict keys mode for spec | |
;; disclaimer: untested, most likely buggy | |
(require '[clojure.spec.alpha :as s]) | |
(require '[clojure.walk :as walk]) | |
(defmacro only-keys | |
[& {:keys [req req-un opt opt-un] :as args}] | |
`(s/and (s/keys ~@(apply concat (vec 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
(gen/generate (s/gen (:args (s/get-spec (resolve `calculate-limits))))) |
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 [p (Pipeline/create (PipelineOptionsFactory/create))] | |
(doto | |
(.. p | |
(apply TextIO.Read/from ("...")) | |
(apply "ExtractWords" | |
(ParDo/of (reify DoFn | |
(processElement [this context] | |
... | |
)))) | |
(apply (Count/perElement)) |
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
(require 'hydra) | |
(global-set-key (kbd "§") 'hydra-windows/body) | |
(make-face 'move-window-buffer-face) | |
(set-face-attribute 'move-window-buffer-face nil | |
:background "#073642") | |
(setq ss/window-move-remap-cookie nil) | |
(defun remove-window-move-indicator () | |
(if ss/window-move-remap-cookie | |
(face-remap-remove-relative |
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 lcs [as bs] | |
(if-not (and as bs) | |
[] | |
(let [[a & ra] as | |
[b & rb] bs] | |
(if (= a b) | |
(cons a (lcs ra rb)) | |
(let [la (lcs as rb) | |
lb (lcs ra bs)] | |
(if (> (count la) (count lb)) la lb)))))) |
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
Example: | |
youtube-dl -f 22 --get-url https://www.youtube.com/watch?v=mMZriSvaVP8 | |
Then with the link: | |
ffmpeg -ss 14350 -i (link) -t 11200 -c:v copy -c:a copy react-spot.mp4 | |
One line version: | |
ffmpeg -ss 14350 -i $(youtube-dl -f 22 --get-url https://www.youtube.com/watch?v=mMZriSvaVP8) -t 11200 -c:v copy -c:a copy react-spot.mp4 | |
You can either pick a format with both video and audio (such as -f 22), or you can use ffmpeg to combine a DASH audio and video stream. You'll need to make sure you're ffmpeg build includes open-ssl (so that it can download the video over https). |
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 leaf [fragment name] | |
[fragment name]) | |
(defn branch [fragment & children] | |
(let [[[tag param]] children] | |
(if (= tag :bidi/param) | |
[[fragment param] (vec (rest children))] | |
[fragment (vec children)]))) | |
(defn param [name] |
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
;;found here: https://github.com/metosin/ring-swagger/blob/1c5b8ab7ad7a5735624986bbb6b288aaf168d407/src/ring/swagger/common.clj#L53-L73 | |
(defn deep-merge | |
"Recursively merges maps. | |
If the first parameter is a keyword it tells the strategy to | |
use when merging non-map collections. Options are | |
- :replace, the default, the last value is used | |
- :into, if the value in every map is a collection they are concatenated | |
using into. Thus the type of (first) value is maintained." | |
{:arglists '([strategy & values] [values])} |
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
(defun ss/erc-fix-fill (fill-fun) | |
(save-excursion | |
(goto-char (point-min)) | |
(re-search-forward "> ") | |
(replace-match ">➭")) | |
(funcall fill-fun) | |
(save-excursion | |
(goto-char (point-min)) | |
(re-search-forward ">➭") | |
(replace-match "> "))) |