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
(defcmd git [& [dispatch :as args]] | |
(if (= dispatch "browse") | |
(let [{:keys [code stderr] | |
remote-url :stdout} (sh-value "git" "remote" "get-url" "origin")] | |
(if (zero? code) | |
(do (println "Opening" remote-url) | |
(sh "open" (clojure.string/trim remote-url))) | |
(println stderr))) | |
(eval `(sh "git" ~@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
""" | |
A super simple Jupyter cell magic that writes the cell to `main.cpp` or | |
specified file, compiles the file using g++ and executes the code using | |
`./a.out` | |
Limitations: the cell must be a complete C++ program. | |
""" | |
from IPython.core.magic import (register_line_magic, | |
register_cell_magic) | |
import subprocess |
The following works in Clojure:
(keys (filter (comp odd? val) {:a 1 :b 2 :c 3}))
The docstrings for keys
and vals
don't indicate that you can do this. Is this accidential or intentional?
I vaguely recall Alex Miller indicating at some point that this capability was deemed useful and is intentionally allowed. Yes, this is an appeal to authority, but nevertheless, it makes a fairly convincing argument.
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 ldnclj.repl | |
(:require [babashka.main :as bb] | |
[cheshire.core :as json] | |
[edamame.core :as e] | |
[sci.core :as sci] | |
[sci.impl.analyzer :as ana] | |
[sci.impl.interop :as interop] | |
[sci.impl.interpreter :as i] | |
[sci.impl.parser :as p])) |
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 logger) | |
(defmacro log [& msgs] | |
(let [m (meta &form) | |
_ns (ns-name *ns*) ;; can also be used for logging | |
file *file*] | |
`(binding [*out* *err*] ;; or bind to (io/writer log-file) | |
(println (str ~file ":" | |
~(:line m) ":" | |
~(:column m)) |
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 bb | |
(import (java.net ServerSocket)) | |
(require '[clojure.string :as string] '[clojure.java.io :as io]) | |
(with-open [server-socket (new ServerSocket 8080) | |
client-socket (.accept server-socket)] | |
(loop [] | |
(let [out (io/writer (.getOutputStream client-socket)) | |
in (io/reader (.getInputStream client-socket)) |
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
# install with brew reinstall --build-from-source ./gh-releases.rb | |
# set GITHUB_TOKEN to a personal Github token | |
# then run: gh-releases list :org babashka :repo :babashka | |
class GhReleases < Formula | |
desc "" | |
homepage "" | |
license "" | |
url "file:///dev/null" | |
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" |
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
"" The Silver Searcher | |
if executable('ag') | |
" Use ag over grep | |
set grepprg=ag\ --nogroup\ --nocolor | |
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore | |
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' | |
" " ag is fast enough that CtrlP doesn't need to cache | |
let g:ctrlp_use_caching = 0 |
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
#Clojerl | |
./bin/clje \ | |
-e "(do (require 'clojure.core.server) \ | |
(clojure.core.server/start-server \ | |
{:name \"socket-repl\" \ | |
:port 4444 \ | |
:accept 'clojure.main/repl \ | |
:address \"localhost\"}))" -r | |
#CLR |
OlderNewer