Skip to content

Instantly share code, notes, and snippets.

View program247365's full-sized avatar
πŸ’­
YOLO πŸ’―

Kevin Ridgway program247365

πŸ’­
YOLO πŸ’―
View GitHub Profile
@developit
developit / *state-machine-component.md
Last active February 6, 2021 00:44
265b lib for building pure functional state machine components. https://github.com/developit/state-machine-component

state-machine-component

A tiny (265 byte) utility to create state machine components using two pure functions.

πŸ”₯ JSFiddle Demo

Usage

The API is a single function that accepts 2 pure functions as arguments:

@nessus42
nessus42 / past-present-and-destiny.md
Last active August 8, 2017 19:09
The Past, The Present, and Destiny

The Past, The Present, and Destiny

Let's take a little break from the current day to discuss some of the history of FPS networking.

In the early days of FPS PvP games (i.e., back in the days of Quake), they were sometimes implemented using a pure client/server networking model. In a pure client/server model, all of the calculations about the game are done on the dedicated server and your console is relegated to being mostly a 3D rendering engine.

This is not how things work in either Destiny 1 or 2. In both games, every console is calculating all of the physics for an entire Bubble all of the time. The reason for this is that you want a first-person shooter to be very snappy. You want the bullets that you shoot from your gun to hit the target now and not half-a-second from now. When you cancel your jump, you want it cancelled now and not half-a-second from now. This is very important for an FPS game to feel visceral, real, and snappy. I.e., for it to feel the same w

⚠️ this is now stupidly out of date

Computers

  • 13" Macbook Pro 3.3 GHz i7 (late 2016)
  • Microsoft Surface Book (2016)

Peripherals

@nessus42
nessus42 / destiny-networking.md
Last active May 31, 2024 10:41
How Networking Works in Destiny 1 and How It Will Differ in Destiny 2 (According to Bungie)

(NOTE: This is the original version of my Reddit post. Since I have made a major revision to the post in order to clarify issues that were left somewhat unclear in the original version, and to address some complaints about minor factual errors, I am preserving the original here just so that no one thinks that I'm trying to pull the wool over anyone's eyes. The updated version is available here. It can probably be left unsaid that this parenthetical comment was not in the original post, but I've learned the hard way that unless you spell everything out in explicit detail and accuracy, someone or another will post a complaint.)

TLDR: In Destiny 1, there are three types of servers: mission servers, zone servers, and physics servers. The first two run in Bungie's server cloud, but the physics server runs on a player's console. The physics server runs on a console in order to save mone

'use strict';
// Dependencies
const gcloud = require('google-cloud', {
projectId: 'sara-bigquery',
keyfileName: 'keyfile.json'
});
const vision = gcloud.vision();
const fs = require('fs');
const async = require('async');
@myshov
myshov / function_invocation.js
Last active February 23, 2026 13:47
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);

tracked npm

@tracked is a decorator for Preact that makes working with state values no different than properties on your component instance.

It's one 300 byte function that creates a getter/setter alias into state/setState() for a given key, with an optional initial value. The "magic" here is simply that it works as a property decorator rather than a function, so it appears to integrate directly into the language.

tracked has no dependencies and works with any component implementation that uses this.state and this.setState().

Installation

var preact = require('preact');
var createRenderer = require('./preact-dom-renderer');
// set up a rendering target
var renderer = createRenderer();
// render some stuff into the internal DOM
renderer.render(preact.h(PreactApp, pageConfig));
// get a snapshot of the current HTML
@developit
developit / preact-8-changes.md
Last active August 25, 2017 00:51
Important changes coming in Preact 8

Removed: Element Recycling

DOM Element recycling will be removed in Preact 8.

This should have no effect on most applications. In fact, it fixes a number of known issues related to element state not being fully reset on reuse.

πŸ’‘ Why? Many DOM properties are stateful, and trying to reset them all when recycling is a game of whack-a-mole. Preact's size makes it infeasible to use whitelists to address these issues, so recycling is being dropped. >

@developit
developit / hydra-alias.md
Last active February 27, 2020 01:54
Alias to invoke Chrome Canary w/ tracing, for IRHydra

An Alias to run Chrome with tracing enabled

For Chrome Canary:

alias hydra='/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --no-sandbox --js-flags="--user-data-dir=/tmp/profile --trace-hydrogen --trace-phase=Z --trace-deopt --code-comments --hydrogen-track-positions --redirect-code-traces"'

For regular ol' Chrome: