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 get-free-port [] | |
(with-open [socket (java.net.ServerSocket. 0)] | |
(.getLocalPort 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" | |
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.plex.pms</string> | |
<key>OnDemand</key> | |
<false/> | |
<key>ProgramArguments</key> |
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
const { evalString } = require("@borkdude/sci"); | |
let printlnArgs = null; | |
function println(...args) { | |
printlnArgs = args.map(arg => arg.toString()).join(" "); | |
} | |
exports.evalClojureExpr = (req, res) => { | |
const { text } = req.body; | |
try { | |
const result = evalString(text, {namespaces: {"clojure.core": {println: println}}}); | |
let value = []; |
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 heredoc [] | |
(let [delim (.readLine *in*)] | |
(->> (repeatedly #(.readLine *in*)) | |
(take-while #(not= delim %)) | |
(interpose \newline) | |
(apply str)))) | |
; The following lines are read (by the reader) as: | |
; "Look )(\"\\T\na here doc!\n" | |
#=(heredoc)""" |
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 clojure-dojo.core) | |
(import '[javax.imageio ImageIO] | |
'[java.awt.image BufferedImage]) | |
(def img (let [f "resources/image.png"] | |
(ImageIO/read (clojure.java.io/file f)))) |
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
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
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 bs.utils.mock-connection | |
"Utilities for using Datomic" | |
(:require [datomic.api :as d]) | |
(:use clojure.repl clojure.pprint) | |
(:import (java.util.concurrent BlockingQueue LinkedBlockingDeque) | |
(datomic Connection))) | |
(defrecord MockConnection | |
[dbAtom, ^BlockingQueue txQueue] |
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
;; Copyright (c) Alan Dipert. All rights reserved. | |
;; The use and distribution terms for this software are covered by the | |
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) | |
;; By using this software in any fashion, you are agreeing to be bound by | |
;; the terms of this license. | |
;; You must not remove this notice, or any other, from this software. | |
(ns alandipert.kahn | |
(:require [clojure.set :refer [difference union intersection]])) |
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 group-by | |
([f] | |
(fn [rf] | |
(let [grouped-value (volatile! (transient {}))] | |
(fn | |
([] (rf)) | |
([result] | |
(rf result (persistent! @grouped-value))) | |
([result input] | |
(let [key (f input)] |
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
;Code from http://peteriserins.com/2011/12/23/sat-in-clojure-core-logic.html | |
;; lein try org.clojure/core.logic "0.8.8" | |
(require '[clojure.core.logic :refer [conde run* fresh ] :as l]) | |
(declare goalify) | |
(defn and-rewrite [expr] | |
`(conde |
NewerOlder