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
;; Credit (Chad Harrington)[https://github.com/chadharrington] from whom I copied | |
;; `sym-map` and who thus inspired the others. | |
(defmacro sym-map | |
"Builds a map from symbols. Symbol names are turned into keywords and become the | |
map's keys. Symbol values become the map's values. | |
(let [a 1 b 2] | |
(sym-map a b)) ;; => {:a 1 :b 2} | |
" | |
[& syms] |
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
// Incomplete code, leaves out the imports and Bubbletea model and setup | |
func nextFreeConsole() (int, error) { | |
f, err := os.OpenFile("/dev/tty0", os.O_WRONLY, 0) | |
if err != nil { | |
return 0, err | |
} | |
defer f.Close() | |
free, err := unix.IoctlGetInt(int(f.Fd()), linuxvt.VT_OPENQRY) | |
if err != nil { |
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 npmap | |
"Like pmap but also takes n to specify the number of threads. Also differs | |
in that it can return the results on a channel. If you don't specify a | |
channel you will get all the results back in a vector after they are all | |
done. If you do pass in a channel results will be put on that channel | |
(by async/pipeline) as they are available. When all computation is done | |
async/pipeline closes said results channel." | |
([f n coll] | |
(->> coll | |
(npmap f n (async/chan)) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 unicorn | |
(:require [#?(:clj clojure.spec :cljs cljs.spec) :as s] | |
[#?(:clj clojure.spec.test :cljs cljs.spec.test) :as stest])) | |
(def names ["Eugene" "Smith" "Crabbs" "Jeff" "Shelly" "Barbra" "Joanne" "Jane"]) | |
(s/def ::name (into #{} names)) | |
(s/def ::is-white boolean?) | |
(s/def ::has-horn boolean?) |
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
# Suppose I've pulled $CHILD out of $PARENT but lost the git history in the proccess. | |
# Let the last commit's sha1 that $CHILD was in $PARENT be denoted $LAST_COMMIT. | |
# Suppose further that I rename $CHILD, now I have $CHILD_OLD_NAME and $CHILD_NEW_NAME. | |
# If $CHILD was not renamed when pulled out you can use just $CHILD or set $CHILD_OLD_NAME and | |
# $CHILD_NEW_NAME to the same thing. | |
cd $PARENT | |
git co $LAST_COMMIT | |
git log --pretty=email --patch-with-stat --reverse --full-index --binary -- $CHILD_OLD_NAME > patch | |
cd ../$CHILD_NEW_NAME | |
git co master |