An introduction to curl using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
| ;; 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}) | 
| ;; 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}) | 
| (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)))) | 
| (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")) | 
| (defn uuid [] (str (java.util.UUID/randomUUID))) | 
| ; 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. | 
| ;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)))) | 
| (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)) | 
An introduction to curl using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
| (ns table-test.core | |
| (:use [seesaw core table swingx])) | |
| ; A predicate that decides whether a row should be highlighted | |
| ; adapter is an instance of JXTable.TableAdapter | |
| ; http://projects.joshy.org/projects/painterreview/swingx/org/jdesktop/swingx/JXTable.TableAdapter.html | |
| (defn hl-predicate [renderer adapter] | |
| ; Highligh all rows where :age is over thirty | |
| (> (.getValueAt adapter (.row adapter) 0) 30)) |