Skip to content

Instantly share code, notes, and snippets.

View lildata's full-sized avatar

Programming is fun lildata

View GitHub Profile
;; 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})
@daveray
daveray / gist:1055523
Created June 30, 2011 02:49
Async Workflows in Seesaw
(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))))
@xaviershay
xaviershay / ocr.main
Created August 7, 2011 06:34
OCR with Clojure. See the blog post at rhnh.net.
(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"))
@gorsuch
gorsuch / gist:1418850
Created December 1, 2011 18:37
clojure uuid
(defn uuid [] (str (java.util.UUID/randomUUID)))
@daveray
daveray / seesaw-repl-tutorial.clj
Created December 7, 2011 04:55
Seesaw REPL Tutorial
; 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.
@forsakendaemon
forsakendaemon / gist.clj
Created January 20, 2012 09:00
A Clojure Gist that allows you to load a Gist by id.
;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))))
@codification
codification / proc.clj
Created March 6, 2012 08:10
Clojure asynchronous process
(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))
@btoone
btoone / curl.md
Last active December 8, 2024 05:16
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@daveray
daveray / table-test.clj
Created April 5, 2012 12:44
Highlighting table rows with Seesaw
(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))