Skip to content

Instantly share code, notes, and snippets.

@willurd
willurd / web-servers.md
Last active May 9, 2024 05:48
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
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.
@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));
@liamcurry
liamcurry / gist:2597326
Created May 4, 2012 19:56
Vanilla JS vs jQuery

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@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:
@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];
@stuartsierra
stuartsierra / errors.clj
Created April 20, 2012 14:27
Example error messages from common mistakes with Datomic
;; Some example error messages resulting from common mistakes
;; using Datomic 0.8.4138
(ns errors
(:use [datomic.api :as d :only (db q)]))
(def uri "datomic:mem://database")
(d/create-database uri)
(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]
@stuarthalloway
stuarthalloway / gist:2158138
Created March 22, 2012 12:54
Many to Many Datomic example
;; Datomic example code
;; make in memory database
(use '[datomic.api :only (q db) :as d])
(def uri "datomic:mem://matches")
(d/create-database uri)
(def conn (d/connect uri))
;; add the match attribute
(d/transact