Skip to content

Instantly share code, notes, and snippets.

View reiddraper's full-sized avatar
🍹

Reid Draper reiddraper

🍹
View GitHub Profile
@Pet3ris
Pet3ris / fsmparse.clj
Created January 27, 2012 12:45
Finite State Machines: jumps, flexible transitions and parsing
(ns fsmparse
(:refer-clojure :exclude [==])
(:use [clojure.core.logic]))
;; We will encode a state machine that accepts lists containing '(w h y) as a sublist
;; Moreover, instead of a recognizer, we will implement a parser, that returns a list
;; of visited states in order
;;
;; +----#-----+----#-----+ +--?--+
;; v | | v |
@lusis
lusis / autostart.md
Created February 2, 2012 05:36
Why autostarting default config packages are a bad thing

For a moment, I'm going to throw away my automation and configuration management hat. I'll let you know when I put it back on. Also, let's ignore that we're talking about Riak specifically for a moment. Also also, let's ignore any (for a brief moment) the proper role of a package manager.

What's your target market?

If you're writing server software, you have two target markets. The system administrator/operations team and the developer.

Why do you want autostart?

The main reason you want autostart is to get people up and running quickly. To do this, you need to ship safe and sane defaults. This means something like a default configuration that listens only on localhost.

@CampingScorpion
CampingScorpion / gist:1861626
Created February 19, 2012 02:15
Mutable objects!
(defn make-foo [n]
(let [foo (atom n)]
{:update (fn [n] (reset! foo n))
:inc (fn [] (swap! foo inc))
:status (fn [] (print @foo))} ))
(defmacro defobject
"doesn't work yet"
[name field-vec & methods]
(let [methods (partition 3 methods)
@Pet3ris
Pet3ris / fst.clj
Created February 25, 2012 13:02
Finite State Transducers: English pluralization
(ns fst
(:refer-clojure :exclude [==])
(:use [clojure.core.logic]))
;; A finite state transducer is essentially a translator between
;; two tapes of symbols. It is normally a translator from an input
;; tape to an output tape, but since we are using core.logic,
;; we hope to relax this restriction :).
;; The main idea is that every transition accepts two symbols
@stuarthalloway
stuarthalloway / gist:1980351
Created March 5, 2012 18:56
frinj unit conversion running inside a Datomic datalog query
;; lein settings
(defproject foo "1.0.0-SNAPSHOT"
:description "Test App"
:dependencies [[com.datomic/datomic "0.1.2678"]
[frinj "0.1.2" :exclusions [org.clojure/clojure]]])
;; load libs
(use 'frinj.core 'frinj.calc)
(frinj-init!)
(use '[datomic.api :only (q db) :as d])
@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]
@ntraft
ntraft / better-than-random
Created April 28, 2012 20:52
My first crosscram-playing bot
;;
;; Neil's Bot
;;
(defn- valid-empty-space? [board [r c]]
(cond
(not (< -1 r (count board))) false
(not (< -1 c (count (nth board r)))) false
:else (nil? (nth (nth board r) c))))
@stuarthalloway
stuarthalloway / gist:2645453
Created May 9, 2012 15:22
Datomic queries against Clojure collections
;; Datomic example code
(use '[datomic.api :only (db q) :as d])
;; ?answer binds a scalar
(q '[:find ?answer :in ?answer]
42)
;; of course you can bind more than one of anything
(q '[:find ?last ?first :in ?last ?first]
"Doe" "John")
@swannodette
swannodette / gist:2719676
Created May 17, 2012 15:35
unify_datums.clj
(ns datomic-play.core
(:use [datomic.api :only [db q] :as d])
(:require [clojure.core.logic :as l]
[clojure.pprint :as pp]))
(def uri "datomic:dev://localhost:4334/hello")
(defprotocol IUnifyWithDatum
(unify-with-datum [u v s]))

Riak Users,

I've been working on some new features for Riak's secondary indexes (2i), and I wanted to get some feedback from the community before proceeding much further.

How does 2i work currently?

2i lets you query index values with