Skip to content

Instantly share code, notes, and snippets.

@TheSeamau5
TheSeamau5 / EntityComponentSystemExploration.md
Created December 29, 2014 23:16
An exploration of the Entity Component System in Elm

#Exploring Entity Component Systems in Elm

Entity-Component-System (or ECS) is a pattern for designing programs that is prevalent in the games industry. This pattern consists of three simple parts:

  • Entity : A uniquely identifiable object that may contain any number of components
  • Component : A property usually representing the raw data of one aspect of the object. (Position is a component, Velocity is a component, Strength is a component, etc...)
  • System : A continuous process performing actions on every entity that possesses a component of the same aspect as that system

To understand this, let us try to make a simple example: Boxes that move in space:

@stuartstevenson
stuartstevenson / jenkins-job-dsl.groovy
Created September 16, 2014 07:50
Jenkins job dsl with distributed job config files. The seed.groovy file scans stash repo branches for jenkins-job-dsl.groovy files and runs them centrally.
Closure job = {
// Job Name
name "${stashProjectKey}-${projectName}-${branchSimpleName}"
// Where should jenkins run the job
label ('master')
// Where should Jenkins get the source code from
scm {
git {
@mchampine
mchampine / pwprot.clj
Created March 13, 2011 19:13
Strong password hasher/verifier for Clojure - incorporating salt and iterations
(ns pwprot
(:import (java.security MessageDigest Security)))
;;generate n random chars
(defn gensalt [n]
(let [charseq (map char (concat
(range 48 58) ; 0-9
(range 97 123)))] ; 0-z
(apply str
(take n
@rby
rby / autoclose.scala
Created December 9, 2010 07:01
Autoclose with for comprehensions
object closable {
type Closable = { def close }
class Autoclose[A <: Closable](c: A){
def foreach(f: A => Unit) = {
try { f(c) }finally { c.close }
}
}
case class Connection(name:String) {
def close = println("closing " + this)
}
<script>window.location.href='http://s3.amazonaws.com/37assets/svn/461-spinner.html';</script>
abstract class LogFormatter[-A] {
def format(a: A): String
}
object LogFormatter {
implicit object StringLogFormatter extends LogFormatter[String] {
def format(s: String) = s
}
implicit object ExceptionLogFormatter extends LogFormatter[Exception] {