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 clojurerng.core | |
(:import [com.modp.random LinearSunJDK]) | |
(:use [ criterium.core])) | |
(def ^:LinearSunJDK linsun (LinearSunJDK.)) | |
;;this is salvaged from | |
;; javarng.googlecode.com/svn/trunk/com/modp/random/LinearSunJDK.java | |
;;and the openJDK source code for .nextDouble |
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
(steam-roller [:a {1 2 3 4} 1 1 :a :a]) | |
-> ([:a {1 2, 3 4} 1 1 :a :a] :a {1 2, 3 4} 1 3 2 4 1 1 :a :a) | |
count: 11 | |
;;identityHashCodes: | |
(map #(System/identityHashCode %) (steam-roller [:a {1 2 3 4} 1 1 :a :a])) | |
(1460028191 | |
2005509007 | |
1545655515 | |
504432400 |
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
;; put this in ~/.emacs.d/init.el : | |
(require 'package) | |
(add-to-list 'package-archives | |
'("melpa" . "http://melpa.milkbox.net/packages/") t) | |
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t) | |
(package-initialize) |
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 traktor.error | |
(:require [datomic.api :as d :refer [db q]])) | |
(d/create-database "datomic:mem://casenum") | |
(def conn (d/connect "datomic:mem://casenum")) | |
;; simple schema | |
@(d/transact conn [{:db/id #db/id [:db.part/db] |
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
(require '[noir.server :as server]) | |
(use 'noir.core 'aleph.http 'lamina.core) | |
(defn async-response [response-channel request] | |
(enqueue response-channel | |
{:status 200 | |
:headers {"content-type" "text/plain"} | |
:body "async response"})) | |
(defpage "/" [] "hey from Noir!") |
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 dsstuff | |
"things i used to do in duckstreams in clojure 1.2.0") | |
;;read-lines from files | |
(defn read-lines-from-file [filename] | |
(with-open [rdr (clojure.java.io/reader filename)] | |
(line-seq rdr))) | |
;;thank you Abhinav Sarkar (http://stackoverflow.com/questions/4118123/read-a-very-large-text-file-into-a-list-in-clojure) |
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 testoi) | |
;; http://api.mongodb.org/java/2.6.3/org/bson/types/ObjectId.html | |
testoi> (import 'org.bson.types.ObjectId) | |
org.bson.types.ObjectId | |
testoi> (ObjectId. "d1700430f92f194fad7ce85a") | |
#<ObjectId d1700430f92f194fad7ce85a> |
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
;; claj's solution to Set Intersection | |
;; https://4clojure.com/problem/81 | |
(fn [a b] (set (filter a b))) |
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
;; claj's solution to Anagram Finder | |
;; https://4clojure.com/problem/77 | |
(fn [a] | |
(set | |
(map set | |
(filter #(< 1 (count %)) | |
(vals | |
(group-by | |
(fn [b] (reduce conj #{} b)) |
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
;; claj's solution to Reverse Interleave | |
;; https://4clojure.com/problem/43 | |
(fn [a b] (map #(take-nth b (drop % a)) (range b))) |
OlderNewer