Skip to content

Instantly share code, notes, and snippets.

Timothy Pratley timothypratley

Block or report user

Report or block timothypratley

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@timothypratley
timothypratley / constrained.cljs
Last active Feb 23, 2019
Rectangle collision
View constrained.cljs
;; load this example in a browser from this link:
;; http://app.klipse.tech/?container=1&cljs_in.gist=timothypratley/f55596fa4c39e9e8326b2cfec0ec4551
(ns constrained.core
(:require [reagent.core :as reagent]
[goog.dom :as dom]))
(set! *warn-on-infer* true)
(defn collision? [x y w h other-rectangles]
(some
View rogue-pt.md

canvas: html

Hi!

Today we will build a rogue like game...


First we need to draw something on the "screen". We do this by calling html.

@timothypratley
timothypratley / forshame.md
Last active May 13, 2019
Error reporting in Clojure are the worst, no error reporting in ClojureScript is the worst.
View forshame.md

For Shame!

Clojure error reporting is a problem. This gist contains examples of missed opportunities for a clear error message. Let's discuss how common scenarios can be improved, and get some "patch welcome" tickets out there with clearly defined expectations.

The problem

@timothypratley
timothypratley / gist:8157438
Last active Jan 1, 2016
Why functions + data is worth an extra argument in preference to classes
View gist:8157438
; starting with the example you had https://gist.github.com/Engelberg/8141352
(def rows 3)
(def cols 4)
(def cells (for [row (range rows), col (range cols)] [row col]))
(defn select-cells-by-row [row]
(filter (fn [[r c]] (= row r)) cells))
@timothypratley
timothypratley / GraphPeer
Created Apr 13, 2012
simple world server
View GraphPeer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Photon.SocketServer;
using PhotonHostRuntimeInterfaces;
using System.ComponentModel;
namespace PhotonGraphServer
View gist:2380150
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DigitalIdeaSolutions.Collections.Generic;
using Newtonsoft.Json;
using ExitGames.Client.Photon.Lite;
using ExitGames.Client.Photon;
using System.Collections;
using System.Threading;
View PolyhedronGeometry.js
/**
* Polyhedrons which support subdivision.
*
* Vertices have 'smooth' normals,
* to make a sharp edge choose a material that uses face normals instead.
*
* @author timothypratley@gmail.com
* @author daniel.deady@knectar.com
* @param radius
* @param detail Final number of triangles = 4^detail * X
View Blackjack.clj
;; This is intended to be entered interactively one part at a time
;; Try to keep state manipulation separate from logic functions
;; deal can just take a current game and return a new game.
;; thanks to persistent data structures, we aren't penalized for doing so.
(defn deal
[game n hand]
(update-in
(update-in game [hand] concat (take n (:deck game)))
[:deck]
View gist:328912
;; Mike Erickson
(def cards (ref nil))
(defn build-test-deck
[]
[[8 \S] [2 \C] [6 \C] [8 \D] [6 \H] [\A \H] [8 \C] [7 \H] [\A
\C] [2 \D] [\K \H] [10 \D] [4 \H] [6 \S] [2 \H] [\Q \H] [3 \D] [10 \S]
[3 \S] [1 \S] [\A \D] [9 \H] [\J \S] [4 \D] [1 \C] [\K \D] [2 \S] [1
\H] [5 \C] [\K \C] [10 \H] [9 \D] [9 \C] [\J \D] [\Q \C] [7 \S] [7 \D]
You can’t perform that action at this time.