Skip to content

Instantly share code, notes, and snippets.

View MysteryMachine's full-sized avatar

Sal Becker MysteryMachine

View GitHub Profile
@nasser
nasser / chance.clj
Created February 8, 2015 22:21
chance macro
(defmacro chance [& body]
(let [r (gensym "chance")
pairs (sort-by first (partition 2 body))
odds (map first pairs)
exprs (map last pairs)
sum (apply + odds)
fracs (map #(float (/ % sum)) odds)
frac-pairs (partition 2 (interleave fracs exprs))]
`(let [~r (rand)]
(cond
(ns snake.core
(:use
[arcadia.core]
[hard.core]
[hard.input]
[hard.tween]))
(declare get-input)
(arcadia.core/defcomponent Pumper []
(ns game.ghost
(:use arcadia.core
nasser.linear)
(:require [nasser.proto :as proto]
[nasser.component :refer [component]])
(:import [UnityEngine Transform Component Time Vector3 Debug Color]))
(defn fly-towards! [^Transform tf ^Vector3 p ^double speed ^double turn-rate]
(let [ds (* speed Time/deltaTime)
target-dir (Vector3/Normalize (v- p (.. tf position)))]
@AlexCharlton
AlexCharlton / go.scm
Last active May 5, 2016 03:48
Go prototype in CHICKEN Scheme
(import chicken scheme)
(use hypergiant srfi-42 miscmacros)
;;;
;;; Game logic
;;;
;; Turns
(define turn (make-parameter 'black))
(ns user
(:use arcadia.core)
(:import [UnityEngine
Vector3
Time
Gizmos
Color
Debug
Plane
Mathf]))
(ns biology.squid
(:use hard.core hard.input hard.tween unity.messages)
(:require unity.core))
(defn squid-start [this])
(defn squid-update [this]
(let [h (get-axis :horizontal)
v (get-axis :vertical)
@mpj
mpj / classless.md
Last active November 13, 2023 16:34

The future is here: Classless object-oriented programming in JavaScript.

Douglas Crockford, author of JavaScript: The Good parts, recently gave a talk called The Better Parts, where he demonstrates how he creates objects in JavaScript nowadays. He doesn't call his approach anything, but I will refer to it as Crockford Classless.

Crockford Classless is completely free of class, new, this, prototype and even Crockfords own invention Object.create.

I think it's really, really sleek, and this is what it looks like:

function dog(spec) {
@staltz
staltz / introrx.md
Last active May 27, 2024 03:11
The introduction to Reactive Programming you've been missing
@nblumoe
nblumoe / vim_fireplace_paredit_cheat_sheet.md
Created April 24, 2013 06:41
Simple cheat sheet for vim fireplace and paredit

fireplace

  • cpr => (require ... :reload)
  • cpR => (require ... :reload-all)

Evaluation

  • :Eval (clojure code) => runs (clojure code) in repl
  • cpp => evaluate inn-most expessions under cursor
  • cp<movement> => evaluate text described by <movement>
  • cqp => opens quasi-repl
  • cqc => quasi-repl command line window