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 file-cols.core | |
"Print the source-line length histogram of a bunch of files as a histogram. | |
Inspired by: https://gist.github.com/rsms/36bda3b5c8ab83d951e45ed788a184f4" | |
(:require [clojure.java.io :as io])) | |
(def uni-bar | |
"Unicode bars for histogram." | |
["" "▏" "▎" "▍" "▌" "▋" "▊" "▉" "█"]) | |
(def quot-rem-8 |
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
Colossal Typewriter | |
by John McCarthy and Roland | |
Silver for the PDP-1 | Photon typesetter | |
? | editors by Michael | |
? \ Barnett & Kalon | |
Expensive Typewriter CREATE/EDIT \ Kelley for TECO | |
for PDP-1 by Steve Piner for CTSS \ IBM 704 for PDP-1 | |
/ | / | \ \__ \ by Dan Murphy | |
/ | / | \ \ \ | | |
* Expensive Typewriter editors EDITS | MEMO/MODIFY | | VEDIT | |
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 clj-spec-playground | |
(:require [clojure.string :as str] | |
[clojure.spec :as s] | |
[clojure.test.check.generators :as gen])) | |
;;; examples of clojure.spec being used like a gradual/dependently typed system. | |
(defn make-user | |
"Create a map of inputs after splitting name." | |
([name email] |
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 ^{:doc "Uniquify" | |
:author "Baishampayan Ghose <[email protected]>"} | |
uniquify | |
(:require [clojure.string :refer [join]])) | |
(defn explode | |
"Explode a directory name to its subcomponents." | |
[^String dir] | |
(seq (.split dir "/"))) |
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 mars.rover) | |
;; A squad of robotic rovers are to be landed by NASA on a plateau on | |
;; Mars. | |
;; This plateau, which is curiously rectangular, must be navigated by the | |
;; rovers so that their on-board cameras can get a complete view of the | |
;; surrounding terrain to send back to Earth. |
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
;;; 99 bottles of beer in Clojure | |
(def bottles " | |
# 99 Bottles of Beer | |
# Brainfuck version | |
# by Michal Wojciech Tarnowski | |
+>+++++++[>>>+++ | |
+++++<<<<+++++ |
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 prime-sieve | |
(:require [clojure.core.async :as async :refer [chan go <! >!]])) | |
;;; concurrent prime sieve in Clojure using core.async | |
;; inspired by a similar implementation in Go | |
;; http://golang.org/doc/play/sieve.go | |
(defmacro go-forever | |
"An infinite loop that runs in a go block." |
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
; STM history stress-test | |
(defn stress [hmin hmax] | |
(let [r (ref 0 :min-history hmin :max-history hmax) | |
slow-tries (atom 0)] | |
(future | |
(dosync | |
(swap! slow-tries inc) | |
(Thread/sleep 200) | |
@r) |
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 props.core | |
(:require [clojure.string :refer [split]] | |
[clojure.java.io :refer [reader]]) | |
(:import java.util.Properties)) | |
(defn- split-key | |
"Split a string key to its subparts. | |
foo -> [foo] | |
foo.bar.baz -> [foo bar baz]" |
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 ^{:doc "Read Java properties file." | |
:author "Baishampayan Ghose <[email protected]>"} | |
in.freegeek.props | |
(:import java.util.Properties) | |
(:require [clojure.java.io :refer [resource reader]] | |
[clojure.string :refer [split]])) | |
(defn- load-props | |
"Load a Java properties file. File should be in classpath." | |
[props-file] |
NewerOlder