Skip to content

Instantly share code, notes, and snippets.

View danlentz's full-sized avatar

Dan Lentz danlentz

View GitHub Profile
(defprotocol ToClojure
(to-clojure [x]))
(extend-protocol ToClojure
List (to-clojure [xs] (map to-clojure xs))
RecommendedItem (to-clojure [x] {:item (.getItemID x)
:value (.getValue x)}))
@danlentz
danlentz / mmap.clj
Created February 18, 2014 05:19
Clojure mmap utilx
; Copyright (c) Chris Houser, April 2008. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
; Functions for memory-mapping files, plus some functions that use a
; mmaped file for "normal" activies -- slurp, load-file, etc.
@danlentz
danlentz / reducers.lisp
Last active August 29, 2015 13:56
Common Lisp implementation of the REDUCERS protocol
;;
;; originally posted:  http://paste.lisp.org/display/132849
;;
;; The fastest and easiest way to learn the essential concepts and motivation
;; for a more generalized notion of collections based on the minimal abstraction
;; of REDUCTIBLE, Rich Hickey gives an excellent overview on his original Clojure
;; implementation of core.reducers. Note that it is not currently part of the
;; default Clojure environment due to the requirement of the ForkJoin concurrency
;; facilities introduced in Java7 (or Java6 + JSR167Y)
(def conv-table (sorted-map 1 :I
4 :IV
5 :V
9 :IX
10 :X
40 :XL
50 :L
90 :XC
100 :C
400 :CD
(defn maybe-word
[s]
(if (= "" s) [] [s]))
(defprotocol WordState
(append-chunk [this chunk] "Append a chunk to current word state")
(append-segment [this segment] "Append a segment to current word state")
(to-word-list [this] "Returns the state as a list of words"))
@danlentz
danlentz / net.cljs
Created December 7, 2013 06:03 — forked from darkone23/net.cljs
(ns example.net
(:require [goog.net.WebSocket]
[goog.events :refer (listen)]
[cljs.core.async :as async :refer (chan <! >! put! close)]
[cljs.core.async.impl.protocols :as proto])
(:require-macros [cljs.core.async.macros :refer (go)]))
(defn ws
"WebSocket as a core.async channel
returns a channel which delivers the ws chan then closes"
(ns parse.core
(:require [instaparse.core :as insta]))
(def parser
(insta/parser
"sexp = lparen operation rparen
<lparen> = <'('>
<rparen> = <')'>
operation = operator + args
operator = '+'
  • workflow

start by opening up PSQL

$ heroku pg:psql -a isis-db

what tables have we got?

\d

let's get a little more detail

\d+

A Beastiary of Badassery
-
SQLisms
--
WITH
arrays and unnest
window functions
JSON
row types
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix.
;;
;; * :use makes functions available without a namespace prefix
;; (i.e., refers functions to the current namespace).
;;
;; * :import refers Java classes to the current namespace.
;;