This file contains hidden or 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 datomic-traverser | |
(:require [clojure.set :as set] | |
[datomic.api :as d] | |
[loom.graph :as graph] | |
[loom.alg :as alg])) | |
;; An implementation of Loom graph backed by a Datomic db, where nodes are | |
;; Datomic entities and edges are determined by datoms of attribute type ref, | |
;; filtered with forward-attr-blacklist and backward-attr-whitelist. | |
;; node-subset, when present, will restrict the nodes and edges to those |
This file contains hidden or 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 Clojure implementation of http://koziolekweb.pl/2016/05/08/lotto-to-fajna-rzecz/. | |
(ns lotto) | |
(defn lotto | |
([] (lotto 49 6 100000)) | |
([n k r] | |
(let [balls (range 1 (inc n)) | |
random-balls #(take k (shuffle balls)) | |
empty-counts (zipmap balls (repeat 0)) |
This file contains hidden or 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 trzeciblank | |
(:require [clojure.string :as string] | |
[clojure.java.io :as io] | |
[clojure.set :refer :all])) | |
(def piatki (set (line-seq (io/reader "/home/nathell/scrabble/w5.txt")))) | |
(defn kandydaci [slowo] | |
(for [i (range 5) x "abcdefghijklmnoprstuwyząćęłńóśźż" | |
:let [kand (str (subs slowo 0 i) x (subs slowo (inc i)))] |
This file contains hidden or 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 http-client | |
(:import [org.mortbay.jetty.client HttpClient ContentExchange] | |
[java.io ByteArrayInputStream])) | |
(defn request | |
"Takes a request conforming to the Ring specification and sends it to | |
the server. Returns a Ring response." | |
[req] | |
(let [{:keys [scheme server-name server-port uri query-string content-type headers character-encoding request-method body]} req | |
client (HttpClient.) |
This file contains hidden or 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 mmu | |
(:gen-class) | |
(:use [clojure.contrib duck-streams])) | |
(defn gc [] | |
(dotimes [_ 4] (System/gc))) | |
(defn used-memory [] | |
(let [runtime (Runtime/getRuntime)] | |
(gc) |
This file contains hidden or 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 read-text [] | |
(take-while (comp not empty?) (repeatedly read-line))) | |
(defn char<= [x y z] | |
(and (>= 0 (compare x y)) (>= 0 (compare y z)))) | |
(defn update-map [m letter] | |
(let [letter (Character/toUpperCase letter)] | |
(if (char<= \A letter \Z) | |
(assoc m letter (inc (get m letter 0))) |
This file contains hidden or 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/expect -f | |
set cp [regsub -all { } [glob *] {:}] | |
spawn java -cp $cp:/home/nathell/programs/clojure/clojure-1.1.0.jar -Xmx4096M -server -Xms4096M clojure.main | |
expect "user" | |
send "(require 'swank.swank)\r" | |
expect "user" | |
send "(defn swank \[\] (swank.swank/start-server \"/dev/null\" :port 4005))\r" | |
send "(swank)\r" | |
interact |