Skip to content

Instantly share code, notes, and snippets.

@CmdrDats
CmdrDats / rush-hour.clj
Created July 20, 2018 14:19
Rush Hour puzzle solver
(ns rush-hour)
;; We were curious what a rush how solver would look like.. and here it is. Ugly, but fast enough.
;; Solves the below expert level one in about 21 seconds on my work core i9
(def cars
[{:car :orange
:char "O"
:pos [0 3]
:size 2

Keybase proof

I hereby claim:

  • I am CmdrDats on github.
  • I am cmdrdats (https://keybase.io/cmdrdats) on keybase.
  • I have a public key whose fingerprint is 98C4 B1D0 D1E3 7C6C AFBC 9E24 9739 BC96 EC14 C7F6

To claim this, I am signing this object:

@CmdrDats
CmdrDats / article.md
Last active August 29, 2015 14:13
FX example, pulled apart.

Feature Expressions - are they answering the problem correctly?

Introduction

At its core, FX (feature expressions) allow writing a set of forms which provide different implementations depending on the 'mode' in which compilation is done.

While FX is great for convenience, the tradeoff is that it strongly encourages conflating the notion of 'how' (platform specific instructions) something is done with 'what' (logical operation) is being done.

The problem

FX lets you can now shoehorn all the different implementations (currently java & javascript, but probably CLR down the line) into a single function, walk away and pretend its a fully portable solution.

@CmdrDats
CmdrDats / cqrs.clj
Last active January 2, 2016 04:44
Simple foray into Clojure CQRS/ES example. Now with Datomic.
(ns server.db.cqrs
(:use
[datomic-schema.schema :only [schema fields part]])
(:require
[datomic.api :as d]
[datomic.function :as df]
[datomic-schema.schema :as s]))
;; Some simple helper functions:
(defn error [^String msg]
Check out README.md to get started editing Clojure with Emacs.
@CmdrDats
CmdrDats / variadic-curry.clj
Last active December 13, 2015 21:28
Non automatic currying to support variadic argument lists...
;; Some helper functions that adds support for currying-like syntax to function definitions but
;; still enable you to use variadic arguments in each function call.
(defn collect-vec
([l] (collect-vec l []))
([[h & t :as p] acc]
(cond
(not (vector? h)) [acc p]
(nil? t) [acc [h]]
:else
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
sudo apt-get update
sudo apt-get upgrade
@CmdrDats
CmdrDats / gist:1704412
Created January 30, 2012 13:33
Entities axample
(defentity-template base-entity
(fields
[id :auto-index]
[version :version]
[uuid :uuid :indexed]
[dateadded :datetime])
(post-create-fn server.entities.all/add-entity-triggers))
(defentity group
(tablename "groups") ; Optional, but mysql doesn't respond well to 'group' as a table name, so better just avoid this altogether.