Skip to content

Instantly share code, notes, and snippets.

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.
@CatherineH
CatherineH / text_to_svg_path.py
Last active December 5, 2023 13:41
Convert a text character to an SVG path.
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')
-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:
@danharper
danharper / gulpfile.js
Last active April 11, 2024 08:31
New ES6 project with Babel, Browserify & Gulp
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));
@stuarthalloway
stuarthalloway / schema_history.clj
Last active March 31, 2017 21:40
Complete schema history of a live Datomic database
;; 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))
@PixnBits
PixnBits / md5.js
Last active May 27, 2022 07:51 — forked from jhoff/md5.js
invalid reference fix
/*
* 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];
@danielsz
danielsz / pushState.cljs
Last active July 15, 2016 15:13
PushState (via Html5History from google closure) with secretary, a client-side routing library for clojurescript. Allows to map absolute urls with routes without the hash-bang hackery.
(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)))))
(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]
(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)))))))
(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)]