This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Readme: In the following pseudo code, [] indicates a subroutine. | |
Sometimes I choose to write the subroutine inline under the [] in order to maintain context. | |
One important fact about the way rollbacks are handled here is that we are storing state for every frame. | |
In any real implementation you only need to store one game state at a time. Storing a game | |
state for every frame allows us to only rollback to the first frame where the predicted inputs don't match the true ones. | |
==Constants== | |
MAX_ROLLBACK_FRAMES := Any Positive Integer # Specifies the maximum number of frames that can be resimulated | |
FRAME_ADVANTAGE_LIMIT := Any Positive Integer # Specifies the number of frames the local client can progress ahead of the remote client before time synchronizing. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from svgpathtools import wsvg, Line, QuadraticBezier, Path | |
from freetype import Face | |
def tuple_to_imag(t): | |
return t[0] + t[1] * 1j | |
face = Face('./Vera.ttf') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-Xmx10g | |
m2.xlarge (4 virtual cores) | |
Both Jetty and Netty execute the same code--generate 8k of random bits and compute a sha1, returning it over the wire. | |
INTERNAL (Benchmark tool runs on same machine) | |
-------- | |
Jetty: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var source = require('vinyl-source-stream'); | |
var buffer = require('vinyl-buffer'); | |
var browserify = require('browserify'); | |
var watchify = require('watchify'); | |
var babel = require('babelify'); | |
function compile(watch) { | |
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Complete schema history for a live Datomic database. | |
(require | |
'[clojure.pprint :as pp] | |
'[clojure.set :as set] | |
'[datomic.api :as d]) | |
;; fill this in with your own database connection | |
(def uri "datomic:dev://localhost:4334/my-db") | |
(def conn (d/connect uri)) | |
(def db (d/db conn)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* http://www.myersdaily.org/joseph/javascript/md5-text.html | |
*/ | |
(function (global) { | |
var md5cycle = function (x, k) { | |
var a = x[0], | |
b = x[1], | |
c = x[2], | |
d = x[3]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def history (Html5History.)) | |
(.setUseFragment history false) | |
(.setPathPrefix history "") | |
(.setEnabled history true) | |
(let [navigation (listen history EventType/NAVIGATE)] | |
(go | |
(while true | |
(let [token (.-token (<! navigation))] | |
(secretary/dispatch! token))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns blog.errors.core | |
(:require-macros | |
[cljs.core.async.macros :refer [go]] | |
[blog.utils.macros :refer [<?]]) | |
(:require | |
[cljs.core.async :refer [>! <! chan close!]])) | |
;; convert Node.js async function into a something | |
;; that returns a value or error on a channel | |
(defn run-task [f & args] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn words-proc [words button interval interval-control scrub] | |
(go (loop [idx 0] | |
(show-word! words idx) | |
(let [[v c] (alts! [button interval scrub]) | |
(condp = c | |
button (do (>! interval-control v) | |
(recur idx)) | |
interval (recur (inc idx)) | |
scrub (do (>! interval-control :stop) | |
(recur v))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns user | |
(:require [clojure.java.io :as io] | |
[datomic.api :as d])) | |
(defn order-schema [] | |
(read-string (slurp (io/resource "schema.edn")))) | |
(defn start-datomic! [uri schema] | |
(d/create-database uri) | |
(let [conn (d/connect uri)] |
NewerOlder