This object type is used in many places
type Vec = {
x: number;
y: number;
};
type DiskDynamics = {
entities: number[];
position: Map<number, Vec>;
velocity: Map<number, Vec>;
size: Map<number, { w: number; h: number }>;
mass: Map<number, number>;
};
type SimulationCtx = {
iteration: number;
};
type CollisionQueryCtx = {
collideNormal: Map<number, Vec>;
distanceUntilCollision: Map<number, number>;
timeUntilCollision: Map<number, number>;
collideWith: Map<number, number>;
};
type RendererCtx = {
domTableDisk: Map<number, jQuery>;
domTableVelocityPointer: Map<number, jQuery>;
};
type Context = SimulationCtx & CollisionQueryCtx & RendererCtx & DiskDynamics;
how to copy a directory from a git repo and make it a new repo while preserving relevant commit history
- Create a new git repo,
git init
- Set original repo as a remote,
git remote add hmwk file://path/to/original/repo
- Download history from original repo,
git remote update
- List commits that change this directory,
git log -- day2009-bouncing-discs
. Or use helper in IDE. - Cherry-pick commits from remote,
git cherry-pick f1a6884d^..5dfa0336
if commits are consecutive. Or cherry-pick them one by one.
Cherry-pick will throw fatal error if specified hash range contains merge commit. And commits from another branch will be "merged" to HEAD which is a very undesirable behaviour.
Subtree merging approach preserves merge commits and full commit history, see this link
TODO: this note should be made into a blog post.
Reference: