Skip to content

Instantly share code, notes, and snippets.

Edmund Jackson ejackson

Block or report user

Report or block ejackson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:1380546
~/scratch/clojurescript$ ./script/bootstrap
Fetching Clojure...
Copying clojure-1.3.0/clojure-1.3.0.jar to lib/clojure.jar...
Cleaning up Clojure directory...
Cleaning up Clojure archive...
Fetching Google Closure library...
Cleaning up Google Closure library archive...
Fetching Google Closure compiler...
Cleaning up Google Closure compiler archive...
Building lib/goog.jar...
View gist:1319377
(defn- ipred [[k v]]
(pred/like k v))
(defn- partial-pred [m]
"Turn a map into a predicate format understood by cql. IE {:a 1 :b 2} --> (pred/and* (pred/=* :a 1) (pred/=* :b 2))"
(apply pred/and* (map ipred m)))
(defprotocol MapFindable
"A protocol for clojureQL searchable things that can be found using a map interface"
(find [this search-map]))
View gist:1293529
(ns relation.test.relation
(:require [relation.relation :as rel]
[relation.database :as db]
[clojureql.core :as cql])
(:use [clojure.test]))
(defmacro my-macro
[x]
`~(reverse x))
View gist:1264459
<build>
<plugins>
<plugin>
<groupId>com.theoryinpractise</groupId>
<artifactId>clojure-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<id>test-clojure</id>
@ejackson
ejackson / database.clj
Created Aug 28, 2011
Basic Clojure interaction with SQL
View database.clj
(ns bookkeeper.database
(:require [clojure.java.jdbc :as sql]
[clj-time.format :as f]))
(def db {:classname "com.mysql.jdbc.Driver"
:subprotocol "mysql"
:subname "//database-server:3306/database"
:user "user"
:password "password"})
View gist:1127627
(eval-after-load 'clojure-mode
'(progn
(require 'paredit)
(defun clojure-paredit-hook () (paredit-mode +1))
(add-hook 'clojure-mode-hook 'clojure-paredit-hook)
(define-key clojure-mode-map "{" 'paredit-open-brace)
(define-key clojure-mode-map "}" 'paredit-close-brace)))
View gist:1127677
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
@ejackson
ejackson / gist:962673
Created May 9, 2011
RIncanter.project.clj
View gist:962673
(defproject com.evocomputing/rincanter
"1.0.0-SNAPSHOT"
:description "Clojure/R integration using rosuda JRIEngine"
:dependencies [[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]
[incanter "1.2.3"]]
:native-dependencies [[jriengine "0.8.4"]]
View nothing.html
<h1>Introduction</h1>
This is a brief post about how laziness can be used to construct a step-wise quicksort, or somebody gets excited about laziness.
<P>
Laziness is not something I'd come across before Clojure, and I've been repeatedly bitten by forgetting about it. So it was a real pleasure the other day to see the laziness revealed in some code, and for once not have this as the result of protracted debugging. I was so taken aback that I'm sharing the experience.
<h1>Quicksort</h1>
<h2>The Algo</h2>
We all know the <a href="http://en.wikipedia.org/wiki/Quicksort">algorithm</a>, and <a href="http://bilfp.wikidot.com/why-functional-programming-matters">here's</a> a pretty Clojure implementation:
<pre class="brush:Clojure">
(defn qsort [[pivot & tail]]
@ejackson
ejackson / gist:911384
Created Apr 9, 2011
binding over map function
View gist:911384
(defn it-works []
(binding [*connection* "hello, world"]
(prn *connection*)))
(defn it-works-not []
(binding [*connection* "hello, world"]
(map
(fn [_] (prn user/*connection*))
[1 2])))
You can’t perform that action at this time.