Skip to content

Instantly share code, notes, and snippets.

View LukeWood's full-sized avatar
:shipit:

Luke Wood LukeWood

:shipit:
View GitHub Profile
@LukeWood
LukeWood / dynamic.ex
Last active February 5, 2018 05:52
Basic module that supports dynamically attached supervised children in elixir
defmodule Dynamic do
defdelegate start_link(), to: Dynamic.Server
defdelegate new, to: Dynamic.Supervisor
end
def color_graph(ordering, adj_list):
coloring = [-1 for _ in ordering]
for node in ordering:
color = 0
used_colors = set([coloring[neighbor] for neighbor in adj_list[node]])
while color in used_colors:
color = color + 1
coloring[node] = color
return coloring
@LukeWood
LukeWood / client.ex
Last active May 20, 2019 02:24
Example of decoupling entities using message passing
defmodule Player.Client do
def effect(pid, effect) do
GenServer.cast(pid, {:effect, effect})
end
end
defmodule Stopwatch.Client do
def subscribe(pid, func) do
GenServer.cast(pid, {:subscribe, func})
end
end
import {subscribe} from "tiny-pubsub"
import {update_bullet} from './update_bullet'
let bullets = {};
subscribe("bullet", bullet => {
bullets[bullet.id] = bullet;
})
subscribe("tick", (current_time, world) => {
# Copies the most recent history matching a given query to the X11 clipboard provided
# Example
# > hcopy run
# > # ctrl-V
# > ./run.sh --some-arg
# Requires X11 Forwarding in SSH
# https://www.unixtutorial.org/get-x11-forwarding-in-macos-high-sierra
const ids = new Set();
export function isIdFree(id: string): boolean {
return ids.has(id);
}
export function takeId(id: string) {
ids.add(id);
}
import * as PIXI from "pixi.js";
import {Emitter, EmitterConfig} from 'pixi-particles';
import {
CustomPIXIComponent,
} from "react-pixi-fiber";
interface ParticleEmitterProps {
x: number;
y: number;
python setup.py sdist bdist_wheel
twine upload dist/*
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',
6: 'stingray',
7: 'cock',
8: 'hen',
9: 'ostrich, Struthio camelus',