Skip to content

Instantly share code, notes, and snippets.

View reiddraper's full-sized avatar
🍹

Reid Draper reiddraper

🍹
View GitHub Profile
(require '[crosscram.core :as crosscram] :reload)
(require '[clojure.core.match :as match])
(require '[clojure.set :as set])
(require 'clojure.pprint)
(defn move [game]
(let [rows (:rows game)
columns (:columns game)]
(loop [moves (match/match (:next-player game)
:horizontal (crosscram/generate-horizontal rows columns)
call pathogen#runtime_append_all_bundles()
set nocompatible
set list
set scroll=6
set scrolloff=999
set softtabstop=4
@reiddraper
reiddraper / question.markdown
Created March 25, 2012 20:10
Understanding Performance and Constraints in core.logic

Clojure 1.3.0 core.logic 0.6.8

This is the base code for which all the run calls use.

(use 'clojure.core.logic)

(defne all-in [x mems]
(use 'clojure.core.logic)
(defne all-in [x mems]
([[?a . ?b] mems]
(membero ?a mems)
(all-in ?b mems))
([() _]))
(defrel cocktail n)
(fact cocktail :martini)
@reiddraper
reiddraper / core.clj
Created February 12, 2012 20:38
async IO + thread pool
(ns chat.core
(:use lamina.core aleph.tcp gloss.core)
(:gen-class))
(def broadcast-channel (permanent-channel))
(defn chat-handler [ch client-info]
(receive-all ch #(async (let [value (if (not= "sleep" %)
%
(task (do (Thread/sleep 5000) "I slept!")))]

Some thoughts...

  1. What about putting the type in the Content-Type field? Something like x-crdt-g-set-v1
  2. What's the rationale for representing things as a hash with lists as values instead of two hashes (in the OR and LWW set for example)? This to me seems closer to how it'll be represented in code (or at least how I've chosen to do with knockbox).

On JSON vs. Protobuf:

JSON has the advantage of easily being used in the browser, so you could actually use the browser's timestamp for some of the operations. This can be useful if for a single key, the single browser is the main actor doing writes. JSON also works easily with javascript mapreduce. If size is a concern, I'd be curious to see the size difference between compressed (snappy maybe?) JSON and Protobuf. I'm not saying Protobuf is a bad choice, just things to consider.

@reiddraper
reiddraper / query.clj
Created December 31, 2011 04:27
sumo querying ideas
; 2i queries
(index-query conn :age 25)
(index-query conn :age 21 80)
(index-query conn :last-name "a" "f")
; is it too much of an abstraction to launch
; a mapreduce query which gets the docs and not
; just the keys?
(index-query conn :email "foo@example.com" :return-body true)
lein search autodoc
== Results from clojars - Showing page 1 / 10 total
[autodoc "0.3.0-SNAPSHOT"] A tool to build HTML documentation from your Clojure source
[autodoc "0.7.0"] A tool to build HTML documentation from your Clojure source
[autodoc "0.7.1-SNAPSHOT"] A tool to build HTML documentation from your Clojure source
[autodoc "0.7.1"] A tool to build HTML documentation from your Clojure source
[org.clojars.rayne/autodoc "0.8.0-SNAPSHOT"] A tool to build HTML documentation from your Clojure source
[com.fxtlabs/autodoc "0.8.0-SNAPSHOT"] A tool to build HTML documentation from your Clojure source
[org.clojars.weavejester/autodoc "0.9.0"] A tool to build HTML documentation from your Clojure source
[org.clojars.weavejester/autodoc "0.9.0-SNAPSHOT"] A tool to build HTML documentation from your Clojure source
(defbox Account
;; the second item in the
;; list is a type or protocol
;; to restrict the value to
(:name LWWRegister :required true)
(:address LWWRegister :required true)
;; specify a default value for this field,
;; in this case, the result of calling the
;; function `lww-set`
(:followers ObservedRemoveSet :default (lww-set)))