Instantly share code, notes, and snippets.

View README.md

See https://dev.clojure.org/jira/browse/CLJS-2993

clj -Srepro -Sdeps '{:deps {github-darwin/gist-2298be76f15a2be3f0ffe3252c3afcb8 {:git/url "https://gist.github.com/darwin/2298be76f15a2be3f0ffe3252c3afcb8" :sha "e654a965e69ae1c51abb07a1c1a7c165759357f2"} org.clojure/clojurescript {:git/url "https://github.com/clojure/clojurescript" :sha "6cbd40f865132b8b13c6b902b715aed43e64f0b1"}}}' -m cljs.main -co @compiler-opts.edn -co '{:output-dir "out-bad"}' -c repro
clj -Srepro -Sdeps '{:deps {github-darwin/gist-2298be76f15a2be3f0ffe3252c3afcb8 {:git/url "https://gist.github.com/darwin/2298be76f15a2be3f0ffe3252c3afcb8" :sha "e654a965e69ae1c51abb07a1c1a7c165759357f2"} org.clojure/clojurescript {:git/url "https://github.com/clojure/clojurescript" :sha "b5e8dbd3316b0119ec3b80a73511127e678ce482"}}}' -m cljs.main -co @compiler-opts.edn -co '{:output-dir "out-good"}' -c repro
View state_monad.clj
(ns experimental.state-monad
(:refer-clojure :exclude [let]))
; This is a poor man's attempt to get something like state monad.
; We could have used clojure.algo.monads, but I wanted to avoid these drawbacks:
; https://www.reddit.com/r/Clojure/comments/8pyxk8/motivation_for_monads/e0gb6on/
; Alternatively we could have used some heavy category theory library like cats or fluokitten, but
; that looked like a pretty complex thing to learn and keep in head.
; Also I want this thing to play well with Cursive.
;
View deps.edn
{:paths ["."]
:deps {metosin/spec-tools {:mvn/version "0.7.2"}
org.clojure/test.check {:mvn/version "0.9.0"}
org.clojure/clojure {:mvn/version "1.9.0"}}}
View 00-readme.md

Wake reason: XHC1

Since macOS High Sierra (maybe even Sierra) I started having trouble putting my iMac (mid 2015) to sleep. After installing clean Mojave system the problem didn't go away, even after jumping through various hoops and trying to disable every software which might be causing it.

The problem

After entering sleep mode the computer did DarkWake unexpectedly. Usually within one minute after sleeping. This was especially annoying because my external drives would spin up at that point.

The solution

View terminal.sh
sudo tccutil reset AppleEvents
osascript -e "tell application \"Finder\" to «event BATFinit»"
View reset.applescript
tell application "System Preferences"
launch
activate
reveal anchor "Privacy_Assistive" of pane id "com.apple.preference.security"
display alert "RESET ACCESSIBILITY APPROVAL LIST" message "This script will reset (clear) the list of applications in the Accessibility section of the Privacy system preference pane." & linefeed & linefeed & "This action requires an administrative password, and cannot be undone." as critical buttons {"Cancel", "Reset"} cancel button "Cancel"
set show all to true
View project.clj.edn
{:description
"A collection of Chrome DevTools enhancements for ClojureScript developers.",
:compile-path "/Users/darwin/code/cljs-devtools/target/classes",
:deploy-repositories
(["clojars"
{:url "https://clojars.org/repo/",
:password :gpg,
:username :gpg,
:creds :gpg}]),
:group "binaryage",
View remove-finder-plist.sh
osascript -e "tell application \"Finder\" to quit"
mv ~/Library/Preferences/com.apple.finder.plist /tmp
osascript -e "tell application \"Finder\" to launch"
View totalfinder-diagnostics.md
  1. Please open /Applications/Utilities/Terminal.app
  2. In the Terminal prompt copy&paste this line and hit return:
curl -sL https://updates.binaryage.com/diagnose-totalfinder.sh | bash
  1. Please send the resulting file totalfinder-diagnostics.tar.gz (on Desktop) to support@binaryage.com
View 01_promise.cljs
(ns promise-test.core
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [cljs.core.async :refer [<! timeout chan put!]]))
(def delay-ms 100)
(defn async [n & [f]]
(go
(<! (timeout delay-ms))
((or f identity) n)))