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 proc | |
| (:import [java.lang ProcessBuilder]) | |
| (:use [clojure.java.io :only [reader writer]])) | |
| (defn spawn [& args] | |
| (let [process (-> (ProcessBuilder. args) | |
| (.start))] | |
| {:out (-> process | |
| (.getInputStream) | |
| (reader)) |
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
| ;requires clj-http (https://github.com/dakrone/clj-http) and clojure.data.json (https://github.com/clojure/data.json) to be available | |
| (require '[clj-http.client :as client] '[clojure.data.json :only (read-json) :as json]) | |
| (defn getfiles [id] (get (json/read-json (get (client/get (str "https://api.github.com/gists/" id)) :body)) :files)) | |
| (defn getcontent [files] (get (get files (first (keys files))) :content)) | |
| (defn loadgist [id] (load-string (getcontent (getfiles id)))) |
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 REPL-based, annotated Seesaw tutorial | |
| ; Please visit https://github.com/daveray/seesaw for more info | |
| ; | |
| ; This is a very basic intro to Seesaw, a Clojure UI toolkit. It covers | |
| ; Seesaw's basic features and philosophy, but only scratches the surface | |
| ; of what's available. It only assumes knowledge of Clojure. No Swing or | |
| ; Java experience is needed. | |
| ; | |
| ; This material was first presented in a talk at @CraftsmanGuild in | |
| ; Ann Arbor, MI. |
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 uuid [] (str (java.util.UUID/randomUUID))) |
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 ocr.main | |
| (:use [clojure.string :only (split trim)]) | |
| (:use [clojure.contrib.duck-streams :only (write-lines read-lines)]) | |
| (:use [clojure.contrib.shell-out :only (sh)]) | |
| (:use [clojure.contrib.math :only (sqrt)])) | |
| ; Input handling | |
| (defn read-text-image-line [line] | |
| (if (= "white" (last (split line #"[,:\s]+"))) "0" "1")) |
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 seesaw.async | |
| (:use [seesaw core])) | |
| ; see http://dotnetslackers.com/articles/net/Programming-user-interfaces-using-f-sharp-workflows.aspx#1478 | |
| (defmacro async | |
| "Macro that executes an async call (the first form), ignores its result, and the | |
| executes the body normally." | |
| [async-call & body] | |
| `(~@(apply list (first async-call) `(fn [& args#] ~@body) (rest async-call)))) |
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
| ;; Examples from: http://www.databasteknik.se/webbkursen/relalg-lecture/index.html | |
| (def employees (table connection-info :employees)) | |
| (def departments (table connection-info :departments)) | |
| ;;== Projection == | |
| ;; SELECT salary FROM employees | |
| @(project employees #{:salary}) |
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
| ;; Examples from: http://www.databasteknik.se/webbkursen/relalg-lecture/index.html | |
| (def employees (table connection-info :employees)) | |
| (def departments (table connection-info :departments)) | |
| ;;== Projection == | |
| ;; SELECT salary FROM employees | |
| @(project employees #{:salary}) |
NewerOlder